1/8/08 5:28 PM \\eng\files\numerical Methods\simulatio...\mtl_ode_sim_RK2ndconv.m 1 of 5

Size: px
Start display at page:

Download "1/8/08 5:28 PM \\eng\files\numerical Methods\simulatio...\mtl_ode_sim_RK2ndconv.m 1 of 5"

Transcription

1 1/8/08 5:28 PM \\eng\files\numerical Methods\simulatio...\mtl_ode_sim_RK2ndconv.m 1 of 5 clc clf clear all ********************************************************************** INPUTS Click the run button and refer to the command window These are the inputs that can be modified by the user dy/dx in form of f(x,y). In general it can be a function of both variables x and y. If your function is only a function of x then you will need to add a 0*y to your function. fcnstr='exp(-x)+0*y' f=inline(fcnstr) x0, x location of known initial condition x0=2 y0, corresponding value of y at x0 y0=1 xf, x location at where you wish to see the solution to the ODE xf=7 a2, parameter which must be between 0 and 1. Certain names are associated with different parameters. a2 = 0.5 Heun's Method = 2/3 Ralston's Method = 1.0 Midpoint Method a2 = 0.5 n, maximum number of steps to take. Needs to be in powers of 2, for example 2,4,8,16,... n=8 ********************************************************************** \n\n2nd Order Runge-Kutta Method of Solving Ordinary Differential Equations')) University of South Florida')) United States of America')) kaw@eng.usf.edu\n')) disp('note: This worksheet demonstrates the use of Matlab to illustrate ')

2 1/8/08 5:28 PM \\eng\files\numerical Methods\simulatio...\mtl_ode_sim_RK2ndconv.m 2 of 5 disp('the Runge-Kutta method, a numerical technique in solving ordinary ') disp('differential equations.') disp(sprintf ('\n*******************************introduction*********************************')) disp('the following simulation illustrates the convergence of the 2nd Order') disp('runge-kutta method of solving ordinary differential equations (ODEs). ') disp('this section is the only section where the user interacts with the ') disp('program. The user enters ordinary differential equation of the ') disp('f(x, y)=dy/dx, the initial conditions, and the value of x at which the') disp('solution is desired. By entering this data, the program will calculate') disp('the exact (Matlab numerical value if it is not exact) value of the ') disp('solution, followed by the results using 2nd Order Runge-Kutta method') disp('with 1, 2, 4, 8... n steps. The program will also display the true') disp('error, the absolute relative percentage true error, the approximate') disp(' error, the absolute relative aprroximate percentage error, and the ') disp('least number of significant digits correct all as a function of number ') disp('of segments.') \n\n*****************************input Data*******************************\n')) f = dy/dx ')) x0 = initial x ')) y0 = initial y ')) xf = final x ')) a2 = constant value between 0 and 1.')) = 0.5, Heun Method')) = 1.0, Midpoint Method')) = , Ralston''s Method')) n = number of steps to take in powers of 2 (2,4,8,16...)')) format short g \n \n')) disp(sprintf([' f(x,y) = dy/dx = ' fcnstr])) x0 = g',x0)) y0 = g',y0)) xf = g',xf)) n = g',n)) \n ')) For this simulation, the following parameters are constant.\n')) Find the spacing, h h=(xf-x0)/n h = ( xf - x0 ) / n ')) = ( g - g ) / g ',xf,x0,n)) = g',h)) The following 3 parameters are needed by the method and calculated in the following fashion. a1=1-a2 \n a1 = 1 - a2'))

3 1/8/08 5:28 PM \\eng\files\numerical Methods\simulatio...\mtl_ode_sim_RK2ndconv.m 3 of 5 p1=1/2/a2 \n q11=p1 \n = 1 - g',a2)) = g',a1)) p1 = 1 / ( 2 * a2 )')) = 1 / ( 2 * g )',a2)) = g',p1)) q11 = p1')) = g',q11)) The following lines solve the ODE via the matlab function ode45. yf is selected to be the exact value at xf. xspan = [x0 xf] [x,y]=ode45(f,xspan,y0) [yfi dummy]=size(y) yf=y(yfi) The proceeding loop runs the method in iteration, generating the approximation at different step sizes as well as the errors. nstep = floor(log2(n)) xaa=zeros(2^nstep+1,1) yaa=zeros(2^nstep+1,1) for i=0:nstep Increases the number of steps to examine in powers of 2 NN(i+1)=2^i h=(xf-x0)/nn(i+1) Find the approximation xa=x0 ya=y0 xaa(1)=x0 yaa(1)=y0 for j=1:nn(i+1) k1 = f(xa,ya) k2 = f(xa+p1*h,ya+q11*k1*h) ya=ya+(a1*k1+a2*k2)*h xa=xa+h store these variables for plotting later xaa(j+1)=xa yaa(j+1)=ya YY(i+1)=ya Find the True Error, and Absolute Relative True Error Et(i+1)=yf-ya Etabs(i+1)=abs((ya-yf)/yf)

