Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- private:
- QVector<double> xI(N), yI(N);
- */
- void MainWindow::on_pushButton_2_clicked()
- {
- float a = 0.2;
- int b = 1.8;
- float x;
- float y;
- int n = 80;
- double dx = (b - a) / n;
- double integral = (sqrt(a+1)*cos(a*a) + sqrt(b+1)*cos(b*b))/2;
- double intCurve;
- double idX;
- for (int i = 1; i < n; i++) {
- x = a + i*dx;
- y = sqrt(x+1)*cos(x*x);
- integral += y;
- }
- integral *= dx;
- for (int j = 1; j < n; j++) {
- idX = (b - a) / n;
- this->xI(j) = a + j*dx;
- y = sqrt(x+1)*cos(x*x);
- intCurve += (sqrt(a+1)*cos(a*a) + sqrt(b+1)*cos(b*b))/2;
- this->yI(j) += intCurve += y;
- b = this->yI(j);
- }
- QMessageBox::information (this, "Integral", QString("Result: %1").arg(integral));
- }
- void MainWindow::on_pushButton_3_clicked()
- {
- double a = 0;
- double b = 20;
- double n = 0;
- double m = 5;
- double h = 0.01;
- int N=(b-a)/h + 2;
- QVector<double> x(N), y(N);
- int i=0;
- for (double X=a; X<=b; X+=h) {
- x[i] = X;
- y[i] = (sqrt(X+1)*cos(X*X));
- i++;
- }
- ui->widget->addGraph();
- ui->widget->graph(0)->setData(x, y);
- ui->widget->xAxis->setLabel("X");
- ui->widget->yAxis->setLabel("Y");
- ui->widget->xAxis->setRange(a, b);
- ui->widget->yAxis->setRange(n, m);
- ui->widget->replot();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement