Monday, July 18, 2011

Sage - notepad for mathematical calculations (similar to Matlab?)

I found by chance tool, which provides option to do varios and often even very complex mathematical calculation incl. resolving equations, generating well looking equations in html, beautiful graphs of functions.
http://en.wikipedia.org/wiki/Sage_(mathematics_software)
On http://www.sagemath.org/ you will find on-line demo, it is easy to start and I recommend testing there the samples shown on wikipedia.
If you happen to know Python, then you will find it very familiar.



Drawing chart of sinus functions:
var("x")
f = sin(x)
fp = f.plot(xmin=0, xmax=10)
fp.show()

Drawing chart of multiple functions
var('x')
f = sin(x) + cos(x)*x^2 + sqrt(x)
fp = f.plot(xmin=0, xmax=20, rgbcolor=(0,0,.5))
tp = sum((f.taylor(x, 0, i).plot(xmin=0, xmax=20, rgbcolor=(0,.5,0)) for i in range(0, 4)))
(tp+fp).show()

Resolving quadratic equation and generating nice html equation text:
show(solve(a*x^2 + b*x + c == 0, x)[0])
Small problems
Note, that I spent very short time experimenting with Sage - so it is likely, problems have good resolution.
What to do next with Sage?

nice looking equations - difficult to use anywhere else (not resolved)
  .. they appear on the demo web page and I thought, they are provided as an image. No, they are provided as html text - what sounded great, but I did not find a way, how to copy paste it anywhere out of the demo page - not even into e-mail written in gmail or int Word. I would appreciate any advice, how to do that. 
using python from dialect pull down - throws exceptions (resolved)
There is pull down on the top, where on the top is "sage" and lover are many other items inc. Python. Since I changed to python, I got exceptions or invalid syntax complains for all the sage samples I was trying to run. Finally I realized, that for sage I have to use sage, then the complains were gone and all worked as it should.
What to do next with Sage?
Sage seems worth to investigate in more detail. I like the concept and first impression is very good - they know, what is needed and how to provide it in simple way.
I see immediate use case in my work any time, I would draw chart for some function - I do not see any more efficient way even using Excel.
Lacking time for such researches, I will have to wait, till some real work for this tool arrives to my desk.

No comments:

Post a Comment