Polynomials UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.

Slides:



Advertisements
Similar presentations
Notes 6.6 Fundamental Theorem of Algebra
Advertisements

Chapter 2 Polynomial and Rational Functions Copyright © 2014, 2010, 2007 Pearson Education, Inc Dividing Polynomials: Remainder and Factor Theorems.
1.5 Quadratic Equations Start p 145 graph and model for #131 & discuss.
Solving Quadratic Equations Algebraically Lesson 2.2.
CIS 101: Computer Programming and Problem Solving Lecture 7 Usman Roshan Department of Computer Science NJIT.
Solving Linear Equations
Matrix Mathematics in MATLAB and Excel
Arithmetic Operations on Matrices. 1. Definition of Matrix 2. Column, Row and Square Matrix 3. Addition and Subtraction of Matrices 4. Multiplying Row.
Functions UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
General Results for Polynomial Equations
Copyright © Cengage Learning. All rights reserved.
Numerical Integration UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the.
Solving Linear Equations UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the.
Bell Work: Find the values of all the unknowns: R T = R T T + T = 60 R = 3 R =
ECON 1150 Matrix Operations Special Matrices
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
WARM UP WHAT TO EXPECT FOR THE REST OF THE YEAR 4 May The Discriminant May 29 Chapter Review May 30 Review May 31 Chapter 9 Test June Adding.
6.1 Using Properties of Exponents What you should learn: Goal1 Goal2 Use properties of exponents to evaluate and simplify expressions involving powers.
Copyright © 2007 Pearson Education, Inc. Slide R-1.
Debugging UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
1 Week 3: Vectors and Matrices (Part III) READING: 2.2 – 2.4 EECS Introduction to Computing for the Physical Sciences.
Time Complexity UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Regression UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
Cell Arrays UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
Slide Chapter 2 Polynomial, Power, and Rational Functions.
Recursion and Induction UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the.
Advanced Topics- Polynomials
Chapter 1 Section 1. Examples: 2 x 2 system 2 x 3 system 3 x 2 system.
§ 1.2 Graphing Linear Equations. Martin-Gay, Beginning and Intermediate Algebra, 4ed 22 Linear Equation in Two Variables A linear equation in two variables.
Sorting UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
Script Files UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Objects and Classes UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Numerical Differentiation UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under.
IEEE Arithmetic UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Searching UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
Struct Arrays UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
4.5 Quadratic Equations Zero of the Function- a value where f(x) = 0 and the graph of the function intersects the x-axis Zero Product Property- for all.
Copyright © 2014, 2010, 2007 Pearson Education, Inc. 1 1 Chapter 9 Quadratic Equations and Functions.
Chapter 1 Polynomial and Rational Functions Copyright © 2014, 2010, 2007 Pearson Education, Inc Dividing Polynomials; Remainder and Factor Theorems.
Copyright © 2006 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Real Zeros of Polynomial Functions ♦ Divide Polynomials ♦ Understand the.
Basics of Matlab UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Objective: To learn & apply the fundamental theorem of algebra & determine the roots of polynomail equations.
3.6 Complex Zereos. The Fundamental Theorem of Algebra The Fundamental Theorem of Algebra says that every polynomial with complex coefficients must have.
Complex Numbers Day 1. You can see in the graph of f(x) = x below that f has no real zeros. If you solve the corresponding equation 0 = x 2 + 1,
Copyright © 2006 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Objective I will use square roots to evaluate radical expressions and equations. Algebra.
§ 6.6 Solving Quadratic Equations by Factoring. Martin-Gay, Beginning and Intermediate Algebra, 4ed 22 Zero Factor Theorem Quadratic Equations Can be.
CMPS 1371 Introduction to Computing for Engineers VECTORS.
Root Finding UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Today in Pre-Calculus Notes: –Fundamental Theorem of Algebra –Complex Zeros Homework Go over quiz.
Copy down the following expressions and circle the like terms. 1. 7x 2 + 8x -2y + 8 – 6x 2. 3x – 2y + 4x 2 – y 3. 6y + y 2 – 3 + 2y 2 – 4y 3 What are like.
Get/Set Methods UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Slide Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Polynomial, Power, and Rational Functions.
Copyright © Cengage Learning. All rights reserved. 4 Complex Numbers.
LAB 2 Vectors and Matrices Dr.Abdel Fattah FARES.
Quadratic Equations P.7.
Sum and Product of Roots
For/Switch/While/Try UC Berkeley Fall 2004, E77 me
Finding Real Roots of Polynomial Equations
CHAPTER R: Basic Concepts of Algebra
2.6 Factor x2 + bx + c provided ________ = b and ______ = c
Solve
Standard Form Quadratic Equation
2.6 Factor x2 + bx + c provided ________ = b and ______ = c
Fundamental Theorem of Algebra
Function Handles UC Berkeley Fall 2004, E Copyright 2005, Andy Packard
Copyright © Cengage Learning. All rights reserved.
Arrays in Matlab UC Berkeley Fall 2004, E Copyright 2005, Andy Packard
Splash Screen.
Basics of Matlab UC Berkeley Fall 2004, E Copyright 2005, Andy Packard
Presentation transcript:

