Calculus - Binghamton University

Download Report

Transcript Calculus - Binghamton University

Chapter 11
Calculus
Symbolic Expressions
Required:
> Symbolic Math Toolbox
> Use Symbolic Variables
Functions for Symbolic Processing
x = sym(‘x’) Creates the symbolic
variable with name x.
syms x y u v
Simplify(ans)
Creates the symbolic
variables x, y, u, & v.
Simplifies the
expression ans.
Symbolic Expression Example
>>syms x y
>>s=x+y;
>>r=sqrt(x^2+y^2);
Symbolic Expression Example
>>n=3;
>>syms x;
>>A=x.^((0:n)’*(0:n))
>>A=
[1, 1, 1, 1]
[1, x, x^2, x^3]
[1, x^2, x^4, x^6]
[1, x^3, x^6, x^9]
Manipulating Expressions
Use the expand command:
>>syms x y
>>expand((x+y)^2)
ans=
x^2+2*x*y+y^2
>>expand(sin(x+y))
ans=
sin(x)*cos(y)+cos(x)*sin(y)
Evaluating Expressions
Use subs(E, old, new) or
double(y):
>>syms x
>>E=x^2+6*x+7;
>>G=subs(E,x,2)
G= 23
Multiple Variables
>>syms x y z
>>E=x^2+6*y+2*z;
>>subs(E,{x,y,z},{2,2,3})
ans =
22
Using Double Command Example
>>sqroot2=sym(‘sqrt(2)’);
>>y=6*sqroot2
y=
6*2^(1/2)
>>z=double(y)
z=
8.4853
Plotting Expressions
Use ezplot command:
>>syms x
>>E=x^2-6*x+7;
>>ezplot(E,[-2 6])
Symbolic Calculus Functions
diff(E) Returns the derivative of
the expression E with respect to
the default independent variable.
diff(E,v)
To variable v.
th
diff(E,v,n) n derivative
int(E)
Returns the integral
limit(E)
Returns the limit
Laplace Transforms
laplace(exp)
Returns Laplace transform.
ilaplace(exp)
Returns inverse Laplace.