¸ÞÀϺ¸³»±â

À̸§°Ë»ö

::: SHIN, Byeong-Chun's Board


97 510 Åë°èÄ«¿îÅÍ º¸±â   ȸ¿ø °¡ÀÔ È¸¿ø ·Î±×ÀÎ °ü¸®ÀÚ Á¢¼Ó --+
Name   ½Åº´Ãá
Subject   Near Minimax interpolation
% cheb_interp.m
% A near-minimax approximation polynomial interpolation of f(x)
% Using Chebyshev-Gauss points as nodes
function cheb_interp(n,a,b)
f = @(x) cos(x);  % Function to be interpolated
xjc = cos(pi*(2*[0:n]+1)./(2*n+2));  % Chebyshev points [-1,1]
xje = linspace(-1,1,n+1);  % Equispaced points
xjc = (xjc+1)/2*(b-a)+a;  xje = (xje+1)/2*(b-a)+a; % transform to [a,b]
yjc = f(xjc);  yje = f(xje); % y-data
xv = linspace(a,b,201);      % x-values for figure
fv = f(xv);                  % y-values of function f(x)
yvc = interp_dd(xjc,yjc,xv); % y-values of interpolation with Cheby
yve = interp_dd(xje,yje,xv); % y-values of interpolation with Equispace pts
% plot
plot(xv,fv-yvc,'r',xv,fv-yve,'b'); grid
title('Error plots of interpolation using Chebyshev(Red), Equispace(Blue)')
xlabel X ; ylabel Y

%%%% Subroutine %%%
% Find interpolation using divide difference method
function yvalues = interp_dd(nodes,fnodes,xvalues);
  m = length(nodes);
  dd = divdif(nodes,fnodes);
  yvalues = dd(m)*ones(size(xvalues));
  for i=m-1:-1:1
      yvalues = dd(i) + ( xvalues-nodes(i) ).*yvalues;
  end
% Find divide differences
function dd = divdif(x,f)
  dd = f;
  m = length(x);
  for i=2:m
      for j=m:-1:i
          dd(j) = ( dd(j)-dd(j-1) )/( x(j)-x(j-i+1) );
      end
  end  

°Ô½Ã¹°À» À̸ÞÀÏ·Î º¸³»±â ÇÁ¸°Æ®Ãâ·ÂÀ» À§ÇÑ È­¸éº¸±â
DATE: 2013.05.13 - 15:46


 ÀÌÀü±Û Least-squares method to approximate a function
 ´ÙÀ½±Û ¼öÇÐ2 ¼ºÀû
±Û³²±â±â»èÁ¦Çϱâ¼öÁ¤Çϱâ´äº¯´Þ±âÀüü ¸ñ·Ï º¸±â