Operations on Symbolic Expressions Guide

Task: get basic knowledge of how to work with Symbolic Toolbox in the MATLAB software package (Part 2).

Operations on Symbolic Expressions

Once an expression or variable is declared as a symbolic object, we can perform standard mathematical operations such as given in the table below.

Function Description Function Description
horner(S) transforms S into the Horner nested polynomial format
[N,D] = numden(S) returns two symbolic numerator and denominator expressions
sym(S,’?’); where ? may be f,r,e, or d symbolic to numeric conversion: f is floating point, r = rational form, e = rational plus an error term, d = decimal expansion when followed by digits(N)
poly2sym(c) converts the polynomial vector c into a symbolic polynomial
pretty(S) produces a typeset type display
A+B symbolic addition of A+B
A/B symbolic division of A/B
A*B symbolic multiplication of AB
S^p symbolic power S^p
A-B symbolic subtraction A-B

Example:

    \[ p_{1}=\frac{1}{y - 3} \]

    \[ p_{2}=\frac{3y}{y + 2} \]

    \[ p_{3}=(y + 4)(y - 3)y \]

syms y
p1 = 1/(y-3);
p2 = 3*y/(y+2);
p3 = (y+4) *(y-3) *y;

% Now operate:

    \[ p_{1}*p_{2}=\frac{1}{y - 3} * \frac{3y}{y + 2} \]

    \[ p_{1}*p_{3}=(y + 4)*y \]

    \[ p_{2}^{3}=\frac{27*y^{3}}{(y + 2)^{3}} \]

    \[ p_{1}+p_{2}=\frac{1}{y - 3} + \frac{3y}{y + 2} \]

    \[ [num,den] = numden(p_{1}+p_{2}) \]

    \[ num=-8*y+2+3*y^{2} \]

    \[ den = (y-3)*(y+2) \]

Solutions to Equations

To solve a single equation, we use:

g = solve(eq,var);

That is, find what value of the independent variable makes eq = 0; var is optional.

– If more than one variable is present, the variable to solve for set with var is:

S = sym('x^{2} + 3*x + 18');
solve(S)

    \[ x=[-\frac{3}{2}+\frac{3}{2}*i*7^{\frac{1}{2}}, -\frac{3}{2}-\frac{3}{2}*i*7^{\frac{1}{2}}] \]

syms \, x \, a \, b \, c

S = sym('a*x^2 + b*x + c'); % Contains four variables

solve(S,x) % Solve for x

    \[ x=[\frac{\frac{1}{2}}{a*(-b+(b^{2}-4*a*c)^\frac{1}{2}}), \frac{\frac{1}{2}}{a*(-b-(b^{2}-4*a*c)^\frac{1}{2}}] \]

%quadratic equation

To solve a system of equations, use:

g = solve(eq_{1},eq_{2},...,eq_{n},var_{1},var_{2},...,var_{n});

The var_{1}, …,var_{n}are the variables to solve for. They must be declared as symbolics using syms.

syms \, x \, y \, z
eq_{4} = sym('3*x+2*y-z=10');
eq_{5} = sym('-x+3*y+2*z=5');
eq_{6} = sym('x-y-z=-1');
solve(eq_{4},eq_{5},eq_{6},x,y,z);

x = -2

y = 5

z = -6


When you get an assignment on a similar topic, such a sample can help you to deal with it. However, only a few students can complete really great tasks. To solve your problem, it is necessary to have someone who can help you. We will assist you with any problem; you just need to visit assignmentshark.com and leave your order. Therefore, you will get qualified help from the expert in the field. For better understanding of how our experts deal with different tasks, you can check out samples on our blog. We have samples presented for different disciplines.

On our site, you can find help with any type of task you may get. Our ordering system is easy and understandable for everyone. If you decide to order on our site, you can be sure that your assignment will contain all formulas and calculations that you need. The more assistance you get from us, the better your grades will be!

Leave a Reply

Your email address will not be published. Required fields are marked *

Customer testimonials

Submit your instructions to the experts without charge.