0% found this document useful (0 votes)
30 views2 pages

Solving A Second Order Differential Equation With Runge Kutta

This document discusses using the Runge-Kutta method to solve differential equations. It first solves a second order differential equation describing motion with constant force by breaking it into two first order equations. It then uses Runge-Kutta to solve the equations numerically, plotting the results. Finally, it solves the equations of motion for a ball thrown in two dimensions.

Uploaded by

sachins1318
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

Solving A Second Order Differential Equation With Runge Kutta

This document discusses using the Runge-Kutta method to solve differential equations. It first solves a second order differential equation describing motion with constant force by breaking it into two first order equations. It then uses Runge-Kutta to solve the equations numerically, plotting the results. Finally, it solves the equations of motion for a ball thrown in two dimensions.

Uploaded by

sachins1318
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

5/11/2012 Numercial methods Differential equations 1

Solving a second order differential equation with Runge Kutta


Consider the equation F = ma. This is a second order equation that can be written

d2x
m F
dt 2
Runge Kutta solves first order equations. We can solve the second order equation by turning it
into two first order equations. A new variable is defined as the first time derivative of x.
We will call this v for historical reasons. The set of two equations below completely describes
the problem:

dx dv F x 0 v 0
v, These are starting values:
F 1 m 1
dt dt m

Runge Kutta can solve these two equations simultaneously.


We must define a vector with the two components x and v.

x On the right side I used the Insert|Matrix command from the matrix menu
X
v and selected one column and two rows. X is the vector containing the
variables that are the answers.

X1 this says dx/dt = v = X1


Now define the derivative of the vector X DX( t X) F
m this says dv/dt = a = F/m

X0 is x and X1 is v. Mathcad numbers the components of vectors beginning with zero, unless you
change it. For example, if you prefer to number beginning with 1, you would type ORIGIN:=1.
But this is NOT recommended except for the simplest programs, because the ORIGIN statement
applies to everything you type after you use it.

Now solve the equations using Runge Kutta for t = 0 to t = 10. Let: tstart 0 tend 10
This interval will be divided into 10 parts: npoints 10

0 We must put the starting values of x and v into the vector Xstart.
Xstart
0 These are the constants of integration.

The equations of motion will be integrated by Runge-Kutta by using the rkfixed function.
The arguments are the starting value of x, the starting and ending values of t, the number of points
on the time interval

F rkfixed ( Xstart tstart tend npoints DX)

The answer matrix F will contain the times and the successive values of the vector X.
5/11/2012 Numercial methods Differential equations 2

The answer matrix returned b y rkfixed: Plots of the distance and velocity:

t X X
0 1 velocity v(t)
0 1 2 10
0 0 0 0 8
1 1 0.5 1 2 6
F
2 2 2 2 4
3 3 4.5 3 2
4 4 8 4 0
F 0 2 4 6 8 10
5 5 12.5 5
0
6 6 18 6 F
7 7 24.5 7
8 8 32 8 distance x(t)
9 9 40.5 9 50
10 10 50 10 40

1 30
F
These plots are what we expected. 20
With constant force, velocity increases linearly 10
with time and distance increases with the square 0
0 2 4 6 8 10
of time. Note that 0.5 a t2 = 50 when t = 10.
0
F
Now throw a ball in two dimensions:
The vector X will contain four components: x, y, dx/dt, dy/dt.

0 x is X0 My starting conditions are that I throw the ball from x,y = 0,0
y is X1 with v = 50 in the x direction and v = 50 in the y direction.
Xstart
0
50 dx/dt is X2
50 dydt is X3 g 9.8 is the acceleration of gravity, in the -y direction

X2 dx/dt = vx = X2
We will again integrate from t = 0 to t = 10
using 10 points.
X dy/dt = vy = X3
DX( t X) 3
dvx/dt = 0 F rkfixed ( Xstart tstart tend npoints DX)
0
dvy/dt = -g
g path of thrown ball
150

This is a plot of y versus x, which is


100
the second column of F versus the 2
first column. This indeed looks like what F
happens when you throw a ball. 50
The zero column of F, not used here,
contains time. 0
0 100 200 300 400 500
1
F

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy