90
90
# ##
91
91
92
92
"""
93
- printpoly(io::IO, p::AbstractPolynomial, mimetype = MIME"text/plain"(); descending_powers=false, offset::Int=0)
93
+ printpoly(io::IO, p::AbstractPolynomial, mimetype = MIME"text/plain"(); descending_powers=false, offset::Int=0, var=p.var, compact=false, mulsymbol="*" )
94
94
95
95
Print a human-readable representation of the polynomial `p` to `io`. The MIME
96
96
types "text/plain" (default), "text/latex", and "text/html" are supported. By
97
97
default, the terms are in order of ascending powers, matching the order in
98
98
`coeffs(p)`; specifying `descending_powers=true` reverses the order.
99
99
`offset` allows for an integer number to be added to the exponent, just for printing.
100
- `var` allows for overriding the variable used for printing. Setting multiplication symbol to ` ""`
100
+ `var` allows for overriding the variable used for printing. Setting `mulsymbol= ""`
101
101
will avoid an operator being printed. Setting `compact=true` will use a compact style for floating point numbers.
102
102
103
103
# Examples
@@ -118,6 +118,15 @@ z - z^-1
118
118
119
119
julia> printpoly(stdout, Polynomial([-1, 0, 1], :z), offset=-1, descending_powers=true, var=:x)
120
120
x - x^-1
121
+
122
+ julia> p = Polynomial([sqrt(i) for i in 1:4])
123
+ Polynomial(1.0 + 1.4142135623730951*x + 1.7320508075688772*x^2 + 2.0*x^3)
124
+
125
+ julia> printpoly(stdout, p, compact=true)
126
+ 1.0 + 1.41421*x + 1.73205*x^2 + 2.0*x^3
127
+
128
+ julia> printpoly(stdout, map(x -> round(x, digits=12), p)) # more control on rounding
129
+ 1.0 + 1.414213562373*x + 1.732050807569*x^2 + 2.0*x^3
121
130
```
122
131
"""
123
132
function printpoly (io:: IO , p:: P , mimetype= MIME " text/plain" ();
0 commit comments