Task 4 and 5 are done
This commit is contained in:
parent
6efd4f5786
commit
67a26248b1
13 changed files with 285 additions and 90 deletions
|
@ -3,12 +3,24 @@
|
|||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
int t3_solve (
|
||||
double t4_solve (
|
||||
double (*f) (double),
|
||||
double x, double h
|
||||
double a, double b,
|
||||
int n
|
||||
) {
|
||||
if (h < DBL_EPSILON)
|
||||
const double h = (b - a) / n;
|
||||
double x = a;
|
||||
double sum = (f(a) + f(b)) * 0.5;
|
||||
|
||||
if (h < NUM_FPE)
|
||||
return DBL_MAX;
|
||||
return (f(x + h) - 2 * f(x) + f(x - h)) / (h * h);
|
||||
|
||||
for (int i = 1; i < (n - 1); ++i)
|
||||
{
|
||||
x += h;
|
||||
sum += f(x);
|
||||
}
|
||||
|
||||
return h * sum;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue