Search code examples
wolfram-mathematica

Double parentheses with three arguments, mathematica


If I assign something like this to variable Res:

Res=Solve[6-5x+x^2==0];

What will do the following line?

Res[[1,1,2]] 

or

Res[[2,1,2]]

Solution

  • Let's examine the FullForm of Res to see what Res[[1,1,2]] means:

    In[1]:= Res = Solve[6 - 5 x + x^2 == 0]
    Out[1]= {{x -> 2}, {x -> 3}}
    
    In[2]:= FullForm[Res]                                                                               
    Out[2]= List[List[Rule[x, 2]], List[Rule[x, 3]]]
    

    Hence:

    Res[[1]]     = List[Rule[x,2]]
    Res[[1,1]]   = Rule[x,2]
    Res[[1,1,2]] = 2