Sunteți pe pagina 1din 10

F.

Palacios 2012
1
> >
> >
(1.5) (1.5)
> >
(1.4) (1.4)
> >
> >
(1.2) (1.2)
(1.3) (1.3)
(1.1) (1.1)
> >
Computacin cientfica y tcnica con Maple
Algunos ejemplos ilustrativos
F. Palacios Quionero
Dept. Matemtica Aplicada III. Universidad Politcnica de Catalua
Ver. 1.1 Abril, 2012
Este documento se ha editado usando las hojas de trabajo (worksheet) de Maple 15
Contenido
Transformada de Laplace 1.
Resonancia 2.
Resolucin de EDOs con dsolve( ) 3.
Sistema de primer orden con excitacin sinusoidal 4.
Resolucin numrica 5.
EDO de segundo orden con amortiguamiento 6.
Dgitos, programacin 7.
1 Transformada de Laplace
with inttrans
addtable, fourier, fouriercos, fouriersin, hankel, hilbert, invfourier, invhilbert, invlaplace,
invmellin, laplace, mellin, savetable
Transformada de Laplace
f dcos w t
f :=cos w t
F dlaplace f, t, s
F :=
s
s
2
Cw
2
Transformada inversa
invlaplace F, s, t
cos w t
Funcin definida por tramos
f d
2 t !1
K1 t !3
1 otherwise
f :=
2 t !1
K1 t !3
1 otherwise
Representacin grfica
plot f, t =K2..4, color =blue, thickness =3, gridlines
F. Palacios 2012
2
(1.8) (1.8)
> >
> >
(1.6) (1.6)
(1.7) (1.7)
> >
(1.10) (1.10)
> >
> >
(1.9) (1.9)
> >
> >
t
K2 K1
0
1 2 3 4
K1
1
2
F dlaplace f, t, s
F :=
2K3 e
Ks
C2 e
K3 s
s
g dinvlaplace F, s, t
g :=2K3 Heaviside K1Ct C2 Heaviside K3Ct
f1 dconvert g, piecewise
f1 :=
2 t !1
undefined t =1
K1 t !3
undefined t =3
1 3!t
plot f1, t =1..4
t
2 3 4
K1
K0.5
0
0.5
1
Resolucin de EDOs lineales usando Laplace
edo dx
..
C
0
2
x =sin w t
edo :=
d
2
dt
2
x t C
0
2
x t =sin w t
edoT dlaplace edo, t, s
edoT :=s
2
laplace x t , t, s KD x 0 Ks x 0 C
0
2
laplace x t , t, s =
w
s
2
Cw
2
alias X =laplace x t , t, s
F. Palacios 2012
3
(2.1) (2.1)
> >
(1.14) (1.14)
> >
> >
(1.15) (1.15)
(1.11) (1.11)
(1.13) (1.13)
(1.16) (1.16)
> >
(2.2) (2.2)
> >
> >
> >
(1.12) (1.12)
> >
X
edoT
s
2
XKD x 0 Ks x 0 C
0
2
X =
w
s
2
Cw
2
Condiciones iniciales en notacin matemtica usual
cis d x
.
0 =v
0
, x 0 =x
0
cis := x 0 =x
0
, D x 0 =v
0
edoT2 deval edoT, cis
edoT2 :=s
2
XKv
0
Ks x
0
C
0
2
X =
w
s
2
Cw
2
Resolvemos respecto de X
solX dsolve edoT2, X
solX :=
wCv
0
s
2
Cv
0
w
2
Cs
3
x
0
Cs x
0
w
2
s
2
Cw
2
s
2
C
0
2
Anti-transformamos
ft dinvlaplace solX, s, t
ft :=x
0
cos
0
t C
sin w t

0
2
Kw
2
C
sin
0
t wK
0
2
v
0
Cv
0
w
2

0
w
2
K
0
2
2 Resonancia
fr dlimit ft, w =
0
fr :=
1
2

2 x
0
cos
0
t
0
2
C2 sin
0
t v
0

0
Csin
0
t Kcos
0
t t
0

0
2
fr1 dcollect fr, t, cos, sin
fr1 :=K
1
2

cos
0
t t

