Mathcad Professional 14.1 Linear Ordinary Differential Equation solver Symbolically solves Linear Ordinary Differential Equations with constant coefficients Luc Meekes Reference, LODEsolve Luc Meekes 2 D0B990B2-5353-490A-A8FF-9272ABE5D10D B1F3D274-8D31-434B-8433-A966BC85BEC1 00000000-0000-0000-0000-000000000000 00000000-0000-0000-0000-000000000000
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}} {\colortbl ;\red0\green0\blue0;} \viewkind4\uc1\pard\cf1\f0\fs16 Date: \{fd\}; Time: \{ft\} \par }
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}} {\colortbl ;\red0\green0\blue0;} \viewkind4\uc1\pard\qc\cf1\f0\fs16 File: \{f\} \par }
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}} {\colortbl ;\red0\green0\blue0;} \viewkind4\uc1\pard\qr\cf1\f0\fs16 Page: \{n\} of \{nn\} \par }

Solving Linear Ordinary Differential Equations

The function $subst f V p$ is a generaly utility function, for symbolic evaluation only, that will take an expression $f$ as the first argument and a vector $V$ of names in as the second argument and replace references to those names with subscripted references to the name given in the third argument $p$ .

$subst f V p n rows V n 0 n 0 f f substitute V p f n 1 V V n rows V j 0 j n f f substitute V j P j j j 1 f f substitute P p f$

The function $GetODEcoeffs ODE y t$ analyzes the Ordinary Differential Equation provided as the first parameter $ODE$ and extracts the coefficients of each of the derivatives of the function sought, the name of which is given as the second parameter $y$ . The independent variable is provided as the last parameter $t$ . The function returns the vector of coefficients.

$GetODEcoeffs ODE y t ODE_ subst subst ODE t t_ y y_ n last ODE_ laplace t_ s_ substitute laplace y_ t_ t_ s_ L_ coeffs s_ P ODE_ coeffs y_ t_ ORIGIN 1 P 0 i 1 n P stack P ODE_ coeffs t_ y_ t_ i ORIGIN 1 P stack P 0$

The function $LaplaceOfODElhs p y0 u Ly$ is a generaly utility function, for symbolic evaluation of linear ordinary differential equations, that will take a vector $p$ with coefficients belonging i'th order differentials of a function, a vector $y0$ with initial conditions, a parameter $u$ that specifies the independent variable for the Laplace domain and a parameter $Y$ to specify the Laplace transform of the function and produces the Laplace transform of the (homogenous part of the) differential equation.

$LaplaceOfODElhs p y0 u Y i p i u i ORIGIN Y k u i k y0 k 1 k i ORIGIN 1 last p ORIGIN last p$

The function $LODEsolve ode f y0 y t$ symbolically solves a linear ordinary differential equation for which the lefthand segment (the part with the derivatives) is given by first parameter $ode$ , the righ hand segment ( inhomogenous part or particular function) is specified through function $f$ , the initial conditions are specfied in vector $y0$ , the sought function is specified through $y$ and the independent variable is specfied through the last parameter $t$ .

$LODEsolve ode f y0 y t y0 stack y0 0 p_ GetODEcoeffs ode y t last y0 last p_ y0 stack y0 0 A LaplaceOfODElhs p_ y0 s_ L_ C subst f t t_ laplace t_ s_ B A C simplify solve L_ B invlaplace s_ t$

By including this Mathcad sheet as a reference into another sheet, it is possible to solve L inear O rdinary D ifferential E quations with constant coefficients.

Note that an include sheet exists for Mathcad 11 (LODEsolve.mcd) separately from Mathcad 15 (LODEsolve.xmcd). The Mathcad 11 sheet will not work in Mathcad 15.

The function $LODEsolve ode f y0 y t$ symbolically solves a Linear Ordinary Differential Equation (ODE) with constant coefficients.

The parameters to the function are:

$ode$ S pecifies the left-hand segment (the part with the derivatives of the sought function ) of the ODE.

Write the function as you would write the right-hand side of a function definition.
You cannot use prime notation (
$y' t$ etc.), you must use $t y t$ and $t y t n$ to describe derivatives.

Note that de ODE must be Linear, you cannot use powers of derivatives

and the coefficients of the derivatives cannot be dependent on $t$ .

$f$ Specifies the rig hand segment (inhomogeneous part or particular function) of the ODE.

The function should be a mathematical function for which the Laplace transform exists.

If no particular function is needed (the ODE is homogenous), supply a $0$ .

$y0$ A vector with the initial conditions of the function and its derivatives.

You cannot specify an initial condition for a $t$ value other than $0$ .

LODEsolve will enlarge the vector with 0's for any initial condition not provided.

$y$ The name of t he sought function, you can use any name (see notes below).

You MUST use the name you give here as the name for the function in $ode$ .

$t$ The name of the independent variable, you can use any name (see notes below) .

You MUST use the name you give here as the name for the independent variable in $ode$ and in $f$ .

Notes:The function $LODEsolve$ is a symbolic only function. This means that you cannot evaluate it numerically.
But you can assign its result to a function and use that numerically.

There are limits to the order of the ODE. Symbolic solutions exist for polynomials up to order 4.

If the span of derivatives exceeds 3, in general no solution will be found.

Since LODEsolve is a symbolic function, you can use it to solve fully symbolic ODE's fully symbolically.

You should not use names that end in _\$. Such names are used internally, and may cause unexpected results.