Funksjoner

En variabel

Vi definerer en funksjon av en variabel:

> f := x -> x^3 - 2*x + 1;

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

La oss derivere den:

> D(f);

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

Annenderivert:

> D(D(f));

proc (x) options operator,
 arrow; 6*x end proc

Vi integrerer:

> Int(f(x),x);

Int(x^3-2*x+1, x)

For å få Maple til å faktisk regne ut integralet bruker vi int med liten forbokstav:

> int(f(x),x);

1/4*x^4-x^2+x

Bestemte integraler skrives slik:

> Int(f(x),x=0..2); symbolsk
int(f(x),x=0..2);
regnes ut

Int(x^3-2*x+1, x = (0 .. 
2))

2

Vi evaluerer funksjonen i et punkt:

> f(2);

5

Flere variable

La oss nå definere en funksjon av to variable:

> f := (x,y) -> sin(x*y)/(1+x^2+y^2);

f := proc (x, y) options 
operator, arrow; sin(x*y)/(1+x^2+y^2) end proc

> f(3,2); Evaluerer i et punkt

1/14*sin(6)

Partiellderiverte av første orden:

> D[1](f); mhp. første variabel, dvs. her x

proc (x, y) options 
operator, arrow; cos(x*y)*y/(1+x^2+y^2)-2*sin(x*y)*x/(1+x^2+y^2)^2 end 
proc

> D[2](f); mhp. annen variabel, dvs. her y

proc (x, y) options 
operator, arrow; cos(x*y)*x/(1+x^2+y^2)-2*sin(x*y)*y/(1+x^2+y^2)^2 end 
proc

Partiellderiverte av annen orden:

> D[1,1](f); to ganger derivert mhp. x
D[2,2](f);
to ganger derivert mhp. y
D[1,2](f);
en gang mhp. x og en gang mhp. y

proc (x, y) options 
operator, arrow; 
-sin(x*y)*y^2/(1+x^2+y^2)-4*cos(x*y)*y*x/(1+x^2+y^2)^2+8*sin(x*y)*x^2/(1+x^2+y^2)^3-2*sin(x*y)/(1+x^2+y^2)^2
 end proc

proc (x, y) options 
operator, arrow; 
-sin(x*y)*x^2/(1+x^2+y^2)-4*cos(x*y)*y*x/(1+x^2+y^2)^2+8*sin(x*y)*y^2/(1+x^2+y^2)^3-2*sin(x*y)/(1+x^2+y^2)^2
 end proc

proc (x, y) options 
operator, arrow; 
-sin(x*y)*y*x/(1+x^2+y^2)+cos(x*y)/(1+x^2+y^2)-2*cos(x*y)*x^2/(1+x^2+y^2)^2-2*cos(x*y)*y^2/(1+x^2+y^2)^2+8*sin(x*y)*y*x/(1+x^2+y^2)^3
 end proc

Vi kan ta partiellderiverte av så høy orden vi måtte ønske:

> D[1,1,1,2,2](f);

proc (x, y) options 
operator, arrow; 
-144*cos(x*y)*y^3/(1+x^2+y^2)^4+14*cos(x*y)*y^3/(1+x^2+y^2)^2+24*sin(x*y)*x/(1+x^2+y^2)^2-72*sin(x*y)*x^3/(1+x^2+y^2)^3+384*sin(x*y)*x^3/(1+x^2+y^2)^5+72*cos(x*y)*...proc (x, y) options 
operator, arrow; 
-144*cos(x*y)*y^3/(1+x^2+y^2)^4+14*cos(x*y)*y^3/(1+x^2+y^2)^2+24*sin(x*y)*x/(1+x^2+y^2)^2-72*sin(x*y)*x^3/(1+x^2+y^2)^3+384*sin(x*y)*x^3/(1+x^2+y^2)^5+72*cos(x*y)*...proc (x, y) options 
operator, arrow; 
-144*cos(x*y)*y^3/(1+x^2+y^2)^4+14*cos(x*y)*y^3/(1+x^2+y^2)^2+24*sin(x*y)*x/(1+x^2+y^2)^2-72*sin(x*y)*x^3/(1+x^2+y^2)^3+384*sin(x*y)*x^3/(1+x^2+y^2)^5+72*cos(x*y)*...

>