Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My question is very basic, When using the Differentiate functionality of Mathematica in this way:

D[0.5 x^2, x]

This results in:


I don't need the 1. but how can I tell mathematica to remove this? It works further along in my code and gives me results like:

{{1. m, 0, 0}, {0, 1. m, 0}, {0, 0, 1. Jcm}}

Any ideas?

share|improve this question
up vote 3 down vote accepted

Do you have the possibility to enter fractional values beforehand?

D[(1/2) x^2, x]

which gives

share|improve this answer

You could use Rationalize:

Rationalize[D[0.5 x^2, x]]


Rationalize[{{1. m, 0, 0}, {0, 1. m, 0}, {0, 0, 1. Jcm}}]

{{m, 0, 0}, {0, m, 0}, {0, 0, Jcm}}

share|improve this answer
expr1 = D[0.5 x^2, x]
expr2 = D[0.25 x^4, x]

(* 1. x  *)

(* 1. x^3  *)



  (*  x *)

  (*  x^3  *)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.