sourcelibs/Polynomials/demos/notation.xtl
1⍝!/usr/bin/env xetal
2⍝# Polynomials written as maths: p_oly< reads the notation when the
3⍝# program is compiled and writes the coefficients in its place.
4⍝# Run with "just demo Polynomials notation".
5
6ᵖʸ⁼u̲se< "Polynomials"
7p ← @ ᵖʸp̲oly< "3x^2 - 2x + 1"
8p
9ᵖʸt̲ext p
10p ᵖʸa̲t 0 1 2
11@ ᵖʸp̲oly< "x^3 - 1"
12@ ᵖʸp̲oly< "-x + 0.5"
13@ ᵖʸp̲oly< "2x + x + 4x^2" ⍝ like powers are added
14ᵖʸr̲oots @ ᵖʸp̲oly< "x^2 - 2"
ᵖʸp̲oly< expands to
(3.0 -2.0 1.0)
ᵖʸp̲oly< expands to
1.0 0.0 0.0 -1.0
ᵖʸp̲oly< expands to
-1.0 0.5
ᵖʸp̲oly< expands to
4.0 3.0 0.0
ᵖʸp̲oly< expands to
(1.0 0.0 -2.0)