Skip to content

Improve printing

Compare
Choose a tag to compare
@saschatimme saschatimme released this 27 Aug 09:11
· 254 commits to master since this release

We now have by default a very nice unicode output for polynomials

julia> @polyvar a b c;

julia> (a^2+b-c)^2
a⁴ + 2a²b - 2a²c +- 2bc + c²

julia> @polyvar x[1:3] y[1:3];

julia> prod(cross(x, y))
-x₁²x₂y₂y₃² + x₁²x₃y₂²y₃ + x₁x₂²y₁y₃² - x₁x₃²y₁y₂² - x₂²x₃y₁²y₃ + x₂x₃²y₁²y₂

julia> @polyvar X[1:3, 1:2, 4:5]; # Only DynamicPolynomials currently

julia> X
3×2×2 Array{PolyVar{true},3}:
[:, :, 1] =
 X₁₋₁₋₄  X₁₋₂₋₄
 X₂₋₁₋₄  X₂₋₂₋₄
 X₃₋₁₋₄  X₃₋₂₋₄

[:, :, 2] =
 X₁₋₁₋₅  X₁₋₂₋₅
 X₂₋₁₋₅  X₂₋₂₋₅
 X₃₋₁₋₅  X₃₋₂₋₅

Also the print function now creates an output which can be copy-pasted back to a file

julia> @polyvar x[1:3]
(PolyVar{true}[x₁, x₂, x₃],)

julia> sum(x)*x[2]
x₁x₂ + x₂² + x₂x₃

julia> print(sum(x)*x[2])
x[1]*x[2] + x[2]^2 + x[2]*x[3]

If this printing doesn't fit your needs you can use the name_base_indices function to create your own custom printing of variables.