(x+y)^2; x/(x+y)+y/(x-y); a:=(x+y)^2; (x-y)^2; b:=ws; % ws - Work Space % By the way, this is a comment a-b; % Free and bound variables % ------------------------ x:=z+1$ a; x:=z-1$ a; clear x; x; a; x:=2*z$ a:=a; clear x; a; clear a,b; a; x:=x+1; % this would lead to an infinite loop % Switches % -------- % mcd - Making Common Denominator off mcd; x/(x+y)+y/(x-y); on mcd; ws; % exp - EXPansion off exp; (x+y)^2; on exp; ws; % gcd - Greatest Common Divisor (x^2-y^2)/(x-y); (x^3-y^3)/(x-y); (x^3-y^3)/(x^2-y^2); on gcd; ws; off gcd; % Small variables % --------------- a:=(x+y+z)^6; weight x=1,y=2$ % x has first order of smallness, y - second order wtlevel 4$ % keep terms up to fourth order of smallness a; clear x,y,a; % Elementary functions % -------------------- sin(-x); cos(pi/4); sin(5*pi/6); log(e^x); log(1); log(e); sqrt(0); sqrt(12*x^2*y); sqrt(x^2-2*x+1); % Differentiation % --------------- f:=e^x*log(y)/sin(x); df(f,x); % derivative in x df(f,x,2); % second derivative in x df(f,x,2,y); % second derivative in x and first one in y f:=y/x; depend y,x; % tell REDUCE that y depends on x df(f,x); nodepend y,x; % remove this dependence df(f,x); clear f; % Integration % ----------- load_package algint; % The package algint extends the integrator capabilities int(1/x+1+x+x^2,x); int(1/(x^4-1),x); df(ws,x); int(x*log(x),x); int(x*sin(x),x); int(x^2*e^x,x); u:=sqrt(x^2-a^2)$ int(u,x); int(1/u,x); clear u; % This integral cannot be calculated in elementary functions int(e^(x^2)/x,x); % Definite integration % -------------------- %load_package defint; %int(sin(x)/x,x,0,infinity); %int(sqrt(x)*e^(-x),x,0,infinity); % Numerical calculations % ---------------------- a:=123456789/987654321; % common divisor is cancelled a^4; % REDUCE works with arbitrarily long integers on rounded; % rounded or real numbers precision 30; % 30 digits precision a:=123456789/987654321; a^4; pi; e; a:=sin(pi/4); a^2; precision 12$ % Numerical integration % --------------------- load_package numeric; % This command shows how much CPU time have been used % since its previous call (or since REDUCE started) showtime; % the space between -10 and .. is essential a:=num_int(exp(-x^2),x=(0 .. 10)); 4*a^2/pi; showtime; a:=num_int(exp(-x^2-y^2),x=(0 .. 10),y=(0 .. 10)); 4*a/pi; showtime; clear a; off rounded; % Plots % ----- % single function plot(sin(x),x=(-pi..pi)); % several functions plot(sin(x),x-x^3/6,x-x^3/6+x^5/120,x=(-pi..pi), xlabel="x",ylabel="f(x)",title="sin and its Taylor series"); % points plot({{0,0},{0.1,0.1},{0.2,0},{0.3,0.2},{0.4,0}}); % parametric plot(point(e^(0.1*t)*cos(t),e^(0.1*t)*sin(t)),t=(-10 .. 10), points=500); % implicit plot(x^2+y^2-1=0,x=(-1 .. 1),y=(-1 .. 1)); % contour plot(x^2+y^6={0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1}, x=(-1 .. 1),y=(-1 .. 1)); % surface plot(sin(sqrt(x^2+y^2))/sqrt(x^2+y^2), x=(-10 .. 10),y=(-10 .. 10),hidden3d,points=40); % space curve a:=0.1$ plot(point(cos(t),sin(t),a*t),t=(-10 .. 10),points=100); clear a; % parametric surface plot(point(sin(u)*cos(v),sin(u)*sin(v),cos(u)), u=(0 .. 2*pi),v=(0 .. 2*pi),points=25); % implicit surface plot(x^2+y^2+z^2-1=0,x=(-1 .. 1),y=(-1 .. 1),z=(-1 .. 1), points=40); % Controlling output form % ----------------------- w:=(x^2*(y^2+2*y)+x*(y^2+z)/(2*a))/(y+2); % revpri - REVerse PRInt - in increasing degrees order on revpri; w; off revpri; order y,x; % order of variables - y, x, and then all the other ones w; order nil; % cancel the order command % allfac - ALL FACtors - put all simple factors out of brackets off allfac; w; on allfac; % div - DIVide all terms of the numerator % by simple factors of the denominator on div; w; off div; % factor - output expressions as powers of x with coefficients factor x; w; % rat - RATional - divide all such parts of the numerator by the % denominator, producing powers of x with rational coefficients on rat; w; on div; w; on revpri; w; off rat,div,revpri; remfac x; % cancel the factor command % nat - NATural mathematical form output: % powers are raised, fractions: numerator over denominator off nat; w; % REDUCE will be able to read such an expression write "Abcd"; % any output is terminated by $ on nat; clear w; % Case sensitivity % ---------------- x+X; % REDUCE does not distinguish small and capital letters input_case nil$ % makes REDUCE case sensitive x+X; end;