# How can I solve the problem : Unrecognized function or variable 'polyeval'.

113 views (last 30 days)
jiangyifei zhu on 25 Jan 2020
Commented: Walter Roberson on 26 Jan 2020
I am using the MATLAB Online on windows in https://matlab.mathworks.com
Is that because I need to download the library(APP) for "polyevalpolyeval" by myself or I wrote any wrong codes?
% Evaluate Taylor polynomials for exp(x) about x = 0 on [-b, b].
% Initialized
b = input('Give the number b defining the interval [-b, b]');
h = b/10;
x = -b:h:b;
max_deg = 4;
% the coefficients are stored in c;
c = ones(max_deg+1, 1);
fact = 1;
for i = 1:max_deg
fact = i*fact;
c(i+1) = 1/fact;
end
This part goes wrong which said that Unrecognized function or variable 'polyeval'.
Error in exp_taylor (line 17)
p1 = polyeval(x,0,c,1);
% calculate the Taylor polynomials
p1 = polyeval(x,0,c,1);
p2 = polyeval(x,0,c,2);
p3 = polyeval(x,0,c,3);
p4 = polyeval(x,0,c,4);
% calculate the errors in the taylor polynomials
true = exp(x);
err1 = true-p1;
err2 = true-p2;
err3 = true-p3;
err4 = true-p4;
% print the errors in tabular format
diary exp_taylor
disp(' x exp(x) err1 err2 err3 err4')
for i =1:length(x)
fprintf('%7.3f%10.3f%14.3ef%14.3ef%14.3e\n',...
x(i),true(i),err1(i),err2(i),err3(i),err4(i))
end
diary off

Walter Roberson on 25 Jan 2020
jiangyifei zhu on 26 Jan 2020
Thanks! I have one more question that as I download the file, how can I execute my code by using that file online?
Walter Roberson on 26 Jan 2020
Copy and paste the function from https://www.mathworks.com/matlabcentral/answers/122115-taylor-polynomial-maximum-error into the editor of MATLAB Online and save it there.