Introduction - University of Mary Hardin–Baylor

Download Report

Transcript Introduction - University of Mary Hardin–Baylor

Introduction
• To this point MATLAB has been used to answer
questions with a numeric value
▫ Variables are assigned specific values
▫ Answers are numbers
• MATLAB can also solve for symbolic answers
▫ Example: Solve a*x + b = 0 for x
 Answer: x = -b/a
• Exact answers can be given instead of
numerically rounded results
Warm-Up Problem
Simplify this expression:
𝑥 2 𝑥 − 6 + 4(3𝑥 − 2)
𝑥+2
2
− 8𝑥
Symbolic Math
• The symbolic math toolbox can be used to solve
many types of problems:
▫
▫
▫
▫
▫
▫
Simplifying complicated expressions
Solving algebraic equations symbolically
Factoring polynomials
Differentiation
Integration
Plotting
• We will take a look at simplifying, solving, and
factoring equations today.
Simplifying
• Lets go back to the warm-up problem:
𝑥 2 𝑥 − 6 + 4(3𝑥 − 2) 𝑥 + 2
• Enter this into MATLAB:
2
− 8𝑥
syms x
s = (x^2*(x-6)+4*(3*x-2))((x+2)^2-8*x)
• Notice the result is not indented in the command
window
• Let’s simplify this expression:
simplify(s)
• To generate this answer, MATLAB tries a bunch of
different methods and returns the one with the fewest
characters – not necessarily the prettiest one to look at
Collect, Expand, Factor
• These 3 operations are all performed by simplify
• Collect(): Collects like terms of the symbolic
variable (like x, x2, etc.)
• Expand(): Uses polynomial multiplication and trig
identities to expand expressions
• Factor(): Takes a polynomial and determines the
factors (opposite of expand)
• Examples:
▫ Try collecting terms in the warm-up problem
▫ Expand sin(x-y)
▫ Factor the result of the collect command in the first
example
Solve
• The solve() command can solve a system of
equations
▫ If the # of equations is equal to the # of variables, then
numerical answers are returned
▫ If the # of equations is less than the # of variables,
then a symbolic solution is returned, in terms of the
symbolic variables
Example:
syms x y t
S = 10*x+12*y+16*t;
[xt yt] = solve(S, ‘5*x-y=13*t’)
Could gaussian elimination be used to solve this system?
Concept Questions
• If you have 3 unknowns and 2 equations, how
many solutions are there?
• Are you guaranteed solutions?
Group Problem
• Two ellipses in the x-y plane have the following
equations:
𝑥−1
62
2
𝑦2
+ 2 = 1,
3
𝑥+2
22
2
(𝑦 − 5)2
+
=1
2
4
Determine the coordinates of the points where the
ellipses intersect.
Plot the ellipses, and the intersection points
For Next Time
• Homework Due