用给定系数绘制多项式 [英] Plotting polynomial with given coefficients

查看:85
本文介绍了用给定系数绘制多项式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试绘制一个在数组中给出系数的多项式:

I'm trying to plot a polynomial with coefficients given in array:

  • 输入: [an,a(n-1),...,a0]
  • 输出:多项式 an x ^ n + a(n-1) x ^(n-1)+ ... + a0
  • input: [an,a(n-1),...,a0]
  • output: plot of polynomial anx^n + a(n-1)x^(n-1) + ... + a0

我想使用matplotlib polt()函数,以便可以在我的julia项目中使用它.任何帮助,将不胜感激 :)

I would like to use matplotlib polt() function so I can use it in my julia project. Any help would be appreciated :)

推荐答案

如果您使用的是Julia的 Polynomials 包,则可以使用这种模式:

If you are using Julia's Polynomials package then something like this pattern will work:

<代码>p = Poly(reverse(ais))#Poly想要[a0,a1,...,an]xs = linspace(a,b,100)#填写a,b情节(xs,p.(xs))

如果您使用的是 plots ,则最后两行可能是 plot(x-> p(x),a,b).

If you are using Plots, the last two lines could be plot(x->p(x), a, b).

这篇关于用给定系数绘制多项式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