Kapitel 1
Einfache Berechnungen
> 1/3 + 1/7;
> evalf( 1/3 + 1/7);
> evalf(Pi, 50);
> abs(2+3*I);
> (3+2*I)/(2-I);
Polynome
> factor(x^4+2*x^3-12*x^2-40*x-32);
> expand((x-1)^4);
> simplify( exp(x*log(y)) );
> simplify(sin(x)^2+cos(x)^2);
> expand( cos(4*x)+4*cos(2*x)+3, trig);
> combine(4*cos(x)^3, trig);
Lösung von Gleichungen
> solve( x^2-x=5, x);
> glsys:={ 2*x + 3*y + z = 1,
> x - y - z = 4,
> 3*x + 7*z = 5}:
> solve( glsys );
> solve( {x^2+y^2=10, x^y=2}, {x,y} );
> evalf(%);
> fsolve( {x^2+y^2=10, x^y=2}, {x,y} );
> display({implicitplot(x^2+y^2=10,x=-4..4,y=-4..4,color=black),implicitplot(x^y=2,x=0.01..4,y=-4..4,color=black)},scaling=constrained);
> fsolve( {x^2+y^2=10, x^y=2}, {x=0..1,y=-4..0} );
Lineare Algebra
> A:=<<1,3>|<2,4>>;B:=<<w|x>,<y|z>>;
> A+B,A.B;
> A^(-1),B^(-1);
> glmat:=<<2|3|1>,<1|-1|1>,<3|0|7>>;
>
> glmat.<x,y,z> = <1,4,5>;
> <x,y,z> = glmat^(-1).<1,4,5>;
>
Limites, Summen und Produkte
> Limit( (sqrt(1+x)-1)/x, x=0)=limit( (sqrt(1+x)-1)/x, x=0);
> Limit(x!/x^x, x=infinity)=limit(x!/x^x, x=infinity);
> Sum(1/i^2,i=1..infinity)=sum(1/i^2,i=1..infinity);
> Product( 1+1/x^2, x=1..infinity )=product( 1+1/x^2, x=1..infinity );
Differentiation, Integration
> diff((x-1) / (x^2+1), x);
> simplify(%);
> diff( sin(x*y), x);
> int( 1/(1+x^3), x);
> int( sin(x^2), x=a..b);
Differentialgleichungen
> dgl := diff(y(x),x) * y(x) * (1+x^2) = x;
> dsolve( {dgl, y(0)=0 }, y(x));
> dgl := (y(x)^2 -x) * D(y)(x) + x^2-y(x) =0;
> dsolve( dgl, y(x),implicit);
Potenzreihen
> series( sin(x), x=0, 10);
> Order:=10:
> dgl := diff(y(x), x$2) + diff(y(x),x) + y(x) = x + sin(x);
> lsg := dsolve( {dgl, y(0)=0, D(y)(0)=0}, y(x), series);
Laplace- und Fourier Transformationen
> with(inttrans);
Warning, the name hilbert has been redefined
Laplace
> laplace( cos(t-a), t, s);
> invlaplace(%,s,t);
> combine(%, trig);
Fourier
> alias(sigma=Heaviside):
> f:=sigma(t+1) - sigma(t-1);
> plot(f,t=-2..2);
> g:=fourier(f,t,w);
> simplify(g);
> plot(g, w=-10..10);
> invfourier(g,w,t); simplify(%);
Vereinfachungen (simplify)
> limit(g, w=0);
> g1:=subs(Dirac(w)=0, g);
> simplify(g1);
> plot(g1, w=-10..10);
> invfourier(g1,w,t); simplify(%);
Interpolation, Approximation
Interpolation
> datax:=[seq(i,i=1..10)]:
> datay:=[seq(rand(10)(), i=1..10)]:
> dataxy:=zip( (x,y)->[x,y], datax, datay);
> f:=interp(datax, datay, y);
Approximation
> with(numapprox);
> x0:=solve(x^2=Pi/2)[1];
> f:=pade(tan(x^2), x=x0, [3,3]):
> evalf(normal(f));
> p1:=plot( tan(x^2), x=x0-.1..x0+.1, -10..10,style=point, color=black):
> p2:=plot(f, x=x0-.1..x0+.1, -10..10, color=red):
>
with(plots):
display(p1,p2);
Funktionen und Terme
> f:=x->(x+a)^2/sin(x);
> f(b);f(a);f(sin(Pi/2));f(f(3));
>
>
Graphik
> plot(sin(x)*exp(1)^(-x/5), x=0..4*Pi);
> plot3d(sin(x)*exp(1)^y, x=0..2*Pi, y=0..Pi, axes=boxed);
Programmierung
>
f:=proc(x::nonnegint)
option remember;
if x=0 then 0
elif x=1 then 1
else f(x-1)+f(x-2) fi
end:
> f(50);