Anonymous user
Resistor mesh: Difference between revisions
→{{header|Mathematica}}
Line 1,271:
=={{header|Mathematica}}==
Use <b>KirchhoffMatrix</b>, <b>PseudoInverse</b>, and <b>GridGraph</b> to compute the resistance between <em>any</em> two points.
{{works
<lang mathematica>
resistanceGraph[g_, prec_:$MachinePrecision]:=
With[{M = PseudoInverse[N[ KirchhoffMatrix[g], prec]]},
Outer[Plus, Diagonal[M], Diagonal[M]] - M - Transpose[M]
Line 1,299 ⟶ 1,300:
{{Out}}
<pre>1.608991241730729655954495520510088761201</pre>
{{works with|Mathematica|9.0}}
|