• Tenglamaning ildizlarini grafik usulda ajrating va uning taqribiy yechimlarini e=0.001 aniqlikda yuqorida sanab o‘tilgan barcha usullar yordamida toping va natijalarni tahlil qiling.
  • 2.oddiy ketma-ketlik usuli
  • 1. oraliqni teng ikkita bo‘lish usuli include include double f(double x) { return log(x) * sqrt(x);
  • 3.Simpsonlar (parabolalar) usuli include include double f(double x) {
  • Simpsonlar (parabolalar) usuli include include double f(double x) {
  • Muhammad Al-Xorazmiy nomida Toshkent Axborot texnologiyalari universiteti




    Download 1,07 Mb.
    Sana21.05.2024
    Hajmi1,07 Mb.
    #247879
    Bog'liq
    al by farrukh





    Muhammad Al-Xorazmiy nomida Toshkent Axborot texnologiyalari universiteti

    2 - amaliy ish


    Bajardi: Zokirov Farruxbek

    1. amaliy

    24-variant
    1-topshiriq


    Tenglamaning ildizlarini grafik usulda ajrating va uning taqribiy yechimlarini e=0.001 aniqlikda yuqorida sanab o‘tilgan barcha usullar yordamida toping va natijalarni tahlil qiling.

    a)


    1.oraliqni teng ikkita bo‘lish usuli
    #include
    #include

    double f(double x) {


    return pow(x, 3) - 4*x + 1;
    }

    int main() {


    double a = 0.1; // boshlang'ich taxmin
    double b = 2.0; // oxirgi taxmin
    double epsilon = 1e-6; // aniqlik

    while (b - a > epsilon) {


    double c = (a + b) / 2.0;
    if (f(c) == 0.0) {
    break;
    } else if (f(a) * f(c) < 0.0) {
    b = c;
    } else {
    a = c;
    }
    }

    double x = (a + b) / 2.0;


    std::cout << "Tenglama ildizi " << x << " ga teng" << std::endl;

    return 0;


    }

    2.oddiy ketma-ketlik usuli
    #include
    #include

    double f(double x) {


    return pow(x, 3) - 4*x + 1;
    }

    int main() {


    double x = 0.1; // boshlang'ich taxmin
    double epsilon = 1e-6; // aniqlik
    double dx = 0.01; // qadam o'lchami

    while (abs(f(x)) > epsilon) {


    x = x + dx;
    }

    std::cout << "Tenglama ildizi " << x << " ga teng" << std::endl;


    return 0;


    }



    3. urinmalar usuli
    #include
    #include

    double f(double x) {


    return pow(x, 3) - 4*x + 1;
    }

    double df(double x) {


    return 3*pow(x, 2) - 4;
    }

    int main() {


    double x = 1.0; // boshlang'ich taxmin
    double epsilon = 1e-6; // aniqlik

    while (abs(f(x)) > epsilon) {


    x = x - f(x) / df(x);
    }

    std::cout << "Tenglama ildizi " << x << " ga teng" << std::endl;


    return 0;


    }

    b)
    1. oraliqni teng ikkita bo‘lish usuli
    #include
    #include


    double f(double x) {
    return log(x) * sqrt(x);
    }


    int main() {
    double a = 0.1; // boshlang'ich taxmin
    double b = 2.0; // oxirgi taxmin
    double epsilon = 1e-6; // aniqlik


    while (b - a > epsilon) {
    double c = (a + b) / 2.0;
    if (f(c) == 0.0) {
    break;
    } else if (f(a) * f(c) < 0.0) {
    b = c;
    } else {
    a = c;
    }
    }


    double x = (a + b) / 2.0;
    std::cout << "Tenglama ildizi " << x << " ga teng" << std::endl;


    return 0;
    }



    2. oddiy ketma-ketlik usuli
    #include
    #include

    double f(double x) {


    return log(x) * sqrt(x);
    }

    int main() {


    double x = 0.1; // boshlang'ich taxmin
    double epsilon = 1e-6; // aniqlik
    double dx = 0.01; // qadam o'lchami

    while (abs(f(x)) > epsilon) {


    x = x + dx;
    }

    std::cout << "Tenglama ildizi " << x << " ga teng" << std::endl;


    return 0;


    }




    1. urinmalar usuli

    #include
    #include


    double f(double x) {
    return log(x) * sqrt(x);
    }


    double df(double x) {
    return 1/x - 1/(2*sqrt(x));
    }


    int main() {
    double x = 1.0; // boshlang'ich taxmin
    double epsilon = 1e-6; // aniqlik


    while (abs(f(x)) > epsilon) {
    x = x - f(x) / df(x);
    }


    std::cout << "Tenglama ildizi " << x << " ga teng" << std::endl;


    return 0;
    }




    1. Topshiriq







    1. 1.To’g’ri To’rtburchaklar usuli

    #include


    #include

    double f(double x) {


    return cos(x) / sqrt(4*pow(x,3) - x);
    }

    double rectangle_method(double a, double b, int n) {


    double h = (b - a) / n;
    double sum = 0;
    for(int i = 0; i < n; i++) {
    sum += f(a + i * h);
    }
    return sum * h;
    }

    int main() {


    double a = 0.8;
    double b = 1.6;
    int n = 1000; // interval soni

    std::cout << "Integral: " << rectangle_method(a, b, n) << std::endl;


    return 0;


    }

    2.Trapetsiyalar usuli

    #include


    #include

    double f(double x) {


    return cos(x) / sqrt(4*pow(x,3) - x);
    }

    double trapezoidal_method(double a, double b, int n) {


    double h = (b - a) / n;
    double sum = 0.5 * (f(a) + f(b));
    for(int i = 1; i < n; i++) {
    sum += f(a + i * h);
    }
    return sum * h;
    }

    int main() {


    double a = 0.8;
    double b = 1.6;
    int n = 1000; // interval soni

    std::cout << "Integral: " << trapezoidal_method(a, b, n) << std::endl;


    return 0;


    }



    3.Simpsonlar (parabolalar) usuli
    #include
    #include


    double f(double x) {
    return cos(x) / sqrt(4*pow(x,3) - x);
    }


    double simpsons_method(double a, double b, int n) {
    double h = (b - a) / n;
    double sum = f(a) + f(b);
    for(int i = 1; i < n; i++) {
    if (i % 2 == 0) {
    sum += 2 * f(a + i * h);
    } else {
    sum += 4 * f(a + i * h);
    }
    }
    return sum * h / 3;
    }


    int main() {
    double a = 0.8;
    double b = 1.6;
    int n = 1000; // interval soni


    std::cout << "Integral: " << simpsons_method(a, b, n) << std::endl;


    return 0;
    }




    1. 1.To’g’ri To’rtburchaklar usuli

    #include
    #include

    double f(double x) {


    return sin(x + 2) * x / (3 * x);
    }

    double rectangle_method(double a, double b, int n) {


    double h = (b - a) / n;
    double sum = 0;
    for(int i = 0; i < n; i++) {
    sum += f(a + i * h);
    }
    return sum * h;
    }

    int main() {


    double a = 12;
    double b = 2;
    int n = 1000; // interval soni

    std::cout << "Integral: " << rectangle_method(a, b, n) << std::endl;


    return 0;


    }


    1. Trapetsiyalar usuli

    #include


    #include

    double f(double x) {


    return sin(x + 2) * x / (3 * x);
    }

    double trapezoidal_method(double a, double b, int n) {


    double h = (b - a) / n;
    double sum = 0.5 * (f(a) + f(b));
    for(int i = 1; i < n; i++) {
    sum += f(a + i * h);
    }
    return sum * h;
    }

    int main() {


    double a = 12;
    double b = 2;
    int n = 1000; // interval soni

    std::cout << "Integral: " << trapezoidal_method(a, b, n) << std::endl;


    return 0;


    }




    1. Simpsonlar (parabolalar) usuli

    #include
    #include


    double f(double x) {
    return sin(x + 2) * x / (3 * x);
    }


    double simpsons_method(double a, double b, int n) {
    double h = (b - a) / n;
    double sum = f(a) + f(b);
    for(int i = 1; i <= n - 1; i++) {
    if (i % 2 == 0) {
    sum += 2 * f(a + i * h);
    } else {
    sum += 4 * f(a + i * h);
    }
    }
    return sum * h / 3;
    }


    int main() {
    double a = 12;
    double b = 2;
    int n = 1000; // interval soni


    std::cout << "Integral: " << simpsons_method(a, b, n) << std::endl;


    return 0;
    }



    3-Topshiriq
    N=24




















    Download 1,07 Mb.




    Download 1,07 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Muhammad Al-Xorazmiy nomida Toshkent Axborot texnologiyalari universiteti

    Download 1,07 Mb.