Javatpoint Logo
Javatpoint Logo

MATLAB Symbolic Mathematics

Symbolic mathematics defines doing mathematics on symbols (not numbers!). For example, a+a is 2a. The symbolic math function is in the Symbolic Math Toolbox in MATLAB. Toolboxes include related functions and are add-ons to MATLAB.

Symbolic Variables and Expressions

MATLAB has type called sym for symbolic variables and expressions, and these work with string.

For example, to generate a symbolic variable a and perform the addition just defined, first, a symbolic variable will be created by passing the string 'a' to the sym function:

Symbolic variables can also store expressions. For example, the variables b and c save symbolic expressions:

All basic numerical operations can be performed on symbolic variables and expressions (e.g., add, subtract, multiply, divide, raise to a power, etc.).

Here are some examples:

Simplification Functions

Several functions work with expressions and simplify the terms. It is not all expressions that can be simplified, but the simplify function does whatever it can to simplify expressions containing gathering like terms.

For example:

The functions collect, expand, and factor works with polynomial expressions. The collect function collects coefficients.

For example:

The expand functions will multiply out terms, and element will do the reverse:

The subs function will substitute an equation for the symbolic variable in expressions.

For example:

With symbolic mathematics, MATLAB works by default with rational numbers, defining that results are kept in fractional forms. For example, performing the addition of 1/3+1/2 would usually result in a double value:

However, by making the function symbolic, the result is symbolic also. Any mathematical function (e.g., double) can modify that:

The numden functions will return the numerator and denominator of the symbolic expressions separately.


Next TopicMATLAB Polynomial




Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA