1

I am trying to calculate a two point Gaussian Quadrature on the interval [0,4] and the function f_n = (x^n) + 2 x - 3 for n = {4, 5, 6}. I want to compare the results I get using Gaussian quadrature done out versus the built in. This is what I have so far but for some reason my f keeps printing in my answer despite being defined.

a = 0;
b = 4;
f[x_] = x^n + 2 x - 3;
n = {4, 5, 6};
Subscript[c, 1] = Abs[b - a]/2
Subscript[c, 2] = Abs[b - a]/2
Subscript[x, 1] = (b - a)/2 (-1/Sqrt[3]) + (b + a)/2
Subscript[x, 2] = (b - a)/2 (1/Sqrt[3]) + (b + a)/2
(*\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(a\), \(b\)]\(f\((x)\)\
\[DifferentialD]x\)\) \[Equal] Subscript[c, 1] f(Subscript[x, \
1])+Subscript[c, 2] f(Subscript[x, 2])*)
\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(a\), \(b\)]\(f \((x)\) \
\[DifferentialD]x\)\)
Subscript[c, 1] f (Subscript[x, 1]) + 
 Subscript[c, 2] f (Subscript[x, 2])
m_goldberg
  • 107,779
  • 16
  • 103
  • 257

0 Answers0