
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?

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>

RE: Stupid Math Question
x^y = z<BR><BR>y log(x) = log(z)<BR><BR>y = log(z) / log(x)

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>

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's the natural logbase einstead 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't matter as long as it's the same.)<BR><BR>

Close Bill :)
I think I'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'll let is slide though, since you did get the final answer right.

** AHEM!!!! **
RTFM!<BR><BR>http://msdn.microsoft.com/library/default.asp?url=/library/enus/script56/html/vsfctlog.asp<BR><BR>Enough said?<BR><BR>

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

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

Bill...
I'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

Forum Rules

