Jump to content

Matrix/Practice/Matrix multiplication: Difference between revisions

From Wikibase
AI-assisted (RonzzWikiCowriter) (via update-page on MediaWiki MCP Server)
AI-assisted (RonzzWikiCowriter) (via update-page on MediaWiki MCP Server)
Line 173: Line 173:


Put the problem in matrix form and determine the quantities of minerals $A$, $B$, and $C$ required to meet the specifications.
Put the problem in matrix form and determine the quantities of minerals $A$, $B$, and $C$ required to meet the specifications.
{{Hidden solution}}
With rows indexed by the constituents $a,b,c$ and columns by the minerals $A,B,C$, an entry is the amount of a constituent, in tonnes, per 1000 t of a mineral. Since $x,y,z$ are in thousands of tonnes, the demand is the matrix product itself:
$$
\begin{pmatrix}
600 & 700 & 700 \\
200 & 100 & 150 \\
100 & 150 & 50
\end{pmatrix}
\begin{pmatrix}
x \\
y \\
z
\end{pmatrix}
=
\begin{pmatrix}
20000 \\
5000 \\
3000
\end{pmatrix}
$$
<syntaxhighlight lang="python" class="pyodide" copy>
import sympy as sp
# rows: constituents a, b, c ; columns: minerals A, B, C
# entry (i, j) = tonnes of constituent i in 1000 t of mineral j
G = sp.Matrix([[600, 700, 700],
              [200, 100, 150],
              [100, 150,  50]])
# monthly requirement, in tonnes
d = sp.Matrix([20000, 5000, 3000])
print("det(G) =", G.det())            # non-zero, so the mineral mix is unique
x = G.solve(d)                      # exact solution, in thousands of tonnes
print("x, y, z (thousand t) =", x.T.tolist())
print("check G x =", (G * x).T.tolist())
print("in tonnes =", [float(c) * 1000 for c in x])
</syntaxhighlight>
{{End hidden}}


== Exercise 5 ==
== Exercise 5 ==

Revision as of 09:32, 19 November 2026

Languages: English · français · Esperanto

The solutions are programmatic: the code in each