Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Another Weird Mathematica Problem

  1. Jun 7, 2008 #1
    When you solve something and it gives answers like this:
    {σ -> 0.653831, μ -> 9.31514, γ -> 7.22386},
    how do you get it to give
    {0.653831, 9.31514, 7.22386}, i.e a set without the symbols?
    Cheers,
     
  2. jcsd
  3. Jun 8, 2008 #2
    What it has given you is a set of replacement rules. These can be executed with the operator /. "replace" as in:

    In[1]:= {σ,μ,γ}/. {σ -> 0.653831, μ -> 9.31514, γ -> 7.22386}

    Out[1]:= {0.653831, 9.31514, 7.22386}

    A typically way to use a set of replacement rules is to give it a name:

    In[2]:=

    constants = {σ -> 0.653831, μ -> 9.31514, γ -> 7.22386};
    {σ,μ,γ}/. constants

    Out[2]:=

    {0.653831, 9.31514, 7.22386}
     
  4. Jun 8, 2008 #3
    Ah, thanks. That makes things heaps easier.
    Cheers,
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Another Weird Mathematica Problem
  1. Mathematica problem (Replies: 2)

Loading...