Higher-Order Ordinary Differential Equations

Background: Another example of for Forward Differencing

Recall how we used forward finite differencing to simulate the behavior of a function that changed proportional to its current size in Lecture 19.  Consider now a function that changes "how fast it changes" proportional to its current change and its current value--in other words its current acceleration is proportional to its velocity and to its size:

Let's work out how to find a finite differencing function:

This is the current change or approximation to velocity

CurrentChangePerDelta [ F_ , i_ , Δ_ ] := F [ i + 1 ] - F [ i ] Δ

This is the current change in change or approximation to acceleration

CurrentChangeinCurrentChangeperDelta [ F_ , i_ , Δ_ ] := Simplify [ CurrentChangePerDelta [ F , i + 1 , Δ ] - CurrentChangePerDelta [ F , i , Δ ] Δ ]

Our model is that the acceleration is proportional to  size of the current function and its velocity, let these proportions be: -α and -β

DifferenceRelation = CurrentChangeinCurrentChangeperDelta [ F , i , Δ ] + β CurrentChangePerDelta [ F , i , Δ ] + α F [ i ] 0

α F [ i ] + β ( - F [ i ] + F [ 1 + i ] ) Δ + F [ i ] - 2 F [ 1 + i ] + F [ 2 + i ] Δ 2 0

Solve this for the "latest" values

ForDiffSol = Solve [ DifferenceRelation , F [ i + 2 ] ] // Flatten

{ F [ 2 + i ] - F [ i ] + β Δ F [ i ] - α Δ 2 F [ i ] + 2 F [ 1 + i ] - β Δ F [ 1 + i ] }

Replace to find the form of the solution

ForDiffSolV2 = ForDiffSol /. i j - 2

{ F [ j ] - F [ - 2 + j ] + β Δ F [ - 2 + j ] - α Δ 2 F [ - 2 + j ] + 2 F [ - 1 + j ] - β Δ F [ - 1 + j ] }

Notice that this forward differnce needs TWO consectutive past values before it can calculate the current value, create a function to Appends the current value to a list by using the last two values:

The fact that TWO consecutive values are needed is not surprising. Because this iteration procedure is giving an approximation to the solution of a second-order ODE, we need to make a numerical approximation to a second derivative. THREE points—the two consecutive ones and the current one—are needed to do this. (If only two points were used, you could only compute the slope of the straight line connecting the points; if three points are used, a circle can be fit to the three points and the inverse of its radius gives the curvature.)

GrowListGeneral [ ValuesList_List , Δ_ , α_ , β_ ] := Module [ { Minus1 = ValuesList [ [ - 1 ] ] , Minus2 = ValuesList [ [ - 2 ] ] } , Append [ ValuesList , 2 * Minus1 - Minus2 + Δ * ( β * ( Minus2 - Minus1 ) - α * Δ * Minus2 ) ] ]

result = GrowListGeneral [ { 1 , 1 } , .001 , 1 , .1 ]

{ 1 , 1 , 0.999999 }

result = GrowListGeneral [ result , .001 , 1 , .1 ]

{ 1 , 1 , 0.999999 , 0.9999970000999999 }

Define a function for specific parameters of the General case, and use it to generate a sequence of length 20

GrowListSpecific [ InitialList_List ] := GrowListGeneral [ InitialList , .001 , 1 , .1 ]

Nest [ GrowListSpecific , { 1 , 1 } , 20 ]

{ 1 , 1 , 0.999999 , 0.9999970000999999 , 0.9999940004009898 , 0.9999900010049496 , 0.9999850020148486 , 0.9999790035346456 , 0.9999720056692887 , 0.9999640085247147 , 0.9999550122078494 , 0.9999450168266074 , 0.9999340224898913 , 0.999922029307592 , 0.9999090373905885 , 0.9998950468507473 , 0.9998800578009227 , 0.9998640703549563 , 0.9998470846276767 , 0.9998291007348995 , 0.999810118793427 , 0.9997901389210478 }

Visualize results (it takes about 45 seconds to visualize 20000 iterations)

ListPlot [ Nest [ GrowListSpecific , { 1 , 1 } , 20000 ] ]

[Graphics:HTMLFiles/Lecture-21_1.gif]

Graphics

Change parameters for Growth Function:

GrowListSpecific [ InitialList_List ] := GrowListGeneral [ InitialList , .001 , 1 , 0 ]

