-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (29 loc) · 696 Bytes
/
main.cpp
File metadata and controls
40 lines (29 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<stdio.h>
#include "recipes.h"
#include<iostream>
#include <cmath>
// #include <array>
using namespace std;
long double f(long double x, long double y) {
long double u = 0.1/0.25;
return -2 * y / ( u * sqrt(1 + pow(y, 2)));
}
int main()
{
// const size_t N = 100;
// array<long double, N> x, y;
int N = 100;
long double x[N], y[N];
long double xmin = 0., xmax = 0.5;
long double h = (xmax - xmin) / (N - 1);
for (int k = 0; k < N; k++) {
x[k] = xmin + k*h;
}
long double y0 = 1.5;
long double (*func)(long double, long double) = &f;
Euler1D(func, y0, N, x, y);
// RungeKutta(func, y0, N, x, y);
for (const auto& e : y) {
std::cout << e << std::endl;
}
}