You are on page 1of 6

1 3

a := -2 3

1 0

> restart:
> with(LinearAlgebra);with(linalg);
[ &x, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm,
BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension,
ColumnOperation, ColumnSpace, CompanionMatrix, ConditionNumber, ConstantMatrix,
ConstantVector, Copy, CreatePermutation, CrossProduct, DeleteColumn, DeleteRow,
Determinant, Diagonal, DiagonalMatrix, Dimension, Dimensions, DotProduct,
EigenConditionNumbers, Eigenvalues, Eigenvectors, Equal, ForwardSubstitute,

b := 1

-8

4
3 3

3 2

3 4

c := 0

0
1
0

FrobeniusForm, GaussianElimination, GenerateEquations, GenerateMatrix, Generic,

> evalf(Eigenvalues(a,b));

GetResultDataType, GetResultShape, GivensRotationMatrix, GramSchmidt, HankelMatrix,

0.2914378157

0.66678109222.217375143 I

0.66678109222.217375143 I
> evalf(Eigenvalues(a));
>

HermiteForm, HermitianTranspose, HessenbergForm, HilbertMatrix, HouseholderMatrix,


IdentityMatrix, IntersectionBasis, IsDefinite, IsOrthogonal, IsSimilar, IsUnitary,
JordanBlockMatrix, JordanForm, KroneckerProduct, LA_Main, LUDecomposition,
LeastSquares, LinearSolve, Map, Map2, MatrixAdd, MatrixExponential, MatrixFunction,
MatrixInverse, MatrixMatrixMultiply, MatrixNorm, MatrixPower, MatrixScalarMultiply,
MatrixVectorMultiply, MinimalPolynomial, Minor, Modular, Multiply, NoUserValue, Norm,
Normalize, NullSpace, OuterProductMatrix, Permanent, Pivot, PopovForm,
QRDecomposition, RandomMatrix, RandomVector, Rank, RationalCanonicalForm,
ReducedRowEchelonForm, Row, RowDimension, RowOperation, RowSpace, ScalarMatrix,
ScalarMultiply, ScalarVector, SchurForm, SingularValues, SmithForm,

4.375478138

1.8122609323.722458079 I

1.8122609323.722458079 I
Soluo de sistemas de equaes no lineares;
> eq[1]:=x*sin(y)-3*x-2=0;
eq1 := x sin( y )3 x20
> eq[2]:=x^2+sin(y)-y=0;
eq2 := x2sin( y )y0

StronglyConnectedBlocks, SubMatrix, SubVector, SumBasis, SylvesterMatrix, ToeplitzMatrix,


Trace, Transpose, TridiagonalForm, UnitVector, VandermondeMatrix, VectorAdd,

> fsolve({eq[1],eq[2]});

VectorAngle, VectorMatrixMultiply, VectorNorm, VectorScalarMultiply, ZeroMatrix,

{ x-0.9743529051, y1.896719219 }
NewtonRaphson em sistemas de equaes no lineares;
> J:=jacobian([lhs(eq[1]),lhs(eq[2])],[x,y]);
>

ZeroVector, Zip ]
[ BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol,
addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat,
charpoly, cholesky, col, coldim, colspace, colspan, companion, concat, cond, copyinto,
crossprod, curl, definite, delcols, delrows, det, diag, diverge, dotprod, eigenvals, eigenvalues,

sin( y )3
J :=
2x
> X[0]:=Vector([-1,1.5]);

-1
X0 :=
1.5

eigenvectors, eigenvects, entermatrix, equal, exponential, extend, ffgausselim, fibonacci,


forwardsub, frobenius, gausselim, gaussjord, geneqns, genmatrix, grad, hadamard, hermite,
hessian, hilbert, htranspose, ihermite, indexfunc, innerprod, intbasis, inverse, ismith, issimilar,

> X[0];

iszero, jacobian, jordan, kernel, laplacian, leastsqrs, linsolve, matadd, matrix, minor, minpoly,
mulcol, mulrow, multiply, norm, normalize, nullspace, orthog, permanent, pivot, potential,
randmatrix, randvector, rank, ratform, row, rowdim, rowspace, rowspan, rref, scalarmul,
singularvals, smith, stackmatrix, submatrix, subvector, sumbasis, swapcol, swaprow, sylvester,
toeplitz, trace, transpose, vandermonde, vecpotent, vectdim, vector, wronskian ]
Problema de Autovalor Genrealizado;
>
> a:=Matrix([[1,3,-8],[-2,3,5],[1,0,4]]);
b:=Matrix([[9,3,3],[1,3,2],[1,3,4]]); c:= IdentityMatrix(3);

x cos( y )

cos( y )1

>
>
>
>
>
>
>
>

-1

1.5
R[0]:=Vector(2): Ji:=Matrix(2,2):
for i to 2 do
R[0][i]:=evalf(subs(x=X[0][1],y=X[0][2],lhs(eq[i])));
for j to 2 do
Ji[i,j]:=evalf(subs(x=X[0][1],y=X[0][2],J[i,j]));
od:
od:
R[0];

