Main Content

pretty

Prettyprint symbolic expressions

pretty is not recommended. Use Live Scripts instead. Live Scripts provide full math rendering while pretty uses plain-text formatting. See What Is a Live Script or Function?

Syntax

Description

pretty(X) prints X in a plain-text format that resembles typeset mathematics. For true typeset rendering, use Live Scripts instead. See What Is a Live Script or Function?

example

Examples

collapse all

Pretty print symbolic expressions.

A = sym(pascal(2))
B = eig(A)
pretty(B)
A =
[ 1, 1]
[ 1, 2]

B =
 
 3/2 - 5^(1/2)/2
 5^(1/2)/2 + 3/2
 
/ 3   sqrt(5) \
| - - ------- |
| 2      2    |
|             |
| sqrt(5)   3 |
| ------- + - |
\    2      2 /

Solve this equation, and then use pretty to represent the solutions in the format similar to typeset mathematics. For better readability, pretty uses abbreviations when representing long expressions.

syms x
s = solve(x^4 + 2*x + 1, x,'MaxDegree',3);
pretty(s)
/         -1         \
|                    |
|           2    1   |
|    #2 - ---- + -   |
|         9 #2   3   |
|                    |
|   1         #2   1 |
| ---- - #1 - -- + - |
| 9 #2         2   3 |
|                    |
|        1    #2   1 |
| #1 + ---- - -- + - |
\      9 #2    2   3 /

where

                 /   2       \
         sqrt(3) | ---- + #2 | 1i
                 \ 9 #2      /
   #1 == ------------------------
                    2

         / sqrt(11) sqrt(27)   17 \1/3
   #2 == | ----------------- - -- |
         \         27          27 /

Input Arguments

collapse all

Input, specified as a symbolic number, scalar variable, matrix variable, array, function, matrix function, or expression.

Version History

Introduced before R2006a

expand all