Numerical integration/Gauss-Legendre Quadrature: Difference between revisions

Content added Content deleted
(Add Axiom example)
Line 45: Line 45:


=={{header|Axiom}}==
=={{header|Axiom}}==
Axiom provides Legendre polynomials and related solvers.<lang Axiom>digits(50)
Axiom provides Legendre polynomials and related solvers.<lang Axiom>NNI ==> NonNegativeInteger
NNI ==> NonNegativeInteger
RECORD ==> Record(x : List Fraction Integer, w : List Fraction Integer)
RECORD ==> Record(x : List Fraction Integer, w : List Fraction Integer)


Line 62: Line 61:
h := (b-a)/2
h := (b-a)/2
h*reduce(+,[wi*f(c+xi*h) for xi in u.x for wi in u.w])
h*reduce(+,[wi*f(c+xi*h) for xi in u.x for wi in u.w])
</lang>Examples:<lang Axiom>f(x) == 4/(1+x^2)
</lang>Examples:<lang Axiom>digits(50)
gaussInt(x +-> 4/(1+x^2), 0, 1, 20)
Type: Void
gaussInt(f,0,1,20)


(1) 3.1415926535_8979323846_2643379815_9534002592_872901276
(1) 3.1415926535_8979323846_2643379815_9534002592_872901276
Line 78: Line 76:
% - integrate(exp(x),x=-3..3)
% - integrate(exp(x),x=-3..3)


(10) - 0.0001721364_3424164402_0651513656_5621888545_81038919
(4) - 0.0001721364_3424164402_0651513656_5621888545_81038919
Type: OrderedCompletion(Expression(Float))</lang>
Type: OrderedCompletion(Expression(Float))</lang>