Calculize: A Mathematical Scripting Language
calculize.com
calculize.com
For example:
m1 = matrix([1, 2, 5],
[2, -1, 6],
[5, 10, -1])
why not adapt a simpler syntax for constructing multi-dimensional arrays: m1 = [1 2 5; # commas are optional
2, -1, 6;
5, 10, -1]
Also, a special constructor for matrices and vectors is redundant - in a mathematical language, a list/array is the special case, not a matrix/vector. Besides, vectors are just a special case of matrices, no need to treat them differently, especially since the dot product is not overloaded in Calculize.Matlab also wins by having a special syntax for matrix transpose. Now, this depends on the implementation ( AFAIK, Matlab doesn't actually transpose the matrix, it simply uses a different algorithm for further calculations), but would still be nice, since it's often useful (necessary) when trying to multiply matrices.
I guess (from the first sentence) that you mean to regard matrices as a special case of tensors (which certainly generalises well), rather than of vectors (which is possible but ugly)?
Vectors are a special case of matrices, which are a special case of tensors (finally, scalars, which is just a fancy name for plain numbers, are a special case of vectors). Although there are many mathematical representation of all these objects (geometrical, functional, etc.), they can be written as multidimensional arrays (after selecting for a base).
Thus, scalars are 1x1 matrices, and a vector of size n is actually a nx1 matrix. Although a common high-school notation of a vector is x = (1, 2, 3), a vector is actually
x = [ 1
2
3 ]
Tensors are the extension of matrices to further dimensions.Or do you simply draw the line at two dimensions, figuring that's as much as anyone will ever need?
http://nb.sagemath.org/ http://sagenb.com/
Features
•Use Sage, Python, R, Octave, and most other mathematical software with any web browser
•Notebook interface that allows you to write and run code, display 2d and 3d plots, and organize and share your work.
In Calculize:
a = 1/3
show a+a+a+a+a+a == 6*a
# => false
show pow 9,18
# => 150094635296999140
# should be: 150094635296999121
show 150094635296999122 - 150094635296999121
# => 0
In Python 2.6.1:
>>> p = 1.0/3.0
>>> p+p+p+p+p+p == 6*p
False
>>> pow(9,18)
150094635296999121
>>> 150094635296999122 - 150094635296999121
1
These minuscule rounding errors are inconsequential for most apps, but for math...Maybe the results will also vary between browsers, because EcmaScript talks of implementation-dependent approximation's.
[Edit: Oops, python got me with it's own quirk - division needs to be from the __future__ or it's integer]
Their contact page 404s unfortunately. There're some visual glitches in their guided tour that i wanted to point out.
Seems like an admirable repurposing of what Coffeescript is doing to create a mathematics toolkit.
(Last note: too bad they didn't name it Calculon!)
# 1. Matrix multiplication
m1 = matrix([1, 2, 5],
[2, -1, 6],
[5, 10, -1])
m2 = matrix([2, 3, 1],
[-3, -1, -3],
[4, 9, -2])
show m1 * m2
Not sure how this could be used for "serious" number crunching (as it runs in-browser) but I imagine it would be a fantastic teaching tool.I don't know how well the string-based workarounds really work, for arbitrary precision math ... but I'd imagine that they wouldn't be terribly fast or convenient. It's a real shame.