# Newton Rapson library for APR calculator in JAVA

Shailesh Kulkarni

Greenhorn

Posts: 11

posted 11 years ago

Hello Everyody,

I want to write Java programme by using formula

p=(C+E)r(1+r)N/(1+r)N-1

and using Newton rapson method (a(1+a)N/(1+a)N-1)- (p/c)=0

where N is raise to value.

C=Loan Amount

E=Extra Cost

R=Interest Rate

N=Number of months

This calculator first calculates the monthly payment using C+E and the original interest rate r = R/1200:

The APR (a = A/1200) is then calculated iteratively by solving the following equation using the Newton-Raphson method:

Is there any libriry in java for Newton rapson method. Or any help is same kind of work. Plz guide me ..!! Its urgent ..!!

I want to write Java programme by using formula

p=(C+E)r(1+r)N/(1+r)N-1

and using Newton rapson method (a(1+a)N/(1+a)N-1)- (p/c)=0

where N is raise to value.

C=Loan Amount

E=Extra Cost

R=Interest Rate

N=Number of months

This calculator first calculates the monthly payment using C+E and the original interest rate r = R/1200:

The APR (a = A/1200) is then calculated iteratively by solving the following equation using the Newton-Raphson method:

Is there any libriry in java for Newton rapson method. Or any help is same kind of work. Plz guide me ..!! Its urgent ..!!

Peter Chase

Ranch Hand

Posts: 1970

posted 11 years ago

Well, if you Google for "java newton raphson", you'll get plenty of help. It would be a good idea to try Google (or your favourite search engine) before posting questions.

To solve with Newton-Raphson, you need a way of evaluating the function f(x) and its first derivative f'(x), at any value of the unknown x.

Hopefully, you can do a bit of calculus to work out an analytic function for your derivative. If not, it is possible to estimate the derivative by evaluating the function at two points very close to the current value of the unknown x.

The Newton-Raphson formula tells you what change in x would make f(x) be zero, if the function were linear. If the function is mildly non-linear then repeated application of the formula will often allow you to get close to the true solution.

Newton-Raphson is not a particularly good solver. If this is a homework assignment, I guess you've been told to use it. If it's a real application, you should look for something better. There are probably open-source libraries with various equation-solvers in them (see that Google search again).

One simple modification to pure Newton-Raphson is to limit the size of the step you take in x. This prevents the algorithm from going mad if it reaches a region of very small derivative.

HTH

To solve with Newton-Raphson, you need a way of evaluating the function f(x) and its first derivative f'(x), at any value of the unknown x.

Hopefully, you can do a bit of calculus to work out an analytic function for your derivative. If not, it is possible to estimate the derivative by evaluating the function at two points very close to the current value of the unknown x.

The Newton-Raphson formula tells you what change in x would make f(x) be zero, if the function were linear. If the function is mildly non-linear then repeated application of the formula will often allow you to get close to the true solution.

Newton-Raphson is not a particularly good solver. If this is a homework assignment, I guess you've been told to use it. If it's a real application, you should look for something better. There are probably open-source libraries with various equation-solvers in them (see that Google search again).

One simple modification to pure Newton-Raphson is to limit the size of the step you take in x. This prevents the algorithm from going mad if it reaches a region of very small derivative.

HTH

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