Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Derivative Calculator

I'm interested in building a derivative calculator. I've racked my brains over solving the problem, but I haven't found a right solution at all. May you have a hint how to start? Thanks

I'm sorry! I clearly want to make symbolic differentiation.

Let's say you have the function f(x) = x^3 + 2x^2 + x

I want to display the derivative, in this case f'(x) = 3x^2 + 4x + 1

I'd like to implement it in objective-c for the iPhone.

like image 797
burki Avatar asked Dec 01 '22 05:12

burki


1 Answers

I assume that you're trying to find the exact derivative of a function. (Symbolic differentiation)

You need to parse the mathematical expression and store the individual operations in the function in a tree structure.

For example, x + sin²(x) would be stored as a + operation, applied to the expression x and a ^ (exponentiation) operation of sin(x) and 2.

You can then recursively differentiate the tree by applying the rules of differentiation to each node. For example, a + node would become the u' + v', and a * node would become uv' + vu'.

like image 101
SLaks Avatar answered Dec 28 '22 11:12

SLaks