News for hackers. Stuff that matters.
Re:Calculize: A Mathematical Scripting Language by tomp on Tuesday August 09, 2011 @12:35PM (#2864636)
Coffeescript-inspired syntax is nice, but unfortunately Matlab is clearly superior for anything mathematical than most other languages, so drawing some inspiration from it wouldn't hurt...

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.

Re:Calculize: A Mathematical Scripting Language by sesqu on Tuesday August 09, 2011 @03:41PM (#2865315)
I don't think you should consider vectors a special case of matrices - that makes tensors difficult to handle. The other way around generalizes better.
Re:Calculize: A Mathematical Scripting Language by JadeNB on Wednesday August 10, 2011 @08:41AM (#2867901)
> I don't think you should consider vectors a special case of matrices - that makes tensors difficult to handle. The other way around generalizes better.

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)?

Re:Calculize: A Mathematical Scripting Language by sesqu on Wednesday August 10, 2011 @10:22AM (#2868309)
No, I certainly do mean to regard matrices as a special case of vectors. While it's true that one rarely needs more than 3 dimensions to their array, I see no point in setting an upper limit.
Re:Calculize: A Mathematical Scripting Language by tomp on Thursday August 11, 2011 @04:27AM (#2871986)
Probably this is just a lapsus lingue, but what you are saying makes no sense.

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.
Re:Calculize: A Mathematical Scripting Language by sesqu on Thursday August 11, 2011 @07:17PM (#2875259)
Right. And how would you characterize the 4-dimensional extension, in terms of the first three?

Or do you simply draw the line at two dimensions, figuring that's as much as anyone will ever need?

Re:Calculize: A Mathematical Scripting Language by JadeNB on Tuesday August 23, 2011 @04:29PM (#2918244)
What are the two dimensions of which you speak here? The 'row' and 'column' dimensions of a matrix? If so, that's exactly what tensors do: A matrix is a 2-tensor (better, a (1, 1)-tensor, but let's not get into that). If you want an m-dimensional generalisation, just use an m-tensor.
Re:Calculize: A Mathematical Scripting Language by GregBuchholz on Tuesday August 09, 2011 @11:43AM (#2864416)
Others might find the Sage Notebook interesting:

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.

Re:Calculize: A Mathematical Scripting Language by autotelicum on Tuesday August 09, 2011 @12:52PM (#2864701)
I like the concept - really nice. It would be cool to see an update of Calculize use a math library instead of JavaScript numbers.

    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]

Re:Calculize: A Mathematical Scripting Language by knowtheory on Tuesday August 09, 2011 @11:33AM (#2864375)
This is pretty awesome!

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!)

Re:Calculize: A Mathematical Scripting Language by j4mie on Tuesday August 09, 2011 @11:47AM (#2864428)
Impressive. They seem to have added operator overloading to CoffeeScript, among other things:

    # 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.
Re:Calculize: A Mathematical Scripting Language by jashkenas on Tuesday August 09, 2011 @11:53AM (#2864459)
One major problem with any JS-based language for number crunching is JS' lack of any numeric types other than a double.

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.

Re:Calculize: A Mathematical Scripting Language by mbrubeck on Tuesday August 09, 2011 @12:54PM (#2864715)
Current versions of Firefox and Chrome have typed arrays, which add more numeric types for performance optimization. Hopefully we will see them in other browsers soon: https://developer.mozilla.org/en/javascript_typed_arrays
Re:Calculize: A Mathematical Scripting Language by Someone on Tuesday August 09, 2011 @06:48PM (#2865848)
It would need lots and lots and lots of work before I would call it a fantastic teaching tool. For example, it is spectacularly naive at plotting functions. Even a relatively simple function such as 1/sin(x) already brings it to its knees.
Re:Calculize: A Mathematical Scripting Language by Vivtek on Tuesday August 09, 2011 @11:52AM (#2864456)
You could use it as a prototyping tool, then run JS on a server for "serious" crunching, maybe.
Re:Calculize: A Mathematical Scripting Language by jashkenas on Tuesday August 09, 2011 @10:09AM (#2864063)
Re:Calculize: A Mathematical Scripting Language by abdulhaq on Tuesday August 09, 2011 @04:07PM (#2865395)
I really like the look of this. I developed http://kayali.sf.net (Maxima/Qt based) and achieving such a clean look is very difficult. Having a web based app makes a lot of sense these days especially for students.
Re:Calculize: A Mathematical Scripting Language by benhamner on Tuesday August 09, 2011 @12:48PM (#2864691)
Nice. A good next step would be to add an interactive window, like the main window in Matlab.
Re:Calculize: A Mathematical Scripting Language by tychonoff on Tuesday August 09, 2011 @11:26AM (#2864351)
Nice.