You are on page 1of 25

Glenn Habibi

The Mathematical Difficulties Encountered in

Long Range Weather Forecasting

Introduction

In science, it is important to study recorded data and fit a

mathematical model to it in order to predict the future. For example, if

the acceleration of a mass is dictated by a function of time, then its

velocity can be predicted into a specific amount of time in the future.

Basically, a scientist has to look at past conditions, compare them with

the present, and form a mathematical model, usually in the form of a

function or equation, which will tell a person what the conditions will be

when a certain amount of time has passed. In the 1960s, many

scientists felt that this fundamental principle could be applied

effectively to weather phenomena. The fundamental equations of

physics that involve how gases behave in the atmosphere will be

presented. These six equations have a total of six unknown weather

variables. This system of equations is rather difficult to solve, and thus

it will be simplified to a double Fourier Series. Once done, the

relationship of the first three terms of the series can be ascertained

and studied.

Though long-range weather prediction seems like a simple

mathematics problem, it is in fact quite rigorous. The trouble seems

to arise because weather in general is dependent on numerous

elements e.g. seasonal changes, latitude, storms, wind, tornadoes,

-1-
Glenn Habibi

precipitation, cloud formations, thunder, lightning et cetera. Some of

these elements illustrate variability with respect to height, namely air

pressure and temperature. Land that is nearer to the water

experiences greater humidity, where landlocked regions tend to be

more arid. In addition, long-range changes to the climate also affect

the weather, namely global warming, which seems to be raising the

average temperature of the entire world. (Ref: EPA on Global Warming

www.epa.gov/globalwarming/climate/index.html)

When one keeps all these factors in mind, long-range numerical

prediction of the weather becomes a rigorous task, and one begins to

lose confidence in the accuracy of such numerical processes. First of

all, one must keep in mind the loss of information due to rounding

(Note that in the 1960s, the computers of the time were hardly

sufficient for such difficult computational needs). In addition, the

equations that describe weather factors are coupled, thus the future

values of each parameter depend on the past values of each

parameter in a manner that is more difficult to predict. Consider an

example of a non-linear system in which the velocity of an object not

only varies with time but with total displacement as well. In such a

situation, it is no longer entirely simple to find the net displacement at

any given time. This non-linearity leads to a number of problems that

give rise to a series of differential equations that behave extremely

chaotically.

-2-
Glenn Habibi

The basic equations that dictate atmospheric dynamics shall be listed

below and studied in a rigorous attempt to solve them for numeric

weather values.

Basic Equations of Atmospheric Dynamics (Saltzman, pp. 329-

221)

The first law of physics that dictates atmospheric dynamics is Newton’s

Law, which relates forces to accelerations. This equation takes the

following form:

ρ Du/Dt = F - ∇ p - Π u

For simplicity, this vector equation is used to study only unit volumes

of space, so the density (ρ ) is actually equivalent to the mass of a unit

of air, because the volume is always one. The quantity u is the

velocity, so Du/Dt is the acceleration of a unit of air. Thus, ρ Du/Dt is

a force in Newtons. On the right side of the equation, ∇ p is the

gradient of pressure, and F is the body force, which is the sum of

gravity (Fg) and the Coriolis force (Fc) caused by the Earth’s rotation:

F = Fg + Fc

Fc = -2ρ (ω Xu) – The Coriolis force is related to the mass and the

cross product between the angular velocity ω and the linear velocity of

the unit of air u.

Fg = -gρ k – Force due to gravity is defined as the acceleration (g),

times the mass, in the direction perpendicular to the Earth’s surface

-3-
Glenn Habibi

(which is the reason for the minus sign and the unit vector k, which is

the unit vector for the vertical direction).

The symbol Π is the turbulent exchange operator, and its operation is

defined as follows:

Π u = µ ρ ∇ 2u

where µ is the coefficient of viscosity. Combining all of these

equations yields one vector equation:

ρ Du/Dt = -∇ p - 2ρ (ω Xu) - gρ ’k + µ ρ ∇ 2u (Newton’s 2nd Law)

Where ρ ’ = ρ - avg ρ , or the value for the field variable ρ in the

