MCPcopy Create free account
hub / github.com/google-deepmind/alphageometry / div

Function div

ar.py:115–129  ·  view source on GitHub ↗

Divide e1 by e2.

(e1: dict[str, float], e2: dict[str, float])

Source from the content-addressed store, hash-verified

113
114
115def div(e1: dict[str, float], e2: dict[str, float]) -> float:
116 """Divide e1 by e2."""
117 e1 = strip(e1)
118 e2 = strip(e2)
119 if set(e1.keys()) != set(e2.keys()):
120 return None
121
122 n, d = None, None
123
124 for v, c1 in e1.items():
125 c2 = e2[v] # we want c1/c2 = n/d => c1*d=c2*n
126 if n is not None and c1 * d != c2 * n:
127 return None
128 n, d = c1, c2
129 return frac(n) / frac(d)
130
131
132def recon(e: dict[str, float], const: str) -> tuple[str, dict[str, float]]:

Callers 1

get_all_eqs_and_whyMethod · 0.85

Calls 1

stripFunction · 0.85

Tested by

no test coverage detected