我是靠谱客的博主 舒服鸭子,这篇文章主要介绍嵌套乘法求函数值(Matlab),现在分享给大家,希望可以做个参考。

function y1 = nest(d,c,x)
% Evaluate the polymial from nested form and evaluate the error compared
% with another simpler method
% input:
% d:the degree of the polynomial
% c:the array of d+1 coefficients
% x:the x-coordinate at which to evaluate
% output:
% y:value of polynomial at x
y1 = c(d+1);
for i = d:-1:1
y1 = y1*x + c(i);
end
y2 = (1-x^100-x+x^101)/(1-x^2);
%using the sum formula to evaluate the polynimial
e = abs(y1-y2);
%evaluate the error
fprintf('the answer using nested multiplication is:');
disp(y1);
fprintf('the answer using sum formula is:')
disp(y2);
fprintf('the error is:');
disp(e);

最后

以上就是舒服鸭子最近收集整理的关于嵌套乘法求函数值(Matlab)的全部内容,更多相关嵌套乘法求函数值(Matlab)内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(120)

评论列表共有 0 条评论

立即
投稿
返回
顶部