This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Create Symbolic Functions

Symbolic functions represent math functions. Use symbolic functions for differentiation, integration, solving ODEs, and other math operations. Create symbolic functions by using syms.

Create a symbolic function f with variables x and y by using syms. Creating f automatically creates x and y.

syms f(x,y)

Assign a mathematical expression to f.

f(x,y) = x^2*y
f(x, y) =

Find the value of f at (3,2).

ans =

Symbolic functions accept array inputs. Calculate f for multiple values of x and y.

xVal = 1:5;
yVal = 3:7;
ans =
[ 3, 16, 45, 96, 175]

You can differentiate symbolic functions, integrate or simplify them, substitute their arguments with values, and perform other mathematical operations. For example, find the derivative of f(x,y) with respect to x. The result dfx is also a symbolic function.

dfx = diff(f,x)
dfx(x,y) =

Calculate df(x,y) at x = y + 1.

ans =
2*y*(y + 1)

If you are creating a constant function, such as f(x,y) = 1, you must first create f(x,y). If you do not create f(x,y), then the assignment f(x,y) = 1 throws an error.

Related Topics