Connecting Tech Pros Worldwide Forums | Help | Site Map

Sometjing to solve my problem

MAgnus
Guest
 
Posts: n/a
#1: Nov 17 '05
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++.



Larry Brasfield
Guest
 
Posts: n/a
#2: Nov 17 '05

re: Sometjing to solve my problem


"MAgnus" <MAgnus@discussions.microsoft.com> wrote in message
news:E2678753-6641-4D7D-9CEE-286C2D1C58FF@microsoft.com...[color=blue]
>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?[/color]

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

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

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.

--
--Larry Brasfield
email: donotspam_larry_brasfield@hotmail.com
Above views may belong only to me.


Larry Brasfield
Guest
 
Posts: n/a
#3: Nov 17 '05

re: Sometjing to solve my problem


"Larry Brasfield" <donotspam_larry_brasfield@hotmail.com> wrote in message news:ugpygKVCFHA.3976@tk2msftngp13.phx.gbl...[color=blue]
> "MAgnus" <MAgnus@discussions.microsoft.com> wrote in message
> news:E2678753-6641-4D7D-9CEE-286C2D1C58FF@microsoft.com...[color=green]
>>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?[/color]
>
> With the application of some algebra, this will become a quadratic.[/color]

Wrong. It is quadratic only for b==1.
[color=blue]
> You can then use the well-known "quadratic formula" to solve for r.
>[color=green]
>> Is there any function that can search for the value of r when r 0<r<1?[/color]
>
> A search is not necessary. It can be solved analytically.[/color]

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.

--
--Larry Brasfield
email: donotspam_larry_brasfield@hotmail.com
Above views may belong only to me.


Rodrigo Corral [MVP]
Guest
 
Posts: n/a
#4: Nov 17 '05

re: Sometjing to solve my problem


What about using the newton-raphson method...


--
Regards,
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org


Rodrigo Corral [MVP]
Guest
 
Posts: n/a
#5: Nov 17 '05

re: Sometjing to solve my problem


Or some other finding algorithm...

http://mathworld.wolfram.com/Root-FindingAlgorithm.html


--
Regards,
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org


Closed Thread