0.0025050134

0.4974949866

1 0
1
e sin( 0 ) _C2 e0 cos( 0 ) 74 _C20.05335557310 e0 cos( 0 )
15
15

> dX:=-Ji^(-1).R[0];
-0.0191136376969470723

dX :=
0.576502430715991498

0.05335557310 e0 sin( 0 ) 74

> X[1]:=X[0]+dX;
-1.01911363769694718

X1 :=
2.07650243071599138
> X[0]:=X[1]:

Equaes diferenciais ordinarias lineares


Equao de movimento amortecido de um corpo com 1 GDL.
d d

> eqd := m x( t ) 20 x( t ) k x( t )20 cos( 20 t )


dt dt

dt

d2

eqd := 150 2 x( t ) 20 x( t ) 50 x( t )20 cos( 20 t )


d
t

dt

Soluo analtica.
> k:=50; m:=150; c:=0.3;

c := 0.3

sin( 0 )

64
1437665

cos( 0 )1.0

_C21.836673847
_C21.836673847
> assign(%);
Finalmente a soluo da equao diferencial.
> eq_aux;
1.836673847 e

15

74 t

0.8003335965 e 15 cos 74 t
sin
15
15

2398
16
cos( 20 t )
sin( 20 t )
7188325
7188325
Em qualquer instante de tempo pode-se determinar a posio e a velocidade do sistema.
> evalf(subs(t=0.5,eq_aux)); evalf(subs(t=0.5,diff(eq_aux,t)));

1.245205591

k := 50
m := 150

9592

1437665
> isolate(%,_C2); evalf(%);

0.7649618551
Soluo numrica.
> dsys := {eqd, x(0)= 0.8,D(x)(0)=0.0};

> eqd;

dsys :=

d2

150 2 x( t ) 20 x( t ) 50 x( t )20 cos( 20 t )

d
t
dt

> resultado:=dsolve(eqd,x(t));

d2

{ 150 2 x( t ) 20 x( t ) 50 x( t )20 cos( 20 t ), x( 0 )0.8, D( x )( 0 )0. }


dt

dt
Soluo pelo mtodo de Runge-Kutta.
> dsol := dsolve(dsys, numeric, method=rkf45,
output=procedurelist,range=0..30):
> dsol(0.5);

resultado := x( t )e

15

74 t

_C2e 15 cos 74 t _C1


sin
15
15

2398
16
cos( 20 t )
sin( 20 t )
7188325
7188325
Determinao de C1 e C2. Para x(0) = 0.8 e D(x)(0) = 1.0
> eq_aux:=rhs(resultado);

eq_aux := e

15

74 t

_C2e 15 cos 74 t _C1 2398 cos( 20 t )


sin
7188325
15
15

16
sin( 20 t )
7188325
> evalf(subs(t=0, eq_aux)=0.8);

0.00033359649151. _C10.8
> isolate(%,_C1);
_C10.8003335965
> assign(%);
> subs(t=0, diff(eq_aux,t))=1.0;

t0.5, x( t )0.768197563745935952, x( t )-0.130962361867184379


dt

> with(plots):
> odeplot(dsol,[t,x(t)]);

> odeplot(dsol,[t,D(x)(t)]);

Plano de fase
> odeplot(dsol,[x(t),D(x)(t)]);

d
t2.5, x( t )0.170201756173711305, x( t )-0.391783712259251127

dt

d
t3.0, x( t )-0.0221309348718498125, x( t )-0.378671062576175720

dt
d

t3.5, x( t )-0.201387204502363665, x( t )-0.328638149145211168


dt

t4.0, x( t )-0.352239987217594197, x( t )-0.273734610869820816


dt

d
t4.5, x( t )-0.465273035475648744, x( t )-0.177343468464130876

dt
d

t5.0, x( t )-0.534304572525855282, x( t )-0.0935471311991692700


dt

d
t5.5, x( t )-0.555098037248683008, x( t )0.00375143682108820300

dt
d

t6.0, x( t )-0.531269002740448637, x( t )0.0958902932846419088


dt

t6.5, x( t )-0.465510744305213998, x( t )0.160615788899196699


dt

t7.0, x( t )-0.367133657795731538, x( t )0.230041566270258707


dt

d
t7.5, x( t )-0.245957893365722020, x( t )0.253898456133835881

dt
d

t8.0, x( t )-0.112081117217420117, x( t )0.272207638418829445


dt

> for i from 0 by 0.5 to 30 do


dsol(i);
od;
d

t0., x( t )0.80000000000000, x( t )0.


dt

t0.5, x( t )0.768197563745935952, x( t )-0.130962361867184379


dt

d
t1.0, x( t )0.675982512402666824, x( t )-0.230038011523358205

dt
d

t1.5, x( t )0.536052906814768804, x( t )-0.325659869901727962


dt

