|
-
January 12th, 2000, 09:58 PM
#1
math / VB CODE thing
i am first going to explain it. It is a program to solve an equation A^X=B, where the user gives A and B. So, this can solve 3 ^ X = 5, without using logarthmic functions. There is a way to do this:
On paper, it is set up like this: (nothing to do with division solving)
_1.___________
3 )5.0000000000
See that 3^1 is the lowest whole number digit below 5 (3^2 is 9, above 5.)
Then you:
1._______
3 )5.0000000
/3^10
You take 5, divide it by 3, and put that to the power of 10 [(5/3)^10]. In this case, it is about 165. Now you repeat the process, this time with 165. You see that 3^4 is the closest whole number before 165, 3^5 is above it. So you add in 4, then do [(165/(3^4))^10], and continue...
Now here is my question, and it is a tough one:
How can I do that in VB code? I have used a do-loop statement, but no luck so far... Word of advice: the correct answer should be 1.462...
-
January 13th, 2000, 04:54 PM
#2
Re: math / VB CODE thing
Well, I don't have an answer that involves code, but I'm sure you will have to use a recursive algorithm.
Function GetExponent(a as Single, b as Single, optional n as Single, optional iPower as Single) as Double
'or something like that
...do process for one time through get the next power(the 10) and next guess (the 4)
...check to see if you should exit or not
...Call GetExponent(a,b,4,10)
End Function
This will call itself until it thinks it's done and then back out, one level at a time. I hope this makes sense. I did this when I was in college, but it has been some time since then. 
Hope this helps somewhat,
john
John Pirkey
MCSD
www.ShallowWaterSystems.com
John Pirkey
MCSD (VB6)
http://www.stlvbug.org
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
|
Click Here to Expand Forum to Full Width
|