Stupid Math Question

1. Senior Member
Join Date
Dec 1969
Posts
220

Stupid Math Question

x ^ y = z<BR><BR>If I know the value of x and z, how can I determine the value of y?

2. Senior Member
Join Date
Dec 1969
Posts
96,118

Do it the computer way...

x ^ y = z<BR><BR>is actually calculated as<BR><BR>z = Exp( y * Log(x) )<BR><BR>Which really means that<BR><BR>Log(z) = y * Log(x)<BR><BR>So<BR><BR>y = Log(z) / Log(x)<BR><BR>Yes, using the LOG() and EXP() functions that are part of VBScript (and most other languages).<BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
415

RE: Stupid Math Question

x^y = z<BR><BR>y log(x) = log(z)<BR><BR>y = log(z) / log(x)

4. Senior Member
Join Date
Dec 1969
Posts
220

RE: Do it the computer way...

Thanks Bill. I always thought I was pretty smart when it came to math, but I never you could do exponentials and roots using logarithms. I guess you DO learn something new every day.<BR><BR>Thanks again.<BR>

5. Senior Member
Join Date
Dec 1969
Posts
96,118

That is the *ONLY* way...

...to do it that will work in a fixed amount of time.<BR><BR>Granted, you could just do multiplies appropriately if the exponent is an integer, but if it was an integer such as in 3 ^ 17881721 that would take longer than just doing the <BR><BR> Exp( 17881721 * Log(3) )<BR><BR>scheme. (That&#039;s the natural log--base e--instead of log base 10, because Exp(n) means e to the n power. You could use Log10 if you had a Exp10 function. The base doesn&#039;t matter as long as it&#039;s the same.)<BR><BR>

6. Senior Member
Join Date
Dec 1969
Posts
415

Close Bill :)

I think I&#039;m gonna have to make a slight correction and point out that<BR><BR>z = Exp( y * Ln(x)) <BR>(If that is the VBScript function for Natural Log)<BR><BR>I&#039;ll let is slide though, since you did get the final answer right.

7. Senior Member
Join Date
Dec 1969
Posts
96,118

** AHEM!!!! **

RTFM!<BR><BR>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctlog.asp<BR><BR>Enough said?<BR><BR>

8. Senior Member
Join Date
Dec 1969
Posts
415

Bested

I should know better than to try and catch you on a technicality, but would you have it any other way?

9. Senior Member
Join Date
Dec 1969
Posts
96,118

Oh, I love it!

And I have to admit to you that I actually *did* go look at the list of functions before I wrote my answer. So I cheated. I actually did RTFM. &#060;grin /&#062;<BR><BR>I was actually hoping that VBS had Log10 and Exp10 (as some languages do) so I could demo it either way, but no such luck.<BR><BR>p.s.: I actually wrote software floating point packages to do Ln and Exp and, of course, power. On 3 different hardware architectures with 3 different floating point bit formats, no less. Talk about an obsolete skill! I might as well have learned to make buggy whips!<BR><BR>

10. Senior Member
Join Date
Dec 1969
Posts
2,092

Bill...

I&#039;m curious, what is it you eat in the morning :-)<BR><BR>Sincerely<BR>Vlince

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•