mode(0)

x=10+[0:100]/10;
y=x.^(-3)+1.0./x^2;
scf(0);
plot2d(x,y,leg="y==x.^(-3)+1.0./x^2");
scf(1);
plot2d(log(x),log(y),leg="log-log  y=x.^(-3)+1.0./x^2");

x=10+[0:100]/10;
y=x.^(-4)+1.0./x^3;
scf(2);
plot2d(x,y,leg="y=x.^(-4)+1.0./x^3");
scf(3);
plot2d(log(x),log(y),leg="log-log  y=x.^(-4)+1.0./x^3");

x=10+[0:100]/10;
y=x.^(-4)+1.0./x^5;
scf(4);
plot2d(x,y,leg="y=x.^(-4)+1.0./x^5");
scf(5);
plot2d(log(x),log(y),leg="log-log  y=x.^(-4)+1.0./x^5");

function y=f(x)
  y=x.*exp(x)
endfunction

function y=P(x)  
  y=f(-1)*(x-1).*(x-3)./(-1-1)/(-1-3)+f(1)*(x+1).*(x-3)/(+1+1)/(1-3)+f(3)*(x-1).*(x+1)/(3-1)/(3+1)
endfunction

Pexp1=P(1)
Pexp2=P(2)
x=-2:0.1:4;
y=f(x);
z=P(x);scf(6);
plot2d(x,y);plot2d(x,z,style=5,leg="y=x.*exp(x)");

function y=f(x)
  y=x.*cos(x)
endfunction

function y=P(x)  
  y=f(-1)*(x-1).*(x-3)./(-1-1)/(-1-3)+f(1)*(x+1).*(x-3)/(+1+1)/(1-3)+f(3)*(x-1).*(x+1)/(3-1)/(3+1)
endfunction

Pcos1=P(1)
Pcos2=P(2)
x=-2:0.1:4;
y=f(x);
z=P(x);scf(7);
plot2d(x,y);plot2d(x,z,style=5,leg="y=x.*cos(x)");

function y=f(x)
  y=x.*sin(x)
endfunction

function y=P(x)  
  y=f(-1)*(x-1).*(x-3)./(-1-1)/(-1-3)+f(1)*(x+1).*(x-3)/(+1+1)/(1-3)+f(3)*(x-1).*(x+1)/(3-1)/(3+1)
endfunction

Psin1=P(1)
Psin2=P(2)
x=-2:0.1:4;
y=f(x);
z=P(x);scf(8);
plot2d(x,y);plot2d(x,z,style=5,leg="y=x.*sin(x)");

function y=tche(n,x)
  if n=0 then y=1
  elseif n=1 then y=x
  else y=2*x.*tche(n-1,x)-tche(n-2,x)
  end
endfunction

x=-1:0.01:1;
y=tche(10,x);
scf(9);
plot2d(x,y,leg="10");
y=tche(10,x);
scf(6);
plot2d(x,y,leg="6");
y=tche(5,x);
scf(11);
plot2d(x,y,leg="5");

function y=tche2(n,x)
  L(1,:)=ones(x)
  L(2,:)=x
  for k =2:n
 L(k+1,:)=2*x.*L(k,:)-L(k-1)
end
y=L(n+1,:)
endfunction

sol702=[tche2(7,0.2),tche(7,0.2)]
sol703=[tche2(7,0.3),tche(7,0.3)]
sol807=[tche2(7,0.2),tche(7,0.2)]
x=-1:0.01:1;
y=tche(10,x);
scf(13);
plot2d(x,y);
  