Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* составить программу решения ур-й методом итераций по ф-ам xn=F1(xn-1,yn-1)
- yn=F2(xn-1,yn-1),n=1.2...
- начальные значения х0 и у0 заданы
- вычисления для системы y*sin(x)-x=0
- x*sin(y)-x=0
- правило остановки счета:abs(x1 - x0) + abs(y1-y0) <= eps, eps=1e-4
- */
- #include <iostream>
- #include <conio.h>
- #include <cmath>
- #include <stdio.h>
- using namespace std;
- float function1(float x, float y){
- return x*sin(y);
- }
- float function2(float x, float y){
- return x / sin(x);
- }
- void iterative_relation(float x, float y){
- float eps = 1e-4;
- float x1 = function1(x,y);
- float y1 = function2(x,y);
- while (abs(x1 - x) + abs(y1 - y) > eps){
- x = x1;
- y = y1;
- x1 = function1(x, y);
- y1 = function2(x, y);
- }
- printf_s("solution to equation x= %6.5f, y= %6.5f", x1, y1);
- }
- int main(){
- float x0, y0;
- cout << "enter initial values of function inputs:" << endl;
- cout << "x0= ";
- cin >> x0;
- cout << "y0= ";
- cin>> y0;
- iterative_relation(x0, y0);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement