[email protected] Contents Solution of Algebraic Equations • • • • Polynomial to symbolic expression Symbolic expression to polynomial conversion Solution of algebraic equation Solution of system of linear equations Taylor.

Download Report

Transcript [email protected] Contents Solution of Algebraic Equations • • • • Polynomial to symbolic expression Symbolic expression to polynomial conversion Solution of algebraic equation Solution of system of linear equations Taylor.

1
[email protected]
Contents
Solution of Algebraic Equations
•
•
•
•
Polynomial to symbolic expression
Symbolic expression to polynomial conversion
Solution of algebraic equation
Solution of system of linear equations
Taylor Series and Function Calculator
• Taylor Series Calculator
• Function Calculator
Solution of Ordinary Differential Equations
•
•
•
•
Ordinary differential Equations
Solution of ordinary Differential Equations
Solution of Non-linear Differential Equations
Solution of several Differential Equations
3
Polynomial to Symbolic Conversion
• If you have stored a polynomial as a coefficient matrix [1 -3 2 5].
• To Convert this into symbolic polynomial we can use poly2sym
command.
5
Symbolic to Polynomial Conversion
• To Convert symbolicexpression to numeric polynomial we can
use MATLAB function sym2poly.
6
Functional Inverse
• g = finverse(f) returns the functional inverse of f.
• g = finverse(f,v) uses the symbolic variable v, where v is a sym,
as the independent variable.
returns
7
Exercise#1
1. Convert following polynomial to symbolic expression.
V  1
3
0
1
2. Convert symbolic expression to polynomial
f  2t  3t  t 10
4
2
3. Find inverse of the function
f  sin(x)
8
Solution of Algebraic Equations
9
Solving Algebraic Equations
If S is a symbolic expression,
attempts to find values of the symbolic variable in S for which S is zero.
10
Solving Algebraic Equations
• If you want to solve for a specific variable, you must specify that variable
as an additional argument.
• For example, if you want to solve S for b, use the command
which returns
11
Solving Algebraic Equations
• Note that these equations are of the form f(x)=0.
• If you need to solve the equations of the form f(x)=q(x), you must use
quoted string.
• For example the command
which returns
12
Exercise#2
1. Solve following equation.
f  ax  3x  bx  4
3
2
2. Solve for y
f  x  2 xy  y
2
2
3. Solve following equation for t.
t 2  3t  4  6
13
Several Algebraic Equations
Suppose you have the system
x2 y2  0
y
x a
2
and you want to solve for x and y. First create the necessary
symbolic objects.
There are several ways to address the output of solve.
14
Several Algebraic Equations
One is to use a two-output call
which returns
x y 0
y
x a
2
2
2
15
Exercise#3
1. Solve following system of linear equations.
3x  4 y  4
x  9y  3
2. Solve following system of linear equations.
4 x  3 y  9 z  11
2 x  2 x  3z  5
x  5y  z  6
16
Symbolic Matrix Operations
17
Symbolic Matrix
This toolbox lets you represent matrices in symbolic form as well as MATLAB’s
numeric form. Given the numeric matrix:
The function sym(a) converts a to the symbolic matrix. The result is
18
Symbolic Matrix
You can Also create a symbolic matrix in the following manner
19
Determinant of Symbolic Matrix
20
Diagonal of Symbolic Matrix
21
Eigen Values of Symbolic Matrix
22
Inverse of Symbolic Matrix
23
Jordan Canonical of Symbolic Matrix
24
Characteristic Polynomial of Symbolic Matrix
25
Rank of Symbolic Matrix
26
Lower Triangle of Symbolic Matrix
27
Upper Triangle of Symbolic Matrix
28
Exercise#4
1. Find determinant, inverse, rank, polynomial and eigen values
of the following symbolic matrix.
 x
A   x  y
 y  z
x y
y
xz
x  y  z
y  z 

z
2. Convert symbolic matrix A to Jordan, upper triangle and lower
triangle form.
29
Function Calculator
30
Function Calculator
• funtool is a visual function calculator that manipulates and displays
functions of one variable.
• At the click of a button, for example, funtool draws a graph
representing the sum, product, difference, or ratio of two functions that
you specify.
• funtool includes a function memory that allows you to store functions
for later retrieval.
31
Function Calculator
• At startup, funtool displays graphs of a pair of functions, f(x) = x and
g(x) = 1.
• The graphs plot the functions over the domain [-2π, 2 π].
• funtool also displays a control panel that lets you save, retrieve,
redefine, combine, and transform f and g.
32
Function Calculator
When you will type funtool in the command following GUI will appear
33
Exercise#05
Solve the following functions using funtool.
(a)
f  3t  t  1 (b) g  t  1
2
(c) num g
3
(d)

fdt
3
(g) f(g)
df
dt
(f) den g
(h) f(x+3)
(g) g(x+1)
(e)
34
Taylor Series Calculator
35
Taylor Series Calculator
• taylortool initiates a GUI that graphs a function against the Nth
partial sum of its Taylor series about a base point x = a.
• The default function, value of N, basepoint, and interval of
computation for taylortool are f = x*cos(x),N = 7, a = 0, and
[-2*pi,2*pi], respectively.
• taylortool('f') initiates the GUI for the given expression f
36
Taylor Series Calculator
37
Exercise#06
1. Represent following functions in Taylor series of fourth
order using taylortool.
f e
sin( x )
2. Represent following functions in Taylor series of 10th
order using taylortool.
f  ln(1  x)
38
Ordinary Differential Equations(ODEs)
39
Ordinary Differential Equations
In MATLAB we use D to denotes differential in an ordinary
differential equation. For example
y'3 y  2
can be entered in MATLAB as
40
Ordinary Differential Equations
The symbols D2, D3, ... DN, correspond to the second, third, ..., Nth
derivative, respectively. The Differential equation
y' ' '  2 y  5
can be entered in MATLAB as
41
Ordinary Differential Equations
Consider following ODE
y' '  cos(2 x)  y
can be entered in MATLAB as
42
Solution of Ordinary Differential Equation
• The function dsolve computes symbolic solutions to ordinary differential
equations.
• The dependent variables are those preceded by D and the default
independent variable is t.
Consider this equation
y'3 y  2
dy
 3y  2
dt
43
Solution of Ordinary Differential Equation
• To change the default variable
y'3 y  2
dy
 3y  2
dx
44
Solution of ODE (with initial conditions)
• To specify an initial condition, use the second input argument as
y'3 y  2,
y(0)  3
45
Solution of non-linear ODE (with initial conditions)
• Nonlinear equations may have multiple solutions, even when initial
conditions are given:
( y' )  x  1,
2
2
x(0)  0
46
Solution of Higher Order ODE (with initial conditions)
• Here is a second order differential equation with two initial conditions.
The commands
2
d y
dy
 cos(2 x)  ,
2
dx
dx
y (0)  0,
y ' (0)  0
47
Solution of Higher Order ODE (with initial conditions)
• Here is a third order differential equation with three initial conditions.
3
d u
 u,
3
dx
u (0)  1, u ' (0)  1, u ' ' (0)  
48
Exercise#7
Solve following differential equations
dy
 4 y  e t
dt
d2y
2 x

4
y

e
dx2
d2y
 xy, y(0)  0, y' (0)  1
2
dx
49
Exercise#7 (contd….)
Solve following differential equations
dy
 4 y  yz ,
dz
y (3)  1
d2y
2 x
 4 y  e , y(0)  1, y(2)  0, y' (1)  8
2
dx
d3y
 xy, y(0)  1, y' (1)  1, y' ' (4)  1
3
dx
50
Solution of Several ODE
• The function dsolve can also handle several ordinary differential
equations in several variables, with or without initial conditions.
• For example, here is a pair of linear, first-order equations.
df
 3 f  4g
dt
dg
 4 f  3g
dt
51
Solution of Several ODE (with initial Conditions)
• If you prefer to recover f and g with initial conditions, type
df
 3 f  4g
dt
dg
 4 f  3 g
dt
f ( 0)  1
g ( 0)  2
52
Exercise#8
Solve following pairs of differential equations
dy
 4 y  yz
dt
dz
 4 zy
dt
dy
 xy,
dt
dx
 4 x  y,
dt
y ( 0)  1
x ( 0)  0
53
Thank you for your Attention
54