Ahmadomari

20 Reputation

3 Badges

11 years, 340 days

MaplePrimes Activity


These are replies submitted by Ahmadomari

Your code look very interesting but could you please finish all of it because the target is not to find "list" bt to find MinChiSqr as it is shown in the code above.

Your code look very interesting but could you please finish all of it because the target is not to find "list" bt to find MinChiSqr as it is shown in the code above.

Dear Maple's expertise 

Here is the code in simpler way with the output. 

The peoblem that I am calling the procedure with the same input but from time to time it gives different output shown in bold below. Although I make  restart for Mape?Is it bug in maple??Any Suggestions please.Should make clearing for some varibale and how?

 

Thanks in advance

The code is

> restart;


> Chisqr1 := proc (w) local x, y, A, B, C, Ds, j, X, altern1, altern2, altern3, altern4, EqCo1, EqCo2, EqCo3, EqCo4, M, XX, M1, M2, MM, ChiSqr, Syss, SS, AA, BB, CC, DDs, S;

x := Vector([0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48]);

y := Vector([16759.00586, 19630.75977, 15190.14551, 11532.44141, 6447.006836, 7827.111816, 3531.188965, 5167.17334, 10127.59277, 11626.91504, 5197.712402, 6539.370605, 6164.602539]);

for j from 1 to 13 do S := S+(y[j]-A-x[j]*B-C*cos(w*x[j])-Ds*sin(w*x[j]))^2 end do;

Syss := Student:-MultivariateCalculus:-Jacobian([S], [A, B, C, Ds]);

X := LinearAlgebra:-Transpose(Syss);

altern1 := simplify(LinearAlgebra:-Determinant(X[1]));

altern2 := simplify(LinearAlgebra:-Determinant(X[2]));

altern3 := simplify(LinearAlgebra:-Determinant(X[3]));

altern4 := simplify(LinearAlgebra:-Determinant(X[4]));

EqCo1 := coeffs(altern1, [A, B, C, Ds]);

EqCo2 := coeffs(altern2, [A, B, C, Ds]);

EqCo3 := coeffs(altern3, [A, B, C, Ds]);

EqCo4 := coeffs(altern4, [A, B, C, Ds]);

M := ArrayTools:-Concatenate(2, EqCo1, EqCo2, EqCo3, EqCo4);

XX := convert(M, Matrix);

M1 := ArrayTools:-Concatenate(1, ArrayTools:-Concatenate(1, linalg:-col(XX, 1 .. 5)), ArrayTools:-Concatenate(1, linalg:-col(XX, 6 .. 10)), ArrayTools:-Concatenate(1, linalg:-col(XX, 11 .. 15)), ArrayTools:-Concatenate(1, linalg:-col(XX, 16 .. 20)));

MM := linalg:-swapcol(M1, 1, 5);

M2 := linalg:-gaussjord(MM);

AA := M2[1, 5];

BB := M2[2, 5];

CC := M2[3, 5];

DDs := M2[4, 5];

SS := 0;

for j from 1 to 13 do SS := SS+(y[j]-AA-x[j]*BB-CC*cos(w*x[j])-DDs*sin(w*x[j]))^2 end do end proc;

for wx from 1 to 200 do ChiSqr2 := Chisqr1(7.14371);

printf("%f\n", ChiSqr2);

end do;

 

 

The output: Idon't know From where the bold output is coming from??

5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
2441295475000.000000
5180185704.000000
5180185704.000000
2323901683.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
2441295475000.000000
5180185704.000000
5180185704.000000
2323901683.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
2441295475000.000000
5180185704.000000
5180185704.000000
2323901683.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
2441295475000.000000
5180185704.000000
5180185704.000000
2323901683.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
3027269579.000000
5180185704.000000
5180185704.000000

Dear Maple's expertise 

Here is the code in simpler way with the output. 

The peoblem that I am calling the procedure with the same input but from time to time it gives different output shown in bold below. Although I make  restart for Mape?Is it bug in maple??Any Suggestions please.Should make clearing for some varibale and how?

 

Thanks in advance

The code is

> restart;


> Chisqr1 := proc (w) local x, y, A, B, C, Ds, j, X, altern1, altern2, altern3, altern4, EqCo1, EqCo2, EqCo3, EqCo4, M, XX, M1, M2, MM, ChiSqr, Syss, SS, AA, BB, CC, DDs, S;

x := Vector([0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48]);

y := Vector([16759.00586, 19630.75977, 15190.14551, 11532.44141, 6447.006836, 7827.111816, 3531.188965, 5167.17334, 10127.59277, 11626.91504, 5197.712402, 6539.370605, 6164.602539]);

for j from 1 to 13 do S := S+(y[j]-A-x[j]*B-C*cos(w*x[j])-Ds*sin(w*x[j]))^2 end do;

Syss := Student:-MultivariateCalculus:-Jacobian([S], [A, B, C, Ds]);

X := LinearAlgebra:-Transpose(Syss);

altern1 := simplify(LinearAlgebra:-Determinant(X[1]));

altern2 := simplify(LinearAlgebra:-Determinant(X[2]));

altern3 := simplify(LinearAlgebra:-Determinant(X[3]));

altern4 := simplify(LinearAlgebra:-Determinant(X[4]));

EqCo1 := coeffs(altern1, [A, B, C, Ds]);

EqCo2 := coeffs(altern2, [A, B, C, Ds]);

EqCo3 := coeffs(altern3, [A, B, C, Ds]);

EqCo4 := coeffs(altern4, [A, B, C, Ds]);

M := ArrayTools:-Concatenate(2, EqCo1, EqCo2, EqCo3, EqCo4);

XX := convert(M, Matrix);

M1 := ArrayTools:-Concatenate(1, ArrayTools:-Concatenate(1, linalg:-col(XX, 1 .. 5)), ArrayTools:-Concatenate(1, linalg:-col(XX, 6 .. 10)), ArrayTools:-Concatenate(1, linalg:-col(XX, 11 .. 15)), ArrayTools:-Concatenate(1, linalg:-col(XX, 16 .. 20)));

MM := linalg:-swapcol(M1, 1, 5);

M2 := linalg:-gaussjord(MM);

AA := M2[1, 5];

BB := M2[2, 5];

CC := M2[3, 5];

DDs := M2[4, 5];

SS := 0;

for j from 1 to 13 do SS := SS+(y[j]-AA-x[j]*BB-CC*cos(w*x[j])-DDs*sin(w*x[j]))^2 end do end proc;

for wx from 1 to 200 do ChiSqr2 := Chisqr1(7.14371);

printf("%f\n", ChiSqr2);

end do;

 

 

The output: Idon't know From where the bold output is coming from??

5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
2441295475000.000000
5180185704.000000
5180185704.000000
2323901683.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
2441295475000.000000
5180185704.000000
5180185704.000000
2323901683.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
2441295475000.000000
5180185704.000000
5180185704.000000
2323901683.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
2441295475000.000000
5180185704.000000
5180185704.000000
2323901683.000000
5180185704.000000
5180185704.000000
5180185704.000000
5180185704.000000
3027269579.000000
5180185704.000000
5180185704.000000

Hi:

Here is the same code again with the same input data. When I call the procedure inside a for loop(say , 3 times),which appears at the end of the code . The problem there were results different in each run (some numbers not all of them).Although the input data the same and I do restart for maple, using restart command.Any Suggestions please.

The code again:

 

Chisqr1 := proc (w)

local x, y, S, A, B, C, Ds, j, Syss, X, altern1, altern2, altern3, altern4, EqCo1, EqCo2, EqCo3, EqCo4, M, XX, M1, M2, MM, ChiSqr;

S := 0;

Syss := 0;

x := Vector([0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48]);

y := Vector([16759.00586, 19630.75977, 15190.14551, 11532.44141, 6447.006836, 7827.111816, 3531.188965, 5167.17334, 10127.59277, 11626.91504, 5197.712402, 6539.370605, 6164.602539]);

S := 0;

for j from 1 to 13 do S := S+(y[j]-A-x[j]*B-C*cos(w*x[j])-Ds*sin(w*x[j]))^2 end do;

Syss := Student:-MultivariateCalculus:-Jacobian([S], [A, B, C, Ds]);

X := LinearAlgebra:-Transpose(Syss);

altern1 := simplify(LinearAlgebra:-Determinant(X[1]));

altern2 := simplify(LinearAlgebra:-Determinant(X[2]));

altern3 := simplify(LinearAlgebra:-Determinant(X[3]));

altern4 := simplify(LinearAlgebra:-Determinant(X[4]));

EqCo1 := coeffs(altern1, [A, B, C, Ds]);

EqCo2 := coeffs(altern2, [A, B, C, Ds]);

