9
1
The Blow-up is a powerful tool in algebraic geometry. It allows the removal of singularities from algebraic sets while preserving the rest of their structure.
If you're not familiar with any of that don't worry, the actual computation is not difficult to understand (see below).
In the following we are considering the blow-up of the point \$(0,0)\$ of an algebraic curve in 2D. An algebraic curve in 2D is given by the zero-locus of a polynomial in two variables (e.g. \$p(x,y) = x^2 + y^2 - 1\$ for the unit circle, or \$p(x,y) = y-x^2\$ for a parabola). The blowup of that curve (in \$(0,0)\$) is given by two polynomials \$r,s\$ as defined below. Both \$r\$ and \$s\$ do describe \$p\$ with the (possible) singularity at \$(0,0)\$ removed.
Challenge
Given some polynomial \$p\$, find \$r\$ and \$s\$ as defined below.
Definition
First of all note that everything I say here is simplified, and does not completely correspond to the actual definitions.
Given a polynomial \$p\$ in two variables \$x,y\$ the blowup is given by two polynomials \$r,s\$ again each in two variables.
To get \$r\$ we first define \$R(x,v) := p(x,vx)\$. Then \$R(x,v)\$ is probably a multiple of \$x\$, i.e. \$R(x,v) = x^n \cdot r(x,v)\$ for some \$n\$ where \$x\$ does not divide \$r(x,v)\$. Then \$r(x,v)\$ is basically what remains after the division.
The other polynomial is defined exactly the same, but we switch the variables: First write \$S(u,y) := p(uy,y)\$. Then \$s\$ is defined such that \$S(u,y) = y^m \cdot s(u,y)\$ for some \$m\$ where \$y\$ does not divide \$s(u,y)\$.
In order to make it clearer consider following
Example
Consider the curve given by the zero locus of \$p(x,y) = y^2 - (1+x) x^2\$. (It has a singularity at \$(0,0)\$ because there is no well defined tangent at that point. )
Then we find
$$R(x,v) = p(x,vx) = v^2x^2-(1+x)x^2 = x^2 (v^2-1-x)$$
Then \$r(x,v) = v^2 -1 -x\$ is the first polynomial.
Similarly
$$S(u,y) = p(uy,y) = y^2 - (1+ uy) u^2 y^2 = y^2 (1 - (1 + uy)u^2)$$
Then \$s(u,y) = 1 - (1 + uy)u^2 = 1 - u^2 + u^3y\$.
Input/Output Format
(Same as here.) The polynomials are represented given as(m+1) x (n+1)
matrices/lists of lists of integer coefficients, in the example below the terms of the coefficients are given in their position:
[ 1 * 1, 1 * x, 1 * x^2, 1 * x^3, ... , 1 * x^n ]
[ y * 1, y * x, y * x^2, y * x^4, ... , y * x^n ]
[ ... , ... , ... , ... , ... , ... ]
[ y^m * 1, y^m * x, y^m * x^2, y^m * x^3 , ..., y^m * x^n]
So an ellipse 0 = x^2 + 2y^2 -1
would be represented as
[[-1, 0, 1],
[ 0, 0, 0],
[ 2, 0, 0]]
If you prefer you can also swap x
and y
. In each direction you are allowed to have trailing zeros (i.e. coefficients of higher degrees that are just zero). If it is more convenient you can also have staggered arrays (instead of a rectangular one) such that all sub sub-arrays contain no trailing zeros.
- The output format is the same as the input format.
Examples
More to be added (source for more)
Trifolium
p(x,y) = (x^2 + y^2)^2 - (x^3 - 3xy^2)
r(x,v) = v^4 x + 2 v^2 x + x + 3 v^2 - 1
s(u,y) = u^4 y + 2 u^2 y + y - u^3 + 3 u
Descartes Folium
p(x,y) = y^3 - 3xy + x^3
r(x,v) = v^3 x + x - 3v
s(u,y) = u^3 y + y - 3u
Examples w/o pictures
Trifolium:
p:
[[0,0,0,-1,1],
[0,0,0, 0,0],
[0,3,2, 0,0],
[0,0,0, 0,0],
[1,0,0, 0,0]]
r: (using the "down" dimension for v instead of y)
[[-1,1],
[ 0,0],
[ 3,2],
[ 0,0],
[ 0,1]]
s: (using the "right" dimension for u instead of x)
[[0,3,0,-1,0],
[1,0,2, 0,1]]
Descartes Folium:
p:
[[0, 0,0,1],
[0,-3,0,0],
[0, 0,0,0],
[1, 0,0,0]]
r:
[[ 0,1],
[-3,0],
[ 0,0],
[ 0,1]]
s:
[[0,-3,0,0],
[1, 0,0,1]]
Lemniscate:
p:
[[0,0,-1,0,1],
[0,0, 0,0,0],
[1,0, 0,0,0]]
r:
[[-1,0,1],
[ 0,0,0],
[ 1,0,0]]
s:
[[1,0,-1,0,0],
[0,0, 0,0,0],
[0,0, 0,0,1]]
Powers:
p:
[[0,1,1,1,1]]
r:
[[1,1,1,1]]
s:
[[0,1,0,0,0],
[0,0,1,0,0],
[0,0,0,1,0],
[0,0,0,0,1]]
7This title definitely isn't what I thought it was... – negative seven – 2019-08-30T09:46:29.987
Suggested testcase:
0+x+x^2+x^3+x^4
– user41805 – 2019-08-31T14:18:04.013@Cowsquack Added it! – flawr – 2019-08-31T15:25:07.667