> restart ;

MAO_TP 00

>

Commandes élémentaires

affectation

> x := 1 ;

x := 1

évaluation

> x; 'x';

1

x

égalité

> y = 1; rel := y = 1 ;

> lhs(rel);

y = 1

rel := y = 1

y

x redevient une variable libre

> x:= 'x';

x := 'x'

puissance

> x ^ n;

x^n

>

Equations

Equation

> eq:= x^2-3*x+2;
solve(eq);

eq := x^2-3*x+2

2, 1

Autre syntaxe

> eq; solve( {%} ); map(Subs,[%], eq);
subs(Subs=subs, %): %;

x^2-3*x+2

{x = 2}, {x = 1}

[Subs({x = 2},x^2-3*x+2), Subs({x = 1},x^2-3*x+2)]

[0, 0]

>

>

Fonctions et dérivation

Définir une fonction

> eq;
f:= unapply(eq,x);
g:= x -> eq;

x^2-3*x+2

f := proc (x) options operator, arrow; x^2-3*x+2 en...

g := proc (x) options operator, arrow; eq end proc

> subs(x=4, eq); f(4); g(4);

6

6

x^2-3*x+2

fonction dérivée

> D(f);
D(f)(3);

proc (x) options operator, arrow; 2*x-3 end proc

3

nombre dérivé

> f(x); diff(f(x), x); subs(x=0, %);

x^2-3*x+2

2*x-3

-3

nombre dérivé, fonction inconnue

> h(x); diff(h(x), x); subs(x=0, %); %;

h(x)

diff(h(x),x)

diff(h(0),0)

Error, wrong number (or type) of parameters in function diff

Equation différentielle

> y:='y': eqd:= diff(y(t),t,t)*t^2+diff(y(t),t)*t+y(t);
dsolve(%);

eqd := diff(y(t),`$`(t,2))*t^2+diff(y(t),t)*t+y(t)

y(t) = _C1*sin(ln(t))+_C2*cos(ln(t))

Problème de Cauchy

> ini:= y(1)=1, D(y)(1)=7;
dsolve({eqd, ini});

ini := y(1) = 1, D(y)(1) = 7

y(t) = 7*sin(ln(t))+cos(ln(t))

>

Graphiques

graphiques

> pl1:= plot(eq, x=-5..+5, linestyle=24, color=blue):

> y:= 'y': pl2:= plot([3/2, y, y=-2..40]) :

> display(pl1,pl2);

[Maple Plot]

> -2; f(%)+D(f)(%)*(x-%); pl3:= plot(%, x=-4..4, color=magenta):

-2

-2-7*x

> f(k)+D(f)(k)*(x-k);
les_tangentes:= [seq(%, k=-5..5)];

k^2-3*k+2+(2*k-3)*(x-k)

les_tangentes := [-23-13*x, -14-11*x, -7-9*x, -2-7*...
les_tangentes := [-23-13*x, -14-11*x, -7-9*x, -2-7*...

> pl3:=plot(les_tangentes, x=-5..5, color=magenta):

> display(pl1, pl3);

[Maple Plot]

>