absence of any movement in the atmosphere.

When Barry Saltzman, a mathematician, decided to study this equation

further, he realized that the Coriolis force, (Fc = - 2ρ (ω Xu)) only

seems to affect weather in a long term manner (Saltzman, pg 330). In

addition, Saltzman realized it was unrealistic to study these

phenomena for a spherical atmosphere on the Earth, for this raised too

many complications. So in his equations, he considers the atmosphere

to be linear, and treats it as a liquid of height H, and infinitely large in

both x and y directions. In other words, Saltzman considers the radius

of the Earth to be infinite (Saltzman, 331). Saltzman then considered

the remaining equations and converted them into their three

component equations. In order to express these equations, it is

appropriate to designate u, v, and w as the velocities in the x, y, and z

directions respectively. When one does this and then divides both

-4-
Glenn Habibi

sides of the equation by ρ , for simplicity, the following equation for the

x direction is found:

Du/Dt = -1/ρ * ∂p/∂x + µ ∇ 2u

When one defines P = (p – avg p) / avg ρ , 1/ρ ∂p/∂x is then equal to

(avg ρ / ρ ) * ∂P/∂x. Here average pressure is the value of the pressure

field in the absence of any movement in the atmosphere (u = 0).

Considering that (avg ρ / ρ ) is very nearly one, ∂P/∂x is equal to 1/ρ *

∂p/∂x. Therefore, the following equation is derived:

Du/Dt = ∂P/∂x + µ ∇ 2u (Equation 1 Saltzman)

Similarly, the equation describing the y direction can be found by

dividing both sides by ρ :

Dv/Dt = -1/ρ * ∂p/∂y + µ ∇ 2v

Using the definition of P, this can be simplified further yet and

expressed as:

Dv/Dt = ∂P/∂y + µ ∇ 2v (Equation 2 Saltzman)

The equation describing the z direction can be found:

Dw/Dt = -1/ρ *∂p/∂z – g * ρ ’/ρ + µ ∇ 2w

Keeping in mind the definition of P, this equation can be simplified:

Dw/Dt = -∂P/∂z – g * ρ ’/ρ + µ ∇ 2w

Utilizing the Equation of State (1/ρ = 1/avg ρ * (1 + ε T), where ε is

the coefficient of volume expansion and T is the current temperature),

the third equation can be further simplifiedt:

-5-
Glenn Habibi

Dw/Dt = -∂P/∂z – gε T + µ ∇ 2w (Equation 3 Saltzman)

The above three equations detail how forces affect a unit volume of air

mass in the atmosphere. In addition to forces, however, air masses

experience other phenomena that cause the behavior of weather.

Saltzman therefore accounts for diffusion of heat in his 4th equation:

DT/Dt = k∇ 2T (Equation 4 Saltzman)

where T is the temperature and k is the coefficient of thermal

conductivity. This equation helps one predict the rate at which heat

energy will diffuse through the air, or how quickly a unit mass of air will

heat up or cool down in relation to surrounding air masses.

The last of Saltzman’s equations involves continuity. Essentially, this

equation states that the rate of change of mass per unit volume of air

must equal the rate of gas transfer across the boundary surfaces of the

unit volume of air:

Dρ /Dt + ∇•(ρ u) = 0 or,

Dρ /Dt = -∇•(ρ u)

In 1879, Oberbeck considered an approximation in which the density

did not change rapidly, making the quantity ∂ρ /∂t nearly zero.

Realizing that ρ does not vary a great deal, it can be factored out of

the divergence (∇•(ρ u)), which then takes the form:

ρ *∇•u = 0

which can be rewritten as:

-6-
Glenn Habibi

∂u/∂x + ∂v/∂y + ∂w/∂z = 0 (Equation 5 Saltzman)

The final equation of Saltzman is the re-stated equation of state, shown

below:

1/ρ = 1/avg ρ * (1 + ε T) (Equation 6 Saltzman)

At this point, it becomes clear that solving these six equations for six

functions of x, y, z, and time is an extremely complicated task.

Therefore, Saltzman proceeded by systematically eliminating