0
Cx
0
cos
0
t C
1
2

2
0
v
0
C1 sin
0
t

0
2
Grficos interactivos
plots :-interactiveparams 'plot', (2.2), t =0 .. 25, labels = t, " " , , 0 =0 .. 30, v 0
=0 .. 10, x 0 =0 .. 10
F. Palacios 2012
4
> >
(3.3) (3.3)
> >
> >
(3.1) (3.1)
> >
(3.2) (3.2)
t
5 10 15 20 25
K0.8
K0.6
K0.4
K0.2
0
0.2
0.4
0.6
0.8
3 Resolucin de EDOs con dsolve( )
edo
d
2
dt
2
x t C
0
2
x t =sin w t
f
2 t !1
K1 t !3
1 otherwise
edo2 d
d
2
dt
2
x t C
0
2
x t =f
edo2 :=
d
2
dt
2
x t C
0
2
x t =
2 t !1
K1 t !3
1 otherwise
sol ddsolve edo2, x
.
0 =v
0
, x 0 =x
0
sol :=x t =
sin
0
t v
0

0
C
cos
0
t x
0

0
2
K2

0
2
C
2

0
2
sin
0
t v
0

0
C
cos
0
t x
0

0
2
K2

0
2
K
1

0
2
C
3 cos
0
K1Ct

0
2
sin
0
t v
0

0
C
cos
0
t x
0

0
2
K2

0
2
C
1

0
2
C
3 cos
0
K1Ct

0
2
K
2 cos
0
K3C

0
2
F. Palacios 2012
5
(4.5) (4.5)
> >
> >
(4.1) (4.1)
> >
(5.2) (5.2)
(4.4) (4.4)
> >
> >
(4.6) (4.6)
(5.1) (5.1)
> >
> >
> >
(5 3) (5 3)
(4.3) (4.3)
> >
> >
(4.2) (4.2)
4 Sistema de primer orden con excitacin sinusuoidal
edo dy
.
Ca y =sin w t
edo :=
d
dt
y t Ca y t =sin w t
sol ddsolve edo, y 0 =y0
sol :=y t =e
Ka t
y0C
w
a
2
Cw
2
C
Kcos w t wCsin w t a
a
2
Cw
2
fy drhs sol
fy :=e
Ka t
y0C
w
a
2
Cw
2
C
Kcos w t wCsin w t a
a
2
Cw
2
vp d a =5, w =360, y0 =1
vp := a =5, w =360, y0 =1
fp deval fy, vp
fp :=
25997
25925
e
K5 t
K
72
25925
cos 360 t C
1
25925
sin 360 t
fp1 devalf fp
fp1 :=1.002777242 e
K5. t
K0.002777242044 cos 360. t C0.00003857280617 sin 360. t
plot fp1, t =0..3
t
0 1 2 3
0
0.2
0.4
0.6
0.8
1
Observamos que no hay respuesta oscilante (ver frmula)
5 Resolucin Numrica
edo dy
.
C
t
1Ct
2
y =sin t
edo :=
d
dt
y t C
t y t
1Ct
2
=sin t
s ddsolve edo, y 0 =0
s :=y t =
0
t
sin _z1 1C_z1
2
d_z1
1Ct
2
dsolve( ) no obtiene solucin exacta; pasamos a resolucin numrica
sn ddsolve edo, y 0 =0 , numeric
F. Palacios 2012
6
(5.6) (5.6)
(5.4) (5.4)
(5.7) (5.7)
(5.8) (5.8)
> >
> >
> >
(5.3) (5.3)
> >
> >
(5.5) (5.5)
> >
> >
> >
> >
sn :=proc x_rkf45 ... end proc
sn 1.5
t =1.5, y t =0.728338957113725
with plots
animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d,
conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, densityplot,
display, dualaxisplot, fieldplot, fieldplot3d, gradplot, gradplot3d, implicitplot,
implicitplot3d, inequal, interactive, interactiveparams, intersectplot, listcontplot,
listcontplot3d, listdensityplot, listplot, listplot3d, loglogplot, logplot, matrixplot, multiple,
odeplot, pareto, plotcompare, pointplot, pointplot3d, polarplot, polygonplot,
polygonplot3d, polyhedra_supported, polyhedraplot, rootlocus, semilogplot, setcolors,
setoptions, setoptions3d, spacecurve, sparsematrixplot, surfdata, textplot, textplot3d,
tubeplot
odeplot sn, t =0..5
t
1 2 3 4 5
y
0
0.6
1.0
Una segunda EDO
edo2 dy
.
C
1
1Ct
2
y =sin t
edo2 :=
d
dt
y t C
y t
1Ct
2
=sin t
sn2 ddsolve edo2, y 0 =0 , numeric
sn2 :=proc x_rkf45 ... end proc
sn2 3
t =3., y t =1.49438163398571
odeplot sn2, t =0..5
t
0 1 2 3 4 5
y
0
0.6
1
1.4
6 EDO de segundo orden con amortiguamiento
edo dx
..
C2
0
x
.
C
0
2
x =sin w t
F. Palacios 2012
7
> >
> >
(6.5) (6.5)
> >
> >
(6.3) (6.3)
(6.1) (6.1)
(6.2) (6.2)
(6.4) (6.4)
edo :=
d
2
dt
2
x t C2
0

d
dt
x t C
0
2
x t =sin w t
sol ddsolve edo, x 0 =0, x
.
0 =0
sol :=x t
=
1
2

e
K C
2
K1
0
t

2
K1 w
w
2

2
Kw
2
C2
0
2

4
K3
2

0
2
C
0
2
K2
3

2
K1
0
2
C2
0
2

2
K1
0
K
1
2

e
K C
2
K1
0
t
w

2
K1
0
2
2

0
2
C2
0
2

2
K1 K
0
2
Cw
2
C

0
2
Kw
2
sin w t K2 cos w t w
0

0
4
C 4
2
K2 w
2

0
2
Cw
4
Caso subamortiguado
sol1 ddsolve edo, x 0 =0, x
.
0 =0 assuming 0! , !1,
0
O0
sol1 :=x t =K
e
K
0
t
sin K
2

0
2
C
0
2
t K
2

0
2
C
0
2
w 2
2

0
2
K
0
2
Cw
2

0
2
4 w
2

4

0
2
K6
2

0
2
w
2
C
2
w
4
Kw
4
C2
0
2
w
2
C
2

0
4
K
0
4
C
2 e
K
0
t
cos K
2

0
2
C
0
2
t
0
w
4
2

0
2
w
2
C
0
4
K2
0
2
w
2
Cw
4
C

0
2
Kw
2
sin w t K2 cos w t w
0

0
4
C 4
2
K2 w
2

0
2
Cw
4
sol2 dcollect sol1, exp, sin, cos
sol2 :=x t = K
sin K
2

0
2
C
0
2
t K
2

0
2
C
0
2
w 2
2

0
2
K
0
2
Cw
2

0
2
4 w
2

4

0
2
K6
2

0
2
w
2
C
2
w
4
Kw
4
C2
0
2
w
2
C
2

0
4
K
0
4
C
2 cos K
2

0
2
C
0
2
t
0
w
4
2

0
2
w
2
C
0
4
K2
0
2
w
2
Cw
4
e
K
0
t
C

0
2
Kw
2
sin w t

0
4
C 4
2
K2 w
2

0
2
Cw
4
K
2 cos w t w
0

0
4
C 4
2
K2 w
2

0
2
Cw
4
Podemos extraer subexpresiones seleccionando y arrastrando
K
sin
0
2
K
2

0
2
t
0
2
K
2

0
2
w 2
2

0
2
K
0
2
Cw
2

0
2
Kw
4
C
2
w
4
K6
2

0
2
w
2
C4 w
2

4

0
2
C2
0
2
w
2
K
0
4
C
2

0
4
K
sin K
2

0
2
C
0
2
t K
2

0
2
C
0
2
w 2
2

0
2
K
0
2
Cw
2

0
2
4 w
2

4

0
2
K6
2

0
2
w
2
C
2
w
4
Kw
4
C2
0
2
w
2
C
2

