Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- const int N = 10;
- const int M = 400;
- const double T = 1.0;
- const double L = 1.0;
- const double h = L/N;
- const double tao = T/M;
- const double A = 5;
- const int C = 5;
- const int B = 1;
- #define UU(x,t) A*B*exp(x*h + t*tao)
- double f(int x, int t) {
- return ((ro(x, t) - kx(x) - k(x, t)*B - p(x, t) + q(x, t)/B)*B*A*exp(L + t*tao));
- }
- double k(double x, double t) {
- return (5 + pow(x*tao, 2) + pow(t*tao, 2));
- }
- double kx(double x) {
- return 2*x*h;
- }
- double p(double x, double t) {
- return (20 + pow(x*h, 2) + 0.5*pow(t*tao, 2));
- }
- double q(double x, double t) {
- return (x + 1 + cos(x));
- }
- double ro(double x, double t) {
- return (10 + x*h + t*tao);
- }
- int main() {
- double u[N+1][M+1] = {};
- //Начальное условие
- for(int i=0; i<N+1; i++) {
- u[i][0] = A*exp(B*i*h);
- }
- //Граничные условия
- for(int j=1; j<M+1; j++) {
- u[0][j] = A*exp(j*tao*B);
- u[N][j] = A*exp((L + j*tao)*B);
- }
- double a[N+1], b[N+1], c[N+1], alpha[N+1], beta[N+1];
- for(int j=0; j<M; j++) {
- alpha[0] = 0;
- beta[0] = C * exp(B * j * tao);
- for(int i=1; i<N; i++) {
- }
- }
- for(int j=M; j>=0; j--) {
- for(int i=0; i<N+1; i++) {
- cout << setprecision(5) << u[i][j] - UU(i,j) << "\t";
- }
- cout << endl;
- }
- cout << endl <<endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement