Python 编程,绘图与矩阵,详细在图里,求代码,急用

fx是方程f(x)的系数列表

gx是方程g(x)的系数列表

q是多项式g(x)除以f(x)的商

r是多项式g(x)除以f(x)的余数

rx是多项式f(x)乘以g(x)的结果

import numpy as np

fx=[1,-14,48]

fxroots=np.roots(fx)

print(fxroots)

gx=[1,-9,18,31,-102]

gxroots=np.roots(gx)

print(gxroots)

q,r=np.polynomial.polynomial.polydiv(gx,fx)

print(q,r)

rx=np.polynomial.polynomial.polymul(fx,gx)

print(rx)



a. To find the roots of the functions f(x) and g(x), we need to set the equations equal to zero and solve for x.
For f(x):
48 - 14x + x' = 0
For g(x):
-102 + 31x + 18x^2 - 9x^3 + x^4 = 0
b. To divide the polynomial g(x) by f(x), we perform polynomial long division:
Dividend: g(x) = -102 + 31x + 18x^2 - 9x^3 + x^4
Divisor: f(x) = 48 - 14x + x'
Performing long division, we have:
-2x^3 + 5x^2 - 4x + 1

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
48 - 14x + x' | x^4 - 9x^3 + 18x^2 + 31x - 102
- (x^4 - 9x^3 + 14x^2 - 2x^3 + 48 - 4x^2 + 5x - x' - 102)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
4x^2 - 4x + x' + 146
Therefore, the result of dividing g(x) by f(x) is:
g(x)/f(x) = -2x^3 + 5x^2 - 4x + 1 + (4x^2 - 4x + x' + 146) / (48 - 14x + x')
c. To multiply the polynomial f(x) by g(x), we simply multiply the two polynomials term by term:
f(x) * g(x) = (48 - 14x + x') * (-102 + 31x + 18x^2 - 9x^3 + x^4)
We can distribute and combine like terms to simplify the expression.

扩展阅读:少儿python编程自学 ... payton编程自学 ... 免费的python编程软件 ... python编程教学 ... python手机版下载安装 ... python matplotlib ... python初学编程必背 ... python编程免费网站 ... python绘图库大全 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网