0
4
K
0
4
F. Palacios 2012
8
(7.1.7) (7.1.7)
> >
> >
> >
> >
> >
> >
> >
> >
(7.1.6) (7.1.6)
> >
> >
(7.1.4) (7.1.4)
(7.1.5) (7.1.5)
> >
(7.1.3) (7.1.3)
(7.1.1) (7.1.1)
(7.1.2) (7.1.2)
CodeGeneration 'Matlab' '(6.5)'
cg = - si n( sqr t ( - Zet a ^ 2 * omega( 0) ^ 2 + omega( 0) ^ 2) * t ) *
sqr t ( - Zet a ^ 2 * omega( 0) ^ 2 + omega( 0) ^ 2) / omega( 0) ^ 2 *
w * ( 0. 2e1 * Zet a ^ 2 * omega( 0) ^ 2 - omega( 0) ^ 2 + w ^ 2) /
( 0. 4e1 * w ^ 2 * Zet a ^ 4 * omega( 0) ^ 2 - 0. 6e1 * Zet a ^ 2 *
omega( 0) ^ 2 * w ^ 2 + Zet a ^ 2 * w ^ 4 - w ^ 4 + 0. 2e1 * omega
( 0) ^ 2 * w ^ 2 + Zet a ^ 2 * omega( 0) ^ 4 - omega( 0) ^ 4) ;
Podemos obtener la expresin Matlab usando el Men de Contexto
7 Dgitos, programacin
7.1 Resolucin ecuaciones
restart
Definimos las expresiones y realizamos un grfico
f dexp Kx
f :=e
Kx
g dx
2
g :=x
2
plot f, g , x =K2..2, color = red, blue
x
K2 K1 0 1 2
1
2
3
4
5
6
7
Solucin exacta con solve( )
s dsolve f =g
s :=2 LambertW K
1
2
, 2 LambertW
1
2
sf devalf s
sf :=K1.588047265C1.540223501 I, 0.7034674224
s1 dsf 2
s1 :=0.7034674224
sf
2
0.7034674224
Solucin numrica con fsolve( )
s2 dfsolve f =g
s2 :=0.7034674225
F. Palacios 2012
9
> >
> >
> >
(7.2.3) (7.2.3)
(7.2.4) (7.2.4)
(7.2.2) (7.2.2)
(7.2.1) (7.2.1)
> >
7.2 Mtodo de Newton-Raphson
Mtodo de Newton-Raphson para ecuaciones f x = 0

x
0
aproximacin inicial
x
j C1
=x
j
K
f x
j
f' x
j
Programa del mtodo y ejecucin con 3 iteraciones
f dx/e
Kx
Kx
2
;
x
0
d0.7;
df dD f ;
n d3;
for j from 0 to n K1 do
x
j C1
dx
j
K
f x
j
df x
j
end do;
f :=x/e
Kx
Kx
2
x
0
:=0.7
df :=x/Ke
Kx
K2 x
n :=3
x
1
:=0.7034721896
x
2
:=0.7034674225
x
3
:=0.7034674225
f a
e
Ka
Ka
2
df a
Ke
Ka
K2 a
f x
3
0.
F. Palacios 2012
10
> >
(7.2.5) (7.2.5)
(7.2.6) (7.2.6)
> >
El mtodo de Newton-Raphson es de orden 2,
e
j C1
zk e
j
2
,
donde e
j
=Kx
j
, y es la solucin de la ecuacin.
Esto intuitivamente significa que podemos doblar el nmero de
decimales exactos a cada iteracin.
Digits d50;
f dx/exp Kx Kx
2
;
x
0
d0.7;
df dD f ;
n d6;
for j from 0 to n K1 do
x
j C1
dx
j
K
f x
j
df x
j
end do;
Digits :=50
f :=x/e
Kx
Kx
2
x
0
:=0.7
df :=x/Ke
Kx
K2 x
n :=6
x
1
:=0.70347218961269235924710536764659532536847293171448
x
2
:=0.70346742250738434708832541148616093662142459848785
x
3
:=0.70346742249839165204985060257268964960601811365475
x
4
:=0.70346742249839165204981860185990213034292843143945
x
5
:=0.70346742249839165204981860185990213034292843103422
x
6
:=0.70346742249839165204981860185990213034292843103423
f x
6
K1. 10
-50

S-ar putea să vă placă și