equations and unknowns as follows.

First, the total derivatives in the above six equations must be replaced

by their equivalent partial derivatives. An example of this is shown

below:

Du/Dt = ∂u/∂t + ∂u/∂x * ∂x/∂t + ∂u/∂y * ∂y/∂t + ∂u/∂z * ∂z/∂t

Since ∂x/∂t = u, ∂y/∂t = v, and ∂z/∂t = w, this can be expressed as:

Du/Dt = ∂u/∂t + u ∂u/∂x + v ∂u/∂y + w ∂u/∂z

For simplification, it is assumed that only turbulence in the x-z plane is

permitted, implying that v = 0 and the derivative of any expression in

terms of y is also zero. This assumption is necessary, for should it not

be made the problem would become a great deal more complicated

and virtually unsolvable. Then, the continuity equation can be used to

define a stream function ψ such that:

u = -∂ψ /∂z and w = ∂ψ /∂x

-7-
Glenn Habibi

The function ψ has been defined such that its derivative with respect

to z and x are the velocity components in those respective directions,

and the continuity equation is automatically satisfied:

∂u/∂x + ∂w/∂z = ∂(-∂ψ /∂z)/ ∂x + ∂(∂ψ /∂x) = 0 Identically

This is so because the mixed second order derivatives of ψ cancel out.

At this point, Saltzman made the presumption that temperature has an

average linear component in terms of the vertical coordinate z, and a

term that fluctuates with turbulence (θ ). In other words:

T(x,z,t) = [Avg T (0,t) – (∆ T/H) * z] + θ (x,z,t)

In other words, the temperature at a certain position in the x – z plane

is dependent on the average temperature, the variation of

temperature with respect to height (H), as well as any fluctuations due

to turbulence (hence the θ ).

Next, Saltzman eliminated the pressure P between the first and the

third equation and substituted θ and ψ whenever possible for u, w,

and T. By doing so, Saltzman arrived at two equations and two

unknowns:

∂/∂t ∇ 2ψ - ∂ψ /∂z ∂/∂x ∇ 2ψ + ∂ψ /∂x ∂/∂z ∇ 2ψ - gε ∂θ /∂x - µ ∇ 4ψ = 0

∂θ /∂t - ∂ψ /∂z ∂θ /∂x + ∂ψ /∂x ∂θ /∂z - ∆ T/H ∂ψ /∂x - k∇ 2θ = 0

If these equations can be solved for ψ and θ , these functions can be

utilized to derive the functions for u and w, which in turn will permit

the derivation for the pressure P. The function θ can be used to

-8-
Glenn Habibi

determine the temperature, which in turn will determine the density

via the equation of state.

Edward Lorenz attempted to solve these equations by expanding them

as a double Fourier series in x and z with the coefficients as functions

of time (Lorenz, 131). Lorenz approximated the two series, keeping

only a total of three terms, as follows:

ψ = X sin(π axH-1) * sin(π zH-1)

θ = Y cos(π axH-1) * sin(π zH-1) – Z sin(2π zH-1)

where a is related to the wavelength in the horizontal direction. In

addition, X, Y, and Z are functions of time alone (Lorenz, 135).

Substituting θ and ψ into the above differential equations provides a

set of three coupled, non-linear, ordinary differential equations:

dX/dt = X’ = -σ X + σ Y

dY/dt = Y’ = -XZ + rX – Y

dZ/dt = Z’ = XY – bZ

Where σ , r, and b are constants. In order to utilize this equation for

practical purposes, functions for X, Y, and Z, with respect to time, must

be established. Once known, these functions can be substituted into

the Fourier series, which will then be used to find functions for ψ and

θ , and subsequently values for temperature, pressure, velocity, and

density of the fluid.

Though X, Y, and Z are coefficients in a Fourier series, one can

abstractly think of them as coordinates of a point in phase space,

-9-
Glenn Habibi

where X, Y, and Z are the three coordinate axes (Gleick, 126). Phase

space has a coordinate system that represents an expression in space

that does not actually exist. Instead of thinking of X, Y, and Z as

