programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# Method to find derivative

Ranch Hand
Posts: 621
ok
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.

Ranch Hand
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).

dhwani mathur
Ranch Hand
Posts: 621
Thanks for giving an idea.

Greenhorn
Posts: 1
Uhm, I know this is a 10 years ago thread but I wanted to give you for users that come here.
I've just done a video introducing a library to do that: