# Converting fractional output to decimal [closed]

This code

p = -0.4884; q = -0.4641; s = 0.013; t = 0.5;
mm = {{1.0, 0.0, p, s}, {0.0, 1.0, p, q}, {-2.0, 0, -(2.0*p+s), 2.0*t+q},
{0. 0,-2.0, -(2.0*s+p) ,2.0*q+t} };
vec = LinearSolve[mm, {1.0, 0.0, 1.0, 0.0}];
vec[[1]]


gives as an output $\frac{1. \left(3.55271\times10^{-15}\text{}^2-1.73201 \text{}+0.0312286\right)}{0.274432 \text{}+0.0322426}$. I understand that Mathematica is smart and wants to keep things fractional as far as it can. But I do not want it. How can I convert this output to simple decimal expression?

-

## closed as too localized by Jens, Yves Klett, Simon Woods, Sjoerd C. de Vries, rm -rf♦Feb 6 '13 at 1:03

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Could you post Mathematica code please ? –  b.gatessucks Feb 5 '13 at 19:02
You probably entered one of the numbers as a string, perhaps by copying it from somewhere else. That prevents the conversion to a numerical result. If you convert everything to numbers there's no problem at all. –  Jens Feb 5 '13 at 19:12
There is no copy paste. Also the code is extra extra short. I can not figure out the problem. It would be great if someone checks the code with their own Mathemtica. –  ivan Feb 5 '13 at 19:19
When I copy paste your code I get output -5.54589 Concidering your LaTeX has \text{} in it like in your previous question, I wonder what's going on. Could you paste the output of vec[[1]]//FullForm and Hold[mm]//FullForm –  ssch Feb 5 '13 at 19:24
There appears to be nothing wrong with the code posted in your question. I, too, get -5.54589 when I evaluate it. –  m_goldberg Feb 5 '13 at 19:27

Just so I can paste my version of the code for comparison, here is an "answer":

p = -0.4884; q = -0.4641; s = 0.013; t = 0.5; mm = {{1.0, 0.0,
p, s}, {0.0, 1.0, p, q}, {-2.0, 0, -(2.0*p + s),
2.0*t + q}, {0.0, -2.0, -(2.0*s + p), 2.0*q + t}};

vec = LinearSolve[mm, {1.0, 0.0, 1.0, 0.0}];

vec[[1]]

(* ==> -5.54589 *)


Mathematica will convert expressions like the one you got at the end to decimals unless some FormBox or String or similar formatting construct is present in some of the objects that look like numbers in your question.

-