Appendix of functions and operations

Reading what is available

Reference for Mathematics Explorer 0.2.0 on GX-TXT Pipeline v0.9.8.10-dev-112-p012. In Graphs a named model uses the public Numeric grammar for branches, definitions and inputs that accept expressions. Algebra discovers operations from saved and compatible Functions. Study uses its own dialogs and results. Scripts use the registered calls and the context of the Job. Overview of the objects

For schema 2 formulas the tables report the names resolved and evaluated in the Numeric 1.67.0 runtime. The conditional Algebra operations are reported according to the installed descriptors and the palette filters. The cases that need a persistent Function are subject to the publishing limits given in the Function chapter. The Script calls are listed by registration, with the actual tests and the relevant dependencies.

Operators, constants and syntax

Form Meaning and condition
x and declared symbols x is the independent coordinate. Use exact identities for parameters and definitions. A branch can use the local ones. In limits and definitions the symbols available at that point apply.
pi, e Dimensionless constants. pi≈3.141592653589793 and e≈2.718281828459045. The schema 2 grammar is case-sensitive.
2, .25, 1e-3 Decimal real literals and scientific notation with a point. The exponent of the literal can use e or E.
+2, -2 Unary sign. The minus is equivalent to negate. -2^2 is −4.
2+3, 2-3 Sum and difference, between equal dimensions, before conversion to the required unit.
2*3, 6/3 Product and quotient. Dimensions are combined. Division by zero is rejected.
2^3^2, 2^-2 Right-associative power. The examples give 512 and 0.25. Exponent in 1. A dimensioned base requires a constant integer with absolute value at most 1024.
(a+b)*x Parentheses for grouping. Explicit multiplication. The comma only separates the arguments of a function.
0^0, 0^-1, (-1)^.5 The runtime returns 1, a non-finite error and a real-domain error respectively.

Function names in schema 2 are exact and lower-case. SIN, ln, pow, min and max were rejected. Use sin, log, power, minimum and maximum. Use the branches of the model for domain conditions. Comparisons, percentages, conditional expressions and implicit multiplication remain outside the Graphs syntax. The parser applies limits of 8,192 characters, 1,024 elements of the evaluation program and 64 dependency symbols. Complex results, NaN and infinities cause an error. In Graphs check the status bar when a previous plot stays visible.

Functions admitted in named formulas

Each example uses numbers in unit 1. With physical quantities choose known linear units and a compatible output unit. The runtime normalises the scales before applying the operations, then converts the output. The radians of the trigonometric functions are treated as dimensionless. To enter an angle in degrees in a formula, explicitly use sin(30*pi/180). Some representations of the canonical Function admit a subset of the Graphs grammar.

