{VERSION 5 0 "IBM INTEL NT" "5.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "Hyperlink" -1 17 "" 0 1 0 128 128 1 2 0 1 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 256 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{PSTYLE "Normal " -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }1 0 0 0 8 4 0 0 0 0 0 0 -1 0 } {PSTYLE "List Item" 0 14 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 3 3 0 0 0 0 0 0 14 5 }{PSTYLE "" 0 256 1 {CSTYLE " " -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 257 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 258 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 259 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 260 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 261 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 262 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 263 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE " " 0 264 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 265 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 266 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 267 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 268 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 269 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "List Subitem" 14 270 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 3 12 0 0 0 0 270 0 }{PSTYLE "" 0 271 1 {CSTYLE " " -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 272 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 273 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 274 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 275 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 276 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 268 "" 0 "" {TEXT -1 0 "" }}{PARA 256 "" 0 "" {TEXT -1 41 "ORDINARY DIFFERENTIAL EQUATIONS POWERTOOL" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 269 "" 0 "" {TEXT -1 26 "Unit 17 -- Shootin g Method" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 264 "" 0 "" {URLLINK 17 "Prof. Douglas B. Meade" 4 "http://www.math.sc.edu/~meade/ " "" }}{PARA 257 "" 0 "" {URLLINK 17 "Industrial Mathematics Institute " 4 "http://www.math.sc.edu/~IMI/" "" }}{PARA 258 "" 0 "" {URLLINK 17 "Department of Mathematics" 4 "http://www.math.sc.edu/" "" }}{PARA 259 "" 0 "" {URLLINK 17 "University of South Carolina" 4 "http://www.s c.edu/" "" }}{PARA 260 "" 0 "" {TEXT -1 19 "Columbia, SC 29208\n" }} {PARA 262 "" 0 "" {TEXT -1 7 "URL: " }{URLLINK 17 "http://www.math.s c.edu/~meade/" 4 "http://www.math.sc.edu/~meade/" "" }}{PARA 263 "" 0 "" {TEXT -1 25 "E-mail: meade@math.sc.edu" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 261 "" 0 "" {TEXT -1 38 "Copyright \251 2001 by Douglas B. Meade" }}{PARA 265 "" 0 "" {TEXT -1 19 "All rights reserved" }} {PARA 267 "" 0 "" {TEXT -1 0 "" }}{PARA 266 "" 0 "" {TEXT -1 67 "----- --------------------------------------------------------------" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 18 "Outline of Unit 17" }} {PARA 14 "" 0 "" {HYPERLNK 17 "17.A" 1 "" "17.A" }{TEXT -1 32 " Overvi ew of the Shooting Method" }}{PARA 14 "" 0 "" {HYPERLNK 17 "17.B" 1 " " "17.B" }{TEXT -1 10 " Example 1" }}{PARA 14 "" 0 "" {HYPERLNK 17 "17 .C" 1 "" "17.C" }{TEXT -1 10 " Example 2" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 14 "Initializat ion" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "with( DEtools ):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "with( plots ):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 15 " with( linalg ):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {SECT 0 {PARA 3 "" 0 "17.A" {TEXT -1 36 "17.A Overview of the Shooting Method" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 508 "The basic idea behind \+ the shooting method is to convert a boundary value problem (BVP) into \+ an initial value problem (IVP). One parameter is introduced for each m issing initial condition. The boundary conditions that are not initial conditions serve as the constraints to determine appropriate values f or the parameters. That is, given an initial guess for the parameters, an iterative solver is used to find values of the parameters that pro duce (approximate) solutions that satisfy the boundary conditions." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 145 "The shoo ting method is quite general. Here it will be demonstrated only for tw o second-order linear two-point boundary value problems of the form" } }{PARA 271 "" 0 "" {TEXT -1 2 " " }{XPPEDIT 18 0 "Diff(y,x$2) + p(x)* Diff(y,x) + q(x)*y = f(x)" "6#/,(-%%DiffG6$%\"yG-%\"$G6$%\"xG\"\"#\"\" \"*&-%\"pG6#F,F.-F&6$F(F,F.F.*&-%\"qG6#F,F.F(F.F.-%\"fG6#F," }{TEXT -1 2 " " }}{PARA 272 "" 0 "" {TEXT -1 2 " " }{XPPEDIT 18 0 "y(a) = r ;" "6#/-%\"yG6#%\"aG%\"rG" }{TEXT -1 2 " " }}{PARA 273 "" 0 "" {TEXT -1 2 " " }{XPPEDIT 18 0 "y(b) = s;" "6#/-%\"yG6#%\"bG%\"sG" }{TEXT -1 4 " . " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 65 "The IVP that will be used as the basis for the shooting method \+ is" }}{PARA 274 "" 0 "" {TEXT -1 2 " " }{XPPEDIT 18 0 "Diff(y,x$2) + \+ p(x)*Diff(y,x) + q(x)*y = f(x)" "6#/,(-%%DiffG6$%\"yG-%\"$G6$%\"xG\"\" #\"\"\"*&-%\"pG6#F,F.-F&6$F(F,F.F.*&-%\"qG6#F,F.F(F.F.-%\"fG6#F," } {TEXT -1 2 " " }}{PARA 275 "" 0 "" {TEXT -1 2 " " }{XPPEDIT 18 0 "y( a) = r;" "6#/-%\"yG6#%\"aG%\"rG" }{TEXT -1 2 " " }}{PARA 276 "" 0 "" {XPPEDIT 18 0 "eval( Diff(y,x), x=a ) = alpha" "6#/-%%evalG6$-%%DiffG6 $%\"yG%\"xG/F+%\"aG%&alphaG" }{TEXT -1 3 " " }}{PARA 0 "" 0 "" {TEXT -1 6 "where " }{XPPEDIT 18 0 "alpha" "6#%&alphaG" }{TEXT -1 57 " is the unknown parameter. Call the solution to this IVP " }{XPPEDIT 18 0 "y^alpha" "6#)%\"yG%&alphaG" }{TEXT -1 22 ". The goal is to find \+ " }{XPPEDIT 18 0 "alpha" "6#%&alphaG" }{TEXT -1 11 " such that " } {XPPEDIT 18 0 "y^alpha" "6#)%\"yG%&alphaG" }{TEXT -1 1 "(" }{XPPEDIT 18 0 "b" "6#%\"bG" }{TEXT -1 4 ") = " }{XPPEDIT 18 0 "s;" "6#%\"sG" } {TEXT -1 94 ". To accomplish this, define a Maple procedure that accep ts the IVP with a specific value for " }{XPPEDIT 18 0 "alpha" "6#%&alp haG" }{TEXT -1 41 ", the unknown function, and the value of " } {XPPEDIT 18 0 "b" "6#%\"bG" }{TEXT -1 26 " and returns the value of " }{XPPEDIT 18 0 "y^alpha" "6#)%\"yG%&alphaG" }{TEXT -1 1 "(" }{XPPEDIT 18 0 "b" "6#%\"bG" }{TEXT -1 1 ")" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "Yb := ( ivp, fn, b ) ->" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 " eval( fn, dsolve( ivp, fn, type=n umeric )(b) );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 14 "and then use, " }{TEXT 256 4 "e.g. " }{TEXT -1 46 ", the Secant Method to solve for the value of " } {XPPEDIT 18 0 "alpha" "6#%&alphaG" }{TEXT -1 11 " for which " } {XPPEDIT 18 0 "y^alpha" "6#)%\"yG%&alphaG" }{TEXT -1 1 "(" }{XPPEDIT 18 0 "b" "6#%\"bG" }{TEXT -1 4 ") - " }{XPPEDIT 18 0 "s;" "6#%\"sG" } {TEXT -1 5 " = 0." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 55 "A more sophisticated and general implementation of the " }{URLLINK 17 "Shooting Method" 4 "http://www.mapleapps.com/Info.asp?Ar ticleID=132" "" }{TEXT -1 23 " is available from the " }{URLLINK 17 "M aple Applications Center" 4 "http://www.mapleapps.com/" "" }{TEXT -1 2 " ." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 0 {PARA 3 "" 0 "17.B" {TEXT -1 14 "17.B Example 1" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 16 "Consider the BVP" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 76 "ode1 := diff( y(x), x$2 ) + 2 * diff( y(x), x ) - 10 * y(x) = 7*exp(-x) + 4;" }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 23 "bc1 := y(0)=2, y(1)=-5;" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 48 "with bounda ry conditions specified at the points" }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "a := 0;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "b := 1;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 44 "The corresponding IVP ha s initial conditions" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "ic1 := bc1[1], D(y)(a)=alpha;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 6 "where " }{XPPEDIT 18 0 "alpha" "6#%&alphaG" }{TEXT -1 24 " is to be chosen to make" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "constraint := lhs(bc1[2])-rhs(bc1[2]):" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "constraint = 0;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 48 "Her e is an implementation of the Secant Method :" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "a0 := 0:" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 75 "y0 := eval( constraint, y(b)=Yb( ev al( \{ode1,ic1\}, alpha=a0 ), y(x), b ) ):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "a1 := 1:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 75 "y1 := e val( constraint, y(b)=Yb( eval( \{ode1,ic1\}, alpha=a1 ), y(x), b ) ): " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "while fnormal(y1-y0)<>0 do" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 " z := solve( y1 = (y1-y0)/(a1-a0)* (a1-x), x );" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 18 " a0, a1 := a1, z; " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 84 " y0, y1 := y1, eval( constrain t, y(b)=Yb( eval( \{ode1,ic1\}, alpha=z ), y(x), b ) );" }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 7 "end do:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "a lpha_opt1 := z;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 111 "The shooting method solution is t he solution to the IVP corresponding to this optimal choice of the par ameter :" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 67 "shoot_sol1 := dsolve( eval( \{ode1,ic1\}, alpha=alpha _opt1 ), y(x) );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 126 "Not surprisingly, because of the \+ simple nature of this example, Maple is able to determine the exact so lution to this problem." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "infolevel[dsolve] := 3:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 53 "exact_sol1 := combine(dsolve( \{ ode1, bc1 \+ \}, y(x) ));" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "infolevel[dsolve] : = 0:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 63 "To compare the solutions, plot the exact and shoo ting solutions" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 67 "plot( [rhs(exact_sol1),rhs(shoot_sol1)], x=0.. 1, color=[BLACK,RED]," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 53 " thic kness=[1,3], legend=['exact','shooting'] );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 87 "Note that \+ the value of the shooting method solution at the right-hand boundary p oint is" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "evalf( eval( rhs(shoot_sol1), x=1 ) );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 79 "This also shows good agreement between the shooting method and \+ exact solutions." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 0 {PARA 3 "" 0 "17.C" {TEXT -1 14 "17.C Example 2" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 16 "Consider the BV P" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 76 "ode2 := x^2 * diff( y(x), x$2 ) + x * diff( y(x), x ) + 4 * y(x) = -2*x + 7;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "bc2 := y (1)=7, y(4)=-1;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 36 "The boundary conditions are given \+ at" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "a := 1;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "b := 4;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 44 "The corresponding IVP has initial conditions" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "i c2 := bc2[1], D(y)(a)=alpha;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 6 "where " }{XPPEDIT 18 0 "a lpha" "6#%&alphaG" }{TEXT -1 24 " is to be chosen to make" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "cons traint := lhs(bc2[2])-rhs(bc2[2]):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "constraint = 0;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 48 "Here is an implementation of the S ecant Method :" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 8 "a0 := 0:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 75 " y0 := eval( constraint, y(b)=Yb( eval( \{ode2,ic2\}, alpha=a0 ), y(x), b ) ):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "a1 := 1:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 75 "y1 := eval( constraint, y(b)=Yb( eval( \{ode2,ic 2\}, alpha=a1 ), y(x), b ) ):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "wh ile fnormal(y1-y0)<>0 do" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 47 " z := \+ solve( y1 = (y1-y0)/(a1-a0)*(a1-x), x );" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 18 " a0, a1 := a1, z;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 84 " y0, y1 := y1, eval( constraint, y(b)=Yb( eval( \{ode2,ic2\}, alp ha=z ), y(x), b ) );" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "end do:" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "alpha_opt2 := z;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 110 " The shooting method solution is the solution to the IVP corresponding \+ to this optimal choice of the parameter." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 67 "shoot_sol2 := dsolve ( eval( \{ode2,ic2\}, alpha=alpha_opt2 ), y(x) );" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 115 "Aga in, because of the simple nature of this example, Maple is able to det ermine the exact solution to this problem." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 53 "exact_sol2 := com bine(dsolve( \{ ode2, bc2 \}, y(x) ));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 63 "To compare th e solutions, plot the exact and shooting solutions" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "plot( [rhs( exact_sol2),rhs(shoot_sol2)], x=1..4," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 40 " color=[BLACK,RED],thickness=[1,3]," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 36 " legend=['exact','shooting'] );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 92 "Note also that the value of the shooting method solution at the right-hand boundary point is" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "evalf( eval( rhs(shoot_sol2) , x=1 ) );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 79 "This also shows good agreement between th e shooting method and exact solutions." }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 9 "[Back to " }{HYPERLNK 17 "ODE Powertool Table of Cont ents" 1 "unit00.mws" "" }{TEXT -1 1 "]" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "0 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }