I’m very excited to talk about an open source mathematics system: SAGE.
SAGE aims to be an open source replacement for MATLAB/Mathematica/Maple. Whats amazing about Sage is the great functionality it gets by working nicely with already available open source math software (Maxima, Numpy etc). Its cute slogan “Building the car instead of reinventing the wheel” summarizes its software reuse philosophy. Because SAGE incorporates many different software projects, its quite complete (though it may never be as consistent or clean like a Mathematica or MATLAB). SAGE uses Python which possibly makes it the only computer algebra system that uses a mainstream computer programming language. The use of Python gives SAGE tremendous flexibility and power.
One of SAGE’s most amazing features…which is actually the main point of the blog…is that you can use it online!! This is really cool because you can do this from a browser anywhere on the Internet. In the future, if you are stuck on a computer which does not have MATLAB/Mathematica, despair not for you can use SAGE.
The SAGE online interpreter is available here. The style of SAGE is a bit like Mathematica. You enter an expression into Notebooks and type Shift+Enter to evaluate it. You can do all kinds of nifty things like collaborate with others and publish your notebook on the web.
___
Nice introductory video on SAGE. Guaranteed to get you all excited…
Another screenshot
SAGE Logo

Technologies in SAGE





MATLAB tip: Avoid loops and use
surfcommandFrequently we will get a function
f(x,y)that we will need to plot. The naive way will be to generate an array forxandyand then iterate through all combinations and then use theplot3function. Here is a sample:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Assume function f(x,y)=-(x^2-2)^2 - (x^2-exp(y))^2% Crude Methodx = -5:.1:5;y = 1:.1:4;points=[];i=1;for xp = xfor yp= yf = -(xp^2-2)^2 - (xp^2-exp(yp))^2;points(i,1) = xp;points(i,2) = yp;points(i,3) = f;i=i+1;endendfigure;hold on;grid on;xlabel('x');ylabel('y');zlabel('f');plot3(points(:,1),points(:,2),points(:,3),'.');hold off;But this code is inefficient. Looping is to be avoided in MATLAB because operations on matrices are faster. Moreover, the
plot3function does not give shading. We get the following as the output:Avoiding loops, we can implement the above code in a different way. We avoid loops and use the
surfcommand.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Assume function f(x,y)=-(x^2-2)^2 - (x^2-exp(y))^2% Better Methodx = -5:.2:5;y = 1:.2:4;x_2d = ones(length(y),length(x))*diag(x);y_2d = diag(y)*ones(length(y),length(x));func = -(x_2d.^2-2).^2 - (x_2d.^2-exp(y_2d)).^2;figure;hold on;grid on;xlabel('x');ylabel('y');zlabel('f');surf(x,y,func);hold off;We get the following output
The trick in the above code involves creating the
x_2dandy_2darray.References:
(1)
plot3(2)
surf