Professional Documents
Culture Documents
Faculty of Engineering
Department of Basic Sciences
Objective:
- Revision for the differentiation and the partial derivatives.
- Solution of ordinary differential equations (1st order)
Syntax (1):
dsolve(eqn): solves the ordinary differential equation eqn. Here eqn is a symbolic equation
containing diff to indicate derivatives. When representing eqn as a symbolic equation, you must create a
symbolic function, for example y(x) as mentioned before. Here x is an independent variable for which
you solve an ordinary differential equation.
Note: Because D indicates differentiation, the names of symbolic variables must not contain D.
Example (1):
Solve the following Differential Equations:
dy
a) = ex - y
dx
dx x
b) ln x =
dy y
dy
c) x 4 - y2 + y 2 x2 + 3 =0
dx
d) x d y + ( y + x 3 ) d x = 0
Page 1 of 3
Pharos University in Alexandria Fall 2022-2023
Faculty of Engineering
Department of Basic Sciences
Note: For this syntax, you can enter the differential equation to be solved in the form of
“dy/dx == equation or dx/dy= = equation” if needed.
Solution:
Syntax (2):
dsolve(eqn,cond): Solves the ordinary differential equation eqn with the initial or boundary
condition cond. Define initial and boundary conditions using symbolic equations, such as y(a) == b ,
here a and b are constants.
Example (2):
Solve the following Differential Equations:
a) dy/dx=a/ y y , y(a)=1
b) dy/dx=a/ ( y 2 1) , y(a)= 2
c) dy/dx=x*y , y(0)=2
d) dy/dx+4 y(x)= e x , y(0) = 1
Page 2 of 3
Pharos University in Alexandria Fall 2022-2023
Faculty of Engineering
Department of Basic Sciences
Note: Specifying the initial condition lets you eliminate arbitrary constants, such as C1, C2,...
Solution:
* (Classwork Activity): Write an M-file that accepts from the user the differential equation to be solved
and displays the result and try the program on any problem from example 1.
© By Engineering Mathematics Group
Page 3 of 3