Polynomials UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Polynomials An n th order polynomial in variable x is written as It is natural to associate a row vector A p with p, namely A few examples: Row vector representations of are >> Ap = [ ]; >> Aq = [ ]; But [ ] also represents q… “leading zeros”

Functions operating on polynomials Let’s spend the lecture writing several useful functions for polynomial manipulation, including –Polynomial addition –Polynomial subtraction –Polynomial multiplication –Polynomial evaluation (use polyval ) –Plotting the graph of a polynomial –Roots of a polynomial (use roots ) The inputs to the functions will be row vectors, representing polynomials.

Polynomial Addition Adding two polynomials requires adding their coefficients. The sum of is simply In terms of the row-vector representation of the polynomials, we simply add them, element-by-element. But the row vectors may be different lengths, and we need to “ align ” them.

Polynomial Addition The row vector representations of are >> A = [ ]; >> B = [ ]; but obviously >> C = A + B will give an error. We need to “pad” B with a zero >> C = A + [ 0 B ]; or add B only to the correct elements of A. >> C = A; >> C(2:end) = C(2:end) + B;

addpoly.m function C = addpoly(A,B) % This adds two row vectors, interpreting % them as polynomials. % Should check that A and B are row vectors lenA = length(A); lenB = length(B); if lenA==lenB C = A+B; elseif lenA<lenB C = [zeros(1,lenB-lenA) A] + B; else C = A + [zeros(1,lenA-lenB) B]; end Inserting the right number of leading zeros to A

subpoly.m function C = subpoly(A,B) % This subtracts two row vectors, % interpreting them as polynomials. % Should check that A and B are row vectors C = addpoly(A,-B);

Polynomial Multiplication Multiplying a(x) = 6x 3 + 5x 2 – 3x + 7 b(x) = 3x 2 + 2x – 4 Express the product as (6x 3 + 5x 2 – 3x + 7)(3x 2 + 2x – 4) = (6x 3 + 5x 2 – 3x + 7)*3x 2 + (6x 3 + 5x 2 – 3x + 7)*2x + (6x 3 + 5x 2 – 3x + 7)*(-4) The result is 5 th order, so we need a 1-by-6 array for the result C = [ ]

Polynomial Multiplication Multiplying a(x) = 6x 3 + 5x 2 – 3x + 7 A = [ ] b(x) = 3x 2 + 2x – 4 B = [3 2 -4] Express the product as (6x 3 + 5x 2 – 3x + 7)(3x 2 + 2x – 4) = (6x 3 + 5x 2 – 3x + 7)*3x 2 + (6x 3 + 5x 2 – 3x + 7)*2x + (6x 3 + 5x 2 – 3x + 7)*(-4) The result is 5 th order, so we need a 1-by-6 array for the result C = [ ]

Polynomial Multiplication Multiplying a(x) = 6x 3 + 5x 2 – 3x + 7 A = [ ] b(x) = 3x 2 + 2x – 4 B = [3 2 -4] Express the product as (6x 3 + 5x 2 – 3x + 7)(3x 2 + 2x – 4) = (6x 3 + 5x 2 – 3x + 7)*3x 2 add A*B(1) to C(1:4) + (6x 3 + 5x 2 – 3x + 7)*2x + (6x 3 + 5x 2 – 3x + 7)*(-4) The result is 5 th order, so we need a 1-by-6 array for the result C = [ ]

Polynomial Multiplication Multiplying a(x) = 6x 3 + 5x 2 – 3x + 7 A = [ ] b(x) = 3x 2 + 2x – 4 B = [3 2 -4] Express the product as (6x 3 + 5x 2 – 3x + 7)(3x 2 + 2x – 4) = (6x 3 + 5x 2 – 3x + 7)*3x 2 add A*B(1) to C(1:4) + (6x 3 + 5x 2 – 3x + 7)*2x + (6x 3 + 5x 2 – 3x + 7)*(-4) The result is 5 th order, so we need a 1-by-6 array for the result C = [ ]

Polynomial Multiplication Multiplying a(x) = 6x 3 + 5x 2 – 3x + 7 A = [ ] b(x) = 3x 2 + 2x – 4 B = [3 2 -4] Express the product as (6x 3 + 5x 2 – 3x + 7)(3x 2 + 2x – 4) = (6x 3 + 5x 2 – 3x + 7)*3x 2 add A*B(1) to C(1:4) + (6x 3 + 5x 2 – 3x + 7)*2x add A*B(2) to C(2:5) + (6x 3 + 5x 2 – 3x + 7)*(-4) The result is 5 th order, so we need a 1-by-6 array for the result C = [ ]

Polynomial Multiplication Multiplying a(x) = 6x 3 + 5x 2 – 3x + 7 A = [ ] b(x) = 3x 2 + 2x – 4 B = [3 2 -4] Express the product as (6x 3 + 5x 2 – 3x + 7)(3x 2 + 2x – 4) = (6x 3 + 5x 2 – 3x + 7)*3x 2 add A*B(1) to C(1:4) + (6x 3 + 5x 2 – 3x + 7)*2x add A*B(2) to C(2:5) + (6x 3 + 5x 2 – 3x + 7)*(-4) The result is 5 th order, so we need a 1-by-6 array for the result C = [ ]

Polynomial Multiplication Multiplying a(x) = 6x 3 + 5x 2 – 3x + 7 A = [ ] b(x) = 3x 2 + 2x – 4 B = [3 2 -4] Express the product as (6x 3 + 5x 2 – 3x + 7)(3x 2 + 2x – 4) = (6x 3 + 5x 2 – 3x + 7)*3x 2 add A*B(1) to C(1:4) + (6x 3 + 5x 2 – 3x + 7)*2x add A*B(2) to C(2:5) + (6x 3 + 5x 2 – 3x + 7)*(-4) add A*B(3) to C(3:6) The result is 5 th order, so we need a 1-by-6 array for the result C = [ ]

Polynomial Multiplication Multiplying a(x) = 6x 3 + 5x 2 – 3x + 7 A = [ ] b(x) = 3x 2 + 2x – 4 B = [3 2 -4] Express the product as (6x 3 + 5x 2 – 3x + 7)(3x 2 + 2x – 4) = (6x 3 + 5x 2 – 3x + 7)*3x 2 add A*B(1) to C(1:4) + (6x 3 + 5x 2 – 3x + 7)*2x add A*B(2) to C(2:5) + (6x 3 + 5x 2 – 3x + 7)*(-4) add A*B(3) to C(3:6) The result is 5 th order, so we need a 1-by-6 array for the result C = [ ] A*B(1) + C(1:1+length(A)-1) A*B(2) + C(2:2+length(A)-1) A*B(3) + C(3:3+length(A)-1) A*B(i) + C(i:i+length(A)-1) Do this for every element of B ( for loop)

multpoly.m function C = multpoly(A,B) % This computes the product of the inputs, % interpreting them as polynomials. lenA = length(A); lenB = length(B); lenC = lenA + lenB - 1; C = zeros(1,lenC); for i=1:lenB idx = i:i+lenA-1; C(idx) = A*B(i) + C(idx); end

Polynomial Evaluation Use the Matlab function polyval >> A = [ ]; >> x = 2.6; >> y = polyval(A,x) polyval works for vectors too >> x = linspace(-3,3,200); >> y = polyval(A,x); >> plot(x,y)

Roots of Polynomials An n th order polynomial (with nonzero leading coefficient) It is a fundamental theorem of algebra that the equation has n solutions, called the roots of p. Label these roots r 1, r 2,…, r n. Another way to say this is that p can be factored into the for Even if the coefficients of p are real numbers, the roots may be complex.

The roots command The command roots computes the roots of a polynomial, and returns them as a column vector. Compute the roots of >> roots([1 1 -2]) >> roots([1 3 5]) >> roots([ ])