introduction to this point matlab has been used to answer questions with a numeric value...

9
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

Upload: nickolas-oliver

Post on 03-Jan-2016

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Introduction To this point MATLAB has been used to answer questions with a numeric value ▫Variables are assigned specific values ▫Answers are numbers MATLAB

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

Page 2: Introduction To this point MATLAB has been used to answer questions with a numeric value ▫Variables are assigned specific values ▫Answers are numbers MATLAB

Warm-Up Problem

Simplify this expression:

Page 3: Introduction To this point MATLAB has been used to answer questions with a numeric value ▫Variables are assigned specific values ▫Answers are numbers MATLAB

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.

Page 4: Introduction To this point MATLAB has been used to answer questions with a numeric value ▫Variables are assigned specific values ▫Answers are numbers MATLAB

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

Page 5: Introduction To this point MATLAB has been used to answer questions with a numeric value ▫Variables are assigned specific values ▫Answers are numbers MATLAB

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

Page 6: Introduction To this point MATLAB has been used to answer questions with a numeric value ▫Variables are assigned specific values ▫Answers are numbers MATLAB

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?

Page 7: Introduction To this point MATLAB has been used to answer questions with a numeric value ▫Variables are assigned specific values ▫Answers are numbers MATLAB

Concept Questions

•If you have 3 unknowns and 2 equations, how many solutions are there?

•Are you guaranteed solutions?

Page 8: Introduction To this point MATLAB has been used to answer questions with a numeric value ▫Variables are assigned specific values ▫Answers are numbers MATLAB

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

Page 9: Introduction To this point MATLAB has been used to answer questions with a numeric value ▫Variables are assigned specific values ▫Answers are numbers MATLAB

For Next Time

•Homework Due