Connecting Tech Pros Worldwide Help | Site Map

can anyone help me with this? im really lost..

Newbie
 
Join Date: Oct 2009
Posts: 9
#1: Oct 4 '09
The following series summation is an approximation for computing the natural logarithm of a floatingpoint
value x:
logx=(x-1)–(x-1)2/2+(x-1)3/3–(x-1)4/4+….+(-1)n+1(x-1)n/n
Where 2 >= x > 0 and n is a positive integer.
Design and implement an interactive program that does the following:
1. Prompts the user to enter a floating-point value for x and reads it.
2. Ensures that x is in the proper range; if not, re prompts the user to enter another value.
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,153
#2: Oct 4 '09

re: can anyone help me with this? im really lost..


  1. I do not believe you have your formula correct (x-1)2/2 is equivalent to (x-1) a similar argument applies to your first 4 terms so they become

    (x-1)–(x-1)+(x-1)–(x-1)

    none of which is equivalent to your last term (-1)n+1(x-1)n/n unless by (-1)n+1 you actually meant (-1) raise to the power (n+1) which is not what you have written. All of which leads to a series that has the value (x-1) if it has an odd number of terms and 0 if it has an even number of terms which is nowhere near equal to log(x).
  2. Of course all that is irrelevant since the program you have to write just takes a floating point number as input and checks it is with-in some valid range. It never tries to use the formula.
  3. An lastly we do not do your work for you on this forum. If you have a problem with the code you have written then please share that code with us and we will help you with your problems.
Newbie
 
Join Date: Oct 2009
Posts: 9
#3: Oct 4 '09

re: can anyone help me with this? im really lost..


ewh.. i made a mistake.. it should be
logx=(x-1)–(x-1)^2/2+(x-1)^3/3–(x-1)^4/4+….+(-1)^n+1 (x-1)^n /n
its the power actually..
can u help..?
Familiar Sight
 
Join Date: Jan 2007
Posts: 188
#4: Oct 5 '09

re: can anyone help me with this? im really lost..


I don`t think so....now you are raising each term to the oneth power? which is the term. You probably mean (x-1)-((x-1)^2)/2+...?
Expert
 
Join Date: Mar 2008
Location: Naperville, Illinois U.S.
Posts: 828
#5: Oct 5 '09

re: can anyone help me with this? im really lost..


How many terms from the equation do you intend to use?

We can't really help you until you first make an effort to write the program. If your attempt doesn't work then tell us what went wrong and we'll try to help.
Newbie
 
Join Date: Oct 2009
Posts: 9
#6: Oct 5 '09

re: can anyone help me with this? im really lost..


actually i also dun know how many terms.. its like this.. (x-1)-[(x-1)^n]/n
then it will plus [(x-1)^n+1]/n+1 then it will minus the same thing but n is increasing by 1...
so the term is like - + - +
i dont how to started this algorothm yet.. but i'll try this.. any problem i will post
it again..
any help is appreciated.. ^^
Reply