# Using Mathematica in Conjunction with LyX. Path Issues?

I am attempting make life easier, and, instead of using Mathematica at the same time that I'm using LyX (a front end for LaTeX), I was hoping that I could just use LyX and use the CAS option to do some of the simple algebraic computations that Mathematica can handle so powerfully.

Of course, this has been a headache for me, as I am not very comfortable with anything Unix related. I already know where to locate Mathematica, its absolute path name, and can put it inside the "PATH prefix" that LyX demands of me. But, even doing that, I cannot get an output on the simplest of computations.

Is anyone familiar with this, because I'm up against a wall. I have no idea what to do. I've been trying for hours.

By the way, as is evident from the picture, I am on a Mac, I don't know if that makes a significant difference.

Thanks!

Edit:

-
Would you elaborate ? Because I don't really see a question being asked here.. Also, any kind of error log is more than welcome :) –  Sektor Feb 23 at 21:51
Certainly. I'm wondering why LyX and Mathematica aren't communicating. I've pointed LyX (with what I assume is the correct path) towards Mathematica and basically said, 'OK, now do some basic calculations when I ask you to.' But, this is not the case, LyX and Mathematica don't seem to understand that I wish for them to interact. Whenever I make LyX do a calculation with Mathematica, nothing happens. LyX says that it is going to get Mathematica, it pops up saying "math-extern Mathematica", but nothing happens! Even though I've pointed LyX towards Mathematica! So that's where the issue lies. :) –  Matthew Feb 23 at 22:05
These posts might be useful, they mention a batch script to set the path (they don't actually mention when to run it though). link –  Ymareth Feb 24 at 9:08

There is a solution described here, where the relevant part is:

...define a wrapper script in your PATH, e.g., /usr/local/bin/math. In this executable script, I have only two lines:

#!/bin/sh
/Applications/Mathematica.app/Contents/MacOS/MathKernel "\$@"


I have Mathematica 9.0.1 and Lyx 2.0.7.1 on OS X 10.9.1, and after creating the above "math" script in /usr/local/bin (BTW, I had to do "chmod 755 math" as well) I tested it using the following steps in Lyx:

1. Insert / Math / Inline Formula
2. Type "Expand[(x+y)^2]" - then leave the cursor just after the "]"
3. Edit / Math / Use Computer Algebra System / Mathematica

Lyx and Mathematica then cooperate to fill in the rest of the equation to give "Expand[(x+y)^2] = x^2 + 2 x y + y^2".

-