mathematica

Best open-source Mathematica equivalent

What is the best open-source equivalent for Mathematica? My requirements are: (most important) Must be a real computer algebra system (CAS). Notably, I don't want Matlab clones -- I want something that can, at least, symbolically differentiate and integrate. Must be programmable. A functional-programming view of the world, like Math...

Mathematica Downvalue Lhs

Does anybody know if there is a built-in function in Mathematica for getting the lhs of downvalue rules (without any holding)? I know how to write the code to do it, but it seems basic enough for a built-in For example: a[1]=2; a[2]=3; BuiltInIDoNotKnowOf[a] returns {1,2} ...

Call a Mathematica program from the command line, with command-line args, stdin, stdout, and stderr.

If you have Mathematica code in foo.m, Mathematica can be invoked with -noprompt and with -initfile foo.m (or -run "<<foo.m") and the command line arguments are available in $CommandLine (with extra junk in there) but is there a way to just have some mathematica code like #!/usr/bin/env MathKernel x = 2+2; Print[x]; Print["There were ",...

ForEach loop in Mathematica.

I'd like something like this: ForEach[i_, {1,2,3}, Print[i] ] Or, more generally, to destructure arbitrary stuff in the list you're looping over, like: ForEach[{i_, j_}, {{1,10}, {2,20}, {3,30}}, Print[i*j] ] (Meta-question: is that a good way to call a ForEach loop, with the first argument a pattern like that?) ADDED: Some a...

Exporting a plot as an image in Mathematica on a machine without X11 (ie, without involving the frontend).

Consider the following dialog with the command-line interface to the kernel: $ math Mathematica 6.0 for Linux x86 (32-bit) In[1]:= p = Plot[x^2, {x,-1,1}] Out[1]= -Graphics- In[2]:= Export["foo.png", p] Out[2]= foo.png That works fine on a machine with $Version = 6.0 for Linux x86 (32-bit) (June 2, 2008) but fails on a machine with ...

F# Seq module implemented in C# for IEnumerable?

F# has a bunch of standard sequence operators I have come to know and love from my experience with Mathematica. F# is getting lots of my attention now, and when it is in general release, I intend to use it frequently. Right now, since F# isn't yet in general release, I can't really use it in production code. LINQ implements some of th...

Equation of a helix parametrized by arc length between two points in space

What is the equation of a helix parametrized by arc length (i.e. a function of arc length) between any two points in space? Is there any function for this ? How do i implement the same using matlab or mathematica ? ...

Abstract algebra and Programming

I am going to start learning Abstract Algebra- Groups, Rings,etc. I am interested to know any programming language, if at all which can help me learn/try the concepts I learn in theory. EDIT: I am not really looking at implementing what I learn. I am interested to know any language which already supports them. Thank You. ...

Mathematica StringReplace to replace a substring containing newlines.

I have something like the following in a string: blah blah BEGINIGNORE this stuff should get stripped out ENDIGNORE more stuff here I would like to do this (perl syntax): s/BEGINIGNORE.*ENDIGNORE//s -- namely, strip out everything between BEGINIGNORE and ENDIGNORE, inclusive. You would think the following would do that in Mathema...

Alternative form of FactorInteger? (Mathematica)

In Mathematica a = FactorInteger[44420069694] assigns {{2, 1}, {3, 1}, {7, 1}, {11, 2}, {13, 1}, {23, 2}, {31, 1}, {41, 1}} to a. Now instead of the factors with their exponents I would like each of those lists expanded. The above factorization would then become {2, 3, 7, 11, 11, 13, 23, 23, 31, 41} I wrote the following functio...

Mathematica's "Disable Dynamic" dialog kills Java

I use Mathematica with JLink for a research project, which involves a lot of computation. Mathematica is used as a graphical frontend for entering the parameters, and later plotting the results. The actual algorithms are located in Java Classes, which are called via JLink. The "link" is an instance named evalFrontend. On the press of a ...

Setting Environment Variables in Mathematica

I need to set an environment variable from a Mathematica notebook. Environment["VARIABLE"] gives the value of the variable. But is it possible to set a variable, too? ...

Evaluating Mathematica

I have a 15-day trial of Mathematica and need to evaluate it, and see if it can be used to help created algorithms for some games we are working on. Are there any good resources that will teach me some basics and let me explore the application. ...

Mathematica GraphPlot with images

Hi All I am trying to use GraphPlot function to build a Graph, where each node is an image. I wanted to display the image as my vertex. Does anybody know how to do this? I tried something like this: GraphPlot[ Map[If[# > 2.0 , 0, 1] &, imgDistT, {2}], VertexRenderingFunction -> (Inset[imgs[[#2]], #1, Center] &) ] But this does ...

Computer Vision with Mathematica

Hi all does anybody here do computer vision work on Mathematica? I would like to know what external libraries are available for doing that. The built in image processing functions are not enough. I am looking for things like SURF, stereo, camera caliberation, multi-view geometry etc.. How difficult would it be to wrap opencv for use in...

Images have a fubar color palette when generated under Xvfb instead of normal X.

When generating a png image file in Mathematica on a linux box running X, there's no problem. Doing the same on a linux machine without X but instead Xvfb the png generates fine but the colors are all screwed up. We tried changing the pixel depth from the default of 8, to no avail. Any other tweaks that might make Xvfb mimic normal X ...

Mathematica & J/Link: Memory Constraints?

I am doing a computing-intensive benchmark using Mathematica and its J/Link Java interface. The benchmark grinds to a halt if a memory footprint of about 320 MB is reached, since this seems to be the limit and the garbage collector needs more and more time and will eventually fail. The Mathematica function ReinstallJava takes the argum...

Inverse 3D (triangle) projection

Hello, I have a 3D math problem which I just can't seem to solve. I have data of 3 points. The data is a (2D) coordinate on a plane, floating somewhere in 3D space. I also know the (2D) coordinate of the projection. That results in the following array of data: [[[x1,y1], [px1,py1], [[x2,y2], [px2,py2], [[x3,y3], [px3,py3]] Where t...

What is a good pattern for writing unit tests within a Mathematica Notebook?

Can anybody recommend a pattern for unit-testing code within a Mathematica notebook? I am familiar with the unit testing infrastructure in Wolfram Workbench, but I would also like to have a good approach that can be used within simple notebooks in the regular GUI. I've been using a simple "Expect" function as demonstrated below. But t...

What typeset programming languages exist?

Mathematica's notebook front end has provided a hugely productive next-generation development environment for over 13 years, particularly suited to technical computing but also more widely applicable. What other languages have IDEs that allow code to be typeset and have inline graphics? ...