Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / February 2005

Tip: Looking for answers? Try searching our database.

Sometjing to solve my problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MAgnus - 02 Feb 2005 10:31 GMT
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 - 02 Feb 2005 18:11 GMT
>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.

Signature

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

Larry Brasfield - 02 Feb 2005 18:34 GMT
>>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.

Wrong.  It is quadratic only for b==1.

> 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.

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.

Signature

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

Rodrigo Corral [MVP] - 02 Feb 2005 20:31 GMT
What about using the newton-raphson method...

Signature

Regards,
Rodrigo Corral Gonz?lez [MVP]

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

Rodrigo Corral [MVP] - 02 Feb 2005 20:34 GMT
Or some other finding algorithm...

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

Signature

Regards,
Rodrigo Corral Gonz?lez [MVP]

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.