Function Minimal example → response Units, domain and boundaries
negate negate(2) → −2 Keeps the unit and coincides with the unary minus. No further constraint on a finite real.
abs abs(-2) → 2 Keeps the unit. Returns zero at zero. The plot of abs(x) has a corner at zero.
floor floor(-1.2) → −2 Integer towards −∞. Keeps the dimension. With scaled units the operation comes before the conversion to the output unit.
ceil ceil(-1.2) → −1 Integer towards +∞. Keeps the dimension, with the same scaling rule as floor.
round round(-1.5) → −2 Nearest integer, halves away from zero. Keeps the dimension, with the same scaling rule as floor.
sign sign(0) → 0 Gives −1, 0 or 1 according to the sign. Output in 1 even if the input has a unit.
sqrt sqrt(4) → 2 Non-negative real root. Input ≥0. The dimension is halved and must be representable in the output unit. sqrt(square(x)) recovers the unit of x.
square square(-3) → 9 Squares, dimension squared. A non-finite response is rejected.
reciprocal reciprocal(4) → 0.25 Inverts value and unit. Zero produces a rejection for infinity.
exp exp(0) → 1 Natural exponential, input and output in 1. An overflow is an error.
expm1 expm1(0) → 0 Computes exp(x)−1, useful near zero. Input and output in 1. Rejects overflow.
log log(e) → 1 Natural logarithm, input >0 and output in 1. Zero gives −∞, a negative value would give a complex one. Both are rejected.
log10 log10(100) → 2 Base-ten logarithm, input >0 and output in 1. Zero and negative values are rejected.
log1p log1p(0) → 0 Natural logarithm of 1+x, accurate near zero. Requires x>−1 and unit 1. The threshold −1 produces −∞ and is rejected.
sin sin(pi/2) → 1 Dimensionless argument in radians, output in 1. Special values use the numerical approximation of the radians.
cos cos(pi) → −1 Dimensionless argument in radians, output in 1.
tan tan(pi/4) → ≈1 Dimensionless argument in radians. Near the poles the value grows in absolute value. tan(pi/2) can be finite and very large with a binary π. The Study in degrees recognises the exact quarter turn.
asin asin(1) → ≈1.5707963 Inverse sine. Input in 1 and in [−1,1] inclusive. Principal branch [−π/2,π/2] in radians, unit 1. Outside the domain it is rejected.
acos acos(-1) → ≈3.1415927 Inverse cosine. Input in 1 and in [−1,1] inclusive. Principal branch [0,π] in radians, unit 1. Outside the domain it is rejected.
atan atan(1) → ≈0.7853982 Inverse tangent. Any finite dimensionless real. Principal branch (−π/2,π/2) in radians, unit 1.
sinh sinh(0) → 0 Hyperbolic sine, input and output in 1. Values with a large absolute value can cause overflow.
cosh cosh(0) → 1 Hyperbolic cosine, input and output in 1; minimum 1 at zero. Rejects overflow.
tanh tanh(0) → 0 Hyperbolic tangent, input and output in 1. For values with a large absolute value it can round to ±1.
add add(2,3) → 5 Functional alias of a+b. Addends of compatible dimension and result of the same dimension.
subtract subtract(2,3) → −1 Functional alias of a−b. The order matters. Compatible dimensions.
minimum minimum(2,3) → 2 Pointwise minimum. Two inputs of compatible dimension. In a tie it gives the common value.
maximum maximum(2,3) → 3 Pointwise maximum. Two inputs of compatible dimension. In a tie it gives the common value.
hypot hypot(3,4) → 5 Euclidean norm of two components with the same dimension. The result has that dimension. Zero if both are zero.
multiply multiply(2,3) → 6 Functional alias of a*b. The units are combined as a product.
divide divide(6,3) → 2 Functional alias of a/b. Combines the units as a quotient. A zero denominator is rejected.
power power(2,3) → 8 Functional alias of a^b. The exponent is always dimensionless. For a base with a dimension use a constant integer in the formula. The real limits of the power apply.
atan2 atan2(4,3) → ≈0.9272952 Takes (Y,X) of compatible dimension. Quadrant-consistent angle in radians, unit 1. The runtime returned 0 with two positive zeros. In the Study the polar origin has an undefined direction.

Differences by schema and context

The historical parser and parseExpression recognise eight one-argument functions, sin, cos, tan, exp, log, log10, sqrt, abs. In that grammar the names are converted to lower case, the only symbols are x, a, b, c and the only constant is pi. The parser has limits of 180 characters, 55 tokens and 32 nodes. The syntax check of the historical model comes before the Numeric evaluation, which resolves the exact names in the string executed. So use lower-case names in the historical models too. parseExpression("SIN(x)") can succeed as a syntax analysis, while SIN(0) is rejected in the Numeric evaluation.

The historical presets are Sine, a*sin(b*x)+c; Polynomial, a*x^2+b*x+c; Decay, a*exp(-b*x)+c; Gaussian, a*exp(-((x-b)/c)^2); Linear, a*x+b; Custom, a formula written by the user. Check domain, units and values separately. In the Gaussian preset, c=0 makes the division unusable.

