I always have to use the
solver so it takes a while to get it done
For x that goes from 1 to 30 (all integers), I want to evaluate "m".
Hi. Here's one idea. To keep the main loop simple, I set the loops to 10.
You only need about 6 loops.
Sub TestIt()
Dim j
For j = 0 To 30
Debug.Print j; FormatNumber(SolveForM(j), 6)
Next j
End Sub
Function SolveForM(x)
'//=======================
'// By: Dana DeLouis
'//=======================
Dim z As Double
Dim j As Long
With WorksheetFunction
z = x
If z = 0 Then z = 0.001
For j = 1 To 10
z = z + Exp(z) * .Power(z, -x) * (Gamma(x + 1, z) - 0.95 * .Fact(x))
Next j
End With
SolveForM = z
End Function
Function Gamma(Alpha, z)
With WorksheetFunction
Gamma = Exp(.GammaLn(Alpha)) * (1 - .GammaDist(z, Alpha, 1, True))
End With
End Function
First few solutions a
0 0.051293
1 0.355362
2 0.817691
3 1.366318
4 1.970150
5 2.613015
--
HTH. :)
Dana DeLouis
Windows XP, Office 2003
"bambinos83" wrote
in message ...
Hi,
I'm having a little problem. I'm trying to calculate a formula which
grows for every calculation I must make. I always have to use the
solver so it takes a while to get it done. Here is my problem.
For x that goes from 1 to 30 (all integers), I want to evaluate "m". I
also want the result of the equation to be 0.95 so here how it goes:
For x=0: 0.95 = exp(-m) - m = 0.051
For x=1: 0.95 = exp(-m) * (1+m) - m = 0.355
For x=2: 0.95 = exp(-m) * (1+m+m²/2) - m = 0.818
For x=3: 0.95 = exp(-m) * (1+m+m²/2+m³/6) - m = 1.366
For x=4: 0.95 = exp(-m) * (1+m+m²/2+m³/6+(m^4)/24)
and so on...
As you may notice, the denominator is the factorial of the exponent of
"m". So, I was wondering if there was a way to simplify those
calculations....
THanks
--
bambinos83
------------------------------------------------------------------------
bambinos83's Profile:
http://www.excelforum.com/member.php...o&userid=32589
View this thread: http://www.excelforum.com/showthread...hreadid=556589