Function expression or procedure
|plot::Conformal, plot::Curve2d, plot::Curve3d, plot::Cylindrical, plot::Function2d, plot::Function3d, plot::Implicit2d, plot::Implicit3d, plot::Iteration, plot::Ode2d, plot::Ode3d, plot::Polar, plot::Sequence, plot::Spherical, plot::Streamlines2d, plot::Sum, plot::Surface, plot::Tube, plot::VectorField2d, plot::VectorField3d, plot::XRotate, plot::ZRotate|
The attribute Function is used for graphs of functions in 2D and 3D, implicit plots, conformal plots etc. which are characterized by a single function.
The attributes XFunction etc. refer to the parametrization of the x, y or z-coordinate of parametrized curves and surfaces. In vector field plots they correspond to the components of the vector field.
When defining a graphical primitive such as a function plot, the mathematical expression defining the function is passed directly to the plot routine generating this object. E.g., one calls plot::Function2d(x*sin(x), x = -5 .. 5) to define the graph of f(x) = x sin(x). Internally, the attribute Function = x*sin(x) is associated with the graphical object.
Wherever function expressions are expected, also piecewise objects or MuPAD procedures can be used. E.g., the calls plot::Function2d(sin(x), x = 0..PI) and plot::Function2d(x -> sin(x), x = 0..PI) are equivalent and associate the attributes Function = sin(x) or Function = x -> sin(x), respectively, with the plot objects.
We define an object of type plot::Function2d representing the graph of f(x) = x sin(x):
f := plot::Function2d(x*sin(x), x = -4 .. 4): plot(f)
Internally, the expression defining the function is turned into the attribute Function = x*sin(x). It is accessible via a corresponding slot of the object:
One can change the object by reassigning a new value to this attribute:
f::Function := 1/x: plot(f):
p := plot::Implicit2d(y*sin(x) - x*cos(y), x=-5..5, y=-5..5):
Internally, the expression defining the function is turned into the attribute Function = y*sin(x) - x*cos(y). It is accessible via a corresponding slot of the object:
For parametrized curves and surfaces, the attributes XFunction, YFunction etc. correspond to the parametrization of the coordinates x, y etc:
c2 := plot::Curve2d([u*cos(u), u*sin(u)], u = 0..5*PI): c2::XFunction, c2::YFunction
c3 := plot::Curve3d([u*cos(u), u*sin(u), u^2], u = 0..5*PI): c3::XFunction, c3::YFunction, c3::ZFunction
s := plot::Surface([u*cos(v), u*sin(v), u^2*sin(2*v)], u = 0..1, v = 0..2*PI): s::XFunction, s::YFunction, s::ZFunction
delete c2, c3, s:
Wherever a function expression is expected, also a piecewise object or a procedure can be used:
f1 := piecewise([x < 0, 0], [x >= 0, x]): f2 := proc(x) begin if x < 0 then 1 else 1 - x^2/2 end_if; end_proc: F1 := plot::Function2d(f1, x = -1..PI/2): F2 := plot::Function2d(f2, x = -1..PI/2): F1::Function, F2::Function
delete f1, f2, F1, F2: