algorithm - Trapez Method in Java -
I found a formula in calculating Trapejhoid method, it works as it should, but I do not know Why should I have the following lines in the Trape method :
yoga = 0.5 * bf + (h * yoga); First : tra [0] = 0.5 * done by the following command in I = i + 2
((B - A) / N) * (function (A) + function (B)); // Calculates the first step value of
Trape method for the next iteration:
/ ** * Next calculation step with Tripjh method * @param e-Louvre border * @param B. On the border * @ Param beef-Preepr step value * @param N -nmber of Divijning Rating * Return Integral area * / public static double Fajhej (Double a , Double b, double beef, int n) {double sum = 0; Double H = ((B - A) / N); For (int i = 1; i
function will be accompanied by a driver loop doubles the number of which The refinement is less than the threshold criterion, refining the approximate integral to the subdivision on each iteration, from a repetition to the difference.
By considering the function value, consider what is required when applying the Trepidoid rule on given. Now, consider the values of the functions required to divide each subinterval into half and apply trapezoid rules to those sub-channels. In the latter case, half of the required function values (give or take 1) are already the same as needed. The values already computed in the code presented are duplicated ( 0.5 * bef
), they only add new values ( i = i + 2
).
Note that for the code to be correct, it seems that the argument should be n
Comments
Post a Comment