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