mathematical difficulties encountered in weather forecasting

Upload: glenn-habibi

Post on 30-May-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    1/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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    2/25

    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 -

    http://www.epa.gov/globalwarming/climate/index.htmlhttp://www.epa.gov/globalwarming/climate/index.html
  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    3/25

    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 Newtons

    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 Earths 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 Earths surface

    - 3 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    4/25

    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 (Newtons 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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    5/25

    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 * / + 2

    w

    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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    6/25

    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 = k2T (Equation 4 Saltzman)

    where T is the temperature and kis 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 Saltzmans 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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    7/25

    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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    8/25

    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, anda

    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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    9/25

    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 oftime 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 inphase space,

    - 9 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    10/25

    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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    11/25

    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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    12/25

    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)

    0

    0.2

    0.4

    0.6

    0.8

    1

    1.2

    1.4

    1.6

    1 2 3 4 5 6

    Dimensionless Time

    AbsoluteErro

    Error in X

    Error in Y

    Error in Z

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

    - 12 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    13/25

    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 XZ + rX Y

    Z = XY + YX bZ

    And the third order as follows:

    X = - X + Y

    Y = -XZ 2ZX XZ + rX Y

    Z = 2XY + XY + YX 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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    14/25

    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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    15/25

    Glenn Habibi

    Error Analysis Summary (Third Order Taylor Series)

    -5.00E+00

    0.00E+00

    5.00E+00

    1.00E+01

    1.50E+01

    2.00E+01

    0 10 20 30 40 50

    Dimensionless Time

    AbsoluteErro

    Error in X

    Error in Y

    Error in Z

    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)

    -5.00E+00

    0.00E+00

    5.00E+00

    1.00E+01

    1.50E+01

    2.00E+01

    2.50E+01

    3.00E+01

    3.50E+01

    0 10 20 30 40 50

    Dimensionless Time

    AbsoluteErro

    Error in X

    Error in Y

    Error in Z

    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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    16/25

    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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    17/25

    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 Methods 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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    18/25

    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:

    0

    12.5

    t = 0.05 (above)

    As illustrated above, discrepancies are evident at the extrema.

    - 18 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    19/25

    Glenn Habibi

    0

    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.

    0

    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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    20/25

    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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    21/25

    Glenn Habibi

    Dim x As Double, y As Double, z As DoubleDim xdot As Double, ydot As Double, zdot As Double, Deltat As DoubleDim Sigma As Double, r As Double, b As Double, N As DoubleDim xdotdot As Double, ydotdot As Double, zdotdot As DoubleDim xdotdotdot As Double, ydotdotdot As Double, zdotdotdot As

    DoubleDim xdotdotdotdot As Double, ydotdotdotdot As Double, zdotdotdotdotAs DoublePrivate Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds AsLong)Private Sub EndProject_Click()EndEnd 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))

    LoopDo While (Abs(y) > 10)

    y = Val(InputBox("Starting y (-10 to +10) = ", , -9))LoopDo While (Abs(z) > 10)

    z = Val(InputBox("Starting z (-10 to +10) = ", , 7))LoopSigma = 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 = 0ydot = 0zdot = 0xdotdot = 0

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

    - 21 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    22/25

    Glenn Habibi

    End Sub

    Private Sub GraphIt_Click()Rem Print N, Delta T and x,y,z after N computations for comparisonDim xsave As Double, ysave As Double, zsave As Double, Deltatsave

    As DoubleDim nsave As DoubleDim i As Double, j As DoubleDim xiter As Double, yiter As Double, ziter As DoubleRem save the original starting points for later computationsxsave = xysave = yzsave = zDeltatsave = Deltatnsave = Ns = 40 ' s is the scale on the screen in units of x,y,z

    Scale (-s, s)-(s, -s) ' Set up the scaleDrawWidth = 8 ' Set the width for clarityRem print out the starting point usedPSet (-7 * s / 8, 7 * s / 8), RGB(255, 0, 0) ' Red dot marks the start of

    the information outputPrint " Starting point at "; x; " , "; y; " , "; z; " Third Order in

    DeltaT

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    23/25

    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 onlyxdotdotdotdot = 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 orderstudy

    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 iRem 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 = "; Deltatxiter = x ' Save the values to compare with the next iterationyiter = yziter = zElse

    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 wellPSet (-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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    24/25

    Glenn Habibi

    yiter = yziter = zEnd IfNext j

    End Sub

    Modified for Runge Kutta

    For i = 1 To NRem Update the x,y,z pointk1x = 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) / 6Next 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 -

  • 8/9/2019 Mathematical Difficulties Encountered in Weather Forecasting

    25/25

    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, FourthEdition, PWS- KENT Publishing Company, Boston, 1978

    http://www.epa.gov/globalwarming/climate/index.htmlhttp://www.epa.gov/globalwarming/climate/index.html