0% found this document useful (0 votes)
57 views9 pages

Activity 3 Symbolic Processing 2024

The document discusses symbolic processing in MATLAB. It defines symbolic objects and variables, and describes functions for performing algebraic operations on symbolic expressions like factoring, expanding, solving equations and more. Examples are provided for working with polynomials represented as vectors and performing operations like multiplication and division.

Uploaded by

Rene Inson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views9 pages

Activity 3 Symbolic Processing 2024

The document discusses symbolic processing in MATLAB. It defines symbolic objects and variables, and describes functions for performing algebraic operations on symbolic expressions like factoring, expanding, solving equations and more. Examples are provided for working with polynomials represented as vectors and performing operations like multiplication and division.

Uploaded by

Rene Inson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Southern Luzon State University

Colllege of Engineering
ECE Department
ECM02- ADVANCED ENGINEERING MATHEMATICS LAB

ACTIVITY 3
SYMBOLIC PROCESSING
(ALGEBRAIC FUNCTION)

Group No:____________ Date Performed:_______________

Names:______________________________ Date Submitted:_______________


______________________________
______________________________

Yr. & Sec:___________________

RATING

__________________________________________
INSTRUCTOR
I. OBJECTIVES:

1. Create Symbolic variables, constants and expressions.


2. Operate on symbolic expressions in doing some arithmetic operations.
3. Perform algebraic operations on symbolic expressions.

II. INTRODUCTORY INFORMATION

Symbolic Processing is the process of obtaining answers in the form of expressions. It


is the term used to describe how a computer performs operations or mathematical
expressions in the way, for example that humans do algebra with pencil and paper

III. MATLAB BACKGROUND

Defining Symbolic Objects


Symbolic object is a data structure that stores a string representation of the symbol. The two
ways to create symbolic object are:
1. Using sym function
Typing x = sym(‘x’) creates the symbolic variable with name x.
2. Using syms command
syms x is equivalent to typing x = sym(‘x’).
Typing syms x y z creates three symbolic variables x, y and z.

Classifications of Symbolic Objects


MATLAB can perform algebraic as well as advanced operations on algebraic variables.
These variables are called symbolic objects which can be classified as:
a. Symbolic Variables are algebra variables that do not have a fixed value and may change
depending on the equation or expression.

Examples x, y, z, theta, alpha


>> theta = sym(‘theta’)
>> syms x y z alpha

b. Symbolic Constants are numbers which we want to be left to its form rather than evaluating
as floating decimals. Using symbolic constant, it avoids the floating-point approximation
inherent in the irrational constant. If you create these symbolic constants, say 𝜋, it temporarily
replaces the built-in numeric constant, and you no longer obtain a numerical value when you
type its name. Its advantage is that they need not be evaluated until a numeric answer is
required.

Examples: pi, e, sqrt(2)


>> syms pi % it displays pi, not the value of 𝜋 which is 3.1415
>> sqrt(sym(2)) % it outputs 2^1/2 not the value of 1.4142
>>sym(2)/sym(5) % it outputs 2/5 not the value of 0.4

c. Symbolic Expression is an expression created using variables enclosed in apostrophes ( ‘ )


or using other symbolic variables separated by mathematical operation. Symbolic Expressions
are automatically created from a symbolic expression whose variables were previously created.
Example: ‘x^2-y^2’, x+y
>> syms x y
>> a = x + y
>> b = sqrt(x^2 – y^2)
Symbolic variables a and b were created even they were not created by sym or syms commands.

2|ECM02L- Advanced Engineering Mathematics for ECE Lab


d. Symbolic matrices are arrays with elements that contain symbolic variables. It can be
created by defining the elements as symbolic objects or defining symbolic matrix variables
with elements not symbolic objects.

Example: [a, b, c; b, c, a; c, a, b]
>> syms a b c
>> A = [a b c;b a c; c a b]

>> syms A
>> A = [1, 2 3; 4, 5, 6]
In both cases, symbolic matrix A was created.

ALGEBRAIC MANIPULATION FUNCTIONS

COMMAND BRIEF DEFINITION


