clear;clc
%
x=-0.9:0.1:0.9;
N=zeros(size(x));Y=zeros(size(x));
fork=1:length(x)
n=1;
y0=log(1+x(k)^2);
y=x(k)^2;
whileabs(y-y0)>1e-9
n=n+1;
y=y+(-1)^(n+1)*x(k)^(2*n)/n;
end
N(k)=n;
Y(k)=y;
end
figure;
subplot(2,1,1);plot(x,x.^2-x.^4/2+x.^6/3-x.^8/4,'r',x,Y,'b')
subplot(2,1,2);scatter(x,N)
不知道理解对错??