ATLAB Lecture 5 SchoolofMathematicalSciencesXiamenUniversityhttp://gdjpkc.xmu.edu.cr horner(f) x^3-6*x^2+11*x-6 -6+(116)*x)*x 1+2.2*x+3.3*x^2 10(15+330)* factor If f is a polynomial with rational coefficients, the statement factor( expresses f as a product of polynomials of lower degree with rational coefficients If f cannot be factored over the rational numbers the result is f itself x^3-6*x^2+11*x-6 (X-1)°(X-2)*(x-3) x^3-6*x^2+11*x-5 x^3-6*x^2+11*x-5 x^6+1 2+1)(x24x2+1) Here is another example involving factor. It factors polynomials of the form xn+ 1. This code >>f= factor(p); >>[p,f returns a matrix with the polynomials in its first column and their factored forms in its x^2+1 x^3+1 (x+1)°(x~2-x+1) x^4+1, x^5+1 (x+1)*(x~4-x^~3+x^2-x+1) (x^2+1)*(x^4-x^2+1)] x^7+1,(x+1)*(1-x+x^2-x^3+x4-x^5+x^6)] 8+ x^8+1] (x+1)*(x^2-x+1)°(x^6-x^3+1) simplify The simplify function is a powerful, general purpose tool that applies a number of algebraic dentities involving sums, integral powers, square roots and other fractional powers, as well as a number of functional identities involving trig functions, exponential and log functions, Bessel functions, hypergeometric functions, and the gamma function. simplify(f) x(x*(x-6)+11)-6 x^3-6*x^2+11*x-6 (1-x^2)(1-x) x+1 (1/a^3+6a^2+12/a+8y(1/3) (2*a+1)y3/a3)^(1/3) syms x y positive: log(x y) log(x)+log(y) exp(x)*exp(y p(xty) cos(x)2+ sin(x)2 Lec5-6MATLAB Lecture 5 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Lec56 f horner(f) x^36*x^2+11*x6 6+(11+(6+x)*x)*x 1.1+2.2*x+3.3*x^2 11/10+(11/5+33/10*x)*x factor If f is a polynomial with rational coefficients, the statement factor(f) expresses f as a product of polynomials of lower degree with rational coefficients. If f cannot be factored over the rational numbers, the result is f itself. f factor(f) x^36*x^2+11*x6 (x1)*(x2)*(x3) x^36*x^2+11*x5 x^36*x^2+11*x5 x^6+1 (x^2+1)*(x^4x^2+1) Here is another example involving factor. It factors polynomials of the form x^n + 1. This code >> syms x; >> n = (1:9)'; >> p = x.^n + 1; >> f = factor(p); >> [p, f] returns a matrix with the polynomials in its first column and their factored forms in its second. [ x+1, x+1 ] [ x^2+1, x^2+1 ] [ x^3+1, (x+1)*(x^2x+1) ] [ x^4+1, x^4+1 ] [ x^5+1, (x+1)*(x^4x^3+x^2x+1) ] [ x^6+1, (x^2+1)*(x^4x^2+1) ] [ x^7+1, (x+1)*(1x+x^2x^3+x^4x^5+x^6) ] [ x^8+1, x^8+1 ] [ x^9+1, (x+1)*(x^2x+1)*(x^6x^3+1) ] simplify The simplify function is a powerful, general purpose tool that applies a number of algebraic identities involving sums, integral powers, square roots and other fractional powers, as well as a number of functional identities involving trig functions, exponential and log functions, Bessel functions, hypergeometric functions, and the gamma function. f simplify(f) x*(x*(x6)+11)6 x^36*x^2+11*x6 (1x^2)/(1x) x+1 (1/a^3+6/a^2+12/a+8)^(1/3) ((2*a+1)^3/a^3)^(1/3) syms x y positive; log(x*y) log(x)+log(y) exp(x) * exp(y) exp(x+y) cos(x)^2 + sin(x)^2 1