
-----------------------------------
kingman202
Mon Feb 07, 2005 10:27 am

Math help
-----------------------------------
Is it possible to use the log function in Turning. If it is possible can someone please post a mini program

-----------------------------------
Delos
Mon Feb 07, 2005 2:01 pm


-----------------------------------
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:


log10x = lnex / ln10x


to compute the necassary log values.

E.g.

put ln (3)
%  -> 1.098612
put ln (3) / ln (10)
% -> equivilant of log(10) -> 0.477121


-----------------------------------
kingman202
Mon Feb 07, 2005 2:23 pm


-----------------------------------
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
Mon Feb 07, 2005 4:19 pm


-----------------------------------
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.

function square (num : int) : int
   result num ** 2
end square

put (square (2)  / square (3))


-----------------------------------
kingman202
Wed Feb 09, 2005 11:18 am


-----------------------------------
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
Wed Feb 09, 2005 1:15 pm


-----------------------------------
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
Thu Feb 10, 2005 10:43 am


-----------------------------------
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
