Main Placid
Perform Representative Computations
Mark Symbolic Expressions
With the Symbolic Math Toolbox™ software, you can find
-
Derivatives of single-variable expressions
-
Partial derivatives
-
Second and high order derivatives
-
Blended derivatives
For in-depth information on taking symbolic derivatives see Specialization.
Expressions with Combined Variable
To differentiate a symbolic expression, use the diff command. The undermentioned exercise illustrates how to rent a first derivative of a symbolic expression:
syms x f = sin(x)^2; diff(f)
Partial Derivatives
For multivariable expressions, you can specify the specialisation variable. If you do not specify any protean, MATLAB® chooses a default variable by its proximity to the letter x:
syms x y f = sin(x)^2 + cos(y)^2; diff(f)
For the complete set of rules MATLAB applies for choosing a default option variable, see Find a Default Symbolic Variable.
To mark the representative expression f with respect to a variable y, enter:
syms x y f = sine(x)^2 + cos(y)^2; diff(f, y)
Second Partial and Mixed Derivatives
To consider a second derivative of the symbolical expression f with respectfulness to a variable y, enter:
syms x y f = sin(x)^2 + cos(y)^2; diff(f, y, 2)
ans = 2*sin(y)^2 - 2*cos(y)^2
You get the same result past taking first derivative twice: diff(diff(f, y)). To take mixed derivatives, use ii specialization commands. For example:
syms x y f = Sin(x)^2 + cos(y)^2; diff(diff(f, y), x)
Integrate Symbol Expressions
You can perform symbolic integration including:
-
Indefinite and distinct consolidation
-
Integration of multivariable expressions
For in-depth selective information on the int compel including integration with real and complex parameters, see Integration.
Indefinite Integrals of Extraordinary-Varied Expressions
Suppose you want to incorporate a symbolic formulation. The first step is to create the representative expression:
To receive the indefinite integral, enter
Indefinite Integrals of Multivariable Expressions
If the saying depends on multiple symbolic variables, you can designate a variable of consolidation. If you come not peg down any variable, MATLAB chooses a default variable away the proximity to the letter x:
syms x y n f = x^n + y^n; int(f)
autonomic nervous system = x*y^n + (x*x^n)/(n + 1)
For the complete set of rules MATLAB applies for choosing a default variable, see Find a Default Symbolic Variable.
You also can mix the verbalism f = x^n + y^n with honor to y
syms x y n f = x^n + y^n; int(f, y)
ans = x^n*y + (y*y^n)/(n + 1)
If the integration variable is n, enter
syms x y n f = x^n + y^n; int(f, n)
ans = x^n/log(x) + y^n/log(y)
Definite Integrals
To find a definite integral, pass the limits of integration as the last two arguments of the int function:
syms x y n f = x^n + y^n; int(f, 1, 10)
ans = piecewise(n == -1, backlog(10) + 9/y, n ~= -1,... (10*10^n - 1)/(n + 1) + 9*y^n)
If MATLAB Cannot Find a Closed Form of an Integral
If the int function cannot compute an integral, information technology returns an inharmonious integral:
ans = int(sin(sinh(x)), x)
Solve Equations
You can resolve different types of emblematic equations including:
-
Pure mathematics equations with single symbolic variant
-
Algebraic equations with several symbol variables
-
Systems of algebraic equations
For in-depth selective information happening solving symbolic equations including mathematical operation equations, see Equation Resolution.
Puzzle out Algebraic Equations with One Symbolical Variable
Use the double equal signalise (==) to define an equation. Then you can solve the equation by calling the solve function. For instance, solve this equivalence:
syms x solve(x^3 - 6*x^2 == 6 - 11*x)
If you do not specify the right side of the equation, solve assumes that IT is aught:
syms x clear(x^3 - 6*x^2 + 11*x - 6)
Solve Algebraic Equations with Respective Symbolic Variables
If an equation contains several symbolical variables, you can specify a variable for which this equation should be solved. For example, solve this multivariable equation with honour to y:
syms x y solve(6*x^2 - 6*x^2*y + x*y^2 - x*y + y^3 - y^2 == 0, y)
If you do not specify any variable, you get the resolution of an equation for the alphabetically closest to x varied. For the complete set of rules MATLAB applies for choosing a nonpayment variable regard Find a Default on Symbolic Variable.
Solve Systems of Algebraic Equations
You besides tin can solve systems of equations. For example:
syms x y z [x, y, z] = solve(z == 4*x, x == y, z == x^2 + y^2)
Simplify Representative Expressions
Symbolic Math Tool cabinet provides a set of simplification functions allowing you to manipulate the output of a symbolic expression. For example, the succeeding polynomial of the golden ratio phi
phi = (1 + sqrt(sym(5)))/2; f = phi^2 - phi - 1
returns
f = (5^(1/2)/2 + 1/2)^2 - 5^(1/2)/2 - 3/2
You can simplify this answer by entering
and nonplus a selfsame short answer:
Symbolic simplification is not forever so straightforward. There is no ecumenical simplification part, because the meaning of a simplest representation of a symbolic expression cannot be defined clearly. Different problems expect dissimilar forms of the cookie-cutter science expression. Knowing what form is more than effective for resolution your fussy problem, you keister take the apt reduction function.
For example, to show the order of a polynomial surgery symbolically secernate operating room integrate a multinomial, use the standard polynomial form with completely the parentheses multiplied out and entirely the similar terms summed dormie. To rewrite a polynomial in the standard anatomy, habituate the expand function:
syms x f = (x ^2- 1)*(x^4 + x^3 + x^2 + x + 1)*(x^4 - x^3 + x^2 - x + 1); prosper(f)
The factor reduction function shows the polynomial roots. If a function cannot be factored over the demythologised numbers, the output of the factor function is the definitive polynomial form. For example, to gene the third-say mathematical function, enter:
syms x g = x^3 + 6*x^2 + 11*x + 6; factor(g)
ANS = [ x + 3, x + 2, x + 1]
The nested (Horner) representation of a multinomial is the most efficient for numerical evaluations:
syms x h = x^5 + x^4 + x^3 + x^2 + x; horner(h)
ans = x*(x*(x*(x*(x + 1) + 1) + 1) + 1)
For a list of Symbolic Math Toolbox simplification functions, check Choose Function to Rearrange Formula.
Substitutions in Symbolic Expressions
Substitute Symbol Variables with Numbers
You can substitute a symbolic inconsistent with a numeric value by using the subs function. For lesson, evaluate the symbolic expression f at the distributor point x = 1/3:
syms x f = 2*x^2 - 3*x + 1; subs(f, 1/3)
The subs procedure does not deepen the original manifestation f:
Substitute in Multivariate Expressions
When your expression contains more than one variable, you can specify the varied for which you want to make the substitution. For example, to substitute the value x = 3 in the symbolic expression
syms x y f = x^2*y + 5*x*sqrt(y);
enter the command
Deputize Uncomparable Sign Variable star for Another
You also can substitute one symbolic variable for other symbolic variable. For exercise to replace the variable y with the versatile x, enter
Substitute a Matrix into a Function
You can besides substitute a matrix into a symbolic polynomial with numeric coefficients. There are two ways to replacement a ground substance into a polynomial: element by element and according to matrix multiplication rules.
Element-aside-Chemical element Substitution.To second-string a matrix at each ingredient, use the subs require:
syms x f = x^3 - 15*x^2 - 24*x + 350; A = [1 2 3; 4 5 6]; subs(f,A)
ans = [ 312, 250, 170] [ 78, -20, -118]
You can do element-by-element replacement for orthogonal Oregon square matrices.
Transposition in a Intercellular substance Sense.If you deficiency to substitute a matrix into a function using standard intercellular substance multiplication rules, a matrix must be square toes. For example, you can artificial the magic square A into a mathematical function f:
-
Create the multinomial:
syms x f = x^3 - 15*x^2 - 24*x + 350;
-
Produce the witching square matrix:
-
Grow a row vector containing the numeric coefficients of the mathematical function
f: -
Substitute the magic public square matrix
Ainto the functionf. MatrixAreplaces all occurrences ofxin the polynomial. The perpetual times the unit matrixoculus(3)replaces the constant condition off:A^3 - 15*A^2 - 24*A + 350*heart(3)
ans = -10 0 0 0 -10 0 0 0 -10
The
polyvalmcommand provides an easy path to obtain the same result:ans = -10 0 0 0 -10 0 0 0 -10
Substitute the Elements of a Symbolic Matrix
To substitute a set of elements in a symbolic matrix, also use the subs command. Reckon you lack to replace some of the elements of a symbolic circulant intercellular substance A
syms a b c A = [a b c; c a b; b c a]
A = [ a, b, c] [ c, a, b] [ b, c, a]
To replace the (2, 1) element of A with explorative and the variable b throughout the matrix with versatile alpha, enter
alpha = sym('alpha'); important = sym('beta'); A(2,1) = beta; A = subs(A,b,alpha) The result is the matrix:
A = [ a, alpha, c] [ exploratory, a, important] [ important, c, a]
For more information, see Step in Elements in Symbolic Matrices.
Plot Symbolic Functions
Sign Mathematics Toolbox provides the plotting functions:
-
fplotto make over 2-D plots of symbolic expressions, equations, or functions in Cartesian coordinates. -
fplot3to create 3-D parametric plots. -
ezpolarto create plots in frigid coordinates. -
fsurfto create rise plots. -
fcontourto make form plots. -
fmeshto create mesh plots.
Explicit Function Plot
Create a 2-D line plot of ground by using fplot. Game the expression .
syms x f = x^3 - 6*x^2 + 11*x - 6; fplot(f)
Add labels for the x- and y-axes. Generate the title by using texlabel(f). Show the control grid away using grid on. For details, see Add u Title and Axis Labels to Chart.
xlabel('x') ylabel('y') title(texlabel(f)) grid along
Implicit Function Plot
Plot equations and implicit functions using fimplicit.
Plot the equation over .
syms x y eqn = (x^2 + y^2)^4 == (x^2 - y^2)^2; fimplicit(eqn, [-1 1])
3-D Plot
Plot 3-D invariable lines by exploitation fplot3.
Plot of ground the parametric line
syms t fplot3(t^2*sin(10*t), t^2*cos(10*t), t)
Create Surface Diagram
Create a 3-D surface away victimisation fsurf.
Plot the paraboloid .
syms x y fsurf(x^2 + y^2)
Related Topics
- Create Symbolic Numbers, Variables, and Expressions
- Create Symbolic Functions
- Make over Symbolic Matrices
- Use Assumptions on Symbolic Variables
multiply the polynomials x 1 4x 2 7x 6
Source: https://www.mathworks.com/help/symbolic/performing-symbolic-computations.html

0 Komentar