Sometjing to solve my problem

G

Guest

I need something an algorithm or something else to
help me with this function when a and b are given from functions before.
(1-(1/(1+r))^b)/r=a this is the function is there anything that can help me?
Is there any function that can search for the value of r when r 0<r<1? IF
somebody knows this it would be a great help for me if you display how i
should write the code in c++.
 
L

Larry Brasfield

MAgnus said:
I need something an algorithm or something else to
help me with this function when a and b are given from functions before.
(1-(1/(1+r))^b)/r=a this is the function is there anything that can help me?

With the application of some algebra, this will become a quadratic.
You can then use the well-known "quadratic formula" to solve for r.
Is there any function that can search for the value of r when r 0<r<1?

A search is not necessary. It can be solved analytically.
IF
somebody knows this it would be a great help for me if you display how i
should write the code in c++.

If this is homework, do it yourself. If you are unable to do simple
algebra or find a common formula on the web, and program for
a living, you have chosen the wrong career.

I suggest more care in choosing subject lines in the future. I and
some other people find it difficult to bother looking at a post when
the author cannot bother to do such a simple thing in order to save
readers' time.
 
L

Larry Brasfield

Larry Brasfield said:
With the application of some algebra, this will become a quadratic.

Wrong. It is quadratic only for b==1.
You can then use the well-known "quadratic formula" to solve for r.


A search is not necessary. It can be solved analytically.

I would write a function to calculate the derivative w.r.t. r, then
use Newton's method (aka "Newton-Raphson method") to find
the roots of (1-(1/(1+r))^b)/r - a == 0. It should converge
rapidly over the range you gave for r.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top