4 1/8/08 5:28 PM \\eng\files\numerical Methods\simulatio...\mtl_ode_sim_RK2ndconv.m 4 of 5 If you are on the 2nd iteration or later, calculate the Relative Error, Absolute Relative Error, and Significant Digits correct. if(i > 0) Ea(i+1)=YY(i+1)-YY(i) Eaabs(i+1)=abs((YY(i+1)-YY(i))/YY(i)) SD(i+1)=floor((2-log10(Eaabs(i+1)/0.5))) if(sd(i+1)<0) SD(i+1)=0 else Ea(1)=0 Eaabs(1)=0 SD(1)=0 Display the results of the study in a table \n\n************************table of Values******************************\n')) disp(' Approx True Relative Approx Rel Appr Sig ') disp(' n Soln Error True Error Error Error Digits ') disp(' ') for i=1:nstep+1 string = '4i +1.3e +1.3e +1.3e +1.3e +1.3e 2i' disp(sprintf(string,nn(i),yy(i),et(i),etabs(i),ea(i),eaabs(i),sd(i))) disp(' ') The following generates 3 plots. This function detects information about your screensize and tries to then place/size the graphs accordingly. scnsize = get(0,'screensize') Graph 1: Exact and Approximate Solution at maximum N hold on xlabel('x') ylabel('y') title('exact and Approximate Solution of the ODE by RK2 Method') plot(x,y,'--','linewidth',2,'color',[0 0 1]) plot(xaa,yaa,'-','linewidth',2,'color',[0 1 0]) leg('exact','approximation') Graph 2: Approximation and True Errors fig2=figure set(fig2,'position',[0.2*scnsize(3),0.2*scnsize(3),0.6*scnsize(3),0.2*scnsize(4)]) subplot(1,3,1) plot(nn,yy,'-o','linewidth',2,'color',[1 0 0]) title('approximate vs Number of Steps') subplot(1,3,2) plot(nn,et,'-o','linewidth',2,'color',[0 0 1])

5 1/8/08 5:28 PM \\eng\files\numerical Methods\simulatio...\mtl_ode_sim_RK2ndconv.m 5 of 5 title('et vs Number of Steps') subplot(1,3,3) plot(nn,etabs,'-o','linewidth',2,'color',[0 0 1]) title('abs et vs Number of Steps') Graph 3: Relative Errors and Significant Digits fig = figure set(fig,'position',[0.2*scnsize(3),0,0.6*scnsize(3),0.2*scnsize(4)]) subplot(1,3,1) plot(nn,ea,'-o','linewidth',2,'color',[0 1 0]) title('ea vs Number of Steps') subplot(1,3,2) plot(nn,eaabs,'-o','linewidth',2,'color',[0 1 0]) title('abs ea vs Number of Steps') subplot(1,3,3) plot(nn,sd,'-o','linewidth',2,'color',[ ]) title('significant Digits Correct vs Number of Steps')

5/21/08 2:16 PM \\eng\files\numerical Methods\sim...\mtl_dif_sim_secondorderdif.m 1 of 5

5/21/08 2:16 PM \\eng\files\numerical Methods\sim...\mtl_dif_sim_secondorderdif.m 1 of 5 5/21/08 2:16 PM \\eng\files\numerical Methods\sim...\mtl_dif_sim_secondorderdif.m 1 of 5 function SecondOrder clc clear all % Revised: % February 11, 2008 % Authors: % Ana Catalina Torres, Dr. Autar Kaw

More information

8/31/08 12:02 AM C:\Documents and Settings\SR.IA-3\Des...\mtl_aae_sim_quadratic.m 1 of 6

8/31/08 12:02 AM C:\Documents and Settings\SR.IA-3\Des...\mtl_aae_sim_quadratic.m 1 of 6 8/31/08 12:02 AM C:\Documents and Settings\SR.IA-3\Des...\mtl_aae_sim_quadratic.m 1 of 6 function mtl_aae_sim_quadratic % % Mfile name % mtl_aae_sim_quadratic.m % Version: % Matlab R2007a % Revised: %

More information

over The idea is to construct an algorithm to solve the IVP ODE (8.1)

