# Plot crossing functions in more explicit format

We want to use Plot3D for presenting the below functions.

These functions cross each other in some points. How can we plot them to show their crossing more explicitly than the default of Mathematica.

f[x_,t_]:= Sin[1/2 t (1 + x)]^2;
g[x_, t_] := 1/2 Sqrt[Sin[t (1 + x)]]^2;
Plot3D[{f[x,t], g[x,t]}, {t, 0, 4 \[Pi]}, {x, 0, 3}]

• You have some bad syntax in there; please check your definitions. – J. M. is away Nov 16 '17 at 6:03
• So sorry, thank you, I corrected that. – Unbelievable Nov 16 '17 at 6:10

We can generate the arguments of the intersections with ContourPlot and grab the result as a MeshRegion. This allows us to represent the intersection as GraphicsComplex. Finally, we can merge all plots with Show.

R = Quiet@DiscretizeGraphics[ContourPlot[f[x, t] - g[x, t] == 0, {x, 0, 3}, {t, 0, 4 \[Pi]}]];
S = Graphics3D[{Thickness[0.015], ColorData[97][3],
GraphicsComplex[
({x, t} \[Function] {x, t,g[x, t]}) @@@ MeshCoordinates[R],
MeshCells[R, 1]
]
}];
plot3d = Plot3D[{f[x, t], g[x, t]}, {x, 0, 3}, {t, 0, 4 \[Pi]}, PlotPoints -> 50];
Show[plot3d, S]


A bit less complex (just play with MeshFunctions):

h = Sin[1/2 y (1 + x)]^2;
g = 1/2 Sqrt[Sin[y (1 + x)]]^2;
Plot3D[{h, g}, {x, 0, 3}, {y, 0, 4 \[Pi]}, MeshFunctions -> {Function[{x, y, z, f}, h - g]}, MeshStyle -> {{Thickness[0.015], White}}, Mesh -> {{0}},
Axes -> True, Boxed -> True, AxesLabel -> (Style[#, 16, Bold] & /@ {"x", "t"}),
PlotPoints -> 35,
PlotStyle -> Directive[Opacity[0.6]], SphericalRegion -> True]