t2.0, x( t )0.362430624143847357, x( t )-0.366168679348157444


dt

d
t8.5, x( t )0.0209981009622273764, x( t )0.262832740153134403

dt

d
t9.0, x( t )0.144895410738542646, x( t )0.224607865387992462

dt
d

t9.5, x( t )0.248523161441303514, x( t )0.189697050143371320


dt

t10.0, x( t )0.325628959586297674, x( t )0.118663392834282552


dt

t10.5, x( t )0.372275182702799301, x( t )0.0627933432392509816


dt

d
t11.0, x( t )0.385074491532969244, x( t )-0.00501406632308102392

dt

d
t11.5, x( t )0.367374376110609302, x( t )-0.0704866677429301232

dt

d
t12.0, x( t )0.320502235527798940, x( t )-0.111485886120185715

dt

d
t21.5, x( t )0.180697789562740185, x( t )0.0285171037753668700

dt

d
t12.5, x( t )0.251354109408570725, x( t )-0.162989617868577241

dt
d

t13.0, x( t )0.166841223339599220, x( t )-0.175687448706170202


dt

t13.5, x( t )0.0735610186714619198, x( t )-0.189077457749280446


dt

d
t22.0, x( t )0.185148975884325384, x( t )-0.00419476011922327152

dt
d

t22.5, x( t )0.175629527115381712, x( t )-0.0389327983676268710


dt

t23.0, x( t )0.151829281254517723, x( t )-0.0521683596811490444


dt

d
t14.0, x( t )-0.0184464532665153981, x( t )-0.182763487493766169

dt

d
t23.5, x( t )0.117669615661472674, x( t )-0.0829969072115040452

dt

t14.5, x( t )-0.104105566634169463, x( t )-0.152863315641104475


dt

t24.0, x( t )0.0766891134480031518, x( t )-0.0833727641257256819


dt

d
t15.0, x( t )-0.175269080662888016, x( t )-0.132066802116669102

dt

d
t24.5, x( t )0.0312858967776036834, x( t )-0.0910424596581187046

dt

t15.5, x( t )-0.227817559179463948, x( t )-0.0788220944133842806


dt

t16.0, x( t )-0.259364681706512722, x( t )-0.0422485289127331951


dt

t25.0, x( t )-0.0125360028629085876, x( t )-0.0892675536756399046


dt

t25.5, x( t )-0.0535448290933100910, x( t )-0.0692570131800291922


dt

t16.5, x( t )-0.267055775822918618, x( t )0.00493617719362985861


dt

t26.0, x( t )-0.0870737907745526563, x( t )-0.0654546704317483520


dt

d
t17.0, x( t )-0.254018729763795636, x( t )0.0521410815369881264

dt

d
t26.5, x( t )-0.111372994107368284, x( t )-0.0335218179330710742

dt

t17.5, x( t )-0.220617158636946004, x( t )0.0767356852970182414


dt

t27.0, x( t )-0.125899066372076568, x( t )-0.0193269383261234877


dt

d
t18.0, x( t )-0.172018240514709292, x( t )0.115971262373570902

dt

d
t27.5, x( t )-0.128313650047365112, x( t )0.00317888915644208528

dt

d
t18.5, x( t )-0.113129986817283437, x( t )0.121243472000395883

dt
d

t19.0, x( t )-0.0480882337691183950, x( t )0.131267490386254820


dt

d
t28.0, x( t )-0.121428066740509211, x( t )0.0294539535110590854

dt
d

t28.5, x( t )-0.104467623651263330, x( t )0.0348086044718017574


dt

t19.5, x( t )0.0154555977306555514, x( t )0.127450017068467398


dt

t20.0, x( t )0.0747044106927244740, x( t )0.103383917107843656


dt

t29.0, x( t )-0.0804480578661681684, x( t )0.0598631252715829122


dt

t29.5, x( t )-0.0519814183531071908, x( t )0.0570617355945889776


dt

d
t20.5, x( t )0.123558313312326099, x( t )0.0925502445904156646

dt

d
t30.0, x( t )-0.0202328932435542237, x( t )0.0630325305362972183

dt
Sistemas de equaes diferenciais Lienares;
O comando Dsolve, resolve tambm sistemas de equaes diferencias lineares;
> sys_ode := diff(y(t),t) = x(t), diff(x(t),t) = -x(t);

d
t21.0, x( t )0.159324516139128874, x( t )0.0518069813453820444

dt

sys_ode :=

d
d
y( t )x( t ), x( t )x( t )
dt
dt

> dsolve([sys_ode]);
{ x( t )_C4 e

( t )

, y( t )_C4 e

( t )

_C3 }

condies iniciais.
> ics := x(0)=1, y(1)=0;
ics := x( 0 )1, y( 1 )0
Solve the system of ODEs subject to the initial conditions ics.
> dsolve([sys_ode, ics]);
{ x( t )e
>
>
>
>

( t )

, y( t )e

1
}
e

( t )

You might also like