over The idea is to construct an algorithm to solve the IVP ODE (8.1) Runge- Ku(a Methods Review of Heun s Method (Deriva:on from Integra:on) The idea is to construct an algorithm to solve the IVP ODE (8.1) over To obtain the solution point we can use the fundamental theorem

More information

Application 2.4 Implementing Euler's Method

Application 2.4 Implementing Euler's Method Application 2.4 Implementing Euler's Method One's understanding of a numerical algorithm is sharpened by considering its implementation in the form of a calculator or computer program. Figure 2.4.13 in

More information

ODE IVP. An Ordinary Differential Equation (ODE) is an equation that contains a function having one independent variable:

ODE IVP. An Ordinary Differential Equation (ODE) is an equation that contains a function having one independent variable: Euler s Methods ODE IVP An Ordinary Differential Equation (ODE) is an equation that contains a function having one independent variable: The equation is coupled with an initial value/condition (i.e., value

More information

Euler s Methods (a family of Runge- Ku9a methods)

Euler s Methods (a family of Runge- Ku9a methods) Euler s Methods (a family of Runge- Ku9a methods) ODE IVP An Ordinary Differential Equation (ODE) is an equation that contains a function having one independent variable: The equation is coupled with an

More information

over The idea is to construct an algorithm to solve the IVP ODE (9.1)

over The idea is to construct an algorithm to solve the IVP ODE (9.1) Runge- Ku(a Methods Review of Heun s Method (Deriva:on from Integra:on) The idea is to construct an algorithm to solve the IVP ODE (9.1) over To obtain the solution point we can use the fundamental theorem

More information

Num. #1: Recalls on Numerical Methods for Linear Systems and Ordinary differential equations (ODEs) - CORRECTION

Num. #1: Recalls on Numerical Methods for Linear Systems and Ordinary differential equations (ODEs) - CORRECTION Num. #1: Recalls on Numerical Methods for Linear Systems and Ordinary differential equations (ODEs) - CORRECTION The programs are written with the SCILAB software. 1 Resolution of a linear system & Computation

More information

Ordinary Differential Equations

Ordinary Differential Equations Next: Partial Differential Equations Up: Numerical Analysis for Chemical Previous: Numerical Differentiation and Integration Subsections Runge-Kutta Methods Euler's Method Improvement of Euler's Method

More information

Jason Yalim. Here we perform a few tasks to ensure a clean working environment for our script.

Jason Yalim. Here we perform a few tasks to ensure a clean working environment for our script. Table of Contents Initialization... 1 Part One -- Computation... 1 Part Two -- Plotting... 5 Part Three -- Plotting Incorrectly... 7 Part Four -- Showing Output Adjacent to Code... 8 Part Five -- Creating

More information

Romberg Integration - Method

Romberg Integration - Method Romberg Integration - Method 2004 Autar Kaw, Loubna Guennoun, University of South Florida, kaw@eng.usf.edu, http://numericalmethods.eng.usf.edu NOTE: This worksheet demonstrates the use of Maple to illustrate

More information

ChE 400: Applied Chemical Engineering Calculations Tutorial 6: Numerical Solution of ODE Using Excel and Matlab

ChE 400: Applied Chemical Engineering Calculations Tutorial 6: Numerical Solution of ODE Using Excel and Matlab ChE 400: Applied Chemical Engineering Calculations Tutorial 6: Numerical Solution of ODE Using Excel and Matlab Tutorial 6: Numerical Solution of ODE Gerardine G. Botte This handout contains information

More information

37 Self-Assessment. 38 Two-stage Runge-Kutta Methods. Chapter 10 Runge Kutta Methods

37 Self-Assessment. 38 Two-stage Runge-Kutta Methods. Chapter 10 Runge Kutta Methods Chapter 10 Runge Kutta Methods In the previous lectures, we have concentrated on multi-step methods. However, another powerful set of methods are known as multi-stage methods. Perhaps the best known of

More information

Problem Exam Review ER-1. (E & P Exercise 2.4-6, Symbolic Solution)

Problem Exam Review ER-1. (E & P Exercise 2.4-6, Symbolic Solution) Name Class Time Math 2250 Maple Project 3: Numerical Methods S2010 Due date: See the internet due dates. Maple lab 3 has three problems L3.1, L3.2, L3.3. References: Code in maple appears in 2250mapleL3-S2010.txt

More information

MATH2071: LAB 2: Explicit ODE methods

MATH2071: LAB 2: Explicit ODE methods MATH2071: LAB 2: Explicit ODE methods 1 Introduction Introduction Exercise 1 Euler s method review Exercise 2 The Euler Halfstep (RK2) Method Exercise 3 Runge-Kutta Methods Exercise 4 The Midpoint Method

More information

x n x n stepnumber k order r error constant C r+1 1/2 5/12 3/8 251/720 abs. stab. interval (α,0) /11-3/10

x n x n stepnumber k order r error constant C r+1 1/2 5/12 3/8 251/720 abs. stab. interval (α,0) /11-3/10 MATH 573 LECTURE NOTES 77 13.8. Predictor-corrector methods. We consider the Adams methods, obtained from the formula xn+1 xn+1 y(x n+1 y(x n ) = y (x)dx = f(x,y(x))dx x n x n by replacing f by an interpolating

More information

Module1: Numerical Solution of Ordinary Differential Equations. Lecture 6. Higher order Runge Kutta Methods

Module1: Numerical Solution of Ordinary Differential Equations. Lecture 6. Higher order Runge Kutta Methods Module1: Numerical Solution of Ordinary Differential Equations Lecture 6 Higher order Runge Kutta Methods Keywords: higher order methods, functional evaluations, accuracy Higher order Runge Kutta Methods

More information

Homework Set #2-3, Math 475B

Homework Set #2-3, Math 475B Homework Set #2-3, Math 475B Part I: Matlab In the last semester you learned a number of essential features of MATLAB. 1. In this instance, you will learn to make 3D plots and contour plots of z = f(x,

More information

Simulation in Computer Graphics. Particles. Matthias Teschner. Computer Science Department University of Freiburg

Simulation in Computer Graphics. Particles. Matthias Teschner. Computer Science Department University of Freiburg Simulation in Computer Graphics Particles Matthias Teschner Computer Science Department University of Freiburg Outline introduction particle motion finite differences system of first order ODEs second

More information

A Study on Numerical Exact Solution of Euler, Improved Euler and Runge - Kutta Method

A Study on Numerical Exact Solution of Euler, Improved Euler and Runge - Kutta Method A Study on Numerical Exact Solution of Euler, Improved Euler and Runge - Kutta Method Mrs. P. Sampoornam P.K.R Arts College for Women, Gobichettipalayam Abstract: In this paper, I will discuss the Runge

More information

Approximate Solutions to Differential Equations Slope Fields (graphical) and Euler s Method (numeric) by Dave Slomer

Approximate Solutions to Differential Equations Slope Fields (graphical) and Euler s Method (numeric) by Dave Slomer Approximate Solutions to Differential Equations Slope Fields (graphical) and Euler s Method (numeric) by Dave Slomer Leonhard Euler was a great Swiss mathematician. The base of the natural logarithm function,

More information

dy = dx y dx Project 1 Consider the following differential equations: I. xy II. III.

dy = dx y dx Project 1 Consider the following differential equations: I. xy II. III. Project 1 Consider the following differential equations: dy = dy = y dy x + sin( x) y = x I. xy II. III. 1. Graph the direction field in the neighborhood of the origin. Graph approximate integral curves

More information

INTRODUCTION TO NUMERICAL ANALYSIS

INTRODUCTION TO NUMERICAL ANALYSIS INTRODUCTION TO NUMERICAL ANALYSIS Cho, Hyoung Kyu Department of Nuclear Engineering Seoul National University 0. MATLAB USAGE 1. Background MATLAB MATrix LABoratory Mathematical computations, modeling

More information

What is MATLAB? It is a high-level programming language. for numerical computations for symbolic computations for scientific visualizations

What is MATLAB? It is a high-level programming language. for numerical computations for symbolic computations for scientific visualizations What is MATLAB? It stands for MATrix LABoratory It is developed by The Mathworks, Inc (http://www.mathworks.com) It is an interactive, integrated, environment for numerical computations for symbolic computations

More information

Thursday 1/8 1 * syllabus, Introduction * preview reading assgt., chapter 1 (modeling) * HW review chapters 1, 2, & 3

Thursday 1/8 1 * syllabus, Introduction * preview reading assgt., chapter 1 (modeling) * HW review chapters 1, 2, & 3 Topics and Syllabus Class # Text Reading I. NUMERICAL ANALYSIS CHAPRA AND CANALE A. INTRODUCTION AND MATLAB REVIEW :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::Week

More information

Matlab Handout Nancy Chen Math 19 Fall 2004

Matlab Handout Nancy Chen Math 19 Fall 2004 Matlab Handout Nancy Chen Math 19 Fall 2004 Introduction Matlab is a useful program for algorithm development, numerical computation, and data analysis and visualization. In this class you will only need

More information

Ordinary differential equations solving methods

Ordinary differential equations solving methods Radim Hošek, A07237 radhost@students.zcu.cz Ordinary differential equations solving methods Problem: y = y2 (1) y = x y (2) y = sin ( + y 2 ) (3) Where it is possible we try to solve the equations analytically,

More information

Application 7.6A The Runge-Kutta Method for 2-Dimensional Systems

Application 7.6A The Runge-Kutta Method for 2-Dimensional Systems Application 7.6A The Runge-Kutta Method for -Dimensional Systems Figure 7.6. in the text lists TI-85 and BASIC versions of the program RKDIM that implements the Runge-Kutta iteration k (,, ) = f tn xn

More information

ODEs occur quite often in physics and astrophysics: Wave Equation in 1-D stellar structure equations hydrostatic equation in atmospheres orbits

ODEs occur quite often in physics and astrophysics: Wave Equation in 1-D stellar structure equations hydrostatic equation in atmospheres orbits Solving ODEs General Stuff ODEs occur quite often in physics and astrophysics: Wave Equation in 1-D stellar structure equations hydrostatic equation in atmospheres orbits need workhorse solvers to deal

More information

Integration Using the Gauss Quadrature Rule - Convergence

Integration Using the Gauss Quadrature Rule - Convergence Integration Using the Gauss Quadrature Rule - Convergence 2004 Autar Kaw, Loubna Guennoun, University of South Florida, kaw@eng.usf.edu, http://numericalmethods.eng.usf.edu NOTE: This worksheet demonstrates

More information

Computer Simulations

Computer Simulations Computer Simulations A practical approach to simulation Semra Gündüç gunduc@ankara.edu.tr Ankara University Faculty of Engineering, Department of Computer Engineering 2014-2015 Spring Term Ankara University

More information

Mechanical Engineering Department Second Year (2015)

Mechanical Engineering Department Second Year (2015) Lecture 7: Graphs Basic Plotting MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as annotating and printing these graphs. This section describes a few of the most

More information

mathcad_homework_in_matlab.m Dr. Dave S#

mathcad_homework_in_matlab.m Dr. Dave S# Table of Contents Basic calculations - solution to quadratic equation: a*x^ + b*x + c = 0... 1 Plotting a function with automated ranges and number of points... Plotting a function using a vector of values,

More information

Page 1 of 7 E7 Spring 2009 Midterm I SID: UNIVERSITY OF CALIFORNIA, BERKELEY Department of Civil and Environmental Engineering. Practice Midterm 01

Page 1 of 7 E7 Spring 2009 Midterm I SID: UNIVERSITY OF CALIFORNIA, BERKELEY Department of Civil and Environmental Engineering. Practice Midterm 01 Page 1 of E Spring Midterm I SID: UNIVERSITY OF CALIFORNIA, BERKELEY Practice Midterm 1 minutes pts Question Points Grade 1 4 3 6 4 16 6 1 Total Notes (a) Write your name and your SID on the top right

More information

Homework Set 5 (Sections )

Homework Set 5 (Sections ) Homework Set 5 (Sections.4-.6) 1. Consider the initial value problem (IVP): = 8xx yy, yy(1) = 3 a. Do 10 steps of Euler s Method, using a step size of 0.1. Write the details in the table below. Work to

More information

From the output we see that the largest eigenvalue of B is about (ii) Use the inverse power method to find the smallest eigenvalue.

From the output we see that the largest eigenvalue of B is about (ii) Use the inverse power method to find the smallest eigenvalue. . Let B be the matrix given by.8635.735.9593.5685.65.735.8984.7439.6447.553.9593.7439.699.635.643.5685.6447.635.056.430.65.553.643.430.5505 (i) Use the power method to find the largest eigenvalue. The

More information

Mathematics for chemical engineers

Mathematics for chemical engineers Mathematics for chemical engineers Drahoslava Janovská Department of mathematics Winter semester 2013-2014 Numerical solution of ordinary differential equations Initial value problem Outline 1 Introduction

More information

TOPIC 6 Computer application for drawing 2D Graph

TOPIC 6 Computer application for drawing 2D Graph YOGYAKARTA STATE UNIVERSITY MATHEMATICS AND NATURAL SCIENCES FACULTY MATHEMATICS EDUCATION STUDY PROGRAM TOPIC 6 Computer application for drawing 2D Graph Plotting Elementary Functions Suppose we wish

More information

Lecture 7 Symbolic Computations

Lecture 7 Symbolic Computations Lecture 7 Symbolic Computations The focus of this course is on numerical computations, i.e. calculations, usually approximations, with floating point numbers. However, Matlab can also do symbolic computations,

More information

Math 225 Scientific Computing II Outline of Lectures

Math 225 Scientific Computing II Outline of Lectures Math 225 Scientific Computing II Outline of Lectures Spring Semester 2003 I. Interpolating polynomials Lagrange formulation of interpolating polynomial Uniqueness of interpolating polynomial of degree

More information

Basic exercises. Array exercises. 1. x = 32:2: x = [ ] a = x + 16 b = x(1:2:end) + 3 c = sqrt(x) or c = x.^(0.5) d = x.^2 or d = x.

Basic exercises. Array exercises. 1. x = 32:2: x = [ ] a = x + 16 b = x(1:2:end) + 3 c = sqrt(x) or c = x.^(0.5) d = x.^2 or d = x. Basic exercises 1. x = 32:2:75 2. x = [2 5 1 6] a = x + 16 b = x(1:2:) + 3 c = sqrt(x) or c = x.^(0.5) d = x.^2 or d = x.*x 3. x = [3 2 6 8]', y = [4 1 3 5]' a = y + sum(x) b = x.^y c = x./y z = x.*y w

More information

Chemical Reaction Engineering - Part 4 - Integration Richard K. Herz,

Chemical Reaction Engineering - Part 4 - Integration Richard K. Herz, Chemical Reaction Engineering - Part 4 - Integration Richard K. Herz, rherz@ucsd.edu, www.reactorlab.net Integrating the component balance for a batch reactor For a single reaction in a batch reactor,

More information

11/30/15 11:09 AM C:\websi...\mathcad_homework_in_Matlab.m 1 of 6

11/30/15 11:09 AM C:\websi...\mathcad_homework_in_Matlab.m 1 of 6 11/30/15 11:09 AM C:\websi...\mathcad_homework_in_Matlab.m 1 of 6 %% mathcad_homework_in_matlab.m Dr. Dave S# %% Basic calculations - solution to quadratic equation: a*x^2 + b*x + c = 0 clc % clear the

More information

18.02 Multivariable Calculus Fall 2007

18.02 Multivariable Calculus Fall 2007 MIT OpenCourseWare http://ocw.mit.edu 18.02 Multivariable Calculus Fall 2007 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 18.02 Problem Set 4 Due Thursday

More information

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment What is MATLAB? MATLAB PROGRAMMING Stands for MATrix LABoratory A software built around vectors and matrices A great tool for numerical computation of mathematical problems, such as Calculus Has powerful

More information

Homework 14 solutions

Homework 14 solutions Section 9.1: Ex 1,5,10,15,16 Section 9.: Ex 1,8,9; AP 1-5,9 Section 9.3: AP 1-5 Section 9.1 Homework 14 solutions 1. (a) Show that y( is a solution to the differential equation by substitution. (b) Find

More information

Basic Graphs. Dmitry Adamskiy 16 November 2011

Basic Graphs. Dmitry Adamskiy 16 November 2011 Basic Graphs Dmitry Adamskiy adamskiy@cs.rhul.ac.uk 16 November 211 1 Plot Function plot(x,y): plots vector Y versus vector X X and Y must have the same size: X = [x1, x2 xn] and Y = [y1, y2,, yn] Broken

More information

Numerical Methods Lecture 1

Numerical Methods Lecture 1 Numerical Methods Lecture 1 Basics of MATLAB by Pavel Ludvík The recommended textbook: Numerical Methods Lecture 1 by Pavel Ludvík 2 / 30 The recommended textbook: Title: Numerical methods with worked

More information

Modelling and Simulation for Engineers

Modelling and Simulation for Engineers Unit T7: Modelling and Simulation for Engineers Unit code: F/503/7343 QCF level: 6 Credit value: 15 Aim This unit gives learners the opportunity to develop their understanding of Ordinary Differential

More information

7.1 First-order initial-value problems

7.1 First-order initial-value problems 7.1 First-order initial-value problems A first-order initial-value problem (IVP) is a first-order ordinary differential equation with a specified value: d dt y t y a y f t, y t That is, this says that

More information

Direction Fields; Euler s Method

Direction Fields; Euler s Method Direction Fields; Euler s Method It frequently happens that we cannot solve first order systems dy (, ) dx = f xy or corresponding initial value problems in terms of formulas. Remarkably, however, this

More information

Hybrid Dynamic Iterations for the Solution of Initial Value Problems

Hybrid Dynamic Iterations for the Solution of Initial Value Problems Hybrid Dynamic Iterations for the Solution of Initial Value Problems Yanan Yu and Ashok Srinivasan Department of Computer Science, Florida State University, Tallahassee, FL32306 Abstract Many scientific

More information

Workpackage 5 - Ordinary Differential Equations

Workpackage 5 - Ordinary Differential Equations Mathematics for I Workpackage 5 - Ordinary Differential Equations Introduction During this laboratory you will be introduced to some of Matlab s facilities for solving ordinary differential equations (ode).

More information

Worksheet 2.7: Critical Points, Local Extrema, and the Second Derivative Test

Worksheet 2.7: Critical Points, Local Extrema, and the Second Derivative Test Boise State Math 275 (Ultman) Worksheet 2.7: Critical Points, Local Extrema, and the Second Derivative Test From the Toolbox (what you need from previous classes) Algebra: Solving systems of two equations

More information

Splines and Piecewise Interpolation. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

Splines and Piecewise Interpolation. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan Splines and Piecewise Interpolation Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan chanhl@mail.cgu.edu.tw Splines n 1 intervals and n data points 2 Splines (cont.) Go through

More information

QUICK INTRODUCTION TO MATLAB PART I

QUICK INTRODUCTION TO MATLAB PART I QUICK INTRODUCTION TO MATLAB PART I Department of Mathematics University of Colorado at Colorado Springs General Remarks This worksheet is designed for use with MATLAB version 6.5 or later. Once you have

More information

Comparison of Some Evolutionary Algorithms for Approximate Solutions of Optimal Control Problems

Comparison of Some Evolutionary Algorithms for Approximate Solutions of Optimal Control Problems Australian Journal of Basic and Applied Sciences, 4(8): 3366-3382, 21 ISSN 1991-8178 Comparison of Some Evolutionary Algorithms for Approximate Solutions of Optimal Control Problems Akbar H. Borzabadi,

More information

LAB #8 Numerical Methods

LAB #8 Numerical Methods LAB #8 Numerical Methods Goal: The purpose of this lab is to explain how computers numerically approximate solutions to differential equations. Required tools: Matlab routine dfield ; numerical routines

More information

Programming for Experimental Research. Flow Control

Programming for Experimental Research. Flow Control Programming for Experimental Research Flow Control FLOW CONTROL In a simple program, the commands are executed one after the other in the order they are typed. Many situations require more sophisticated

More information

An Improved Algorithm for Scan-converting a Line

An Improved Algorithm for Scan-converting a Line An Improved Algorithm for Scan-converting a Line *Md. Hasanul Kabir 1, Md. Imrul Hassan 2, Abdullah Azfar 1 1 Department of Computer Science & Information Technology (CIT) 2 Department of Electrical &

More information

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices Introduction to Interactive Calculations Matlab is interactive, no need to declare variables >> 2+3*4/2 >> V = 50 >> V + 2 >> V Ans = 52 >> a=5e-3; b=1; a+b Most elementary functions and constants are

More information

W1005 Intro to CS and Programming in MATLAB. Plo9ng & Visualiza?on. Fall 2014 Instructor: Ilia Vovsha. hgp://www.cs.columbia.

W1005 Intro to CS and Programming in MATLAB. Plo9ng & Visualiza?on. Fall 2014 Instructor: Ilia Vovsha. hgp://www.cs.columbia. W1005 Intro to CS and Programming in MATLAB Plo9ng & Visualiza?on Fall 2014 Instructor: Ilia Vovsha hgp://www.cs.columbia.edu/~vovsha/w1005 Outline Plots (2D) Plot proper?es Figures Plots (3D) 2 2D Plots

More information

Differential Equations (92.236) Listing of Matlab Lab Exercises

Differential Equations (92.236) Listing of Matlab Lab Exercises Differential Equations (92.236) Listing of Matlab Lab Exercises This page contains a summary list of the Matlab lab exercises available for this course. We will have roughly 10 12 lab sessions that highlight

More information

Armstrong Atlantic State University Engineering Studies MATLAB Marina 2D Plotting Primer

Armstrong Atlantic State University Engineering Studies MATLAB Marina 2D Plotting Primer Armstrong Atlantic State University Engineering Studies MATLAB Marina D Plotting Primer Prerequisites The D Plotting Primer assumes knowledge of the MATLAB IDE, MATLAB help, arithmetic operations, built

More information

A Quick Guide to MATLAB

A Quick Guide to MATLAB Appendix C A Quick Guide to MATLAB In this course we will be using the software package MATLAB. The most recent version can be purchased directly from the MATLAB web site: http://www.mathworks.com/academia/student

More information

MS213: Numerical Methods Computing Assignments with Matlab

MS213: Numerical Methods Computing Assignments with Matlab MS213: Numerical Methods Computing Assignments with Matlab SUBMISSION GUIDELINES & ASSIGNMENT ADVICE 1 Assignment Questions & Supplied Codes 1.1 The MS213 Numerical Methods assignments require students

More information

Flow Control. Spring Flow Control Spring / 26

Flow Control. Spring Flow Control Spring / 26 Flow Control Spring 2019 Flow Control Spring 2019 1 / 26 Relational Expressions Conditions in if statements use expressions that are conceptually either true or false. These expressions are called relational

More information

CE890 / ENE801 Lecture 1 Introduction to MATLAB

CE890 / ENE801 Lecture 1 Introduction to MATLAB CE890 / ENE801 Lecture 1 Introduction to MATLAB CE890: Course Objectives Become familiar with a powerful tool for computations and visualization (MATLAB) Promote problem-solving skills using computers

More information

Exploring Fractals through Geometry and Algebra. Kelly Deckelman Ben Eggleston Laura Mckenzie Patricia Parker-Davis Deanna Voss

Exploring Fractals through Geometry and Algebra. Kelly Deckelman Ben Eggleston Laura Mckenzie Patricia Parker-Davis Deanna Voss Exploring Fractals through Geometry and Algebra Kelly Deckelman Ben Eggleston Laura Mckenzie Patricia Parker-Davis Deanna Voss Learning Objective and skills practiced Students will: Learn the three criteria

More information

Computational Mathematics/Information Technology. Worksheet 2 Iteration and Excel

Computational Mathematics/Information Technology. Worksheet 2 Iteration and Excel Computational Mathematics/Information Technology Worksheet 2 Iteration and Excel This sheet uses Excel and the method of iteration to solve the problem f(x) = 0. It introduces user functions and self referencing

More information

Graphing Techniques and Transformations. Learning Objectives. Remarks

Graphing Techniques and Transformations. Learning Objectives. Remarks Graphing Techniques and Transformations Learning Objectives 1. Graph functions using vertical and horizontal shifts 2. Graph functions using compressions and stretches. Graph functions using reflections

More information

(Part - 1) P. Sam Johnson. April 14, Numerical Solution of. Ordinary Differential Equations. (Part - 1) Sam Johnson. NIT Karnataka.

(Part - 1) P. Sam Johnson. April 14, Numerical Solution of. Ordinary Differential Equations. (Part - 1) Sam Johnson. NIT Karnataka. P. April 14, 2015 1/51 Overview We discuss the following important methods of solving ordinary differential equations of first / second order. Picard s method of successive approximations (Method of successive

More information

The listing says y(1) = How did the computer know this?

The listing says y(1) = How did the computer know this? 18.03 Class 2, Feb 3, 2010 Numerical Methods [1] How do you know the value of e? [2] Euler's method [3] Sources of error [4] Higher order methods [1] The study of differential equations has three parts:.

More information

Excel and the solution of linear and non-linear simultaneous equations. Part 1

Excel and the solution of linear and non-linear simultaneous equations. Part 1 Comp Math/IT 2007-08 g.bowtell@city.ac.uk www.staff.city.ac.uk/g.bowtell 1 Worksheet 3 Weeks beginning 5 th November and 12 th November 2007 Excel and the solution of linear and non-linear simultaneous

More information

Euler s Method with Python

Euler s Method with Python Euler s Method with Python Intro. to Differential Equations October 23, 2017 1 Euler s Method with Python 1.1 Euler s Method We first recall Euler s method for numerically approximating the solution of

More information

You can change the line style by adding some information in the plot command within single quotation marks.

You can change the line style by adding some information in the plot command within single quotation marks. Plotting Continued: You can change the line style by adding some information in the plot command within single quotation marks. y = x.^2; plot(x,y, '-xr') xlabel('x, meters') ylabel('y, meters squared')

More information

Differentiation. J. Gerlach November 2010

Differentiation. J. Gerlach November 2010 Differentiation J. Gerlach November 200 D and diff The limit definition of the derivative is covered in the Limit tutorial. Here we look for direct ways to calculate derivatives. Maple has two commands

More information

Mass-Spring Systems. Last Time?

Mass-Spring Systems. Last Time? Mass-Spring Systems Last Time? Implicit Surfaces & Marching Cubes/Tetras Collision Detection & Conservative Bounding Regions Spatial Acceleration Data Structures Octree, k-d tree, BSF tree 1 Today Particle

More information

C =

C = file:///c:/documents20and20settings/ravindra/desktop/html/exercis... 1 of 5 10/3/2008 3:17 PM Lab Exercise 2 - Matrices Hyd 510L, Fall, 2008, NM Tech Programmed by J.L. Wilson, Sept, 2008 Problem 2.1 Create

More information

Drawing fractals in a few lines of Matlab

Drawing fractals in a few lines of Matlab Drawing fractals in a few lines of Matlab Thibaud Taillefumier Disclaimer: This note is intended as a guide to generate fractal and perhaps cool-looking images using a few functionalities offered by Matlab.

More information

CS205b/CME306. Lecture 9

CS205b/CME306. Lecture 9 CS205b/CME306 Lecture 9 1 Convection Supplementary Reading: Osher and Fedkiw, Sections 3.3 and 3.5; Leveque, Sections 6.7, 8.3, 10.2, 10.4. For a reference on Newton polynomial interpolation via divided

More information

Flatness Definition Studies

Flatness Definition Studies Computational Mechanics Center Slide 1 Flatness Definition Studies SEMI P-37 and SEMI P-40 M. Nataraju and R. Engelstad Computational Mechanics Center University of Wisconsin Madison C. Van Peski SEMATECH

More information

INTRODUCTION TO MATLAB PLOTTING WITH MATLAB

INTRODUCTION TO MATLAB PLOTTING WITH MATLAB 1 INTRODUCTION TO MATLAB PLOTTING WITH MATLAB Plotting with MATLAB x-y plot Plotting with MATLAB MATLAB contains many powerful functions for easily creating plots of several different types. Command plot(x,y)

More information

Additional Plot Types and Plot Formatting

Additional Plot Types and Plot Formatting Additional Plot Types and Plot Formatting The xy plot is the most commonly used plot type in MAT- LAB Engineers frequently plot either a measured or calculated dependent variable, say y, versus an independent

More information

Problem Set #9 (With Solutions)

Problem Set #9 (With Solutions) IC-3 Optimal Control Spring 009 Benoît Chachuat ME C 6, Ph: 3518, benoit@mcmaster.ca Problem Set #9 (With Solutions) The objective of this problem is to solve, via the direct sequential approach, the following

More information

Nested functions & Local functions

Nested functions & Local functions Lab 5 Nested functions & Local functions Nested functions are functions defined within functions. They are helpful when: - We wish to write small or temporary functions which do not merit creation of a

More information

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored. From Vertices to Fragments: Rasterization Reading Assignment: Chapter 7 Frame Buffer Special memory where pixel colors are stored. System Bus CPU Main Memory Graphics Card -- Graphics Processing Unit (GPU)

More information

Math 20A lecture 10 The Gradient Vector

Math 20A lecture 10 The Gradient Vector Math 20A lecture 10 p. 1/12 Math 20A lecture 10 The Gradient Vector T.J. Barnet-Lamb tbl@brandeis.edu Brandeis University Math 20A lecture 10 p. 2/12 Announcements Homework five posted, due this Friday

More information

Lecturer: Keyvan Dehmamy

Lecturer: Keyvan Dehmamy MATLAB Tutorial Lecturer: Keyvan Dehmamy 1 Topics Introduction Running MATLAB and MATLAB Environment Getting help Variables Vectors, Matrices, and linear Algebra Mathematical Functions and Applications

More information

Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane.

Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane. Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane c Sateesh R. Mane 2018 16 Lecture 16 May 3, 2018 Numerical solution of systems

More information

Double Pendulum. Freddie Witherden. February 10, 2009

Double Pendulum. Freddie Witherden. February 10, 2009 Double Pendulum Freddie Witherden February 10, 2009 Abstract We report on the numerical modelling of a double pendulum using C++. The system was found to be very sensitive to both the initial starting

More information

Mathematical Methods and Modeling Laboratory class. Numerical Integration of Ordinary Differential Equations

Mathematical Methods and Modeling Laboratory class. Numerical Integration of Ordinary Differential Equations Mathematical Methods and Modeling Laboratory class Numerical Integration of Ordinary Differential Equations Exact Solutions of ODEs Cauchy s Initial Value Problem in normal form: Recall: if f is locally

More information

15.3: Double Integrals over General Regions

15.3: Double Integrals over General Regions 15.3: ouble Integrals over General Regions Marius Ionescu November 19, 2012 Marius Ionescu () 15.3: ouble Integrals over General Regions November 19, 2012 1 / 15 ouble Integrals over General Regions Fact

More information

Computation of Velocity, Pressure and Temperature Distributions near a Stagnation Point in Planar Laminar Viscous Incompressible Flow

Computation of Velocity, Pressure and Temperature Distributions near a Stagnation Point in Planar Laminar Viscous Incompressible Flow Excerpt from the Proceedings of the COMSOL Conference 8 Boston Computation of Velocity, Pressure and Temperature Distributions near a Stagnation Point in Planar Laminar Viscous Incompressible Flow E. Kaufman

More information

Approximate First and Second Derivatives

Approximate First and Second Derivatives MTH229 Project 6 Exercises Approximate First and Second Derivatives NAME: SECTION: INSTRUCTOR: Exercise 1: Let f(x) = sin(x 2 ). We wish to find the derivative of f when x = π/4. a. Make a function m-file

More information

An Introductory Tutorial on Matlab

An Introductory Tutorial on Matlab 1. Starting Matlab An Introductory Tutorial on Matlab We follow the default layout of Matlab. The Command Window is used to enter MATLAB functions at the command line prompt >>. The Command History Window

More information

This document describes how I implement the Newton method using Python and Fortran on the test function f(x) = (x 1) log 10 (x).

This document describes how I implement the Newton method using Python and Fortran on the test function f(x) = (x 1) log 10 (x). AMS 209 Foundations of Scientific Computing Homework 6 November 23, 2015 Cheng-Han Yu This document describes how I implement the Newton method using Python and Fortran on the test function f(x) = (x 1)

More information

Introduction to Programming with Matlab. Jim Dove

Introduction to Programming with Matlab. Jim Dove Introduction to Programming with Matlab Jim Dove Spring Semester, 2005 Chapter 1 INTRODUCTION 1.1 The Need for Computers Statistical physics or N-body simulations not possible Monte-Carlo Simulations Many

More information

MATLAB BEGINNER S GUIDE

MATLAB BEGINNER S GUIDE MATLAB BEGINNER S GUIDE About MATLAB MATLAB is an interactive software which has been used recently in various areas of engineering and scientific applications. It is not a computer language in the normal

More information

Transactions on Information and Communications Technologies vol 10, 1995 WIT Press, ISSN

Transactions on Information and Communications Technologies vol 10, 1995 WIT Press,   ISSN Numerical solutions to arbitrarily sized systems of coupledfirstorder ordinary differential equations using computer algebra software P. Mitic, P.O. Thomas Faculty of Mathematics and Computing, The Open

More information