Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- составить программу вычисления корня у-я согласнo итерационной ф-ле xk+1=xk-f(xk)/f'(xk), к =1,2,3.. с точностью до eps=1Е-3
- правило остановки счета:(abs(x1 - x0) <= eps); ур -е :cos(x0) + 2 * x0 - 1=0. предварительно произвести уточнение корней на отрезке [-1,2]
- */
- #include <iostream>
- #include <conio.h>
- #include <cmath>
- #include <iomanip>
- #include <stdio.h>
- using namespace std;
- float function(float x0){
- return x0 - (cos(x0-0.5) + 2 * x0 - 1) / (-sin(x0-0.5) + 2);
- }
- float iterative_relation(float x0){
- float eps = 1e-4;
- float x1 = function(x0);
- while (abs(x1 - x0) > eps){
- x0 = x1;
- x1 = function(x0);
- }
- return x1;
- }
- int main(){
- float x0;
- cin >> x0;
- printf_s("x1 = %6.5f", iterative_relation(x0));
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement