I am working on my homework, which is exercise 11.2b) from "Numerical Linear Algebra" by Trefethen.
The exercise asks me to fit a function $f(x) = \dfrac{1}{x}$ by a linear combination of the functions $e^x, \sin(x)$ and gamma function $\Gamma(x)$ on $[0,1]$ using Matlab. They also state that the following fact might be helpful: if $g(x)=\dfrac{1}{\Gamma(x)}$, then $g'(0)=1$.
I have written a Matlab code solving the least-square problem. I let $x$ is linspace(0,1,1000) and $A$ is matrix whose columns are $e^x, \sin(x), \Gamma(x)$. Then, the coefficients are computed by using this code on Matlab: $A\backslash b$. However, it turns out to be wrong. Moreover, if I did it this way, I did not use the fact they give me.
Can somebody please give me any idea on this? Any help is really appreciated!