# Erratic spikes in graph from Plot3D

**URL:** <https://community.wolfram.com/t/erratic-spikes-in-graph-from-plot3d/23867>\
**Category:** Questions\
**Tags:** graphics-and-visualization\
**Created:** [April 14, 2024, 11:05pm UTC](https://community.wolfram.com/t/erratic-spikes-in-graph-from-plot3d/23867 "2024-04-14T23:05:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgolber](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@dgolber](https://community.wolfram.com/u/dgolber)\
**Post date:** [April 14, 2024, 11:05pm UTC](https://community.wolfram.com/t/erratic-spikes-in-graph-from-plot3d/23867/1 "2024-04-14T23:05:18Z")

</div>

The function eFunc returns None outside a curve. At the edge of the curve, the Plot3D plot has spikes. These are spurious: They are not there in the function. And in fact, the spikes change location depending on the range of y!!! I instrumented eFunc to record (in “record”) the result of every call to eFunc. As you see in demo.nb, there are no values in any of the calls to eFunc that give a value corresponding to the spikes.

And then ListPlot3D@record produces the desired plot without the spikes.

Sigh. I think that when “working” with Mathematica, I spend half of my time dealing with stuff that is obscure, badly documented, doesn’t match the documentation, or (in this case) just doesn’t work right.

I don’t think I’m asking for help … the only “help” I would want would be for the Mathematica staff to jump up and send me a corrected Plot3D.

Oh: I’m running 12.2 on Windows 10. At the moment, I’m facing more or less East.

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/7e0c67c7-4ec3-46bb-a836-3e2ee2b5e1a9)

---

<div class="post-metadata">

**Author:** ![mroge02](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mroge02/32/28775_2.png) [@mroge02](https://community.wolfram.com/u/mroge02)\
**Post date:** [April 15, 2024, 5:44pm UTC](https://community.wolfram.com/t/erratic-spikes-in-graph-from-plot3d/23867/2 "2024-04-15T17:44:51Z")

</div>

A point outside a domain can test inside at machine precision either (1) from round-off error or (2) because machine-precisions comparisons are done with tolerance.

The points `Plot3D` plugs into the function depend on the `y` range. Change it and I would expect different spikes, if the first paragraph explains the behavior.

I don’t have a definitive fix. I base mine on the function being plotted. I might use `WorkingPrecision`, `Internal`$EqualTolerance`, `SetPrecision`, `RegionFunction`, `Exclusions`, `"ExtrapolationHandler"` in interpolating functions, and maybe other things. I probably can’t add much more specificity without a specific function to address.

---

<div class="post-metadata">

**Author:** ![danl](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/danl/32/41267_2.png) [@danl](https://community.wolfram.com/u/danl)\
**Post date:** [April 16, 2024, 3:03pm UTC](https://community.wolfram.com/t/erratic-spikes-in-graph-from-plot3d/23867/3 "2024-04-16T15:03:07Z")

</div>

Beyond the useful possibilities Michael notes, I will emphasize that we cannot readily address what we cannot run. A full example containing code for `eFunc` would address this shortcoming.

---

<div class="post-metadata">

**Author:** ![dgolber](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@dgolber](https://community.wolfram.com/u/dgolber)\
**Post date:** [April 16, 2024, 11:38pm UTC](https://community.wolfram.com/t/erratic-spikes-in-graph-from-plot3d/23867/4 "2024-04-16T23:38:38Z")

</div>

Here’s a simple example.

[demo3 .nb](https://community.wolfram.com/uploads/short-url/tf521MDT6m3i7wfflnwQ97g7KiE.nb) (117 KB)

---

<div class="post-metadata">

**Author:** ![danl](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/danl/32/41267_2.png) [@danl](https://community.wolfram.com/u/danl)\
**Post date:** [April 16, 2024, 11:57pm UTC](https://community.wolfram.com/t/erratic-spikes-in-graph-from-plot3d/23867/5 "2024-04-16T23:57:46Z")

</div>

Unfortunately I cannot replicate those spikes using version 13.2 or 14.0 on Ubuntu Linux. It might be platform dependent.
