90 likes | 144 Views
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
E N D
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:
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: • Enter this into MATLAB: 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; [xtyt] = 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: Determine the coordinates of the points where the ellipses intersect. Plot the ellipses, and the intersection points
For Next Time • Homework Due