# Math Help - How to extract mathematica output

1. ## How to extract mathematica output

Hello

The output to my mathematica cell is just a long algebraic equation produced from Solve[].

$
\left\{\left\{u_{i,1+j}\to \frac{1}{2 h^2}\left(-2 h^2 k f_{i,j}+2 h^2 u_{i,j}+2 b h^2 k u_{i,j}-h k u_{-1+i,j} \mu _{i,j}+h k u_{1+i,j} \mu _{i,j}+2 k u_{-1+i,j} \sigma _{i,j}-4 k u_{i,j} \sigma _{i,j}+2 k u_{1+i,j} \sigma _{i,j}\right)\right\}\right\}$

I want to collect the terms on the right. i.e I want to do something like

$\text{Collect}\left[\%,\left\{u_{i,j-1},u_{i,j},u_{i,j+1}\right\}\right]$

But the % symbol doesn't exactly reference the output I need. Does anyone know how to access the right hand side of the assignment above?

2. The % symbol is still needed. You'll find that the code %[[1]][[1]] will access the expression

$u_{i,1+j}\to \frac{1}{2 h^2}\left(-2 h^2 k f_{i,j}+2 h^2 u_{i,j}+2 b h^2 k u_{i,j}-h k u_{-1+i,j} \mu _{i,j}+h k u_{1+i,j} \mu _{i,j}+2 k u_{-1+i,j} \sigma _{i,j}-4 k u_{i,j} \sigma _{i,j}+2 k u_{1+i,j} \sigma _{i,j}\right)$

with no curly braces. Incidentally, in Mathematica, the arrow symbol is not assignment. If you type in the symbol
$u_{i,1+j}$, you're just going to get the symbol right back at you (i.e., Mathematica doesn't know what it is.) Try this command:

$u_{i,1+j}/.\%[[1]][[1]]$

right after the Solve command. The /. symbol is a replace command. For example: if I type in

Code:
Solve[x^2-1==0,x]
, the result will be

Code:
{{x->-1},{x->1}}
If immediately after that I go with

Code:
x/.%[[1]][[1]]
the result is

Code:
-1
Make sense?