f(x) := exp(-x^2)*sin(%pi*x^3);

plot2d(f, [x, -2, 2]);

plot2d(f(x), [x, -2, 2]);

wxplot2d(f(x), [x, -2, 2]);

amp_plus: exp(-x^2);

amp_minus: -exp(-x^2);

wxplot2d([f, amp_plus, amp_minus], [x, -2, 2], [color, red, blue, black]);

f(x, k) := exp(-x^2)*sin(k*%pi*x^3);

with_slider(k, makelist(i, i, 1, 40), f(x, k), [x, -2, 2]);

load(implicit_plot);

implicit_plot(x^3+y^3-5*x*y+1/5, [x, -3, 3], [y, -3, 3]);

f: (x^2+y^2)^3 + 5.12*(x^2+y^2)^2 - 5.15*(x^4-y^4) - 14.7456*y^2;

implicit_plot(f, [x, -1.2, 1.2], [y, -1.2, 1.2], [same_xy, true]);

sf: subst([x=r*cos(t), y=r*sin(t)], f);

nsf: expand(sf/r^2);

sols: solve(nsf, r);

rsol1: rhs(sols[1]);

wxplot2d([parametric, rsol1*cos(t), rsol1*sin(t), [t, 0, 2*%pi]], [same_xy, true]);

x: [-1.0,0.0,1.0,2.0,1.6,1.2,0.0,-1.6,-2.1,-2.8,-2.0,-0.9,0.0,1.0,0.0,0.0,-1.0];

y: [0.0,1.0,1.0,0.0,-1.5,-2.1,-2.8,-2.5,-2.0,-0.7,2.3,3.7,5.0,8.0,9.0,-6.0,-7.2];

wxplot2d([discrete, x, y]);

kill(all);
f(x, y) := cos(x*y);

plot3d(f, [x, -%pi, %pi], [y, -%pi, %pi]);

wxplot3d(f, [x, -%pi, %pi], [y, -%pi, %pi]);

wxplot3d(f, [x, -%pi, %pi], [y, -%pi, %pi], [azimuth, 45], [elevation, 75]);

f(x,y) := x^3 - 3*x*y^2;

wxplot3d(f, [x, -1, 1], [y, -1, 1]);

w: u + %i*v;

z: rectform(exp(w));

x: realpart(z);

y: imagpart(z);

wxplot3d([x, y, u], [u, -4, 1], [v, -3*%pi, 3*%pi]);

wxplot3d([x, y, v], [u, -4, 1], [v, -3*%pi, 3*%pi]);

kill(all);
array(a, 2, 2);

a[1, 1]: 3;

listarray(a);

M: genmatrix(a, 2, 2, 0, 0);

matrixp(M);

M[1, 2];
M[2, 2];

h[i, j] := mod(i*j, 13);

M: genmatrix(h, 13, 13, 1, 1);

M: matrix([1, 2], [3, 4]);

A: genmatrix(lambda([i, j], random(100)-50), 3, 3, 1, 1);

row(A, 2);
matrixp(%);

col(A, 3);
matrixp(%);

determinant(A);

B: genmatrix(lambda([i, j], random(100)-50), 3, 3, 1, 1);

A+B;

A*B;

A.B;

B.A;

b: genmatrix(lambda([i, j], random(100)-50), 3, 1, 1);

A*b;

A.b;

addcol(A, b);

X: matrix([x[1], x[2], x[3]]);

X: transpose(X);

A.X = b;

eqs: makelist(lhs(%)[i, 1] = rhs(%)[i, 1], i, 1, 3);

sols: solve(eqs);

sol: invert(A).b;

A.sol;

b;

A[1, 2]: A[2, 1];
A[1, 3]: A[3, 1];
A[2, 3]: A[3, 2];

A;

eigenvalues(A);

rectform(float(%));

eigenvectors(A);

load(linearalgebra);

V: eigens_by_jacobi(A);

d: zeromatrix(3, 3)$
d[1, 1]: V[1][1]$
d[2, 2]: V[1][2]$
d[3, 3]: V[1][3]$
d;

A.V[2];

V[2].d;

V[2].d.invert(V[2]);

A;

A: genmatrix(lambda([i, j], random(100)-50), 3, 3, 1, 1);

b: gramschmidt(A);

genmatrix(lambda([i, j], ev(b[i].b[j])), 3, 3, 1, 1);

ob: map(lambda([x], ev(x/sqrt(x.x))), b);

genmatrix(lambda([i, j], ev(ob[i].ob[j])), 3, 3, 1, 1);

float(%);