I am trying to integrate the function I have to find the value of N which makes the highest precision possible, when using the double float, which I have run the program with moving values, by n constant values of N There is no difference between the given formulas. However I am stuck in an infinite loop. Thanks Beth 1 / ((1 + x ^ 2) x ^ 0.5) I am using the Triplizium rule between 0 and infinity 0.
contains # lt; Stdio.h & gt; # Include & lt; Math.h> # Include & lt; Float.h & gt; Double differential (double x, double h, double y, double n, double total) {h = (y-x) / (n -1); Total = total + 0.5 * (1 / ((1 + pow (x, 2)) * SQL); X = x + h; While (x & lt; y) {total = total + (1 / ((1 + pau (x, 2)) * scert (x)); X = x + h; // printf ("t -% lf \ n", total); // printf ("x -% lf \ n", x); } Total = total + 0.5 * (1 / ((1 + pau (x, 2)) * scert (x)); Total = Total * h; Total return; } Main () {Double X, Y, Total, H, C, D, F, N, Finnish; X = DBL_EPSILON; Y = 331; Total = 0; N = 0.5; C = difference (x, h, y, n, total); D = 0; Finish = 0; While (end == 0) {d = difference (x, h, y, n, total); If (D == C) {ends = 1; } And {c = d; D = 0; H ++; Printf ("% lf / n", h); }} Printf ("% lf \ n", d); }
your iter ()
function, in H
is negative, which causes x
becomes negative. Returns a negative number sqrt ()
returns NaN
. In addition, because h
is negative, x
is reduced, thus always is less than y
, Which is the reason for the infinite loop.
h
is negative because the denominator ( N-1
) -0.5
(n passed as 0.5 is).
No comments:
Post a Comment