Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters

function [eps_original, eps_accelerated] = CL4_PiEstimate(N)
% Input
% N: maximum value of n (refer to computer lab slides)
% Output
% eps_original: True Percent Relative Error of the original estimate
% eps_accelerated: True Percent Relative Error of the accelerated estimate
eps_original = 0;
eps_accelerated = 0;
%Vector and matrix needed for computation
v = zeros(1,N+1);
M = zeros(N+1,N+1);
pi_estimate=0;
%Write Your Code Here
num = 1;
for n=1:N+1
v(n)= 4(-1)^(n-1)/(2(n-1)+1)+pi_estimate
pi_estimate=v(n)
end
Set M(1,1:N+1)=v(1:N+1)
for n = 1:N
for j = 1:N-n+1
M(n+1,j)=(M(n,j)+M(n,j+1))/2;
end
end
end

1 个评论

This is my code for accelerated Maclaurin series, but I am stuck on (n)= 4(-1)^(n-1)/(2(n-1)+1)+pi_estimate for the above errors, even though I am not sure if my code is correct entirely, I want to fix this error first. I appreciate any help!

请先登录,再进行评论。

回答(1 个)

类别

帮助中心File Exchange 中查找有关 Parallel Computing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by