File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Method to find derivative Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Method to find derivative" Watch "Method to find derivative" New topic

Method to find derivative

dhwani mathur
Ranch Hand

Joined: May 08, 2007
Posts: 621
I have to find derivative of a function in java,but i am not getting which method and from which class of java package i should use.Please
if anyone has any idea your suggestions are welcome.
Thanks in advance.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
I presume by derivative, you mean f'(x) = dy/dx, where y = f(x).

There's no function, to my knowledge, to find the derivative in Java. You won't find that in many, if any, general-purpose programming languages. You'd need something maths-specific - maybe Matlab (I don't know if it actually has this feature, but it might).

There are two completely different ways you might want your derivative.

First, you might want to do it analytically. That is, given some machine-understandable formula for f(x), it should be able to work out an exact formula for f'(x). This would only be possible for certain classes of function, for which derivatives are reasonably easy to compute analytically.

The alternative is that you might want to compute the derivative numerically, at a particular value of x. A numerical method can work for any type of f(x) - well any f(x) that's not discontinuous anyway. There are various algorithms for this: try the Numerical Recipes books, for instance. All of these will be inexact, but they can get close to an exact answer, depending on the algorithm chosen and the type of function f(x).

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
dhwani mathur
Ranch Hand

Joined: May 08, 2007
Posts: 621
Thanks for giving an idea.
I agree. Here's the link:
subject: Method to find derivative
It's not a secret anymore!