| 1 | initial version |
Iterating on @FrédéricC's answer...
In the following we
RDF and CDF: "real double field", "complex double field" -- floating-point real and complex numbers,Doing this, the spike however reaches higher and higher values, so it becomes necessary to truncate the z values.
Pick a colormap and define $\tau = 2\pi$.
sage: cm = colormaps.jet
sage: tau = 2 * RDF.pi()
Define f:
sage: def f(x, y):
....: z = CDF(x, y)
....: return (z - 2) / (z + 3)**2
Define f_abs (modulus of f):
sage: f_abs = lambda x, y: f(x, y).abs()
Define truncation:
sage: trunc = lambda x, t: x if x.abs() < t else RDF.nan()
Pick a bound to truncate:
sage: zbound = 8
Define f_abs_trunc as f_abs truncated to the chosen bound.
sage: f_abs_trunc = lambda x, y: trunc(f_abs(x, y), zbound)
Define f_arg_color as the coloring for the argument of f:
sage: f_arg_color = lambda x, y: f(x, y).arg() / tau + RDF(0.5)
Compute the plot:
sage: p = plot3d(f_abs_trunc, (-4, 4), (-4, 4), color=(f_arg_color, cm), plot_points=200)
Show the plot (choose viewer='threejs' or viewer='jmol' or viewer='tachyon'):
sage: p.show(viewer='threejs')
Increasing plot_points further makes a nicer plot while also increasing the time to show the plot.
Try for example plot_points=400 or even plot_points=800.
One can also increase zbound to see more of the spike (try for example zbound=1e2 or zbound=2e5).
Or plot f_abs instead of f_abs_trunc to avoid truncation altogether.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.