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 and surfaces of various kinds from a mathematical point of view, not a technical point of view.

Drawing a plane 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 of a function of a single real variable

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:

curve(graph(arctan, −10, 10))

Image 4

Drawing a parameterised plane 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)❩;
curve([0, 6⋅π] @ F)

Image 5

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

Image 6

Drawing a surface expressed as an equation in Cartesian coordinates

Given an equation f(x, y, z) = 0 in the Cartesian coordinates x, y, and z, the set { (x, y, z) ∈ ℝ³ : f(x, y, z) = 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.

surf(z = 6⋅sin(x⋅y/4)⋅arctan(2⋅√(x^2+y^2))⋅exp(−(x^2+y^2)/32))

Image 7

Or,

AdjustVisual(ans, "show surface": false, "show parameter curves": true)

Image 8

Drawing a parameterised surface

Given a function F: D_F → ℝ³ where D_F ⊂ ℝ², the image of a rectangle [a, b]×[c, d] ⊂ D_F under F is a surface and can be plotted directly:

F ≔ (θ, φ) ↦ θ⋅❨sin(θ)⋅cos(φ), sin(θ)⋅sin(φ), cos(θ)❩;
surf([0, π] × [0, 2⋅π] @ F)

Image 9

Drawing a parameterised space curve

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

Image 10

See also