EqCo3 := coeffs(altern3, [A, B, C, Ds]);

EqCo4 := coeffs(altern4, [A, B, C, Ds]);

M := ArrayTools:-Concatenate(2, EqCo1, EqCo2, EqCo3, EqCo4);

XX := convert(M, Matrix);

M1 := ArrayTools:-Concatenate(1, ArrayTools:-Concatenate(1, linalg:-col(XX, 1 .. 5)), ArrayTools:-Concatenate(1, linalg:-col(XX, 6 .. 10)), ArrayTools:-Concatenate(1, linalg:-col(XX, 11 .. 15)), ArrayTools:-Concatenate(1, linalg:-col(XX, 16 .. 20)));

MM := linalg:-swapcol(M1, 1, 5);

M2 := linalg:-gaussjord(MM);

A := M2[1, 5]; B := M2[2, 5];

C := M2[3, 5];

Ds := M2[4, 5]; S := 0; for j to 13 do

S := S+(y[j]-A-x[j]*B-C*cos(w*x[j])-Ds*sin(w*x[j]))^2 end do;

evalf(%) end proc;

for indexSubunit from 1 to 3 do

for wx from 1 to 200 do

ChiSqr2 := Chisqr1(wx-1+0.14371);

printf("%f\n", %)

end do;

printf("\n")

end do: 

Hi:

Here is the same code again with the same input data. When I call the procedure inside a for loop(say , 3 times),which appears at the end of the code . The problem there were results different in each run (some numbers not all of them).Although the input data the same and I do restart for maple, using restart command.Any Suggestions please.

The code again:

 

Chisqr1 := proc (w)

local x, y, S, A, B, C, Ds, j, Syss, X, altern1, altern2, altern3, altern4, EqCo1, EqCo2, EqCo3, EqCo4, M, XX, M1, M2, MM, ChiSqr;

S := 0;

Syss := 0;

x := Vector([0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48]);

y := Vector([16759.00586, 19630.75977, 15190.14551, 11532.44141, 6447.006836, 7827.111816, 3531.188965, 5167.17334, 10127.59277, 11626.91504, 5197.712402, 6539.370605, 6164.602539]);

S := 0;

for j from 1 to 13 do S := S+(y[j]-A-x[j]*B-C*cos(w*x[j])-Ds*sin(w*x[j]))^2 end do;

Syss := Student:-MultivariateCalculus:-Jacobian([S], [A, B, C, Ds]);

X := LinearAlgebra:-Transpose(Syss);

altern1 := simplify(LinearAlgebra:-Determinant(X[1]));

altern2 := simplify(LinearAlgebra:-Determinant(X[2]));

altern3 := simplify(LinearAlgebra:-Determinant(X[3]));

altern4 := simplify(LinearAlgebra:-Determinant(X[4]));

EqCo1 := coeffs(altern1, [A, B, C, Ds]);

EqCo2 := coeffs(altern2, [A, B, C, Ds]);

EqCo3 := coeffs(altern3, [A, B, C, Ds]);

EqCo4 := coeffs(altern4, [A, B, C, Ds]);

M := ArrayTools:-Concatenate(2, EqCo1, EqCo2, EqCo3, EqCo4);

XX := convert(M, Matrix);

M1 := ArrayTools:-Concatenate(1, ArrayTools:-Concatenate(1, linalg:-col(XX, 1 .. 5)), ArrayTools:-Concatenate(1, linalg:-col(XX, 6 .. 10)), ArrayTools:-Concatenate(1, linalg:-col(XX, 11 .. 15)), ArrayTools:-Concatenate(1, linalg:-col(XX, 16 .. 20)));

MM := linalg:-swapcol(M1, 1, 5);

M2 := linalg:-gaussjord(MM);

A := M2[1, 5]; B := M2[2, 5];

C := M2[3, 5];

Ds := M2[4, 5]; S := 0; for j to 13 do

S := S+(y[j]-A-x[j]*B-C*cos(w*x[j])-Ds*sin(w*x[j]))^2 end do;

evalf(%) end proc;

for indexSubunit from 1 to 3 do

for wx from 1 to 200 do

ChiSqr2 := Chisqr1(wx-1+0.14371);

printf("%f\n", %)

end do;

printf("\n")

end do: 

Thanks very much for your help. I appriciate that.

Thanks very much for your help. I appriciate that.

Page 1 of 1