From 226346ea5305944f8225ccb66a85d53424628e09 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sun, 7 May 2023 21:04:42 +0300 Subject: [PATCH] I love basketball --- My balls/lagranjames.m | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 My balls/lagranjames.m diff --git a/My balls/lagranjames.m b/My balls/lagranjames.m new file mode 100644 index 0000000..26d9077 --- /dev/null +++ b/My balls/lagranjames.m @@ -0,0 +1,19 @@ +X = [2 2.2 2.4 2.6 2.8] +Y = [0.52 0.63 0.85 1.1 1.3] + +function solution = lagranjames(X,Y,x) + L = 0; + for k = [1:length(X)] # Summation loop + + l = 1; + for i = [1:length(X)] # Product loop + if ( i != k ) # no 0s in our bottom fraction + l = l * ( x - X(i) ) / ( X(k) - X(i) ); # This the Π part of the rule + endif + endfor + L = L + l * Y(k); # This is the sigma part + endfor + solution = L; + +endfunction +balls = lagranjames(X,Y,2.3)