WolframLang: Force Numerical Result

By Xah Lee. Date: . Last updated: .

Symbolic Result vs Numerical Result

All computation are done symbolically by default, returning symbolic (exact) result. For example, 3/2 return just itself, not 1.5. And 6/4 return the rational number 3/2. Another example: 3/2 + 5/9 return 37/18

3/2
(* return itself *)

3/2 + 5/9
(* return 37/18 *)

If parts of expression contains approximate number, then the result is approximate.

3/2 + 5/9.
(* return 2.05556 *)

Force Numerical Result

To force numerical result, use N[expr]. When N is wrapped around expression, the entire expression is computed numerically.

N[3/2]
(* return 1.5 *)

A common way to use N is via postfix notation, That is, N[expr] is the same as expr//N

x = ((1/2)^5 + (3/2)^2)^3
(* 389017/32768 *)

x //N
(* 11.871856689453125 *)