Another Weird Mathematica Problem

  • Context: Mathematica 
  • Thread starter Thread starter spastic
  • Start date Start date
  • Tags Tags
    Mathematica Weird
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
spastic
Messages
6
Reaction score
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,
 
Physics news on Phys.org
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}
 
Ah, thanks. That makes things heaps easier.
Cheers,