|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: numerical solution of differential equations
Quote:
And I have some long-overdue hardware to return to you ![]() |
|
#2
|
||||
|
||||
|
Re: numerical solution of differential equations
Quote:
So, a monotonic function only increases (or decreases). It seems Euler integration would be better suited (read: more accurate) because the midpoint method depends on points behind the given point that's being calculated, which will tend to keep the slope smaller than it should be, whereas because the function doesn't tend to change direction (up or down) as much (it can only go one direction - monotonic), approximating ahead will tend to be better than approximating while taking into account behind the current point as well. |
|
#3
|
|||||
|
|||||
|
Re: numerical solution of differential equations
What surprises me more than the gain in amplitude for Euler (which is pretty easy to guess if you consider what happens to energy at different points) is the excellent prediction of the period. I'll have to give this a look.
I was able to do a version without the two extra columns that tracked pretty closely, using the parabolic formula for constant acceleration to calculate the next position, and the average acceleration assuming constant jerk (x''') to calculate the next velocity. Code:
x[n+1] = x[n] + dt*(x'[n] + x''[n]*dt/2) x''[n+1] = -x[n+1] x'[n+1] = x'[n] + dt*(x''[n] + x''[n+1])/2 Last edited by GeeTwo : 12-23-2016 at 11:16 AM. Reason: Fixd sign on second equation, formatted cleaner |
|
#4
|
||||
|
||||
|
Re: numerical solution of differential equations
Quote:
Quote:
![]() |
|
#5
|
||||
|
||||
|
Re: numerical solution of differential equations
I've attached your spreadsheets modified for 1/4*x^3 + 1.
It seems that the Euler method does approximate it better. |
|
#6
|
||||
|
||||
|
Re: numerical solution of differential equations
@Mark: Where did you get the accel formula for columns D and G. |
|
#7
|
||||
|
||||
|
Re: numerical solution of differential equations
Not sure. Must have been really tired
. I did that over, and also added an error column to show the difference between Xa and the predicted X (Xm or Xe).I set dt = 0.01 s and compared the errors at t = 1, 2, 4 s For 1s: Midpt error: 0.598 Euler error: 0.585 For 2s: Midpt error: 2.834 Euler error: 2.748 For 4s: Midpt error: 50.070 Euler error: 48.113 Seems that, at least for this function, the Euler method holds up better. Tomorrow, I'll try it with a function where the second derivative isn't always positive on the interval I'm testing. |
|
#8
|
||||
|
||||
|
Re: numerical solution of differential equations
And the new sheets:
|
|
#9
|
||||
|
||||
|
Re: numerical solution of differential equations
where did you get the revised accel formula?
|
|
#10
|
||||
|
||||
|
Re: numerical solution of differential equations
I took the derivative of the actual velocity function. Is this not correct?
|
|
#11
|
|||||
|
|||||
|
Re: numerical solution of differential equations
No, as I read it you're setting x''=3x/2. This would be solved by a function of the form x=Ae3x/2
|
|
#12
|
||||
|
||||
|
Re: numerical solution of differential equations
Could you explain what this means? I'm not sure I understand...
|
|
#13
|
||||
|
||||
|
Re: numerical solution of differential equations
Quote:
I am assuming what you actually meant by that is x(t) = 1/4*t^3 + 1 Is that correct? If so, then in order to investigate the performance of Euler vs Midpoint numerical solution (in the context of this thread) you need to convert that to an initial value problem (IVP) consisting of a differential equation (involving only x, x', and x'') plus initial values for x(t) and x'(t) at some point t=to. Last edited by Ether : 12-24-2016 at 05:39 PM. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|