Skip to content

Instantly share code, notes, and snippets.

@bakfoo
Last active July 20, 2026 14:26
Show Gist options
  • Select an option

  • Save bakfoo/bb5bc32ee6db046466c49d4e3c8669c6 to your computer and use it in GitHub Desktop.

Select an option

Save bakfoo/bb5bc32ee6db046466c49d4e3c8669c6 to your computer and use it in GitHub Desktop.
A Counterexample to the Jacobian Conjecture
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 7,
"id": "58f9d66e-cc23-436c-b97c-a2407b8ccc8b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"det J = -2\n",
"expanded:\n",
"f = x**3*y**3*z + 3*x**2*y**4 + 3*x**2*y**2*z + 7*x*y**3 + 3*x*y*z + 4*y**2 + z\n",
"g = 3*x**3*y**2*z + 9*x**2*y**3 + 6*x**2*y*z + 12*x*y**2 + 3*x*z + y\n",
"h = -x**3*z - 3*x**2*y + 2*x\n",
"Jacobian:\n",
"⎡ 3 3 2 2 ↪\n",
"⎢ 3⋅y ⋅(x⋅y + 1) + y ⋅(3⋅x⋅y + 4) + 3⋅y⋅z⋅(x⋅y + 1) 3⋅x⋅y ⋅(x⋅y + ↪\n",
"⎢ ↪\n",
"⎢ 3 2 2 ↪\n",
"⎢9⋅x⋅y + 6⋅x⋅y⋅z⋅(x⋅y + 1) + 3⋅y ⋅(3⋅x⋅y + 4) + 3⋅z⋅(x⋅y + 1) ↪\n",
"⎢ ↪\n",
"⎢ 2 ↪\n",
"⎣ - 3⋅x ⋅z - 6⋅x⋅y + 2 ↪\n",
"\n",
"↪ 2 2 ↪\n",
"↪ 1) + x⋅y ⋅(3⋅x⋅y + 4) + 3⋅x⋅z⋅(x⋅y + 1) + 2⋅y⋅(x⋅y + 1)⋅(3⋅x⋅y + 4) (x⋅ ↪\n",
"↪ ↪\n",
"↪ 2 2 2 ↪\n",
"↪ 9⋅x ⋅y + 6⋅x ⋅z⋅(x⋅y + 1) + 6⋅x⋅y⋅(3⋅x⋅y + 4) + 1 3⋅x⋅( ↪\n",
"↪ ↪\n",
"↪ 2 ↪\n",
"↪ -3⋅x ↪\n",
"\n",
"↪ 3 ⎤\n",
"↪ y + 1) ⎥\n",
"↪ ⎥\n",
"↪ 2⎥\n",
"↪ x⋅y + 1) ⎥\n",
"↪ ⎥\n",
"↪ 3 ⎥\n",
"↪ -x ⎦\n",
"(0, 0, -1/4) -> (-1/4, 0, 0)\n",
"(1, -3/2, 13/2) -> (-1/4, 0, 0)\n",
"(-1, 3/2, 13/2) -> (-1/4, 0, 0)\n"
]
}
],
"source": [
"import sympy as sp\n",
"\n",
"x, y, z = sp.symbols('x y z')\n",
"\n",
"f = (1+x*y)**3*z + y**2*(1+x*y)*(4+3*x*y)\n",
"g = y + 3*x*(1+x*y)**2*z + 3*x*y**2*(4+3*x*y)\n",
"h = 2*x - 3*x**2*y - x**3*z\n",
"\n",
"F = sp.Matrix([f, g, h])\n",
"J = F.jacobian([x,y,z])\n",
"detJ = sp.factor(J.det())\n",
"\n",
"fe, ge, he = map(sp.expand, (f, g, h))\n",
"\n",
"print(\"det J =\", detJ)\n",
"print(\"expanded:\")\n",
"print(\"f =\", fe)\n",
"print(\"g =\", ge)\n",
"print(\"h =\", he)\n",
"print(\"Jacobian:\")\n",
"\n",
"sp.pprint(J)\n",
"\n",
"points = [\n",
" (0, 0, sp.Rational(-1, 4)),\n",
" (1, sp.Rational(-3, 2), sp.Rational(13, 2)),\n",
" (-1, sp.Rational(3, 2), sp.Rational(13, 2)),\n",
"]\n",
"\n",
"for p in points:\n",
" image = F.subs(dict(zip((x, y, z), p))).applyfunc(sp.simplify)\n",
" print(p, \"->\", tuple(image))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "427a780d-89e9-4583-80f5-3f9c3286aea0",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.14.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment