Go to Post Mentors learn from, are inspired by, and emulate each other. A team with a great lead mentor leads to a productive, inspired, and ultimately successful group of mentors. - Jared Russell [more]
Home
Go Back   Chief Delphi > Other > Math and Science
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Old 23-12-2016, 21:52
Hitchhiker 42's Avatar
Hitchhiker 42 Hitchhiker 42 is offline
Roboter
AKA: Mark Lavrentyev
FRC #4557 (FullMetal Falcons)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: Cromwell, CT
Posts: 459
Hitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to behold
Re: numerical solution of differential equations

Quote:
Originally Posted by Ether View Post


@Mark: Where did you get the accel formula for columns D and G.


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.
__________________



2016 - NE District Championship Entrepreneurship Award
2016 - Hartford District Industrial Design Award
2016 - Waterbury District Engineering Inspiration Award
Reply With Quote
  #17   Spotlight this post!  
Old 23-12-2016, 21:53
Hitchhiker 42's Avatar
Hitchhiker 42 Hitchhiker 42 is offline
Roboter
AKA: Mark Lavrentyev
FRC #4557 (FullMetal Falcons)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: Cromwell, CT
Posts: 459
Hitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to behold
Re: numerical solution of differential equations

And the new sheets:
Attached Files
File Type: xls Copy of Euler-2.XLS (280.0 KB, 6 views)
File Type: xls Copy of Midpoint.XLS (363.5 KB, 4 views)
__________________



2016 - NE District Championship Entrepreneurship Award
2016 - Hartford District Industrial Design Award
2016 - Waterbury District Engineering Inspiration Award
Reply With Quote
  #18   Spotlight this post!  
Old 23-12-2016, 21:57
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: numerical solution of differential equations

Quote:
Originally Posted by Hitchhiker 42 View Post
And the new sheets:
where did you get the revised accel formula?



Reply With Quote
  #19   Spotlight this post!  
Old 24-12-2016, 15:22
Hitchhiker 42's Avatar
Hitchhiker 42 Hitchhiker 42 is offline
Roboter
AKA: Mark Lavrentyev
FRC #4557 (FullMetal Falcons)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: Cromwell, CT
Posts: 459
Hitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to behold
Re: numerical solution of differential equations

Quote:
Originally Posted by Ether View Post
where did you get the revised accel formula?



I took the derivative of the actual velocity function. Is this not correct?
__________________



2016 - NE District Championship Entrepreneurship Award
2016 - Hartford District Industrial Design Award
2016 - Waterbury District Engineering Inspiration Award
Reply With Quote
  #20   Spotlight this post!  
Unread 24-12-2016, 15:40
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,531
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: numerical solution of differential equations

Quote:
Originally Posted by Hitchhiker 42 View Post
I took the derivative of the actual velocity function. Is this not correct?
No, as I read it you're setting x''=3x/2. This would be solved by a function of the form x=Ae3x/2
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #21   Spotlight this post!  
Unread 24-12-2016, 16:43
Hitchhiker 42's Avatar
Hitchhiker 42 Hitchhiker 42 is offline
Roboter
AKA: Mark Lavrentyev
FRC #4557 (FullMetal Falcons)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: Cromwell, CT
Posts: 459
Hitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to behold
Re: numerical solution of differential equations

Quote:
Originally Posted by GeeTwo View Post
No, as I read it you're setting x''=3x/2. This would be solved by a function of the form x=Ae3x/2
Could you explain what this means? I'm not sure I understand...
__________________



2016 - NE District Championship Entrepreneurship Award
2016 - Hartford District Industrial Design Award
2016 - Waterbury District Engineering Inspiration Award
Reply With Quote
  #22   Spotlight this post!  
Unread 24-12-2016, 17:21
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: numerical solution of differential equations

Quote:
Originally Posted by Hitchhiker 42 View Post
Could you explain what this means? I'm not sure I understand...
In post14 you wrote:
Quote:
Originally Posted by Hitchhiker 42 View Post
I've attached your spreadsheets modified for 1/4*x^3 + 1.
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 : 24-12-2016 at 17:39.
Reply With Quote
  #23   Spotlight this post!  
Unread 24-12-2016, 17:39
Hitchhiker 42's Avatar
Hitchhiker 42 Hitchhiker 42 is offline
Roboter
AKA: Mark Lavrentyev
FRC #4557 (FullMetal Falcons)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: Cromwell, CT
Posts: 459
Hitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to behold
Re: numerical solution of differential equations

Quote:
Originally Posted by Ether View Post
In post14 you wrote:


I am assuming what you actually meant by that is

x(t) = 1/4*t^3 + 1

Is that correct?


Yes, sorry about that. That was what I meant.
__________________



2016 - NE District Championship Entrepreneurship Award
2016 - Hartford District Industrial Design Award
2016 - Waterbury District Engineering Inspiration Award
Reply With Quote
  #24   Spotlight this post!  
Unread 24-12-2016, 21:04
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: numerical solution of differential equations

Quote:
Originally Posted by Hitchhiker 42 View Post
Yes, sorry about that. That was what I meant.
OK.

x(t) = 1/4*t^3 + 1 is the analytical solution to the Initial Value Problem

a(t) = sqrt(3*v(t))

with initial values*

x(0.01) = 1.00000025

and

v(0.01) = 7.5e-5

As you can see from the spreadsheet, the Midpoint method gives much better results for that IVP than Forward Euler and Forward/Backward Euler.


* selected to avoid the stationary point at t=0

Attached Files
File Type: xls x=1+0.25(t^3).XLS (94.0 KB, 5 views)
Reply With Quote
  #25   Spotlight this post!  
Unread 25-12-2016, 04:18
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,531
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: numerical solution of differential equations

Quote:
Originally Posted by GeeTwo View Post
No, as I read it you're setting x''=3x/2. This would be solved by a function of the form x=Ae3x/2
Quote:
Originally Posted by Hitchhiker 42 View Post
Could you explain what this means? I'm not sure I understand...
Sorry, that should have been x''=Ae√3t/√2

if x=Ae√3t/√2,
then x'=√3Ae√3t/√2/√2 (chain rule)
and x''=3Ae√3t/√2/2 (chain rule again) = 3x/2.

Edit: I knew there was more to it, and just figured out the other part:

x''=3x/2 ==> x= Ae√3t/√2 + Be-√3t/√2
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.

Last edited by GeeTwo : 25-12-2016 at 04:47.
Reply With Quote
  #26   Spotlight this post!  
Unread 25-12-2016, 07:50
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: numerical solution of differential equations

Quote:
Originally Posted by Hitchhiker 42 View Post
I've attached your spreadsheets modified for 1/4*x^3 + 1
Quote:
Originally Posted by Ether View Post
I am assuming what you actually meant by that is

x(t) = 1/4*t^3 + 1

Is that correct?
Quote:
Originally Posted by Hitchhiker 42 View Post
Yes, sorry about that. That was what I meant.
Quote:
Originally Posted by Hitchhiker 42 View Post
I took the derivative of the actual velocity function. Is this not correct?
Yes, but you got x and t confused.

given:

x(t) = 1/4*t^3 + 1

... take time derivative of x(t) to get:

x'(t) = (3/4)*t^2

...take time derivative of x'(t) to get:

x''(t) = (3/2)*t


Now solve for the differential equation:

solve x'(t) for t:

x'(t) = (3/4)*t^2 => t=sqrt(4x'(t)/3)

... and then substitute for t in x''(t):

x''(t) = (3/2)*t = (3/2)*sqrt(4x'(t)/3) = sqrt(3*x'(t))




Last edited by Ether : 25-12-2016 at 08:11.
Reply With Quote
  #27   Spotlight this post!  
Unread 25-12-2016, 16:46
Hitchhiker 42's Avatar
Hitchhiker 42 Hitchhiker 42 is offline
Roboter
AKA: Mark Lavrentyev
FRC #4557 (FullMetal Falcons)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: Cromwell, CT
Posts: 459
Hitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to behold
Re: numerical solution of differential equations

Quote:
Originally Posted by Ether View Post
Yes, but you got x and t confused.

given:

x(t) = 1/4*t^3 + 1

... take time derivative of x(t) to get:

x'(t) = (3/4)*t^2

...take time derivative of x'(t) to get:

x''(t) = (3/2)*t


Now solve for the differential equation:

solve x'(t) for t:

x'(t) = (3/4)*t^2 => t=sqrt(4x'(t)/3)

... and then substitute for t in x''(t):

x''(t) = (3/2)*t = (3/2)*sqrt(4x'(t)/3) = sqrt(3*x'(t))



I see... so that column is in terms of x', not t. I've updated the spreadsheet to reflect that and it seems to show that the Euler method does better.
dt = 0.01s, error measured at t=3s.

Euler error: 0.2061
Midpoint error: 5.0828

This, I presume, is for the reason I mentioned in my first post.
__________________



2016 - NE District Championship Entrepreneurship Award
2016 - Hartford District Industrial Design Award
2016 - Waterbury District Engineering Inspiration Award
Reply With Quote
  #28   Spotlight this post!  
Unread 26-12-2016, 00:03
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: numerical solution of differential equations

Quote:
Originally Posted by Hitchhiker 42 View Post
I see... so that column is in terms of x', not t. I've updated the spreadsheet to reflect that and it seems to show that the Euler method does better.
You're still struggling with this, but I can't point out your error since you didn't post your spreadsheet.

I think you may have overlooked my earlier post #24. The attachment shows how to set up the formulas.

The Midpoint method is clearly better than either Forward/Forward Euler or Forward/Backward Euler for this IVP.



Last edited by Ether : 26-12-2016 at 00:23.
Reply With Quote
  #29   Spotlight this post!  
Unread 28-12-2016, 22:05
Hitchhiker 42's Avatar
Hitchhiker 42 Hitchhiker 42 is offline
Roboter
AKA: Mark Lavrentyev
FRC #4557 (FullMetal Falcons)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: Cromwell, CT
Posts: 459
Hitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to behold
Re: numerical solution of differential equations

I redid the midpoint spreadsheet - now at t=9.96s with dt=0.01s, the error is only 0.96. I replaced the Am column with the Am = sqrt(3*x').

Now to search for a possible explanation...
I did find this http://www.physics.drexel.edu/~steve...rs/simple.html

My guess would be that for this function, which, on the interval being examined, is concave up always (x'' > 0), the Euler method uses a point from farther back than the midpoint method to determine the slope (beginning of the interval slope vs. mid-interval slope). As it's concave up, the Euler method lags behind the midpoint method in growth, and so grows slower than the actual function by more than the midpoint method.

Now to test a method where it uses the end of the interval's slope...
Attached Files
File Type: xls Copy of Copy of Midpoint-1.XLS (363.5 KB, 3 views)
__________________



2016 - NE District Championship Entrepreneurship Award
2016 - Hartford District Industrial Design Award
2016 - Waterbury District Engineering Inspiration Award
Reply With Quote
  #30   Spotlight this post!  
Unread 28-12-2016, 22:18
Hitchhiker 42's Avatar
Hitchhiker 42 Hitchhiker 42 is offline
Roboter
AKA: Mark Lavrentyev
FRC #4557 (FullMetal Falcons)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: Cromwell, CT
Posts: 459
Hitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to behold
Re: numerical solution of differential equations

Quote:
Originally Posted by Hitchhiker 42 View Post
Now to test a method where it uses the end of the interval's slope...
Drat... I tried it using the slope at the end of the interval instead of at the beginning, and it turned out to have a tad bit more error compared to the actual function.
Attached Files
File Type: xlsx euler both.xlsx (212.2 KB, 2 views)
__________________



2016 - NE District Championship Entrepreneurship Award
2016 - Hartford District Industrial Design Award
2016 - Waterbury District Engineering Inspiration Award
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 14:11.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi