You are on page 1of 18

Symbolic Math Toolbox-

Symbolic Math Toolbox



MATLAB .
: y=x^2+1
??? Undefined function or variable x .
x .
x,y,a

. , ,
.
MATLAB Symbolic Math Toolbox , ,

.

Symbolic Math Toolbox



MATLAB
. MATLAB
, .
syms .
:
syms arg1 arg2 arg3 argN

Expand(f)

>> syms a x y
>> f=a*(x+y);

a*x+a*y

>> syms x
>> f=(x-1)*(x-2)*(x-3);

x^3-6*x^2+11*x-6

>> syms x y;
>> f=cos(x+y);

cos(x)*cos(y)-sin(x)*sin(y)

>> syms a b
>> f=exp(a+b);

exp(a)*exp(b)

Factor(f)

>> syms x
>> f=x^3-6*x^2+11*x-6;

(x-1)*(x-2)*(x-3)

>> syms x
>> f=x^3-6*x^2+11*x-5;

x^3-6*x^2+11*x-5

>> syms x
>> f=x^6+1;

(x^2+1)*(x^4-x^2+1)

Simplify(f)

>> syms x
>> f=(1-x^2)/(1-x);

1+x

>> syms a
>>
f=(1/a^3+6/a^2+12/a+8)^(1/3);

((2*a+1)^3/a^3)^(1/3)

>> syms x y
>> f=exp(x)*exp(y);

exp(x+y)

>> syms x
>> f=cos(x)^2+sin(x)^2;

pretty (ans)
.


solve(f,x) f .
,
solve(f) .
:
3x+4=17
solve(3*x+4=17)
ans =13/3 .

.


q1, q2, q3
, z
solve (q1, q2, q3, x,y,z)
x, y, z .
solve (q1, q2, q3) .
q1=x+y+z=0;
q2=4*x+5*y+z-3=0;
q3=-2*x+y-3=0;
[x y z]=solve(q1, q2, q3)
x = -1
y = 3/2
z = -1/2


diff .
:
syms x;
diff(cos(x))
ans = -sin(x)
,
.

.
diff(cos(x), 2)
ans= -cos x
cos x sin x
cos x .
.

f ( x)

Mathematical
Operator

df
dx
df
da

d2 f
db 2

df
f ( x h) f ( x )
lim
dx
h
x 0

Matlab Command

diff ( f )

diff ( f , a)
diff ( f , b,2)

diff ( f , x)


int , .
int (s, v, a, b)
s
v
a
b -
:
syms t;
int(t*x^3, t) . :
ans= *t^2*x^3
.
0 1 x2 :
int(x^2, 0,1)
ans= 1/3


.
MATLAB inf .
:
e-x [0,] .
int (exp (-x), 0, inf)

Mathematical
Operator

Matlab Command

f ( x)dx

int( f )

f (t )dt

int( f , t )

f ( x)dx

int( f , a, b)

a
b

f (t )dt
a

int( f , t , a, b)


limit .
: syms x a;
limit (sin(a*x)/x,x,0)
ans= a

Mathematical
Operator

Matlab Command

lim f ( x)

lim it ( f )

lim f ( x)

lim it ( f , x, a)

x a

lim f ( x)

lim it ( f , x, a, ' left ' )

lim f ( x)

lim it ( f , x, a, ' right ' )

x0

xa

x a

lim it ( f , a)


f taylor(f, x, n)
.
:
f -
x -
n
:
f= (x-1)e-2x 5
f= (x-1)*exp^(-2*x);
taylor(f, x, 5);
pretty(ans)
-1-3x-4x2+10/3x3-2x4


Dsolve
. t .
y dy .
:
y+0.2y=1 .
dsolve(Dy+1/5*y=1)
ans= 5+exp(-1/5*t)*C1
MATLAB -; C1 .
.
dsolve(Dy+1/5*y=1, y(0)=1, x)
ans= 5-4*exp(-1/5*x)


x t- .
y- D2y y D3y
.
:
dsolve(D2y+1/5*Dy+13*y=120*cos(3*t), Dy(0)=0, y(0)=0);
ans= simple(ans)
ans= -11*exp(-2*t)*sin(3*t)-3*exp(-2*t)*cos(3*t)+9*sin(3*t)+3*cos(3*t)
simple :
y= simple(ans)
y= -11*exp(-2*t)*sin(3*t)-3*exp(-2*t)*cos(3*t)+9*sin(3*t)+3*cos(3*t)
.

You might also like