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"pl:" 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)