View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis Dana DeLouis is offline
external usenet poster
 
Posts: 947
Default Problem solver call from vb6

Just an idea. Sometimes, you can get more accuracy by using Newton's
Equation directly in your code. This isn't fancy, but I was thinking
something like this...

Sub TestIt()
Debug.Print FX(1)
Debug.Print FX(0)
End Sub

Returns:
0.624031260377961
0.10013561506815

Function FX(Guess) As Double

Dim B9, B7, B3, B2, K
Dim Num, Den
Dim J As Long
Dim X As Double

B2 = 0.28
B3 = 0.26
B7 = 0.19
B9 = 0.003
K = 1.52765618
X = Guess

For J = 1 To 12

Num=Exp((B7-(B9+X)/K))*((B9+X)/(B7*K))^B7-B3/B2

Den=((B7*((B9+X)/(B7*K))^(B7+1)*(B7*K-X-B9))/_
(Exp(((B9-B7*K+X)/K))*(B9+X)^2))

X = X - Num / Den
Next J
FX = X
End Function

--
HTH :)
Dana DeLouis
Windows XP & Office 2003


"Dana DeLouis" wrote in message
...
Hi. If the second equation is correct, and given your data, a math
program shows that there are two solutions for A150 that can make your
equation equal to Zero.
A150 ~ .1001 & A150 ~ .624
You may have to adjust Solver's options for Precision, Tolerance, and
Convergence.

--
HTH :)
Dana DeLouis
Windows XP & Office 2003


"xyfix" wrote in message
ups.com...
You're right, when you say that tha 25.4 gets cancelled out, but it is
a conversion constant (inch to millimeter) and I' ve already removed
it. I'm going to try your idea and get back to you.

xyfix

Dana DeLouis schreef:

Hi. I don't have a solution, just an idea.
Although not based on anything, I try to avoid Solver problems that gets
data from other sheets. I would try to move everything to one sheet.
I would try to use Range Names if possible. Note that 2.718^x = Exp(x).
I used a Constant k to represent 1.527...
It appears to me that 25.4 just cancels out. Is the equation correct?

See if this is a little easier to read.

=Exp((B7-(A150+B9)/k))*((A150+B9)/(B7*k))^B7-B3/B2

Range("Target").Formula = ...etc

vs...

Sheets("outputExpansion").Cells(149, 1).Formula = "=((InputValues!B9
+$A$150)/(1.52765618*
InputValues!B7))^InputValues!B7*(2.71828182845904^ (InputValues!B7
-($A$150 + InputValues!B9)/1.52765618))- ((InputValues!B3
*25.4)/(InputValues!B2 * 25.4)) "

--
HTH :)
Dana DeLouis
Windows XP & Office 2003


"xyfix" wrote in message
ups.com...
Is there anyone who can help me???