distances in the air, they are hypothetical values of expressions (in this

case, coefficients of a Fourier Series). One must be careful not to

confuse X, Y, and Z as coordinates in real space, but more as

coordinates that define this abstract type of space. The above three

equations determine how the “point” in phase space is defined, based

on the previous point. When one views these quantities in this

manner, some rather interesting properties express themselves. First

of all, Lorenz noted that this portrayal has a tendency to “orbit” about

two points in phase space, these points are aptly called attractors. In

addition, it was soon discovered that this function, at no point in time,

repeats itself; it is completely non-periodic. Each point is distinctly

different from each other point on the graph. Next, I subject the

Lorenz Attractor to a rigorous study in an attempt to find an accurate

solution to the differential equation, which could then be used for

reliable long-range predictions.

Procedure

The above equations unfortunately do not lend themselves to an exact

mathematical solution. It is impossible to express X, Y and Z in terms

of known functions in a closed form. It is therefore necessary to solve

these equations numerically. This was done with a computer program,

- 10 -
Glenn Habibi

which visually expressed the attractor, originally with a first-order

expression of the Taylor Series. The computer program prompts the

user to enter the parameters (namely σ , r, and b), as well as the

increment of time between successive iterations (∆ t), and the total

number of iterations (n). The total range of time therefore runs from

time 0 to time n * ∆ t. The computer program used a simple iterative

loop to compute the new values of X, Y, and Z based on the old values

of X, Y, and Z and the derivatives X’, Y’, and Z’ as dictated by the

function. This was done as follows:

X(t + ∆ t) = X(t) + X’(t) * ∆ t

Where X’(t) = -σ X(t) + σ Y(t). When studying the error associated

with this procedure, the goal is to have the longest amount of time

pass without losing accuracy, or a large n * ∆ t value. Accuracy

improves as ∆ t values are chosen to be very small. However, ∆ t must

still be a reasonable value, since small ∆ t values increase

computational time. In addition, the total number of points must be

very large, but still within reason for memory space purposes. In order

to study error for a given range, a computer program was run, which

kept a constant value for n * ∆ t while varying ∆ t (and n inversely

proportionally). This procedure was run repeatedly and the final point

of the attractor was recorded for each run. The difference between

these final point values was used to determine the degree of the error.

- 11 -
Glenn Habibi

Results and Error Analysis

Theoretically, the final point values for identical starting point values

should be identical. When the product n * ∆ t was approximately 1 or

less, the final points were extremely close to one another, with error of

the 10-7 th degree. However, as soon as the total time passage value

was approximately 6, the loss of accuracy became clear. Note that

this time value is dimensionless, and is merely a proportional

representation of the product n *∆ t. The results of this can be seen

below:

First Order Approximation – Table 1

t (n * Delta t) Error in X Error in Y Error in Z Best Delta t


0.1 0.00002 0.000628 0.00037 0.000005
1 0.00002 0.000197 0.000206 0.000005
4 0.00189 0.003 0.0015 0.000002
6 0.012 0.0165 0.004 0.000003
8 0.485 0.678 0.89 0.000004
10 0.7 1.153 1.391 0.000005

Error Analysis (First Order Taylor Series)

1.6
1.4
Absolute Error

1.2
1 Error in X
0.8 Error in Y
0.6 Error in Z
0.4
0.2
0
1 2 3 4 5 6
Dimensionless Time

The starting point for the above data was (-10,-9,7).

- 12 -
Glenn Habibi

At this point, it became clear that perhaps the cause of this error is

that the first order approximation is not accurate enough. The

procedure was therefore improved by including the second order, and

subsequently the third order terms of the Taylor Series. The second

order derivatives were computed using the original equations that

define the attractor as follows:

X’’ = dX’/dt = -σ X’ + σ Y’

Y’’ = -XZ’ – X’Z + rX’ – Y’

Z’’ = X’Y + Y’X – bZ’

And the third order as follows:

X’’’ = -σ X’’ + σ Y’’

Y’’’ = -XZ’’ – 2Z’X’ – X’’Z + rX’’ – Y’’

Z’’’ = 2X’Y’ + X’’Y + Y’’X – bZ’’

The computer program used the current values of X, Y, and Z to

compute the numerical values of X’, Y’, and Z’, which are then used to

compute the second and then third derivatives. The Taylor Series can

then be expressed as follows:

X(t + ∆ t) = X(t) + X’(t) * ∆ t + 1/2X’’(t) * ∆ t2 + 1/6X’’’(t) * ∆ t3

Y(t + ∆ t) = Y(t) + Y’(t) * ∆ t + 1/2Y’’(t) * ∆ t2 + 1/6Y’’’(t) * ∆ t3

Z(t + ∆ t) = Z(t) + Z’(t) * ∆ t + 1/2Z’’(t) * ∆ t2 + 1/6Z’’’(t) * ∆ t3

When the third order Taylor Series approximation was attempted, an n

* ∆ t value in excess of 20 produced inconsistent results, as compared

to 6 with only the first order series.

- 13 -
Glenn Habibi

Results for Higher Order Approximations

With this failure, it became clear that another method of integration

was necessary. Therefore, the Runge Kutta method of numerical

integration was attempted. In this method, each derivative, instead of

symbolically attained, is computed numerically utilizing the initial

functions. This method therefore eliminates re-computation of the

derivatives, making for less computational time and faster analysis

(Burden, 251). Using this algorithm up to and including the fourth

order revealed slightly better results, with constancy up to

approximately n * ∆ t of about 30. To do a fair comparison, a Taylor

Series approximation was redone up to fourth order as well. In this

case, n * ∆ t of approximately 30 was the limit before the

inconsistency in results became clear. Both methods, when utilized to

the fourth order produced nearly identical results (As shown in Tables

2 and 3).

Third Order Taylor Approximation – Table 2

t (n * Delta t) Error in X Error in Y Error in Z Best Delta t


10 7.98 E -8 2.2 E -7 8.74 E -7 0.00002
20 -4.305 E -2 1.58 E -2 -7.577 E-2 0.00002
25 -0.2153 0.324 -0.06925 0.00002
30 -3.1 8.307 16.97 0.00002
40 7.98 2.285 8.744 0.00002

- 14 -
Glenn Habibi

Error Analysis Summary (Third Order Taylor Series)

2.00E+01

1.50E+01
Absolute Error

1.00E+01 Error in X
Error in Y
5.00E+00 Error in Z

0.00E+00
0 10 20 30 40 50
-5.00E+00
Dimensionless Time

Fourth Order Runge Kutta Approximation- Table 3

t (n * Delta t) Error in X Error in Y Error in Z Best Delta t


20 5.87E-05 2.18E-05 1.04E-04 2.00E-05
25 1.73E-04 4.60E-04 7.94E-04 2.00E-05
30 0.1282294 0.058268 0.399198 2.00E-05
40 12.83314 8.8955 31.03902 2.00E-05

Error Analysis Summary (Runge Kutta 4th Order)

3.50E+01
3.00E+01
Absolute Error

2.50E+01
2.00E+01 Error in X
1.50E+01 Error in Y
1.00E+01 Error in Z
5.00E+00
0.00E+00
-5.00E+00 0 10 20 30 40 50
Dimensionless Time

At this point, it has become obvious that the attractor is indeed a very

complicated mathematical entity. To get a visual appreciation of its

complexity, it is interesting to project it into the X-Y plane, the X-Z

plane, and the Y-Z plane. For clarity, the distance from each point in

- 15 -
Glenn Habibi

phase space to each attractor was computed, and is utilized to

determine the amount of green or red in the color:

Discussion

To attain a better understanding of how difficult it is to solve for the

function numerically in terms of X, Y, and Z, it is instructive to view

these coordinates as functions of time. The following graph was made

for X, Y, and Z as functions of time in the range 0 < t < 20. The sharp

relative extrema present in these graphs are extremely difficult to

negotiate numerically. The graph also exhibits rapid oscillations with

varying amplitudes in a seemingly chaotic manner:

0 Time 20

X: Red Y: Green Z: Blue

- 16 -
Glenn Habibi

The best numerical method implemented, namely Runge Kutta to the

