Documentation Center

  • Trial Software
  • Product Updates

pretty

Prettyprint symbolic expressions

Syntax

pretty(X)

Description

pretty(X) prints symbolic output of X in a format that resembles typeset mathematics.

Examples

The following statements:

A = sym(pascal(2))
B = eig(A)
pretty(B)

return:

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:

syms a b c d x
s = solve(a*x^3 + b*x^2 + c*x + d, x);
pretty(s)

For better readability, pretty uses abbreviations when representing long expressions:

/          b         \
|    #3 - --- - #4   |
|         3 a        |
|                    |
|            b    #3 |
| #2 + #1 - --- - -- |
|           3 a    2 |
|                    |
|            b    #3 |
| #2 - #1 - --- - -- |
\           3 a    2 /

where

         sqrt(3) (#4 + #3) i
   #1 == -------------------
                  2

             2
            b      c
         - ---- + ---
              2   3 a
           9 a
   #2 == ------------
             2 #5

         /     / /          3         \2   /     2        \3 \      3               \1/3
         |     | |  d      b      b c |    |    b      c  |  |     b      d     b c |
   #3 == | sqrt| | --- + ----- - ---- |  + | - ---- + --- |  | - ----- - --- + ---- |
         |     | | 2 a       3      2 |    |      2   3 a |  |       3   2 a      2 |
         \     \ \       27 a    6 a  /    \   9 a        /  /   27 a          6 a  /

             2
            b      c
         - ---- + ---
              2   3 a
           9 a
   #4 == ------------
              #5

         /     / /          3         \2   /         2  \3 \      3               \1/3
         |     | |  d      b      b c |    |  c     b   |  |     b      d     b c |
   #5 == | sqrt| | --- + ----- - ---- |  + | --- - ---- |  | - ----- - --- + ---- |
         |     | | 2 a       3      2 |    | 3 a      2 |  |       3   2 a      2 |
         \     \ \       27 a    6 a  /    \       9 a  /  /   27 a          6 a  /
Was this topic helpful?