0% found this document useful (0 votes)
182 views2 pages

Analytical Solution..... This Is A First Order Separable Ordinary Differential Equation. The

This document provides instructions for using Excel to numerically solve a first order ordinary differential equation using the Runge-Kutta method. It describes how to: 1) Define a user function in VBA for the differential equation. 2) Set up the spreadsheet with columns for x-values, y-values, and the Runge-Kutta approximations K1-K4. 3) Enter the Runge-Kutta formulas to calculate successive y-values down the column. 4) Plot the numerical solution curve by graphing the x and y columns.

Uploaded by

gardinta
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
182 views2 pages

Analytical Solution..... This Is A First Order Separable Ordinary Differential Equation. The

This document provides instructions for using Excel to numerically solve a first order ordinary differential equation using the Runge-Kutta method. It describes how to: 1) Define a user function in VBA for the differential equation. 2) Set up the spreadsheet with columns for x-values, y-values, and the Runge-Kutta approximations K1-K4. 3) Enter the Runge-Kutta formulas to calculate successive y-values down the column. 4) Plot the numerical solution curve by graphing the x and y columns.

Uploaded by

gardinta
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

EXAMPLE OF THE RUNGE KUTTA METHOD USING EXCEL Problem: Solve y = x 2 y y y( 0) = 1 0 x 1 Analytical solution.....

....This is a first order separable ordinary differential equation. The exact solution is y = e 3 . Numerical solution..... We ish to !a"e the #$%#& or"sheet flexible enou'h to allo us to use any function or any step si(e. )n our proble!* let+s use a step si(e of h , .1. ST#- 1. ///////////////////////////////////////////////////////////////////////
If you are using version 97 or 2000: First,choose tools, macro, security, medium, tools, macro, visual basic, insert , module .To reuse the function, security must be set to mediumnot high. On the blank screen that appears, enter the function f(x,y) as follows function f(x,y) f y!x"2#y
x 3 3 x

end function *********************************************************************** * If you re u!"#$ %er!"o# &''(: )))))))*HEN +OU SA,E THIS FILE- CHOOSE SA,E AS AND THEN CHOOSE MACRO.ENA/LED *ORK/OOK0 )))))) If you 1u!2 ! %e ! u!u l- you 3"ll #o2 be ble 2o reu!e 24e m 5ro0 0ou ill need to add a De%elo6er tab to the top of the #xcel pa'e. %lic" on the 1icrosoft 2ffice button in the upper left corner of the #xcel or"sheet. 3 drop do n !enu ill appear. 3t the botto! of it* you ill see #xcel 2ptions tab. Select the S4o3 De%elo6er T b by chec"in' the box and then clic" 24. 5ro! no on* unless you are or"in' in the ca!pus labs* you should have that tab available. %lic" on it and press the M 5ro Se5ur"2y button. The security level should be set as D"! ble ll m 5ro! 3"24 #o2"f"5 2"o#!. Then clic" 24. 6o that e have ta"en care of the preli!inaries* let+s create a user defined function. To do this* %lic" on ,"!u l / !"5 under the 7eveloper tab. %lic" on I#!er20 %lic" on Mo7ule. 2n the blan" screen that appears* enter the function f(x*y) as follo s. fu#52"o# f89-y: f;y*9<&.y e#7 fu#52"o# /////////////////////////////////////////////////////////////////////// / ST#- 2. 3fter the function is entered* proceed as follo s. 7o not close the !odule. %lic" on #xcel tab at botto! of screen to return to spreadsheet. ST#- 3. We ish to set up the step si(e. Type h , in one cell and .1 in the ad8acent cell. &et+s na!e the cell ith the .1 in it. When e type the for!ulas* e can 8ust type h and not have to enter the cell address. 5or version 2009* clic" on the Formul ! Tab and choose 7ef"#e # me and na!e the cell ith the .1 in it 4. (For earlier !ersions of "xcel,
choose insert name define from the menu and #ust name this cell $.)

ST#- :. 5ill in all the infor!ation that you can on the spreadsheet. See notes fro! the ;un'e 4utta 1ethod &ecture. The 'iven initial point is the first entry under the xi colu!n and the yi colu!n. 2ther yi values ill be 'enerated usin' the ;un'e 4utta for!ulas. 6otice that you are able to fill in the xi colu!n before even enterin' for!ulas. 3l ays refer to the proble! you are as"ed to solve to initially fill in your or"sheet. )f you are as"ed to use a step si(e of .0< for x bet een .< and 2* you ill have to ad8ust the or"sheet accordin'ly. 0ou are no ready to enter the for!ulas. This ill be a tedious process* but you need only do it once. We are !a"in' the spreadsheet flexible enou'h that any step si(e or any differential equation can be used. 5irst* enter the for!ula for "1......Type ,f(clic" on cell ith initial xi value* clic" on cell ith initial yi value) -ress enter. 6ext* enter the for!ula for "2......Type ,f(clic" on cell ith initial xi value = .</h* clic" on cell ith initial y value = .</h/clic" on cell ith "1). -ress enter. %ontinue enterin' for!ulas for "3 and ": in a si!ilar !anner. See section >.2 in your text for for!ulas if you do not have your notes handy. 5inally* you are ready to enter a for!ula for y1. %emember, t$e &ur&ose of

all t$is 'or( is to get an estimate for eac$ of t$e yi values)


)n the cell beneath the initial y value* enter the for!ula for y1. The for!ula is ,clic" on y0 = h?@ / (clic" on first entry under "1 headin' = 2/ clic" on first entry under "2 headin' = 2/clic" on first entry under "3 headin' = clic" on first entry under ": headin') 0ou have 8ust entered y1 , y0 = h?@("1=2"2=2"3=":). The typin' is doneAAA Bi'hli'ht the for!ula cells and dra' do n to co!plete the table. 0ou should see the values that are in !y handout. 6othin' is co!plete ithout a beautiful plot of the results. We ill plot the solution curve by plottin' the xi and yi values. 5irst* hi'hli'ht the 2 colu!ns of xi and yi...includin' the cells ith the na!es xi and yi in the!. %lic" on the I#!er2 T b. ) use the scatterplot ith the dots connected. ("arlier !ersions
click on the chart wi$ard icon. %t often has a blue, yellow, and red bar graph. &hoose '( ()catter). Then, follow the menu choices. )

-ress the L you2 2 b to see the options for creatin' axis labels and chart titles. For 24e 54 r2 2"2le- 6u2 your # me0

You might also like