fourth order, fails to solve this function effectively at large values of

time. The reason for this seems to be apparent when one observes the

above graph. It appears that the extrema that are present are

numerous and non-periodic. This makes it very difficult to fit a

numerical solution to such a function.

Since Runge Kutta to the fourth order seemingly did not present a

consistent solution, this raises the question of to what level does this

method contribute to numerical integration process. It is not possible

to study the Runge Kutta Method’s effectiveness in the environment of

the attractor, for it is not a precisely computable function. To remedy

this difficulty, a function that resembles a portion of the X-Y-Z plots

was studied with this method instead. Since this function can be

solved without this numerical process as well as utilizing this process, a

comparison here would be of great help to analyze the validity of the

Runge Kutta Method. The function selected was as follows:

X = e0.2t + 10 * e-0.2t * sin(2π t)

The reason for the selection of this function is that the sin function will

produce the oscillations reminiscent of the attractor, and the negative

exponential will produce the decay in the amplitude. The positive

exponential changes the point about which the function oscillates. The

Runge Kutta fourth order approximation was then implemented to

numerically solve for X as a function of time in the range 0 < t < 12.5,

- 17 -
Glenn Habibi

with ∆ t set at 0.05, 0.01, and 0.001, successively. In the following

three charts, the red is the exact function, as stated above, where the

green is the result of the Runge Kutta approximation:

12.5

∆ t = 0.05 (above)

As illustrated above, discrepancies are evident at the extrema.

- 18 -
Glenn Habibi

12.5

∆ t = 0.01 (above)

As seen above, with more points and less time between those points,

discrepancies are much smaller. Since the next terms in the Runge

Kutta series are yet smaller, it is clear that four terms seems to be

enough to navigate this function. It is for this reason that it seems

strange that a similar method cannot accurately depict the attractor.

12.5

∆ t = 0.001 (above)

With a very small ∆ t and a subsequently large number of iterations, in

this case 12500, it is almost impossible to observe any errors at all. In

- 19 -
Glenn Habibi

fact, the two graphs are so close to one another that it appears as

though one is on top of the other.

Conclusion

The equations that define the changes in atmospheric phenomenon

with time are well known equations of physics. It is a trivial matter to

predict the effects of forces on matter, and realize what forces must be

accounted for, and so on. However, the resulting differential equations

do not lend themselves to closed-form solutions. In order to even

obtain such symbolic representations, many approximations and

assumptions (e.g. the neglect of the Coriolis Force) had to be made.

Each of these approximations was necessary to simplify the equations

to represent them in a form that could be solved with known

mathematics. In spite of all these approximations, the Lorenz

Attractor, the very heart of the solution, remains unsolvable over long

periods of time, even with the most modern scientific analysis and

computer systems, these functions continue to elude exact solutions,

due to the fundamental chaotic behavior of an atmospheric system

depicted by the attractor. The inability of obtaining an exact solution

indicates that the underlying physical parameters (e.g. pressure,

temperature) cannot be found precisely, making long-range weather

prediction virtually impossible at this point in meteorology.

Computer Programs

Third and Fourth Order Taylor Approximation

- 20 -
Glenn Habibi

Dim x As Double, y As Double, z As Double


Dim xdot As Double, ydot As Double, zdot As Double, Deltat As Double
Dim Sigma As Double, r As Double, b As Double, N As Double
Dim xdotdot As Double, ydotdot As Double, zdotdot As Double
Dim xdotdotdot As Double, ydotdotdot As Double, zdotdotdot As
Double
Dim xdotdotdotdot As Double, ydotdotdotdot As Double, zdotdotdotdot
As Double
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As
Long)
Private Sub EndProject_Click()
End
End Sub

Private Sub EnterData_Click()


