Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- double f(double x, double y) {
- return - x * y;
- }
- int main(void) {
- double a = 0.;
- double b = 3.;
- int n = 1000;
- double h = (b - a) / n;
- double x = 0., ye = 1., yh = 1.;
- for (int i = 0; i < n; i++) {
- x += h;
- ye += h * f(x, ye);
- double k1 = f(x, yh);
- double k2 = f(x + h, yh + h * k1);
- yh += h * (k1 + k2) / 2.;
- printf("%lf %lf %lf\n", x, ye, yh);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement