Results 1 to 2 of 2

Math Help - How to extract mathematica output

  1. #1
    Junior Member
    Joined
    Oct 2009
    From
    London
    Posts
    42

    How to extract mathematica output

    Hello

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

    <br />
\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?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    5
    Awards
    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?
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 0
    Last Post: September 30th 2011, 04:07 AM
  2. Replies: 5
    Last Post: August 20th 2011, 08:10 AM
  3. Mathematica: Converting output display for derivatives
    Posted in the Math Software Forum
    Replies: 2
    Last Post: August 7th 2009, 12:02 PM
  4. How to extract values from an equation
    Posted in the Algebra Forum
    Replies: 3
    Last Post: June 9th 2009, 04:49 PM
  5. Replies: 4
    Last Post: May 15th 2009, 04:37 AM

Search Tags


/mathhelpforum @mathhelpforum