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

(如图所示,内容以英文为准。图1是任务内容,图2是任务内容的中文翻译)

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)

追问

不知这几题会不会?

网页链接

网页链接

网页链接

网页链接

追答

第一道题回答完毕,审核通过了,显示出来了,可以采纳了.
第二道题回答完毕,正在申诉,请耐心等待....

追问

感谢回答,我到时再一次性采纳

追答

后面的第三第四题,我还没完全弄清楚,而且我还不知道有没有时间答后面两题.
所以如果没问题,就请先采纳第一第二题.

温馨提示:答案为网友推荐,仅供参考
第1个回答  2023-06-02
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.
相似回答