Basic Learning of MATLAB -------- polynomials and their operations

Source: Internet
Author: User

Directly upload the Code (including detailed instances and comments)

% Polynomial and Its Operation % use the poly2sym () function to construct the polynomial % instance to construct the polynomial: 2 * x ^ 6 + 3 * x ^ 5 + 4 * x ^ 4 + 8 * x + 1A = [2 3 4 0 0 8 1]; poly2sym () % result ans = 2 * x ^ 6 + 3 * x ^ 5 + 4 * x ^ 4 + 8 * x + 1% polynomial root (that is, the polynomial expression = x corresponding to 0 value) % instance A = [2 3 4 0 0 8 1]; poly2sym (a) % constructor x = roots () % obtain the root of the polynomial % result ans = 2 * x ^ 6 + 3 * x ^ 5 + 4 * x ^ 4 + 8 * x + 1X =-0.7708 + 1.4984i-0.7708- 1.4984i-1.2805 0.7237 + 0.7586i 0.7237-0.7586i-0.1251%, x) % result ans = 1.0e-013 *-0.0111-0.0833i-0.0111 + 0.0833i 0.3453 0.0022 + 0.20.1i 0.0022-0.20.1i 0.0111% as shown in the result, the root obtained is an approximate value instead of an exact value % polynomial derivation polyder (h) % instance A = [2 3 4 0 0 8 1]; poly2sym () % construct polynomial x = polyder (a) % evaluate the polynomial poly2sym (x) % Show the polynomial % result after the derivation: ans = 2 * x ^ 6 + 3 * x ^ 5 + 4 * x ^ 4 + 8 * x + 1X = 12 15 16 0 0 8ans = 12 * x ^ 5 + 15 * x ^ 4 + 16 * x ^ 3 + 8% polynomial valuation polyval (p, x) % Where p represents the polynomial coefficient, X represents the point of the required value % if X is a matrix, polyvalm (p, x) is required) to implement % instance A = [2 3 4 0 0 8 1]; poly2sym (a) % to construct a polynomial polyval (A, [1 2 3 4]) % calculated polynomial value at x = 1 2 3 4% result ans = 2 * x ^ 6 + 3 * x ^ 5 + 4 * x ^ 4 + 8 * x + 1ans = 18 305 2536 12321% when X is a matrix, solve a = [1 0 1]; % x ^ 2 + 1B = [1 2 3; 4 5 6; 7 8 9] polyvalm (a, B) % is actually equivalent to directly replacing the two-dimensional matrix of B with the variable X, returns the Matrix Polynomial % result of B ^ 2 + e x = 1 2 3 4 5 6 7 8 9ans = 31 36 42 66 82 96 102 126 151% rational polynomial residue () the function is used to calculate the representation of rational polynomials % rational polynomials. The molecular denominator polynomials are used to represent % [R, P, K] = residue (B, A), where B represents the coefficients of the molecular polynomials, a Represents the coefficient of the denominator polynomial % instance B = [3 5 3 8]; poly2sym (B) % molecular polynomial A = [4 6 0-5]; poly2sym () % denominator polynomial [R, P, K] = residue (B,) % calculated rational polynomial % result R =-0.3939 + 0.7790i-0.3939-0.7790i 0.9127 P =-1.1230 + 0.6438i-1.1230-0.6438i 0.7460 K = 0.7500% result description B (s) R (1) R (2) R (n) ---- = -------- + .... + -------- + K (s) a (s) S-P (1) S-p (2) S-P (n)


Basic Learning of MATLAB -------- polynomials and their operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.