numerical - gauss-legendre in c++ -


I am trying to create the Gauss-Pound code according to the following algorithms:

For n points

That is, it has been created 2n equation system (if We demand the order 2n-1,

and Wi:

  #include & lt; iostream & gt; # list; cstido & gt; #include & lt; cstdlib & gt; Gt; # Include & lt; iomanip & gt; # Include & lt; cmath & gt; Namespace std; const double pi = 3.14; // My work with border (-1,1) double F (double X) ) {Double y; Y = (pi / 4.0) * (log ((* pi * (x + 1.0)) / 4.0 +1.0); return y;} double legend (int n) {double * l, * w, * t; double x , Zodiac 1, zodiac 2, results; l = new double [n]; w = new double [n]; t = new double [n]; while (n  Eps) {Results = pound (n); Cout & lt; & Lt; "\ Nfor n =" & lt; & Lt; N & lt; & Lt; ", Error =" & lt; & Lt; Fibers (error-precision) & lt; & Lt; ", Value =" & lt; & Lt; result; N ++; } Return 0; }   

My problems are:

1) The compiler gives me: Error: invalid operands of types "double" * ??? And "dual" binary one operator * รข ???? - & gt; As a result = w * f (* t);

2) I'm not sure that I have done the whole thing right. I mean, if I mixed all the things together and if I implemented the right algorithm.

I do not know the algorithm but your code is wrong.
first:

  while (n <10) {l [0] = 1; L [1] = X; (Li [i + 1] = // pound condom (int i = 1; i & lt; = 10 for (* 2.0 * i + 1.0) * x * l [i] - i * l [i-1] ; I ++)) / (i 1.0 +);}   

You should change the value of n (increment, subtraction, etc.) otherwise it is an endless Loop.

Second:

  // weight ww = 0; (Ii = 1; i   

If you want to reset it, use memset (w, 0, sizeof (double) * n); Do not become equal to 0; .

Last:

  results = W * f (* t);   

Since you are using w and t as punctuation points, you Some types of index such as must be given = or [IND] * F (T [IND]); Here you are multiplying the value of pointer w Is not that which is the value of the w ( w is the value of your code) the first value of the double array indicated by t with.

In addition, I could not find any connection between your code and the formulas. Therefore, my modest advice is that do not use C or C ++ for this. If you want, do not use the indicators, because it seems that you are not familiar with them. You can easily get the std :: vector instead of the indicator.

Comments