Tuesday, August 6, 2019

Bary: The Barycentric Interpolation in MatLab


Purpose
  • The library "Bary" provides MatLab functions for the barycentric interpolation.

Click Here to Download the Codes


Specifications
  • Name:Bary
  • Author: Feng Chen
  • Version: 1.0
  • Language: MATLAB

Simple Example
  • Equation: c1(x)u(x)+c2(x)u(x)+c3(x)u(x)=f(x),Ω=(a,b),u satisifies the general boundary condition.
  • Parameters: c1(x)=4x2,c2(x)=3x,c3(x)=2.
  • Exact solution and input functions: u(x)=sinx,
    then f(x) is calculated accordingly.

Quick Start
  • Compiling and running:
    matlab test_bvp
    
  • Output:
     
    error =
    
       1.1180e-13
    
  • CPU: Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
  • OS: Ubuntu 18.04.
  • Release: MATLAB R2019a.

References
  • Tee, T. & Trefethen, L. A Rational Spectral Collocation Method with Adaptively Transformed Chebyshev Grid Points, SIAM Journal on Scientific Computing, Volume 28, Number 5, 1798-1811, (2006).

Core Subroutines
    
    
    function [P L U A] = bc_bvp_matrix(c1, c2, c3, a1, a2, b1, b2, D1, D2)
    
    n = length(c1);
    A = diag(c1)*D2 + diag(c2)*D1 + diag(c3);
    A(1,:) = a1*[1 zeros(1,n-1)] + b1*D1(1,:);
    A(n,:) = a2*[zeros(1,n-1) 1] + b2*D1(n,:);
    [L,U,P] = lu(A); 
    
    
    
    

No comments:

Post a Comment