I’m trying to reproduce the sin(x) approximation example from “Linear algebra done right” using Maxima, but I get weird results. Here is my code:
load("eigen");
ip (f, g) := integrate (f * g, u, a, b);
basis: makelist (u^k, k, 0, 5);
e: gramschmidt (basis, ip), a=-%pi, b=%pi;
re: map(ip, makelist (sin(u), _, 1, 6), e)*e, a=-%pi, b=%pi;
expand(float(apply("+", re)));
which gives me 4.867477078388566*u^5 - 66.27194960446585*u^3 + 195.5285758118965*u
while the correct result is 0.987862*x − 0.155271*x^3 + 0.00564312*x^5
What am I doing wrong?