How to create a differentiation function ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

How to create a differentiation function ?

Is there any way to create a function that will return the derivative of any function passed to it? What is the general way to do it??

29th Mar 2017, 9:14 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
5 Answers
+ 9
I don't think it's possible. But with a little effort, you can do it for simpler functions.
29th Mar 2017, 9:22 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 6
Consider a(x)^b for example. Scan the input as a string and extract a, b values and apply the formula. This is not even 1% of differentiation though. As far as my knowledge goes, we can't do differentiation.
29th Mar 2017, 9:28 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 4
But how, sir? I mean, is if-else the only way? Maybe there's an algorithm or some formula?
29th Mar 2017, 9:24 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 4
But there is NumPy in Python which has a diff() function for derivative... It can give an answer for any function, polynomial entered... Now I wonder, how did they make that?
29th Mar 2017, 9:30 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 3
@JPM7 Thank You!!!
29th Mar 2017, 9:38 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar