Symbolic Math
Symbolic Math
Computer
Programming
Dr. Deniz Kutluay
Symbolic Math
001
Basic Computer Programming Dr. Deniz Kutluay
004
Basic Computer Programming Dr. Deniz Kutluay
006
Basic Computer Programming Dr. Deniz Kutluay
007
Basic Computer Programming Dr. Deniz Kutluay
The default order starts with x, and followed by letters, according to their closeness to x. If
there are two letters equally close to x, the letter that is after x in alphabetical order is first
(y before w, and z before v). (Consider v-w-x-y-z)
The default symbolic variable in a symbolic expression is the first variable in the default
order.
The default symbolic variable in an expression S can be identified by typing findsym(S,1) .
010
Basic Computer Programming Dr. Deniz Kutluay
012
Basic Computer Programming Dr. Deniz Kutluay
013
Basic Computer Programming Dr. Deniz Kutluay
014
Basic Computer Programming Dr. Deniz Kutluay
015
Basic Computer Programming Dr. Deniz Kutluay
016
Basic Computer Programming Dr. Deniz Kutluay
018
Basic Computer Programming Dr. Deniz Kutluay
Solving algebraic
equations
Solving a single equation:
Solving algebraic
equations
Solving a single equation:
Solving algebraic
equations
Solving a single equation:
Solving algebraic
equations
Solving a single equation:
Solving algebraic
equations
Solving a system of equations:
Solving algebraic
equations
Solving a system of equations:
Solving algebraic
equations
Solving a system of equations:
The output from the solve command, which is the solution of the system, can have two
different forms. One is a cell array and the other is a structure.
A structure is an array in which the elements (called fields) are addressed by textual field
designators. The fields of a structure and the elements of a cell array can be arrays of
different sizes and types.
025
Basic Computer Programming Dr. Deniz Kutluay
Solving algebraic
equations
Solving a system of equations: [varA, varB, varC] = solve (eq1,eq2,eq3)
Solving algebraic
equations
Solving a system of equations:
027
Basic Computer Programming Dr. Deniz Kutluay
Solving algebraic
equations
Solving a system of equations:
Differentiation
Symbolic differentiation can be carried
out by using the diff command.
029
Basic Computer Programming Dr. Deniz Kutluay
Differentiation
If the expression contains more than
one variable, the differentiation is
carried out with respect to the default
symbolic variable.
Integration
Symbolic integration can be carried out For indefinite integration
by using the int command. The
command can be used for determining
indefinite integrals and definite
integrals.
Integration
For indefinite integration
If the expression contains more than
one variable, the integration is carried
out with respect to the default symbolic
variable.
032
Basic Computer Programming Dr. Deniz Kutluay
Integration
033
Basic Computer Programming Dr. Deniz Kutluay
Solving an ordinary
differential equation
An ordinary differential equation (ODE)
can be solved symbolically with the A first-order ODE A second-order ODE
dsolve command.
034
Basic Computer Programming Dr. Deniz Kutluay
Solving an ordinary
differential equation
General solution:
The solution can be general or particular.
Solving an ordinary
differential equation
In specifying the equation the letter D A second derivative is typed as D2, third
denotes differentiation. If y is the derivative as D3, and so on. For example, the
dependent variable and t is the equation
𝑑𝑦
independent variable, Dy stands for 𝑑𝑡 .
is typed in as
036
Basic Computer Programming Dr. Deniz Kutluay
Solving an ordinary
differential equation
The variables in the ODE equation that is A general solution of the first-order ODE
typed in the dsolve command do not
have to be previously created symbolic
variables.
037
Basic Computer Programming Dr. Deniz Kutluay
Solving an ordinary
differential equation
The variables in the ODE equation that is
typed in the dsolve command do not
have to be previously created symbolic A general solution of the second-order ODE
variables.
038
Basic Computer Programming Dr. Deniz Kutluay
Solving an ordinary
differential equation
039
Basic Computer Programming Dr. Deniz Kutluay
Solving an ordinary
differential equation
A particular solution of an ODE can be Particular solution:
obtained if boundary (or initial)
conditions are specified.
Solving an ordinary
differential equation
Particular solution:
The boundary conditions are typed in as
strings in the following:
041
Basic Computer Programming Dr. Deniz Kutluay
Solving an ordinary
differential equation
Particular solution:
The second-order ODE with the initial
conditions
042
Basic Computer Programming Dr. Deniz Kutluay
Plotting symbolic
expressions
Plotting a symbolic expression S that
contains one or two variables can be
done by using ezplot command.
Plotting symbolic
expressions
044
Basic Computer Programming Dr. Deniz Kutluay
Plotting symbolic
expressions
If the symbolic expression S has two
symbolic variables, var1 and var2, the
expression is assumed to be a function
with the form S(varl,var2) = 0.
Plotting symbolic
expressions
Plotting symbolic
expressions
047
Basic Computer Programming Dr. Deniz Kutluay
Numerical calculations
with symbolic
expressions
There may be a need to substitute 1- Substituting a numerical value for one symbolic
variable:
numbers for the symbolic variables and
calculate the numerical value of the A numerical value (or values) can be substituted for one
expressions. symbolic variable when a symbolic expression has one
or more symbolic variables.
This can be done by using the subs
command.
048
Basic Computer Programming Dr. Deniz Kutluay
Numerical calculations
with symbolic
expressions
The value of S is calculated for each
value of number and the result is
assigned to R, which will have the same
size as number.
049
Basic Computer Programming Dr. Deniz Kutluay
Numerical calculations
with symbolic
expressions
If S has one variable, the output R is
numerical.
050
Basic Computer Programming Dr. Deniz Kutluay
Numerical calculations
with symbolic
expressions
The variables are typed as a cell array 2- Substituting a numerical value for two or more
symbolic variables:
(inside curly braces { } ).
A numerical value (or values) can be substituted for two
A cell array is an array of cells where or more symbolic variables when a symbolic expression
each cell can be an array of numbers or has several symbolic variables.
text.
Numerical calculations
with symbolic
expressions
052
Basic Computer Programming Dr. Deniz Kutluay
Numerical calculations
with symbolic
expressions
If, for at least one variable, the
substituted numbers are an array, the
mathematical operations are executed
element-by-element and the outcome is
an array of numbers or expressions.
Numerical calculations
with symbolic
expressions
A second method for substituting
numerical values for symbolic variables
is to first assign numerical values to the
variables and then use the subs
command.
054
Thank
You