sourcelibs/Plot/demos/functions.xtl

1⍝│ A mathematical function plotted over a range, not a sequence: the 2⍝│ horizontal axis reads x's own values. A sine wave, a parabola, and 3⍝│ both together, titled and named. 4⍝│ Run with "just demo Plot functions". 5 6"p:" u̲se< "Plot" 7 8xs ← 100 ᵖl̲inspace (0.0 − 6.28, 6.28) ⍝ -2pi to 2pi 9wave ← ᵖf̲unction! (2 100 r̲eshape xs c̲at 's̲in e̲ach xs) 10 11ys ← 100 ᵖl̲inspace (-3.0, 3.0) 12curve ← ᵖf̲unction! (2 100 r̲eshape ys c̲at ys × ys) 13 14both ← ("sine" "parabola") ᵖf̲unctions! ((e̲nclose 2 100 r̲eshape xs c̲at 's̲in e̲ach xs) c̲at e̲nclose 2 100 r̲eshape ys c̲at ys × ys) 15 16titled ← ("sin(x) and x^2" "x" "y" "sin(x)" "x^2") ᵖf̲unctionChart! ((e̲nclose 2 100 r̲eshape xs c̲at 's̲in e̲ach xs) c̲at e̲nclose 2 100 r̲eshape ys c̲at ys × ys)