Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Math help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kingman202




PostPosted: Mon Feb 07, 2005 10:27 am   Post subject: Math help

Is it possible to use the log function in Turning. If it is possible can someone please post a mini program
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Mon Feb 07, 2005 2:01 pm   Post subject: (No subject)

AFAIK, there is not log function in OOT. However, there is a ln function (natural log).
Thus being, you can simply use the change of base forumla:


log
10x = lnex / ln10x


to compute the necassary log values.

E.g.
code:

put ln (3)
%  -> 1.098612
put ln (3) / ln (10)
% -> equivilant of log(10) -> 0.477121
kingman202




PostPosted: Mon Feb 07, 2005 2:23 pm   Post subject: (No subject)

Thanks, I have one problem.
How do i enter this equation so turing can understand this.

n=log(s/p)
---------
log(1+i)

how can i get turing to use this equation
Delos




PostPosted: Mon Feb 07, 2005 4:19 pm   Post subject: (No subject)

My suggestion is to create your own log fcn. This can be done using the function keyword. Set it up with the necassary parameters (you'll probably just need one if you're working on a purely base 10 log) and then use that in your eqn.

e.g.
Turing:

function square (num : int) : int
   result num ** 2
end square

put (square (2)  / square (3))
kingman202




PostPosted: Wed Feb 09, 2005 11:18 am   Post subject: (No subject)

That is great. But I am still getting the wrong answer.
For example if i Put in
log (26/7)/ log (55/5)
the answer is -0.57
put in turing I comes out to be 1.9876.
That is way off. Any Suggestion
Delos




PostPosted: Wed Feb 09, 2005 1:15 pm   Post subject: (No subject)

I guess I should have mentioned this earlier.

Post your code.

No one will be able to help you too much unless we know exactly what you're talking about...in this case I don't know if your '(55/5)' means 55 divided by five, or 55 to the base 5, or something else...
So, post up.
kingman202




PostPosted: Thu Feb 10, 2005 10:43 am   Post subject: (No subject)

Ok
I got the LOG fourmula to work. Thanks for your help. I do have one more formula i can not figure out.

var formula : string
var p, m, s, r, t : real

loop
put "a. S=P(1+i)**n, b. P= S/(1+i)^n,c. n=log(s/p)/log(1+i) "
get formula
if formula = "a" then
put "For this formula I sovle for S "
put "We need some valuse "
put "please input your P value "
get p
put "Now we need I. But to get I we Need R and M "
put "Please enter R value "
get r
put "Please enter M value "
get m
put "Now we Need N But to get N we need T and use the m value "
get t
put "The answer is "
put p * (1 + (r / m)) ** (m * t)
elsif formula = "b" then
put "For this formula we need to solve for P "
put "Please Enter your S value "
get s
put "Now we need I. But to get I we Need R and M "
put "Please enter R value "
get r
put "Please enter M value "
get m
put "Now we Need N But to get N we need T and use the m value "
get t
put "The answer Is "
put s / (1 + (r / m)) ** (m * (t))
elsif formula = "c" then
put "This Formula we solve for n "
put "Please Input The S value "
get s
put "Please input P value "
get p
put "Please enter r value "
get r
put "Please enter m value "
get m
put "the total is "
put (ln (s / p) / ln (10)) / (ln (1+(r / m)) / ln (10))

end if
end loop

There is my program Now can someone help do this. I would like the user to input numbers but if someone inputs a percent i would like to be able to convert that percent into a decimal number.
Any suggestions
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: