function f=tridiag(a,b,c,f)
    n=length(b);
    for i=1:n-1
        a(i)=a(i)/b(i);
        b(i+1)=b(i+1)-a(i)*c(i);
    end
    for i=1:n-1
        f(i+1)=f(i+1)-a(i)*f(i);
    end
    f(n)=f(n)/b(n);
    for i=n-1:-1:1
        f(i)=(1/b(i))*(f(i)-c(i)*f(i+1));
    end
end