Rem Read the paramters to start with
Do While (Abs(x) > 10)
x = Val(InputBox("Starting x ( -10 to +10) = ", , -10))
Loop
Do While (Abs(y) > 10)
y = Val(InputBox("Starting y (-10 to +10) = ", , -9))
Loop
Do While (Abs(z) > 10)
z = Val(InputBox("Starting z (-10 to +10) = ", , 7))
Loop
Sigma = Val(InputBox("Parameter Sigma = ", , 10#))
r = Val(InputBox("Parameter r = ", , 28#))
b = Val(InputBox("Paramter b = ", , 2.67))
Deltat = Val(InputBox("Delta t, the time interval = ", , 0.0001))
N = Val(InputBox("N, the total number of iterations = ", , 200000))
GraphIt.Enabled = True
End Sub

Private Sub Form_Load()


xdot = 0
ydot = 0
zdot = 0
xdotdot = 0
ydotdot = 0
zdotdot = 0
Sigma = 0
r=0
b=0
Deltat = 0
N=0
GraphIt.Enabled = False ' Disable graph portion until data is entered

- 21 -
Glenn Habibi

End Sub

Private Sub GraphIt_Click()


Rem Print N, Delta T and x,y,z after N computations for comparison
Dim xsave As Double, ysave As Double, zsave As Double, Deltatsave
As Double
Dim nsave As Double
Dim i As Double, j As Double
Dim xiter As Double, yiter As Double, ziter As Double
Rem save the original starting points for later computations
xsave = x
ysave = y
zsave = z
Deltatsave = Deltat
nsave = N
s = 40 ' s is the scale on the screen in units of x,y,z
Scale (-s, s)-(s, -s) ' Set up the scale
DrawWidth = 8 ' Set the width for clarity
Rem print out the starting point used
PSet (-7 * s / 8, 7 * s / 8), RGB(255, 0, 0) ' Red dot marks the start of
the information output
Print " Starting point at "; x; " , "; y; " , "; z; " Third Order in
DeltaT <------ N * DeltaT = "; N * Deltat

Rem Loop N times to see a good portion of the attractor


For j = 1 To 20 Step 4
Rem reset x,y and z
x = xsave
y = ysave
z = zsave
Deltat = Deltatsave * (1 - (j - 1) / 20)
Rem re-compute N to keep N*Deltat the same to cover the same
portion of the attractor
N = nsave * Deltatsave / Deltat
For i = 1 To N
Rem Compute xdot,ydot,zdot
xdot = Sigma * (y - x)
ydot = (r * x - y - x * z)
zdot = (x * y - b * z)
Rem Compute the second derivatives xdotdot etc.
xdotdot = Sigma * (ydot - xdot)
ydotdot = r * xdot - ydot - xdot * z - zdot * x
zdotdot = xdot * y + ydot * x - b * zdot
Rem Compute the third derivatives here.
xdotdotdot = Sigma * (ydotdot - xdotdot)

- 22 -
Glenn Habibi

ydotdotdot = -xdotdot * z - zdotdot * x - 2 * xdot * zdot - ydotdot


+ r * xdotdot
zdotdotdot = xdotdot * y + ydotdot * x + 2 * xdot * ydot - b *
zdotdot
Rem Compute the fourth order derivatives here. Set them to
zeros to study third order only
xdotdotdotdot = Sigma * (ydotdotdot - xdotdotdot)
ydotdotdotdot = -xdotdotdot * z - xdotdot * zdot - zdotdotdot * x -
zdotdot * xdot - 2 * (xdotdot * zdot + xdot * zdotdot) - ydotdotdot + r *
xdotdotdot
zdotdotdotdot = xdotdotdot * y + xdotdot * ydot + ydotdotdot * x
+ ydotdot * xdot + 2 * (xdotdot * ydot + xdot * ydotdot) - b *
zdotdotdot
Rem ----> Set the above three to zero here to do a third order
study
Rem Update the x,y,z point
x = x + xdot * Deltat + 0.5 * xdotdot * Deltat * Deltat +
xdotdotdot * Deltat * Deltat * Deltat / 6 + xdotdotdotdot * Deltat *
Deltat * Deltat * Deltat / 24
y = y + ydot * Deltat + 0.5 * ydotdot * Deltat * Deltat +
ydotdotdot * Deltat * Deltat * Deltat / 6 + ydotdotdotdot * Deltat *
Deltat * Deltat * Deltat / 24
z = z + zdot * Deltat + 0.5 * zdotdot * Deltat * Deltat +
zdotdotdot * Deltat * Deltat * Deltat / 6 + zdotdotdotdot * Deltat *
Deltat * Deltat * Deltat / 24
Next i
Rem print the output
If (j = 1) Then

PSet (-7 * s / 8, 7 * s / 8 - s * j / 11), RGB(0, 255, 0)


Print " Final Position is at "; x; " , "; y; " ' "; z; " N= "; N; "
Delta t = "; Deltat
xiter = x ' Save the values to compare with the next iteration
yiter = y
ziter = z
Else

PSet (-7 * s / 8, 7 * s / 8 - s * j / 11), RGB(0, 255, 0)


Print " Final Position is at "; x; " , "; y; " ' "; z; " N= "; N; "
Delta t = "; Deltat
Rem Print the differences as well
PSet (-7 * s / 8, 7 * s / 8 - s * (j + 1) / 11), RGB(0, 0, 255)

Print "--->DeltaX= "; x - xiter; " DeltaY = "; y - yiter; " DeltaZ= "; z
- ziter
xiter = x ' Save the values to compare with the next iteration

- 23 -
Glenn Habibi

yiter = y
ziter = z
End If
Next j
End Sub

Modified for Runge Kutta

For i = 1 To N
Rem Update the x,y,z point
k1x = Deltat * Sigma * (y - x)
k1y = Deltat * (-x * z - y + r * x)
k1z = Deltat * (x * y - b * z)
k2x = Deltat * Sigma * ((y + 0.5 * k1y) - (x + 0.5 * k1x))
k2y = Deltat * (-(x + 0.5 * k1x) * (z + 0.5 * k1z) - (y + 0.5 * k1y) + r *
(x + 0.5 * k1x))
k2z = Deltat * ((x + 0.5 * k1x) * (y + 0.5 * k1y) - b * (z + 0.5 * k1z))
k3x = Deltat * Sigma * ((y + 0.5 * k2y) - (x + 0.5 * k2x))
k3y = Deltat * (-(x + 0.5 * k2x) * (z + 0.5 * k2z) - (y + 0.5 * k2y) + r *
(x + 0.5 * k2x))
k3z = Deltat * ((x + 0.5 * k2x) * (y + 0.5 * k2y) - b * (z + 0.5 * k2z))
k4x = Deltat * Sigma * ((y + k3y) - (x + k3x))
k4y = Deltat * (-(x + k3x) * (z + k3z) - (y + k3y) + r * (x + k3x))
k4z = Deltat * ((x + k3x) * (y + k3y) - b * (z + k3z))

x = x + (k1x + 2 * k2x + 2 * k3x + k4x) / 6

y = y + (k1y + 2 * k2y + 2 * k3y + k4y) / 6

z = z + (k1z + 2 * k2z + 2 * k3z + k4z) / 6


Next I

Works Cited

1. Saltzman, Barry, Finite Amplitude Free Convection as an Initial

Value Problem, The Journal of Atmospheric Sciences, Volume 19,

pages 329-341, Manuscript Received May 5, 1962

2. Lorenz, Edward N., Deterministic Nonperiodic Flow, The Journal of

Atmospheric Sciences, Volume 20, pages 130-141, Manuscript

Received November 18, 1962

- 24 -
Glenn Habibi

3. Haltiner, G.J., Numerical Weather Prediction, Department of

Meteorology, Naval Post-Graduate School, Monterey, California,

John Wiley & Sons Inc. New York, 1971

4. Thompson, Philip D., Numerical Weather Analysis and Prediction,

Macmillan Company, NY, 1961

5. Ruelle, David, Turbulence, Strange Attractors, and Chaos, World

Scientific Series A Volume 16, New Jersey, 1995

6. Environmental Protection Agency on Global Warming,

www.epa.gov/globalwarming/climate/index.html

7. Gleick, James, Chaos: Making a New Science, Penguin Books USA

Inc., New York, 1987

8. Burden, Richard L., Faires, Douglas J., Numerical Analysis, Fourth


Edition, PWS- KENT Publishing Company, Boston, 1978

- 25 -

You might also like