Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdlib.h"
- #include "stdio.h"
- #include "math.h"
- double f(double x, double y) {
- return x*y;
- }
- double Y(double x) {
- return exp(x*x/2);
- }
- int main(int argc, char ** argv) {
- const double x0 = 0;
- const double y0 = 1;
- const double b = 1;
- const double eps = 0.0001;
- const int m = 1;
- const double h = pow(eps, 1.0 / m);
- const int n = (b - x0) / h;
- double x = x0;
- double y = y0;
- for (int i = 1; i <= n; i++) {
- y += f(x, y) * h;
- x = x0 + i * h;
- }
- printf("%f", fabs(Y(b) - y));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement