08-23-2015, 07:01 PM
Hello,
First of all sorry for my bad English .
I'm making a program to calculate integrals by gaussian quadrature and I have the following problem , I've done two different ways.
Program 1 , due to the unique character of this calculator , sometimes it works, sometimes not , so i try to make the program 2
Program 2 , do not put the correct result in a0 .
Program 1
Programa 2
Let's see if someone can lend me a hand, thanks .
First of all sorry for my bad English .
I'm making a program to calculate integrals by gaussian quadrature and I have the following problem , I've done two different ways.
Program 1 , due to the unique character of this calculator , sometimes it works, sometimes not , so i try to make the program 2
Program 2 , do not put the correct result in a0 .
Program 1
Code:
#pragma mode( separator(.,;) integer(h64) )
EXPORT Cuadratura_Gaussiana()
// Calculo de las raices de los polinomios de Legendre
BEGIN
local i,aux;
local nr:=3;
M1:=makemat(0,nr,2); // 1ª col factores de ponderación ,2ª col raices
// Cálculo de las raices de los polinomios de Legendre
M2:=CAS.zeros(legendre(nr));
// Cálculo de los coeficientes
F1:=CAS.diff(legendre(nr));
for i from 1 to nr do
M1(i,2):=M2(i);
aux:=F1(M2(i));
M1(i,2):=2/((1-M2(i)^2)*(aux^2)); // coeficiente
end;
end;
Programa 2
Code:
#pragma mode( separator(.,;) integer(h64) )
coeficientes();
EXPORT Cuadratura_Gaussiana()
BEGIN
local n:=3;
M1:=makemat(0,n,4);
coeficientes(n);
msgbox("Orden de las columnas: c_i, r_i , F(r_i), c_i*F(ri)");
editmat(M1);
end;
#cas
coeficientes(nr):=
BEGIN
// Cálculo de las raices y los coeficientes para la cuadratura gaussiana de de nr términos
local i,a0;
M2:=zeros(legendre(nr)); //raices del polinomio
// Cálculo de los coeficientes de ponderacion
for i from 1 to nr do
M1(i,2):=M2(i);// raiz del polinomio;
a0:=subst(diff(legendre(nr)),x=M2(i));
L1(i):=a0;
M1(i,1):=2/((1-M2(i)^2)*(a0^2));//coeficiente;
end;
END;
#end
Let's see if someone can lend me a hand, thanks .