From 6696577d20dabe3fecba0d4cfc9800dcb7b60260 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sun, 19 Mar 2023 23:09:45 +0200 Subject: [PATCH] init bruv --- LICENSE | 21 +++++++++++++++++++++ LU.m | 32 ++++++++++++++++++++++++++++++++ newton.m | 25 +++++++++++++++++++++++++ the greatest | 1 + 4 files changed, 79 insertions(+) create mode 100644 LICENSE create mode 100644 LU.m create mode 100644 newton.m create mode 100644 the greatest diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..031ed88 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2023 Author + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/LU.m b/LU.m new file mode 100644 index 0000000..f3cfbdd --- /dev/null +++ b/LU.m @@ -0,0 +1,32 @@ + + + +# upper matrix ballocks. +clear,clc +#U2 = -A(2,1)/A(1,1) * A(1, :) + A(2, :) +#U3 = -A(3,1)/A(1,1) * A(1, :) + A(3, :) +#U_temp = [A(1,:); U2; U3] +#U3 = -A(3,2)/U_temp(2,2) * U_temp(2, :) + U_temp(3, :) +#U = [A(1,:); U2; U3] +#L = [1, 0, 0; A(2,1)/A(1,1),1,0;(A(3,1)/A(1,1)),(A(3,2)/U_temp(2,2)),1] + +# U_temp var = A (matrix) +# for i < n +# j = i + 1 + # for j <= n + # U_temp(j, :) = -U_temp(j,i)/U_temp(j,i) * U_temp(i, :) + U_temp(j, :) + + A = [5,2,4;2,1,1;1,-5,-3]; + b = [17;0;13;]; + U_temp = A + L_temp = eye(3); + for i = [1:length(A)-1] + for j = [i+1: length(A)] + L_temp(j,i) = U_temp(j,i)/U_temp(i,i); + U_temp(j, :) = -U_temp(j,i)/U_temp(i,i) * U_temp(i, :) + U_temp(j, :); + endfor + endfor + U_temp + L_temp +#another for loop that's like we create another matrix for Z +L_temp*U_temp\b diff --git a/newton.m b/newton.m new file mode 100644 index 0000000..c9c52a8 --- /dev/null +++ b/newton.m @@ -0,0 +1,25 @@ +clc +clear +%b = [4;9;2]; +%A = [3 4 5; 1 3 1; 3 5 9;]; % must be ; in here +%x = A \ b %% balls +function line_equation = line_func(x) + line_equation = 3 * x^2 - e()^x +endfunction + +function root = newton_method(a, b, e) + c = (a + b) / 2 + if( abs(line_func(c)) <= e) + printf("root found!") + root = c + return + endif + + if(line_func(c) < 0) + newton_method(c,b,e) + else + newton_method(a,c,e) + endif +endfunction + + newton_method(0,1,10^-10) diff --git a/the greatest b/the greatest new file mode 100644 index 0000000..de5e18a --- /dev/null +++ b/the greatest @@ -0,0 +1 @@ +# Created by Octave 7.3.0, Sun Mar 05 13:19:01 2023 EET