Post Reply 
New algorithms for numerical integration and ODE solutions
03-15-2014, 06:31 PM
Post: #5
RE: New algorithms for numerical integration and ODE solutions
When I ran your mod using Gauss2 on Sheet10, I got a result that was not very accurate. the result was something like 0.69.

Because of the small slope at zero, the first value of h was 1000, then Y2=0 and the calculation of h is exited. X2 is then reduced to 5 (XMax), then the Gauss algorithm calculates the integral in one interval from 0 to 5.

I recommend modifying the calculation of h as follows:

XMaxDelta = (Xmax - X1) / 5
' Put an upper limit on the interval size

h = 2 * Abs(YMaxDelta / MyDx(sFx, X1))
If (h > XMaxDelta) Then h = XMaxDelta
For i = 1 To 100 ' prevent infinite loop (may not be necessary)

h = h / 2
X2 = X1 + h
Y2 = MyFx(sFx, X2)
If (Abs(Y2 - Y1) <= YMaxDelta) Then Exit For

Next i

A better way might be to remove EPSILON from MyDx (allow that function to be as accurate as possible) and calculate 1/h first to avoid a divide by zero, then limit 1/h.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: New algorithms for numerical integration and ODE solutions - Dan W - 03-15-2014 06:31 PM



User(s) browsing this thread: 1 Guest(s)