Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Construct a computer program that uses both the secant method and the Runge-Kutt

ID: 3683389 • Letter: C

Question

Construct a computer program that uses both the secant method and the Runge-Kutta method (that you developed in assignment #3) to obtain a numerical solution to the two-point boundary-value problem: x' = f(t,x) = x + 0.09 x 2 + cos(10 t) differential equation x(0) + x(1) - 3.0 = 0 boundary condition Starting with the initial guesses 0.7 and 1.0 for the (unknown) initial value, x(0), obtain an approximation to x(0) {for the final solution, x(t)} such that the boundary condition is satisfied to within a tolerance of 10-4 . Use a fixed stepsize of 0.025 (i.e., take 40 steps each time you integrate the differential equation from t=0 to t=1). Write your program so that the output shows the values of x(0), x(1), and x(0)+x(1)-3 (the error in satisfying the boundary condition) at the end of each iteration of the secant method. After the last iteration of the secant method, re-integrate from t=0 to t=1 and print out the solution for x(t) over the range [0,1]. Your solution for x(t) should resemble the solution plotted below.

2.25 1.75 1.5 1.25 0.2 0.4 0.6 0.8 0.75

Explanation / Answer


It looks like you want to begin with the guess values for x(0) and integrate the
differential equation using your RK algorithm to determine values for x(1).
Then use the secant method on the boundary condition equation to find a new
guess value for x(0).

So, first integration using guess x(0) = 0.7 yields values p_0 = x(0), and fp_0 = x(0) + x(1) - 3.0
Second integration using guess x(0) = 1.0 yields values p_1 = x(0), and fp_1 = x(0) + x(1) - 3.0

Apply secant method to find new guess for x(0):

x(0) = p_1 - ( (fp_1)(p_1 - p_0)/( fp_1 - fp_0) )

Rinse, repeat, until x(0) + x(1) - 3.0 is within desired tolerance of zero.