# The difference between Infix.printStrict and Infix.print

#1

What is the difference between Infix.printStrict and Infix.print?

PrintStrict:

/// Strict formatting, prints an exact representation of the expression tree

and:

Print:

/// Nicer human readable but slightly denormalized output

I learned that the difference will be in the following example:

open MathNet.Symbolics

let some = "tan(z)/sin(y)"
let expr = some |> Infix.parseOrUndefined

expr
|> Infix.printStrict
|> printfn “Infix.printStrict: %s”

expr
|> Infix.print
|> printfn “Infix.print: %s”

Print:

``````Infix.printStrict: sin(y)^(-1)*tan(z)
Infix.print: tan(z)/sin(y)
``````

But I would like to know what else operations lead to the difference in the output string.

(Christoph Rüegg) #2

The reason for this distinction is that expressions are always represented in a simplified/normalized form which does not know about subtraction and division (since they are redundant).

For example, `a - b` is actually represented as `sum(a, (-1)*b)`.

Since this is very relevant when writing algebraic algorithms on top of symbolics, `printStrict` allows to print the expression very closely to the actual data structure so you can understand what is really happening.

However, using subtraction and division is much more readable for humans, so `print` tries to revert this simplification, by transforming negative coefficients and powers back to negations, subtractions and divisions (and also prints some symbols like pi and infinity with proper Unicode characters).

#3

Thanks for the detailed answer