Algosim documentation: Visualization

Visualization

Algosim contains quite a few visualization functions that are used to draw plots and diagrams, such as

Please see Visualization functions for detailed descriptions of all these functions.

This article, however, tries to give a conceptual overview of the facilities used to plot mathematical curves of various kinds from a mathematical point of view, not a technical point of view.

Drawing a curve expressed as an equation in Cartesian coordinates

Given an equation f(x, y) = 0 in the Cartesian coordinates x and y, the set { (x, y) ∈ ℝ² : f(x, y) = 0 } can be drawn directly assuming the equation can be rewritten so that one of the variables is isolated on one side of the equation.

plot(y = sin(x))

Image 1

plot(x = y^2 + 10⋅sin(y))

Image 2

It’s also possible to plot regions defined similarly:

plot(cos(x) <  y < 2⋅cos(x), −π, π)

Image 3

Drawing a graph

Given a function f: D_f → ℝ, its graph is the set { (x, y) ∈ ℝ² : x ∈ D_f ∧ y = f(x) }.

Although the above method clearly can be used to draw graphs, it is also possible to use the graph function:

plot(graph(arctan, −10, 10))

Image 4

Drawing a parameterised curve

Given a function F: D_F → ℝ² where D_F ⊂ ℝ, the image of an interval [a, b] ⊂ D_F under F is a curve and can be plotted directly:

F ≔ t ↦ t⋅❨cos(t), sin(t)❩;
plot([0, 6⋅π] @ F)

Image 5

f ≔ t ↦ (e^sin(t) − 2⋅cos(4⋅t) + sin((2⋅t − π)/24)^5) ⋅ ❨cos(t), sin(t)❩;
plot([0, 100, 0.01] @ f)

Image 6

See also