Anonymous user
Resistor mesh: Difference between revisions
→{{header|Mathematica}}
m (→{{header|Phix}}: added syntax colouring the hard way) |
|||
Line 1,271:
=={{header|Mathematica}}==
{{works with|Mathematica|8.0}}
<lang mathematica>resistanceGraph[g_, prec_:$MachinePrecision]:=
With[{M = PseudoInverse[N[ KirchhoffMatrix[g], prec]]},
Outer[Plus, Diagonal[M], Diagonal[M]] - M - Transpose[M]
]
r = resistanceGraph[GridGraph[{10, 10}], 40];
r[[12, 68]]</lang>
{{Out}}
<pre>1.608991241730729655954495520510088761201</pre>
{{trans|Maxima}}
<lang mathematica>gridresistor[p_, q_, ai_, aj_, bi_, bj_] :=
|