查看单个帖子
旧 2019-11-26, 21:01   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
默认 Horner's algorithm using matrices

I am working o this question but I am having some difficulties as this is my first year of doing any type of programming



Write a non-recursive function HornerSimple which evaluates a polynomial p(x) using the Horner algorithm. The function should return the value of the polynomial for a given x and coefficient list a. It should be passed the following two arguments in exactly this order, i.e. it should be called as HornerSimple(a,x):
a : The list a = [a0, a1, . . . , an] of integer coefficients. Note that Matlab starts counting at 1, i.e. a(1) stores a0, a(2) stores a1 and so on; a contains n + 1 entries.
x : The integer number or a square matrix with integer entries at which the polynomial is evaluated.



The function HornerSimple should also work in the special case when the list a=[] is empty. In this case it
should return a zero matrix of the same size as x (and the 1 × 1 matrix [0] if x is a number).



[This is my code so far but I get error when I test it and I do not know how to change it to make it correct1





More answer...
poster 当前离线   回复时引用此帖