--- /dev/null
+function c_norm = c_norm(w, a, b, v)
+ ##
+ ## The norm on C[a,b] induced by c_inner_product.
+ ##
+ ## INPUT:
+ ##
+ ## * ``w`` -- The weight function.
+ ##
+ ## * ``a`` -- The left endpoint of the interval.
+ ##
+ ## * ``b`` -- The right endpoint of the interval.
+ ##
+ ## * ``v`` -- The vector.
+ ##
+ ## OUTPUT:
+ ##
+ ## The norm of `v`; that is, the inner product sqrt(<v, v>).
+ ##
+ c_norm = sqrt(c_inner_product(w, a, b, v, v));
+end
P = NA;
elseif (n == 0)
## One of our base cases.
- P = @(x) 1
+ P = @(x) 1;
elseif (n == 1)
## The second base case.
- P = @(x) x
+ P = @(x) x;
else
## Compute recursively.
- prev = legendre_p(n-1)
- prev_prev = legendre_p(n-2)
- P = @(x) (1/n)*( (2*n - 1)*prev(x) - (n-1)*prev_prev(x) )
+ prev = legendre_p(n-1);
+ prev_prev = legendre_p(n-2);
+ P = @(x) (1/n).*( (2*n - 1).*x.*prev(x) - (n-1).*prev_prev(x) );
end
end
P = NA;
else
## Compute the Legendre polynomial over [-1,1] and mangle it.
- P = legendre_p(n)
- P_tilde = @(x) P( (2/(b-a))*x + 1 - (2*b)/(b-a) )
+ P = legendre_p(n);
+ P_tilde = @(x) P( (2/(b-a)).*x + 1 - (2*b)/(b-a) );
end
end