ListPlot [ Nest [ GrowListSpecific , { 1 , 1 } , 20000 ] ]

[Graphics:HTMLFiles/Lecture-21_2.gif]

Graphics

Second-Order Linear Homogeneous ODEs with Constant Coefficients, Analysis of the Solution Basis

Analysis of basis solutions to  y'' + βy' + γy = 0 in terms of constant coefficients β and γ

First write a general expression for this homogeneous ODE:

TheODE [ function_ , var_ ] := D [ function [ var ] , { var , 2 } ] + β D [ function [ var ] , var ] + γ function [ var ]

TheODE [ y , x ]

γ y [ x ] + β y [ x ] + y ′′ [ x ]

Guess a solution and substitute it into the left-hand side of the ODE:

TheGuess [ x_ ] := Exp [ λ x ]

TheODE [ TheGuess , x ]

x λ γ + x λ β λ + x λ λ 2

This will be a solution when the resulting quadratic expression in λ is equal to 0:

LambaSolution = Solve [ TheODE [ TheGuess , x ] 0 , λ ]

{ { λ 1 2 ( - β - β 2 - 4 γ ) } , { λ 1 2 ( - β + β 2 - 4 γ ) } }

The two roots λ+ and λ+ are:

LambdaPlus = λ /. Flatten [ LambaSolution ] [ [ 2 ] ]

1 2 ( - β + β 2 - 4 γ )

LambdaMinus = λ /. Flatten [ LambaSolution ] [ [ 1 ] ]

1 2 ( - β - β 2 - 4 γ )

Assuming that β and γ are real, the solutions can be characterized by the roots of the quadratic equation. That is, our solution is known to be e λt :  the solution monotonically grows or shrinks in time if the roots are real-positive or real-negative. The condition that the roots are real is γ < β 2 4

If the roots have an imaginary part, the solutions can oscillate. Whether the oscillation amplitudes grow or shrink depends on whether the real part of λ is positive or negative.

We now do some calculations to make an annotated map on the β–γ plane of solution scenarios for the λ values:

ComplexReal = Plot [ β ^ 2 / 4 , { β , - 1 , 1 } , AxesLabel { β , γ } ]

[Graphics:HTMLFiles/Lecture-21_3.gif]

Graphics

ComplexRealAnnote = Show [ ComplexReal , Graphics [ Text [ Complex\nCongugate\nRoots , { 0.25 , 0.25 } , { - 1 , 1 } ] ] , Graphics [ Text [ Real Roots , { 0.75 , 0.05 } ] ] ]

[Graphics:HTMLFiles/Lecture-21_4.gif]

Graphics

If the roots complex, then the sign of the real part is determined only by the sign of β; i.e., λ = - β 2 ± ( β 2 ) 2 - γ

ComplexPosNeg = ParametricPlot [ { 0 , t } , { t , 0 , .25 } , PlotStyle { Thickness [ 0.015 ] , Hue [ 0 ] } , DisplayFunction Identity ]

Graphics

ComplexPosNegAnnote = Show [ ComplexPosNeg , Graphics [ Text [ StyleForm [ Positive\nReal\nPart , FontColor Hue [ 0 ] ] , { - .5 , 0.15 } , { - 1 , 1 } ] ] , Graphics [ Text [ StyleForm [ Negative\nReal\nPart , FontColor Hue [ 0 ] ] , { .5 , 0.15 } , { 1 , 1 } ] ] , DisplayFunction $DisplayFunction ]

[Graphics:HTMLFiles/Lecture-21_5.gif]

Graphics

ComplexPlot = Show [ ComplexRealAnnote , ComplexPosNegAnnote ]

[Graphics:HTMLFiles/Lecture-21_6.gif]

Graphics

Find the conditions where the real roots are positive and/or negative

Reduce [ { LambdaPlus > 0 , LambdaMinus > 0 } ]

β < 0 && 0 < γ β 2 4

AnnotePosRealRoots = Graphics [ Text [ StyleForm [ Positive Roots , FontColor Hue [ .6 ] ] , { - 1. , 0.025 } , { - 1 , 0 } ] ]

Graphics

Reduce [ { LambdaPlus > 0 , LambdaMinus < 0 } ]

β Reals && γ < 0

MixedRealRoots = Plot[0, {t, -1, 1}, PlotStyle→ {Hue[0.6], Thickness[0.015]}, DisplayFunction→Identity]

