Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Derivatives in Java?

Im making a calculator app for Android, and a user requested for a derivatives calculator. Is there any preloaded function or a custom method available? Thanks.

like image 353
Jordan DeBarth Avatar asked Jul 21 '12 21:07

Jordan DeBarth


2 Answers

If Internet access is going to be available, you could delegate differentiation to Wolfram Alpha. Although free of charge API usage comes with limitations in the number of API calls.

like image 171
johnidis Avatar answered Oct 03 '22 20:10

johnidis


I'll attempt to answer, following on from @Ernest in the comments.

It depends largely on what derivatives you want to include. If you want to be able to differentiate only polynomials then it would be pretty easy to just write your own differentiation methods because they're really straightforward.

The part that requires thought is in representing the polynomials. This could simply be done by storing each term as a pair consisting of the coefficient and the exponent parts. With some simple multiplication and subtraction, you can differentiate.

You could take it a step further using recursion and implement the Chain Rule for differentiation to allow differentiation of nested polynomials.

For most people, this is probably good enough, or better than they need.

My suggestion: limit your scope and have fun doing it yourself

like image 29
Mike T Avatar answered Oct 03 '22 21:10

Mike T