The Trigonometry Study allows degrees, uses the principal branch and can qualify cases such as the polar origin and the exact quarter turn. The Continuous transfer Study evaluates a complex frequency response and can keep a row with gain −∞ and undefined phase. These results belong to their dialogs. The Expression field in Graphs uses the finite real contract. In Mathematical Function a provider can show a notation richer than the one editable in Graphs, including pieces, indexed functions, finite terms and formal-only formulas. Inspector and copy

Graphs operations

Path Input and result
Operations → Plot / Refresh Visible functions, domains, samples and units. Redraws the native view.
Show derivative of selected function / branch Admitted function or branch. Sampled derivative in units Y/X.
Operations → Analyze → roots Optional interval and selected function. Candidates for f(X)=0.
Operations → Analyze → intersections Second function and common domain. Candidates for f(X)=g(X).
Operations → Analyze → extrema Function or branch and interval. Extremum candidates with numerical qualification.
Operations → Integrate selected / Integrate F1 Samples of the scope. Signed trapezoidal integral, per component when provided.
Operations → Cancel calculation Calculation in progress. Requests interruption and leaves the last adopted outcome available.

Procedure and expected values

Algebra operations

In Algebra → Operand A / Operand B → Operation → Apply the capabilities of the provider, current revisions and units apply. The table concerns the descriptors exposed when both inputs are admissible. The compatibility check is point by point and the name of the provider alone does not guarantee that the operation appears. The complete branch with the canonical operands requires the prerequisites of case 214.

Operation Prerequisites and parameters Result
Add Functions A and B scalar AST, piecewise, retained polynomials of the expected provider or a declared quantity + fit combination. Compatible inputs. Response A+B on the intersection of the domains. With a quantity Function and a compatible fit, the mixed sum can be offered in both orders.
Subtract Functions Two compatible scalar_real_ast. Response A−B. Check the order and the common points.
Multiply Functions Two scalar_real_ast or two piecewise of the same compatible provider. Response A·B in the common domain. For piecewise it respects branch priority and holes.
Divide Functions Two compatible scalar_real_ast, with provable conditions for the divisor. Response A/B. The provider can refuse admission if it cannot prove the condition on the denominator.
Raise Function to Integer Power Source A and B with an exact integer exponent from −16 to 16 according to the scalar_real_ast provider. Power of the response A. Input B must represent the admitted integer; negative powers require handling of the zeros.
Compose Functions (left after right) A and B compatible scalar_real_ast. A(B(x)). Domain also constrained to the image of B. Swapping A and B changes the result.
Compose Fitter after Mathematics A is function.accepted_polynomial_v1, B is function.quantity_real_ast_v1, same unit context. Composition of the fit after B, with compatible intermediate units. The mixed variant requires this order.
Scale Function A piecewise with a scale descriptor. Enter the dimensionless scalar factor. Response multiplied by the factor, with boundaries and holes kept.
Combine Corresponding Terms A and B finite_sum with compatible families and indices. Combines the corresponding terms, keeping the admitted order and structure.
Scale Terms A finite_sum with a scale descriptor. Enter the factor. New family with scaled terms.
Reindex Terms A finite_sum. Enter admitted integer factor and offset. New index law within the declared domain. An incompatible reordering is rejected.
Rename Symbol A scalar_real_ast or finite_sum. Choose source ID, new ID and label. Renames the symbol in its declaration and in the relevant uses. Check conflicts and scope.
Substitute Coordinate A scalar_real_ast or finite_sum. B scalar_real_ast in a compatible unit context. Indicate the symbol. Replaces the coordinate with the declaration of B in the admissible domain.

In Algebra → View formula you can consult an operand or a result, copy the notation and move on to publishing with Publish result… when admitted. For a single operand that can be evaluated, Evaluate samples… → Evaluate requires the coordinates in the unit of the Function and reports the values in request order. Evaluate sampled slopes and Evaluate model tangents require the accepted polynomial provider. For secants give two or more increasing X. For tangents repeated or unordered X are also admitted. Evaluate ordinary derivative, when declared for piecewise, distinguishes admitted values from unavailable ones at the boundaries. Undo Algebra operation, Redo Algebra operation and Cancel Algebra request follow the state of the history or of the request. Results and samples

