Student Support Forum: 'Bug in Mathematica 3 and 4?' topicStudent Support Forum > General > "Bug in Mathematica 3 and 4?"

 < Previous Comment Help | Reply To Comment | Reply To Topic
 Author Comment/Response Forum Moderator email me 09/29/00 7:17pm >Look at this:> >f[k_] := (x /. Solve[6x^2 == k(3x^2 + 3x + 1), x][[2]]) > >This is just giving f the value of the second solution to the equation. > >Now, type > >IN: f[k] >OUT: ''some formatted output for the function f'' > >Make a new function > >g[k_]:= ''copy the output of f[k] here'' > >Now compare: > >IN: f[1] //N >OUT: 1.26376 > >IN: g[1] //N >OUT: -0.263763 > >See, what is happening is that g is giving the values of the 1st solution to the Solve output, instead of the 2nd as it should be! > >I'm not looking for work-arounds for this, as I have already diagnosed the problem and the solution is obvious. I just wanted to point out that mathematica is doing something strange. > >Casey Mann > ======== Not a bug. Look a the results (both parts) of the Solve command for f[k] and f[1] : In[10]:= f[k_] := (x /. Solve[6x^2 == k(3x^2 + 3x + 1), x]) In[16]:= kfirst=f[k] Out[16]={(-3*k - Sqrt[3]*Sqrt[8*k - k^2])/(6*(-2 + k)), (-3*k + Sqrt[3]*Sqrt[8*k - k^2])/(6*(-2 + k))} In[17]:= kfirst/.k->1 Out[17]= {1/6*(3 + Sqrt[21]), 1/6*(3 - Sqrt[21])} In[18]:= f[1] Out[18]= {1/6*(3 - Sqrt[21]), 1/6*(3 + Sqrt[21])} In your code, Mathematica is delivering the second part in each case. Tom Zeller Forum Moderator URL: ,

 Subject (listing for 'Bug in Mathematica 3 and 4?') Author Date Posted Bug in Mathematica 3 and 4? Casey Mann 09/29/00 7:05pm Re: Bug in Mathematica 3 and 4? Forum Modera... 09/29/00 7:17pm
 < Previous Comment Help | Reply To Comment | Reply To Topic