Ordinary Differential Equations with SCILAB

Ordinary Differential Equations with SCILAB

Ordinary Differential Equations with SCILAB By Gilberto E. Urroz, Ph.D., P.E. Distributed by i nfoClearinghouse.com ©2001 Gilberto E. Urroz All Rights Reserved A "zip" file containing all of the programs in this document (and other SCILAB documents at InfoClearinghouse.com) can be downloaded at the following site: http://www.engineering.usu.edu/cee/faculty/gurro/Software_Calculato rs/Scilab_Docs/ScilabBookFunctions.zip The author's SCILAB web page can be accessed at: http://www.engineering.usu.edu/cee/faculty/gurro/Scilab.html Please report any errors in this document to: [email protected] Download at InfoClearinghouse.com 1 © 2001 Gilberto E. Urroz ORDINARY DIFFERENTIAL EQUATIONS 4 Introduction to differential equations 4 Definitions 5 Ordinary and partial differential equations 5 Order and degree of an equation 5 Linear and non-linear equations 5 Constant or variable coefficients 6 Homogeneous and non-homogeneous equations 6 Solutions 6 General and particular solutions 7 Verifying solutions using SCILAB 7 Initial conditions and boundary conditions 8 Symbolic solutions to ordinary differential equations 8 Solution techniques for first-order, linear ODEs with constant coefficients 9 Integrating factors for first-order, linear ODEs with variable coefficients 11 Exact differential equations 12 Solutions of homogeneous linear equations of any order with constant coefficients 12 Obtaining the particular solution for a second-order, linear ODE with constant coefficients 14 Applications of ODEs I : analysis of damped and undamped free oscillations 17 Undamped motion 17 Damped motion 18 Initial conditions for damped oscillatory motion 19 Creating phase portraits of oscillatory motion 22 Applications of ODEs II : analysis of damped and undamped forced oscillations 24 Applications of ODEs III: Oscillations in electric circuits 27 Finite differences and numerical solutions 29 Finite differences 29 Finite difference formulas based on Taylor series expansions 31 Forward, backward and centered finite difference approximations to the first derivative 32 Forward, backward and centered finite difference approximations to the second derivative 33 Solution of a first-order ODE using finite differences - Euler forward method 33 A function to implement Euler’s first-order method 35 Finite difference formulas using indexed variables 39 Solution of a first-order ODE using finite differences - an implicit method 40 Explicit versus implicit methods 42 Outline of explicit solution for a second-order ODE 42 Outline of the implicit solution for a second-order ODE 43 Systems of ordinary differential equations 44 Systems of ordinary differential equations using matrices 44 Systems of linear homogeneous ODEs - solution using matrices 45 Systems of linear nonhomogeneous ODEs - solution using matrices 49 Converting second-order linear equations to a system of equations 50 SCILAB functions for the numerical solutions of initial value problems (IVP) 52 Download at InfoClearinghouse.com 2 © 2001 Gilberto E. Urroz Applications of numerical solutions to IVPs 65 Systems of ODEs from mechanical systems 65 System of ODEs from Electric Circuits 68 Solving a fourth-order equation 72 The Van der Pol equation 74 The Rössler flow 77 Solutions to boundary value problems (BVPs) 79 The shooting method 80 A function to implement the shooting method 80 Outline of the implicit solution for a second-order BVP 83 Function bvode for the solution of boundary value problems 84 Function bvode applied to a third-order boundary value problem 88 Application of bvode to a third-order problem with one interior fixed point 89 Application of bvode to a fourth-order problem with two interior fixed points 91 Boundary value problems with eigenvalues 93 Numerical solution to a boundary value problem with eigenvalues 93 A function for calculating eigenvalues for a boundary value problem 95 Exercises 97 Download at InfoClearinghouse.com 3 © 2001 Gilberto E. Urroz Ordinary Differential Equations The chapter starts with a review of concepts of differential equations and symbolic solution techniques that can be applied using SCILAB. Since SCILAB is not a symbolic environment, its applications to symbolic solutions of ordinary differential equations (ODEs) is limited. However, SCILAB can be used to calculate intermediate numerical steps in the solutions. The strength of SCILAB in solving ODEs is in its numerical applications. Thus, the chapter also includes a number of numerical solutions to ODEs through user-programmed and pre- programmed SCILAB functions. Introduction to differential equations Differential equations are equations involving derivatives of a function. Because many physical quantities are given in terms of rates of change of a certain quantity with respect to one or more independent quantities, derivatives appear frequently in the statement of physical laws. For example, the flux of heat, q [J/m2], in a one-dimensional direction is given by q = -k⋅(dT/dx), where T[K or oC] is the temperature, x [m] is positions, and k [J/(m K) or J/(m oC)]. This equation can be considered as a differential equation if q and k are known, and we are trying to solve for the temperature as a function of x, i.e., T = T(x). The equation of conservation of energy for heat transfer in one-dimension, where there are no sources or sink of heat, requires that the rate of change of the heat flux across an area perpendicular to the x-axis be zero, i.e., dq/dx = 0,or, d dT − k ⋅ = 0 . dx dx If k is a constant, i.e., not a function of x, then, the equation of conservation of energy reduces to d2T/dx2 = 0. The last two expressions are also differential equations. The solution for these equations will be a function T = T(x) representing the temperature. Download at InfoClearinghouse.com 4 © 2001 Gilberto E. Urroz Definitions The following definitions allow us to classify equations, thus providing general guidelines for obtaining solutions. Ordinary and partial differential equations When the dependent variable is a function of a single independent variable, as in the cases presented above, the differential equation is said to be an ordinary differential equation (ODE). If the dependent variable is a function of more than one variable, a differential equation involving derivatives of this dependent variable is said to be a partial differential equation (PDE). An example of a partial differential equation would be the time-dependent would be the Laplace’s equation for the stream function, ψ(x,y,z), of a three-dimensional, inviscid flow: ∂2ψ/∂x2 + ∂2ψ/∂y2 + ∂2ψ/∂x2 = 0. Order and degree of an equation The order of a differential equation is the order of the highest-order derivative involved in the equation. Thus, the ODE dy/dx + 3xy = 0 is a first-order equation, while Laplace’s equation (shown above) is a second-order equation. The degree of a differential equation is the highest power to which the highest-order derivative is raised. Therefore, the equation (d3y/dt3)2+(d2y/dx2)5-xy = ex, is a third order, second-degree ODE, while the equation ∂y/∂t = c⋅(∂y/∂x), is a first-order, first-degree PDE. Linear and non-linear equations An equation in which the dependent variable and all its pertinent derivatives are of the first degree is referred to as a linear differential equation. Otherwise, the equation is said to be non-linear. Examples of linear differential equations are: 2 2 d x/dt + β⋅(dx/dt) + ωo⋅x = A sin ωf t, and ∂C/∂t + u⋅(∂C/∂x) = D⋅(∂2C/∂x2). Download at InfoClearinghouse.com 5 © 2001 Gilberto E. Urroz Constant or variable coefficients The following equation: d3y/dt3+π⋅ (d2y/dx2)2-5⋅y = ex, where all the coefficients accompanying the dependent variable and its derivative are constant, would be classified as a third order, linear ODE with constant coefficients. Instead, the equation ∂2C/∂t2 – u(x,t)⋅ (∂C/∂x) = 0, would be classified as a second-order, linear PDE with variable coefficients. Homogeneous and non-homogeneous equations Typically, differential equations are arranged so that all the terms involving the dependent variable are placed on the left-hand side of the equation leaving only constant terms or terms involving the independent variable(s) only in the right-hand side. When arranged in this fashion, a differential equation that has a zero right-hand side is referred to as a homogeneous equation. Examples of homogeneous equations are: 2 2 d x/dt + β⋅(dx/dt) + ωo⋅x = 0, and (x-1)⋅(dy/dx) + 2⋅x⋅y = 0. On the other hand, if the right-hand side of the equation, after placing the terms involving the dependent variable and its derivatives on the left-hand side, is non-zero, the equation is said to be non-homogeneous. Non-homogeneous versions of the last two equations are: 2 2 -t/τ d x/dt + β⋅(dx/dt) + ωo⋅x = Ao⋅e , and (x-1)⋅(dy/dx) + 2⋅x⋅y = x2-2x. Solutions A solution to a differential equation is a function of the independent variable(s) that, when replaced in the equation, produces an expression that can be reduced, through algebraic manipulation, to the form 0 = 0. For example, the function y = sin x, is a solution to the equation d2y/dx2 + y = 0, because when we replace y into the equation we have -sin x + sin x = 0, Download at InfoClearinghouse.com 6 © 2001 Gilberto E. Urroz or, 0 = 0, for all values of x. This follows from the fact that dy/dx = cos(x), and d2y/dx2 = -sin(x). General and particular solutions A general solution is one involving integration constants so that any choice of those constants represents a solution to the differential equation. For example, the function x = C⋅e-t, is a general solution to the equation dx/dt + x = 0, because, substituting C⋅e-t for x in the equation produces - C⋅e-t + C⋅e-t = 0.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    107 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us