Study operations

Each row starts from Study. Cancel Job is used while a job can be cancelled. Changing a scientific input can invalidate the previous review. For the conditions and the verified examples open the linked chapter.

Dialog and commands Inputs, outcome and condition
Study a piecewise Function… · Review intervals, Find extrema, Publish Graph Piecewise Dataset with the required capability, window and inclusion of the boundaries. Intervals, extrema, infimum/supremum and samples per segment. Piecewise
Study a fitted polynomial… · Find candidates, Estimate integral, Study shape Accepted fit. roots, extrema, intersections with a distinct fit, integral, shape with optional Equal-scale Euclidean on axes in 1. Polynomials
Graph a saved physical Function… · Review and Publish Graph Scalar physical provider, domain and samples. Traces with units and holes. Possible Koren, load line and SPICE controls for the dedicated provider. Physical Functions
Study a physical surface… · Review grid / Review slice, Evaluate partials, Find rectangle extrema, Koren parameter study…, Publish Graph Bilinear or Koren Function depending on the action, X/Y grids, surface, mesh, contour3, hold X, hold Y. Contours with 2–512 levels, extrema on the closed rectangle and One-sided / Unavailable at the edge. Surfaces
Series RLC frequency response… · Review response, Publish Graph Positive R, L, C and increasing frequencies in Hz or rad/s. Impedance, Vc/Vin, gain and phase. Series RLC
Parallel RLC current response… · Review response, Publish Graph Same units. Current in the resistor relative to the source, impedance, gain and phase. Parallel RLC
Continuous transfer response… · Review response, Publish Graph Coefficients in decreasing powers, one or two proper stages up to second order; single, cascade, sum, difference, quotient. Response and poles/zeros, with qualification of the singularities. Transfer
Trigonometry and plane geometry… · Calculate, Unit circle…, Periodic curves… Angle and phase, inverses, Cartesian/polar conversions in both directions, two triangle laws. Output according to mode, deg/rad scale and coordinate unit. Trigonometry
Fourier partial sums… · Fit and review, Publish Graph, Store Function… Time and response columns, period, fit harmonics 1–32, one or more retained orders from 0 to the order of the fit. Estimate, residuals, Graph and conditional Function. Fourier
Unilateral Laplace transform… · Evaluate transform / Publish Graph, Review expression / Store Function Step, exponential, damped sine/cosine for complex evaluation. Rectangular pulse for declaration. Laplace
Lagrangian action and residual… · Evaluate path / Solve and review, Publish Graph Straight-line trajectory, Dataset, initial conditions or fixed endpoints. Action, residual and trajectory in the respective modes. Fixed endpoints requires Octave optim. Action
Legendre transform at one state… · Evaluate state, Store state Dataset q,v pairs and mass/stiffness per coordinate. Momenta and H at the requested state. Legendre
Declare quadratic Lagrangian or Hamiltonian… · Review Function, Store Function Coordinate, mass, stiffness, form L(q,v) or H(q,p). The P012 canonical branch depends on the provider. Declarations

Script Bridge of the viewer

Register a Script in Python Scripts or Octave Scripts and list MATHEMATICS_EXPLORER_API_v1@1 among the required APIs. In Python use gxtxt_api_call(api, "operation", [arguments]). In Octave use gxtxt_api_call(api, 'operation', {arguments}). The rows below document the registration of the viewer. The entry point and the policy of the Job decide admission. The state, the receipts and the revisions cited must belong to the Job and to the Session. The question mark indicates an optional argument.

Registered operation and signature Effect and conditions
initialState() Historical initial model; schema 1, three rows F1/F2/F3, parameters a/b/c, default values and units.
initialState2() Named initial model; schema 2, Sine function and amplitude parameter.
presets() Dictionary of the names of the historical presets and their formulas.
finiteNumber(value, label) Validates a numeric text with a label for the error. Returns a finite real.
tokenize(expression) Splits the string into tokens of the historical grammar. Returns kind/text, including end.
parseExpression(source) Builds the AST of the historical grammar. Does not evaluate the formula.
validateState(state) Checks the declared fields and returns the validated state. Requires consistent units and identities.
evaluateExpression(expression, x, parameters, units, outputUnit) Evaluates the formula at the declared X with parameters and units. Returns values and units. Uses the names and rules of the actual evaluator.
calculate(state) Computes the traces from the schema 1 or 2 state. Returns computed_id and samples for the Job.
analyzeFirst(state, mode) roots/extrema/intersections analysis of the historical model, with the selection provided by the schema.
analyzeSelected(state, mode, otherFunction?, minimum?, maximum?) Analysis of the selected branch or function. For intersections provide another function. The limits are in the unit of X.
integralOfFirst(computed_id) Integrates F1 of the retained calculation. Requires the computed_id of the Job.
integralOfSelected(computed_id) Integrates the schema 2 selection per component with effective units and limits.
nativeModel(state, computed) Declarative Native2D rendering from the state and the retained numerical result. Distinguishes components and units. Does not open the GUI.
sessionToken() Obtains the lifetime token of the active Session.
listDocuments() Lists the Mathematics documents in the Session.
readDocument(id, sessionToken) Reads the state and the receipt of the selected revision. The ID must be a Mathematics document of the Session.
saveDocument(state, currentId, sessionToken, expected_receipt_id?) Saves the document, updating an existing ID only with the expected receipt.
saveWorkspace(state, expected_receipt_id, sessionToken, name?) Saves a validated state and returns identity and revision. An upgrade from schema 1 to 2 creates a distinct Workspace.
publishComputed(state, computed_id, document_receipt_id, sessionToken, outputId) Publishes the data of the retained calculation with a free prefix and a valid receipt of the saved state.
publishGraph(state, computed_id, document_receipt_id, sessionToken, datasetId) Publishes samples and Graph with retained references and current revision. Check the objects already created in case of error.
functionSourceReference(document_id, function_id) Captures function ID, Workspace, digest and revision of a saved declaration.
functionSourceHandoff(reference) Reads the verified JSON with program, domain and units of the declaration.
functionSourceRecipe(reference) Prepares UTF-8 JSON in a uint8 column for the installed constructor. Requires the provider context.
publishFunctionDataset(reference, dataset_id) Builds and publishes the canonical Function Dataset from a saved declaration and a free ID. In P012 the Sine path has limit 214.
planPiecewiseGraph(dataset_id, maximum_samples, window?) Establishes the grid of each interval of a piecewise Function. Optional window in the unit of the coordinate.
publishPiecewiseGraph(dataset_id, maximum_samples, options) Samples the intervals and publishes the Datasets and a Graph variant. Checks revision and ID in options.
analyzePiecewiseExtrema(dataset_id, expected_dataset_revision, window?) Finds extrema and qualifies whether they are attained. Requires a declared piecewise provider, revision and optional window.
publishFiniteTermsGraph(dataset_id, query_values, selection, options) Evaluates selected terms of a finite Function at the requested coordinates. Saves the series in the order of the selection and returns the Graph.
publishPhysicalFunctionGraph(dataset_id, sample_count, options) Samples an admitted physical Function in the effective domain. options contains new ID, title, revision and optional window.
publishSurfaceGraph(dataset_id, request, options) Publishes a grid_yx grid and a Native3D Graph. options contains ID, title, revision, style and optional levels.
publishSurfaceSlice(dataset_id, request, options) Publishes a points_xy section and a Native2D Graph. options requires held_axis besides ID, title and revision.
analyzeSurfaceExtrema(dataset_id, rectangle, expected_dataset_revision) Analyses rectangle limits with two coordinates per axis. Returns exact rational extrema, vertices and admissible whole edges.
composeContinuousCascade(stage_a, stage_b) Composes two proper SISO stages with real coefficients in decreasing powers of s. Returns the unreduced polynomials of the cascade.
composeContinuousParallel(stage_a, stage_b, operation) Adds or subtracts two SISO stages. operation is add or subtract. Keeps order, numerators and unreduced denominator.
composeContinuousQuotient(stage_a, stage_b) Divides A by B without cancelling the original constraints. Keeps the denominators and the numerator of the divisor for the guards.

Discovery and reading example

from gxtxt import gxtxt_api_call, gxtxt_api_has_operation

api = "MATHEMATICS_EXPLORER_API_v1"
print(gxtxt_api_has_operation(api, "initialState2"))
state = gxtxt_api_call(api, "initialState2", [])
print(state["schema"], state["functions"][0]["label"])
api = 'MATHEMATICS_EXPLORER_API_v1';
state = gxtxt_api_call(api, 'initialState2', {});
disp(state.schema);

To read a Function already present and check the capabilities use MATHEMATICAL_MODEL_PROVIDER_API_v1@1 in the Job, besides any dependencies of the recipe. The relevant operations are construction_context(provider_id), construct_function(provider_id, ...) or construct_declared_function(provider_id, recipe) according to the contract, publish_function(...) with the constructor receipt, read_dataset_function(dataset_id), inspect_dataset_function(...), list_algebra_operations(provider_id), apply_algebra_operation(...) and evaluate_dataset_function(...). For grids and curves the specific inputs of the provider apply, including sample_surface_dataset and sample_static_triode_dataset. Formal declarations without an evaluator give inspection when admitted and leave sampling unavailable.

Function provider calls used in the flows

Relevant call Prerequisites and result
read_dataset_function(dataset_id), read_function(provider_id, dataset_id) Read a canonical Dataset in the Session. The second form also requires the identity of the provider. They return data and the receipt of the verified revision.
inspect_dataset_function(dataset_id) Returns inspection data and representation from the admitted definition.
evaluate_dataset_function(dataset_id, query_values) Real values at the coordinates in their unit. Requires a declared evaluator. An excluded domain can prevent the request.
evaluate_dataset_terms(dataset_id, query_values, selection) Evaluates terms of a supported finite Function. selection identifies the indices and the coordinate unit. See publishFiniteTermsGraph to keep them.
evaluate_dataset_function_tangent(dataset_id, query_values) Tangents of the accepted polynomial, in units Y/X, with coordinates that may also repeat.
evaluate_dataset_function_derivative(dataset_id, query_values) Ordinary derivative when declared, with qualification of the points at the edge or at jumps.
study_accepted_polynomial(dataset_id, request), study_accepted_polynomial_intersections(left_dataset_id, right_dataset_id, request) Searches and studies of the admitted fit. The request indicates analysis, interval and unit. The intersections use two distinct fits.
sample_surface_dataset(dataset_id, request), sample_static_triode_dataset(dataset_id, request) Request at points or on an ordered grid with coordinates and units. Returns values and references to the source.
study_static_triode_parameters(dataset_id, request) Requires the Koren provider and the admitted operation on the parameters and on the physical coordinates.
list_algebra_operations(provider_id), apply_algebra_operation(provider_id, operation_id, operands, title) First discover the descriptor. Then specify references and parameters in the required form. The result of Apply keeps the sources.
construction_context(provider_id) Reads the context of units, operators, version and recipe of the constructor.
construct_declared_function(provider_id, named_json_uint8), construct_function(provider_id, named_json_uint8, domain, title) Build the carrier admitted by the provider. The second form is for the retained model and requires explicit support and a title.
publish_function(provider_id, function_uint8, options) Verifies and registers the canonical carrier with admitted ID and options. In the P012 profile the Sine, formal and fit paths of the guide run into the provider limit before the carrier is created.

For the other numerical, Signal and RF/Magnetics operations consult the corresponding Math manuals already distributed and the Runtime catalogues. Here the use in Scripts is limited to the data, documents and operations that serve the work in Mathematics.