\\ PARI Program for A180414 and related sequences. \\ The method used here is to iteratively compute new possible resistances for larger networks \\ using a minimal set of indecomposable networks replacing each edge in the network with \\ all possible values such that the total number of resistors is as required. \\ The minimal indecomposable networks are: \\ 1) two edges in parallel \\ 2) two edges in series \\ 3) a three connected graph with one edge removed and the resitance being measured \\ between the two endpoints of the removed edge. \\ The first two cases are handled separately and third case is dealt with using a precomputed \\ list of 3-connected graphs. \\ This method is attractive because there are comparatively few 3-connected graphs and that \\ data can be constructed using graph theoretic tools (and the counts verified against \\ theoretical results). \\ The following is data for 3-connected graphs up to 11 edges. \\ To compute resistances of networks with more than 10 resistors additional data is needed. \\ Sequence A338511 gives the number of such graphs. \\ See the Hugo Pfoertner link in that sequence for a zip-file of all the graphs up to 18 edges. ThreeConnectedData={ [ \\ 1..5 there are none. [], [], [], [], [], [ \\ 6 edges [[1,2], [1,3], [1,4], [2,3], [2,4], [3,4]] ], [], \\ 7 edges [ \\ 8 edges [[1,3], [1,4], [1,5], [2,3], [2,4], [2,5], [3,5], [4,5]] ], [ \\ 9 edges [[1,3], [1,4], [1,5], [2,3], [2,4], [2,5], [3,4], [3,5], [4,5]], [[1,4], [1,5], [1,6], [2,4], [2,5], [2,6], [3,4], [3,5], [3,6]], [[1,3], [1,4], [1,5], [2,4], [2,5], [2,6], [3,5], [3,6], [4,6]] ], [ \\ 10 edges [[1,2], [1,3], [1,4], [1,5], [2,3], [2,4], [2,5], [3,4], [3,5], [4,5]], [[1,4], [1,5], [1,6], [2,4], [2,5], [2,6], [3,4], [3,5], [3,6], [4,6]], [[1,3], [1,4], [1,6], [2,4], [2,5], [2,6], [3,5], [3,6], [4,6], [5,6]], [[1,3], [1,4], [1,5], [1,6], [2,4], [2,5], [2,6], [3,5], [3,6], [4,6]] ], [ \\ 11 edges [[1,4], [1,5], [1,6], [2,4], [2,5], [2,6], [3,4], [3,5], [3,6], [4,6], [5,6]], [[1,3], [1,4], [1,5], [1,6], [2,4], [2,5], [2,6], [3,5], [3,6], [4,6], [5,6]], [[1,3], [1,4], [1,5], [1,6], [2,3], [2,4], [2,5], [3,5], [3,6], [4,6], [5,6]], [[1,3], [1,4], [1,5], [1,6], [2,3], [2,4], [2,5], [2,6], [3,5], [3,6], [4,6]], [[1,4], [1,5], [1,7], [2,5], [2,6], [2,7], [3,5], [3,6], [3,7], [4,6], [4,7]], [[1,4], [1,5], [1,7], [2,4], [2,6], [2,7], [3,5], [3,6], [3,7], [4,6], [5,7]], [[1,4], [1,5], [1,6], [2,4], [2,6], [2,7], [3,5], [3,6], [3,7], [4,7], [5,7]] ] ];} \\ ***************************************************************************************** \\ Program code. \\ ***************************************************************************************** \\ Determines conductance (1/resistance) of a network. \\ Solves Kirchoff's laws using linear algebra. \\ g is the graph of edges and u is a vector of conductance at each edge. \\ One edge must have conductance 0 - this is the edge for the voltage source. \\ Returns conductance of network between the end-points of the edge that \\ is the voltage source. Conductance(g,u)={ my( n = vecmax(concat(g)), M = matrix(n,n), B = vectorv(n) ); for(i=1, #g, my([v1,v2]=g[i]); M[v1,v2]=M[v2,v1]=-u[i]); for(i=1, n, M[i,i] = -vecsum(M[i,])); for(i=1, #g, if(!u[i], my([v1,v2] = g[i]); M[v1,]=vector(n); M[v1,v1]=1; B[v2]=1; return(1/matsolve(M,B)[v2]); )); oo } \\ Deals with bridges of all kinds (not serial/parallel circuits) \\ n is number of edges \\ u is resistances for edges < n \\ Returns set of resistances with n edges. BridgeCombinations(n, u)={ if(n<5, Set(), my(S=Map()); for(e=5, n, my(gg=ThreeConnectedData[e+1]); if (#gg, forpart(p=n, forperm(p, q, forvec(x=vector(e,i,[1,#u[q[i]]]), my(v=vector(e, i, 1/u[q[i]][x[i]])); for(k=1, e+1, my(v2=vector(e+1, i, if(i==k, 0, v[i-(i>k)]))); for(j=1, #gg, mapput(S, 1/Conductance(gg[j], v2), 1); )))), , [e,e]) )); Set(Mat(S)[,1])) } \\ SerPar \\ Combines a two sets of resistors in serial and parallel. \\ Returns vector of resistances. SerPar(u,v)=concat(concat(vector(#u,i,vector(#v,j,u[i]+v[j]))), concat(vector(#u,i,vector(#v,j,1/(1/u[i]+1/v[j]))))) \\ Computes resistances for next number of resistors. \\ n is number of edges \\ u is resistances for n < edges ExtendResistances(n, u)={ my(t=Set(concat(vector(n\2, k, SerPar(u[k], u[n-k]))))); Vec(setunion(t, BridgeCombinations(n, u))); } \\ Resistances table \\ Because generating the resistances is comparatively slow and there are a \\ number of different sequences that can be computed from the data it makes \\ sense to put it into a global variable. \\ Dependending on how much data is included in ThreeConnectedData this could take a while. ResistancesData = vector(#ThreeConnectedData-1); ResistancesData[1] = [1]; \\ seed 1 ohm resistor \\ Fill the array one new resistor at a time { gettime(); for(n=2, #ResistancesData, if (!ResistancesData[n], ResistancesData[n] = ExtendResistances(n, ResistancesData); print("N = ", n, ": distinct resistances = ", #ResistancesData[n], ", time = ", gettime()) )); } \\ ***************************************************************************************** \\ A few sequences. \\ ***************************************************************************************** \\ The remainder of this file is definitions for sequences that can be computed \\ from ResistancesData once it has been initialised. In all cases, the functions \\ return as many terms as possible based on the available data. \\ Number of different resistances that can be obtained by combining n one ohm resistors. A180414()={ my(v=vector(#ResistancesData), S=Set()); for(n=1, #v, S=setunion(S, ResistancesData[n]); v[n]=#S+1); v } \\ Number of distinct resistances that can be produced from a circuit with exactly n unit resistors. A337517()={ my(v=vector(#ResistancesData, n, #ResistancesData[n])); v } \\ Number of distinct resistances that can be obtained by a network of exactly n equal resistors, but not by any network with fewer than n equal resistors. A338197()={ my(v=vector(#ResistancesData), S=Set()); for(n=1, #v, my(t=#S); S=setunion(S, ResistancesData[n]); v[n]=#S-t ); v } \\ Number of resistance values R=x/y that can be obtained by a network of at most n one-ohm resistors such that a network of more than n one-ohm resistors is needed to obtain the resistance y/x. A339547()={ my(v=vector(#ResistancesData), S=Set()); for(n=1, #v, my(t=#S); S=setunion(S, ResistancesData[n]); v[n]=sum(k=1, #S, !setsearch(S,1/S[k])) ); v } \\ T(m,n) (m, n >= 1) is the minimum number of unit resistors needed to produce resistance m/n. \\ returns vector of diagonals - concatenate for sequence. A338573(lim=50)={ my(n=#ResitancesData, M=matrix(lim,lim)); forstep(k=#ResistancesData, 1, -1, my(S=ResistancesData[k]); for(i=1, #S, my(r=S[i]); if (numerator(r) + denominator(r)-1<=lim, M[numerator(r), denominator(r)] = k)) ); my(L=List()); for(k=1, lim, my(v=vector(k, i, my(r=(k+1-i)/i); M[numerator(r), denominator(r)])); if (#select(t->!t, v), break); listput(L, v); ); Vec(L); } \\ ***************************************************************************************** \\ More sequences \\ ***************************************************************************************** \\ A338580 (k=10), A338587 (k=7) A338580(k=10)={ my(S=setminus(ResistancesData[k], Set(concat(ResistancesData[1..k-1])))); [numerator(r) | r<-vecsort(S), r<1] } \\ k=5..10: A338595, A338596, A338597, A338598, A338599, A338590. A338595(k=5)={ my(S=setminus(ResistancesData[k], Set(concat(ResistancesData[1..k-1])))); [denominator(r) | r<-vecsort(S), r<1] } \\ Common demoninator of resistances that can be obtained by a network of exactly n equal resistors, but not by any network with fewer than n equal resistors. A338600()={ my(v=vector(#ResistancesData), S=Set()); for(n=1, #v, my(t=#S); my(T=setminus(ResistancesData[n], S)); S = setunion(S, T); v[n]=denominator(T)); v } \\ A338605, A338606, A338607, A338608, A338609 A338605(k=5)={ my(S=setminus(ResistancesData[k], Set(concat(ResistancesData[1..k-1])))); my(d=denominator(S)); vecsort(select(t->t