collect(E) Collects coefficients of like powers in the expression E.
expand(E) Expands the expression E by carrying out powers and some algebraic
expansion.
factor(E) Factors the expression E.
horner(E) Transforms a symbolic polynomial E into its nested form.
pretty(E) Displays the expression E on the screen in a form that resembles
typeset mathematics.
double(E) Converts the symbolic constant to numeric form. The expression E
must not contain any symbolic variables.
simple(E) Searches for the shortest form of the expression E in terms of number
of characters. When called, the function displays the results of each
step of its search. When called without the argument, simple acts on
the previous expression.
The form [r,how] = simple(E) does not display intermediate steps,
but saves those steps in the string how. The shortest form found is
stored in r.
subs(E, old, new) Substitutes new for old in the expression E, where old can be a
symbolic variable or expression, new can be a symbolic variable,
expression, or matrix, or a numeric value or matrix.
simplify(E) Simplifies the expression E using Maple’s simplification rules.
A = solve(E) Solves a symbolic expression/s or equation represented by the
expression E. If E represents an equation, the equation’s expression
must be enclosed in single quotes. If E represents an expression, then
the solution obtained will be the roots of the expression E; that is, the
solution of the equation E = 0. You need not declare the symbolic
variable with the sym or syms function before using solve.

EXERCISES 3.1 ALGEBRAIC MANIPULATIONS


A. Factor out the indicated expression from the given symbolic expression:
1. 𝑥 𝑠𝑖𝑛 𝑦 + 3𝑥 2 𝑐𝑜𝑠 2𝑦 𝑠𝑖𝑛 𝑦 , 𝑠𝑖𝑛 𝑦
2. 𝑥 𝑦 3 – 3𝑥 𝑡𝑎𝑛𝑦 + 4 𝑥 𝑒 𝑥 , 𝑥
Hint. Use sym and collect command

COMMAND RESULT

3|ECM02L- Advanced Engineering Mathematics for ECE Lab


B. Expand the following algebraic expressions:
1. (𝑥 − 2)(𝑥 − 3)(𝑥 2 + 6)
2. Polynomial with roots 1 , 2, 4
Hint. Use sym and expand command

COMMAND RESULT

C. Factor out the following expressions:


1. 𝑥 3 − 6𝑥 2 + 11𝑥 − 6
2. 𝑥 4 + 5𝑥 3 − 10𝑥 2 + 20𝑥 − 56
Hint. Use sym and factor command

COMMAND RESULT

D.Create the following symbolic constants, and express answers in terms of symbolic and
decimal constants:
3√2+5−6√2
1. √2, 𝐴 = 7−√2
2. 𝜋, 𝐵 = (7 + 8/7) ∗ 𝜋
Hint. Use sym and double command

COMMAND RESULT

E. Express
𝑓 = 𝑥^3 − 6 ∗ 𝑥^2 + 11 ∗ 𝑥 − 6 and
𝑔 = (𝑥 − 1) ∗ (𝑥 − 2) ∗ (𝑥 − 3)
in typeset display mathematics
Hint. Use sym and pretty command

COMMAND RESULT

F. Evaluate the following expressions at the given values of the variables:


𝑒𝑥𝑝1 = 𝑥 3 + 6𝑥 − 7 at 𝑥 = 𝑦
Hint. Use sym and subs command

4|ECM02L- Advanced Engineering Mathematics for ECE Lab


COMMAND RESULT

G. Evaluate the function:


𝐹 = 𝑥 4 − 2𝑥 2 + 𝑥 − 3 𝑎𝑡 𝑥 = 2 and at 𝑥 = 𝑡 − 2
Hint. Use sym , expand and subs command

COMMAND RESULT

H. Find the roots of the polynomial expression:


𝑥 2 − 6𝑥 + 8 = 0
Hint. Use syms and roots command

COMMAND RESULT

I. For the given expression, solve for x in terms of y and y in terms of x.


𝑥 2 − 2𝑥𝑦 + 𝑦 2 + 9 = 0
Hint. Use syms and solve command

COMMAND RESULT

J. Solve for the systems of equation:


𝑥 − 2𝑦 + 3𝑧 = 10
𝑥 + 3𝑦 − 2𝑧 = 9
4𝑥 + 2𝑦 − 2𝑧 = 5
Hint. Use syms and solve command

COMMAND RESULT

5|ECM02L- Advanced Engineering Mathematics for ECE Lab


POLYNOMIAL ALGEBRA
Polynomial algebra is another way of representing a polynomial expression in terms of a
vector. The vector [a b c d] is equivalent to the algebraic expression 𝑎𝑥 3 + 𝑏𝑥 2 + 𝑐𝑥 + 𝑑,
where the last term of the expression is the constant of the polynomial.

FUNCTION BRIEF DESCRIPTION


E = poly2sym(p,x) Converts a polynomial coefficient vector p to a symbolic
polynomial in terms of the variable x. If the variable is not
given, the default variable x will be used.
v = sym2poly(E) Converts the expression E to a polynomial coefficient vector.

Example:
>> poly2sym([1 2 3]) % it creates 𝑥 2 + 2𝑥 + 3
>> poly2sym(1:2:11, z) % it creates 𝑧 5 + 3𝑧 4 + 5𝑧 3 + 7𝑧 2 + 9𝑧 + 11
>> syms x
>> sym2poly(2*x^2-x+6) % it outputs [2 -1 6]

POLYNOMIAL ALGEBRA FUNCTIONS


FUNCTION BRIEF DESCRIPTION
conv(a,b) Computes the product of the two polynomials described by the
coefficient arrays a and b. The two polynomials need not be the
same degree. The result is the coefficient array of the product
polynomial.
[q, r] = deconv(num,den) Computes the result of dividing a numerator polynomial, whose
coefficient array is num, by a denominator polynomial represented
by the coefficient array den. The quotient polynomial is given by
the coefficient array q, and the remainder polynomial is given by
the coefficient array r.
poly(r) Computes the coefficients of the polynomial whose roots are
specified by the vector r. The result is a row vector that contains
the polynomial’s coefficients arranged in descending order of
power
[r,p,k] = residue(a,b) Finds the residues, poles and direct term of a partial fraction
expansion of the ratio polynomials b(x) / a(x). Residue (r) is the
numerator of each partial fraction with the corresponding
denominator x – p where p are the poles. K is the polynomial
vector representing the quotient of b and a.
polyval(a, x) Evaluates a polynomial at specified values of its independent
variable x, which can be a matrix or a vector. The polynomial’s
coefficients of descending powers are stored in the array a. The
result is the same size as x.
roots(a) Computes the roots of a polynomial specified by the coefficient
array a. The result is a column vector that contains the
polynomial’s roots

6|ECM02L- Advanced Engineering Mathematics for ECE Lab


Use polynomial algebra to solve the following:

EXERCISE 3.2 POLYNOMIAL ALGEBRA


A. Verify that the product of
𝑃1 = 20𝑥 3 – 7𝑥 2 + 5𝑥 + 10 and 𝑃2 = 4𝑥 2 + 12𝑥 – 3 is
80𝑥 5 + 212𝑥 4 – 124𝑥 3 + 121𝑥 2 + 105𝑥 – 30.
Hint. Use conv command

COMMAND RESULT

B. Verify that the quotient P1/P2 of


𝑃1 = 12𝑥 3 + 5𝑥 2 − 2𝑥 + 3 and 𝑃2 = 3𝑥 2 − 7𝑥 + 4 is
4𝑥 + 11 with a remainder of 59𝑥 – 41
Hint. Use deconv command

COMMAND RESULT

C. Find the coefficients of the polynomial given the roots are 1 , -2, 3
Hint. Use poly command

COMMAND RESULT

D. Decompose into partial fractions of:


𝑥 2 + 5𝑥 + 8
(𝑥 − 3)(𝑥 + 1)2

Hint. Use residue command

COMMAND RESULT

E. Evaluate the result of the polynomial division P1/P2 at 𝑥 = 2


𝑃1 = 6𝑥 3 + 4𝑥 2 – 5
𝑃2 = 12𝑥 3 − 7𝑥 2 + 3𝑥 + 9
Hint. Use polyval command

COMMAND RESULT

7|ECM02L- Advanced Engineering Mathematics for ECE Lab


F. Find the roots of the polynomial
𝑥 3 – 7𝑥 + 6 = 0
Hint. Use roots command

COMMAND RESULT

IV. ADDITIONAL EXERCISES


Answer the following on space provided.
1. Create a script <actvity3A_1.m> that would be able to perform the following operations
using symbolic processing.
a. Factor out completely: 𝑥12 − 1
b. Isolate the trigonometric factor of : 𝑦 2 𝑡𝑎𝑛 𝑥 + 2𝑦 𝑡𝑎𝑛 𝑥 − 𝑡𝑎𝑛𝑥
c. Find the simplest form for the trigonometric expression: cos2 𝑥 (1 + cot 2 𝑥)
d. Expand the expression: (𝑥 − 3)3 (𝑥 − 4)𝑥 2 (𝑥 2 + 1)
e. From the expression 𝐸 = 𝑥 3 + 1
𝐸(𝑡+𝑑)−𝐸(𝑡)
Simplify: and evaluate at d = 0
𝑑
COMMAND RESULT

a.

b.

c.

d.

8|ECM02L- Advanced Engineering Mathematics for ECE Lab


e.

V. SUMMARY AND CONCLUSION

9|ECM02L- Advanced Engineering Mathematics for ECE Lab

You might also like