AnnoteMixedRealRoots = Show[MixedRealRoots, Graphics[Text[StyleForm["Mixed Real Roots", FontColor→Hue[.6]], {0.2, -0.1}, {-1, 0}]], DisplayFunction→$DisplayFunction]

Graphics

[Graphics:HTMLFiles/Lecture-21_9.gif]

Graphics

Reduce [ { LambdaPlus < 0 , LambdaMinus < 0 } ]

β > 0 && 0 < γ β 2 4

AnnoteNegRealRoots = Graphics [ Text [ StyleForm [ Negative Roots , FontColor Hue [ .6 ] ] , { 1. , 0.025 } , { 1 , 0 } ] ]

Graphics

Show [ ComplexPlot , AnnotePosRealRoots , AnnoteMixedRealRoots , AnnoteNegRealRoots ]

[Graphics:HTMLFiles/Lecture-21_10.gif]

Graphics

Determination of Specific Solution using Boundary Values

Second order ODEs require that two conditions  be specified to generate a particular solution.

Example of y(0) = 0 and y(L)=1
The general solution will have the form:

GeneralSolution [ x_ ] := CPlus Exp [ LambdaPlus x ] + CMinus Exp [ LambdaMinus x ]

General :: spell1 : Possible spelling error: new symbol name \" CPlus \" is similar to existing symbol \" Plus \". More… "Possible spelling error: new symbol name \\\"\\!\\(CPlus\\)\\\" is similar to existing symbol \\\"\\!\\(Plus\\)\\\". \\!\\(\\*ButtonBox[\\\"More\[Ellipsis]\\\", ButtonStyle->\\\"RefGuideLinkText\\\", ButtonFrame->None, ButtonData:>\\\"General::spell1\\\"]\\)"

General :: spell1 : Possible spelling error: new symbol name \" CMinus \" is similar to existing symbol \" Minus \". More… "Possible spelling error: new symbol name \\\"\\!\\(CMinus\\)\\\" is similar to existing symbol \\\"\\!\\(Minus\\)\\\". \\!\\(\\*ButtonBox[\\\"More\[Ellipsis]\\\", ButtonStyle->\\\"RefGuideLinkText\\\", ButtonFrame->None, ButtonData:>\\\"General::spell1\\\"]\\)"

Apply the two boundary conditions and solve the resulting equations for constants CPlus and CMinus:

SolutionOne = Solve [ { GeneralSolution [ 0 ] == 0 , GeneralSolution [ L ] == 1 } , { CPlus , CMinus } ]

{ { CPlus - 1 1 2 L ( - β - β 2 - 4 γ ) - 1 2 L ( - β + β 2 - 4 γ ) , CMinus 1 1 2 L ( - β - β 2 - 4 γ ) - 1 2 L ( - β + β 2 - 4 γ ) } }

Write the resulting solution:

SpecificSolutionOne = Simplify [ GeneralSolution [ x ] /. Flatten [ SolutionOne ] ]

1 2 ( L - x ) ( β + β 2 - 4 γ ) ( - 1 + x β 2 - 4 γ ) - 1 + L β 2 - 4 γ

Second example with different form of boundary condition:  y(0) = 1 and y'(0)=0

DGen = D [ GeneralSolution [ x ] , x ]

1 2 CMinus 1 2 x ( - β - β 2 - 4 γ ) ( - β - β 2 - 4 γ ) + 1 2 CPlus 1 2 x ( - β + β 2 - 4 γ ) ( - β + β 2 - 4 γ )

Now the constants CPlus and CMinus are found by solving:

SolutionTwo = Solve [ { GeneralSolution [ 0 ] 1 , ( DGen /. x 0 ) 0 } , { CPlus , CMinus } ]

{ { CPlus 1 2 + β 2 β 2 - 4 γ , CMinus - β - β 2 - 4 γ 2 β 2 - 4 γ } }

{ { CPlus 1 2 + β 2 β 2 - 4 γ , CMinus - β - β 2 - 4 γ 2 β 2 - 4 γ } }

And the new solution is:

SpecificSolutionTwo = Simplify [ GeneralSolution [ x ] /. Flatten [ SolutionTwo ] ]

- 1 2 x ( β + β 2 - 4 γ ) ( ( - 1 + x β 2 - 4 γ ) β + ( 1 + x β 2 - 4 γ ) β 2 - 4 γ ) 2 β 2 - 4 γ

Example of Higher-Order equation and Visualization of Solutions:
The Beam Equation

Visualizing Beam Deflections:

Set up the ODE solution (we will specify a unit beam stiffness) EI = 1

BeamEquation [ y_ , x_ , w_ , BC1_ , BC2_ ] := DSolve [ Flatten [ { y '''' [ x ] == w [ x ] , BC1 , BC2 } ] , y [ x ] , x ] // Flatten

Set up some typical boundary conditions:

Clamped[y_ , x_ , position_, slope_] := {y[x] == position, y '[x] == slope}

PointLoad[y_, x_, position_, moment_] := {y[x] == position, y''[x] == moment}

FreeEnd[y_ , x_] := {y''[x] == 0, y'''[x] == 0}

noload [ x_ ] := 0

BeamEquation [ y , x , noload , Clamped [ y , 0 , 0 , 0 ] , PointLoad [ y , 1 , - .1 , 0 ] ]

{ y [ x ] 0. + 0. x - 0.15 x 2 + 0.05 x 3 }

Clamped Beam, loaded at the end

Plot [ Evaluate [ y [ x ] /. BeamEquation [ y , x , noload , Clamped [ y , 0 , 0 , 0 ] , PointLoad [ y , 1 , - .25 , 0 ] ] ] , { x , 0 , 1 } , PlotRange { - 0.5 , 0.5 } , AspectRatio 1 ]

[Graphics:HTMLFiles/Lecture-21_14.gif]

Graphics

Clamped Beam, Free end, unit applied load

unitload [ x_ ] := 1

Plot [ Evaluate [ y [ x ] /. BeamEquation [ y , x , unitload , Clamped [ y , 0 , 0 , 0 ] , FreeEnd [ y , 1 ] ] ] , { x , 0 , 1 } , PlotRange { - 0.5 , 0.5 } , AspectRatio 1 ]

[Graphics:HTMLFiles/Lecture-21_15.gif]

Graphics

Clamped Beam, Point load at end, Point load at Middle

midload [ x_ ] := - 10 DiracDelta [ x - 1 / 2 ]

Plot [ Evaluate [ y [ x ] /. BeamEquation [ y , x , midload , Clamped [ y , 0 , 0 , 0 ] , PointLoad [ y , 1 , 0 , 0 ] ] ] , { x , 0 , 1 } , PlotRange { - 0.5 , 0.5 } , AspectRatio 1 ]

[Graphics:HTMLFiles/Lecture-21_16.gif]

Graphics

Point Loaded on both ends, loaded in the middle as above

midload [ x_ ] := - 10 DiracDelta [ x - 1 / 2 ]

Plot [ Evaluate [ y [ x ] /. BeamEquation [ y , x , midload , PointLoad [ y , 0 , 0 , 0 ] , PointLoad [ y , 1 , 0 , 0 ] ] ] , { x , 0 , 1 } , PlotRange { - 0.5 , 0.5 } , AspectRatio 1 ]

[Graphics:HTMLFiles/Lecture-21_17.gif]

Graphics

Point Loaded on both ends, with linear distributed load positive at left and negative at right

testload [ x_ ] := 100 * ( 1 / 2 - x )

Plot [ Evaluate [ y [ x ] /. BeamEquation [ y , x , testload , PointLoad [ y , 0 , 0 , 0 ] , PointLoad [ y , 1 , 0 , 0 ] ] ] , { x , 0 , 1 } , PlotRange { - 0.5 , 0.5 } , AspectRatio 1 ]

[Graphics:HTMLFiles/Lecture-21_18.gif]

Graphics

Clamped on both ends, with a "box" placed at x = 3/4

boxload [ x_ ] := - 100 * ( UnitStep [ x - ( 3 / 4 - 1 / 8 ) ] - UnitStep [ x - ( 3 / 4 + 1 / 8 ) ] )

Plot [ boxload [ x ] , { x , 0 , 1 } ]

[Graphics:HTMLFiles/Lecture-21_19.gif]

Graphics

Plot [ Evaluate [ y [ x ] /. BeamEquation [ y , x , boxload , Clamped [ y , 0 , 0 , 0 ] , Clamped [ y , 1 , 0 , 0 ] ] ] , { x , 0 , 1 } , PlotRange { - 0.5 , 0.5 } , AspectRatio 1 ]

[Graphics:HTMLFiles/Lecture-21_20.gif]

Graphics


Created by Mathematica  (November 8, 2005) Valid XHTML 1.1!