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 with|Mathematica|8.0}}
▲Use <b>KirchhoffMatrix</b>, <b>PseudoInverse</b>, and <b>GridGraph</b> to compute the resistance between <em>any</em> two points.
resistanceGraph[g_, prec_:$MachinePrecision]:= ▼
▲<lang mathematica>resistanceGraph[g_, prec_:$MachinePrecision]:=
With[{M = PseudoInverse[N[ KirchhoffMatrix[g], prec]]},
Outer[Plus, Diagonal[M], Diagonal[M]] - M - Transpose[M]
|