Last active
April 23, 2021 19:39
-
-
Save lecuseasar/ed10ca0c2fe1c23caa127cce4dec5776 to your computer and use it in GitHub Desktop.
my matlab homework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clc; clear; close all; | |
fprintf("Jacobi iter. x^2 - 2 * x - y = .5 AND x^2 + 4 * y^2 = 4 \n"); | |
x_0 = 0; | |
y_0 = 0; | |
E = 1.0E-4; | |
fprintf("i x_1 y_1 error_x error_y \n"); | |
for index = 1:100 | |
x_1 = (x_0^2 - y_0 + .5) / 2; | |
y_1 = sqrt((4 - x_0^2) / 4); | |
error_x = abs(x_1 - x_0); | |
error_y = abs(y_1 - y_0); | |
fprintf('%4.1f %7.4f %7.4f %7.4f %7.4f \n', index, x_1, y_1, error_x, error_y); | |
if abs(x_1 - x_0) < E && abs(y_1 - y_0) < E | |
break; | |
else | |
x_0 = x_1; | |
y_0 = y_1; | |
end | |
end | |
disp('Denklemin kokleri'); | |
disp([x_1, y_1]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment