algorithm to find derivative
calculus, derivative, math
Solution
If you are limited to polynomials (which appears to be the case), there would basically be three steps:
- Parse the input string into a list of coefficients to x^n
- Take that list of coefficients and convert them into a new list of coefficients according to the rules for deriving a polynomial.
- Take the list of coefficients for the derivative and create a nice string describing the derivative polynomial function.
If you need to handle polynomials like `a*x^15125 + x^2 + c`, using a `dict` for the list of coefficients may make sense, but require a little more attention when doing the iterations through this list.
Problem
I'm writing program in Python and I need to find the derivative of a function (a function expressed as string). - For example: `x^2+3*x` - Its derivative is: `2*x+3` Are there any scripts available, or is there something helpful you can tell me?