How to resolve the algorithm Cramer's rule step by step in the 11l programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Cramer's rule step by step in the 11l programming language
Table of Contents
Problem Statement
Given
which in matrix format is
Then the values of
x , y
{\displaystyle x,y}
and
z
{\displaystyle z}
can be found as follows:
Given the following system of equations:
solve for
w
{\displaystyle w}
,
x
{\displaystyle x}
,
y
{\displaystyle y}
and
z
{\displaystyle z}
, using Cramer's rule.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Cramer's rule step by step in the 11l programming language
Source code in the 11l programming language
F det(mm)
V m = copy(mm)
V result = 1.0
L(j) 0 .< m.len
V imax = j
L(i) j + 1 .< m.len
I m[i][j] > m[imax][j]
imax = i
I imax != j
swap(&m[imax], &m[j])
result = -result
I abs(m[j][j]) < 1e-12
R Float.infinity
L(i) j + 1 .< m.len
V mult = -m[i][j] / m[j][j]
L(k) 0 .< m.len
m[i][k] += mult * m[j][k]
L(i) 0 .< m.len
result *= m[i][i]
R result
F cramerSolve(aa, detA, b, col)
V a = copy(aa)
L(i) 0 .< a.len
a[i][col] = b[i]
R det(a) / detA
V A = [[2.0, -1.0, 5.0, 1.0],
[3.0, 2.0, 2.0, -6.0],
[1.0, 3.0, 3.0, -1.0],
[5.0, -2.0, -3.0, 3.0]]
V B = [-3.0, -32.0, -47.0, 49.0]
V detA = det(A)
L(i) 0 .< A.len
print(‘#3.3’.format(cramerSolve(A, detA, B, i)))
You may also check:How to resolve the algorithm Active object step by step in the F# programming language
You may also check:How to resolve the algorithm Determine if a string is numeric step by step in the REXX programming language
You may also check:How to resolve the algorithm Date manipulation step by step in the Java programming language
You may also check:How to resolve the algorithm Hailstone sequence step by step in the 360 Assembly programming language
You may also check:How to resolve the algorithm Fibonacci n-step number sequences step by step in the Phix programming language