The rank of the Jacobian of
eqns = {x^2 + y^2 - 2 (1 + x + y) z + 3 z^2,
z - (x^2/2 - x^3/(12 Sqrt[3]) + y^2/2 + (x y^2)/(4 Sqrt[3]))};
as a mapping $F:{\bf R}^3 \rightarrow {\bf R}^2$ drops to $1$ at the origin, which is why numerical error in ContourPlot3D makes the intersection, given by the inverse image $F^{-1}(\{(0,0)\})$, appear to flatten out near the origin.
One way to trace the path is to start at some point (found with FindRoot) and use the cross product of the normals to the surface as the tangent velocity to intersection curve. The origin is still a problem, for the velocity is indeterminate there; but we get lucky and the solver steps over the bad point.
eqns = {x^2 + y^2 - 2 (1 + x + y) z + 3 z^2,
z - (x^2/2 - x^3/(12 Sqrt[3]) + y^2/2 + (x y^2)/(4 Sqrt[3]))};
vars = Variables@eqns;
vel = Cross @@ D[eqns, {{x, y, z}}] // #/Sqrt[# . #] & // Simplify;
vel = vel /. v : x | y | z :> v[t];
boundaryEVT[x_, a_, b_] := {
WhenEvent[x < a, "StopIntegration"],
WhenEvent[x > b, "StopIntegration"]};
curve = NDSolveValue[{
D[Through[vars[t]], t] == vel,
Through[vars[0]] == ({0.5, y, z} /.
FindRoot[eqns /. x -> 0.5, {y, -0.2}, {z, 0.3}]),
boundaryEVT[x[t], -1, 1], boundaryEVT[y[t], -1, 1],
boundaryEVT[z[t], -1, 1]
}, Through[vars[t]], {t, -3, 3}];
tdom = Flatten@{t, First[curve] /. t -> "Domain"};
pp = ParametricPlot3D[curve, Evaluate@tdom,
PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}, PlotStyle -> Magenta]
An alternative is to increase sampling in ContourPlot3D and hope it resolves the jaggedness of the curve. One might have to raise WorkingPrecision to handle the numerical problem at the origin, but again we get lucky (?).
cp = ContourPlot3D[
{x^2 + y^2 - 2 (1 + x + y) z + 3 z^2 == 0,
z - (x^2/2 - x^3/(12 Sqrt[3]) + y^2/2 + (x y^2)/(4 Sqrt[3])) == 0},
{x, -1, 1}, {y, -1, 1}, {z, -1, 1},
BoundaryStyle -> {1 -> None, 2 -> None, {1, 2} -> {Blue}},
ContourStyle -> None, Mesh -> None,
MaxRecursion -> 8, PlotPoints -> 35, AxesLabel -> Automatic]
Compare:
Show[cp, pp /. l_Line :> {Dashed, l}]
Note that
Method -> {"Projection",
"Invariants" -> (eqns /. v : x | y | z :> v[t])}
might normally be used in NDSolve to make the solution track the intersection curve with greater accuracy. However, if this is tried, one finds that the bad behavior of the Jacobian causes the numerical integration to stop when the solution reaches the origin.
ContourPlot3D[{z - x^2/2 - x^3/(12 Sqrt[3]) + y^2/2 + (x y^2)/(4 Sqrt[3]), x^2 + y^2 - 2 (1 + x + y) z + 3 z^2}, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, Contours -> {0}, ContourStyle -> None, Mesh -> None, BoundaryStyle -> {1 -> None, 2 -> None, {1, 2} -> {Blue}}, MaxRecursion -> 0, PlotPoints -> 45]– J. M.'s missing motivation May 30 '22 at 20:55MaxRecursion -> 8, PlotPoints -> 35helps quite a bit. (Note that the Jacobian is of deficient rank at the origin, which explains the poor result near the origin.) – Michael E2 May 31 '22 at 23:40