# Avoiding computational underflow when using Plot3D

**URL:** <https://community.wolfram.com/t/avoiding-computational-underflow-when-using-plot3d/23033>\
**Category:** Questions\
**Tags:** graphics-and-visualization, tuning-and-debugging\
**Created:** [October 31, 2023, 1:46am UTC](https://community.wolfram.com/t/avoiding-computational-underflow-when-using-plot3d/23033 "2023-10-31T01:46:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![frenkelfamily](https://avatars.discourse-cdn.com/v4/letter/f/439d5e/32.png) [@frenkelfamily](https://community.wolfram.com/u/frenkelfamily)\
**Post date:** [October 31, 2023, 1:46am UTC](https://community.wolfram.com/t/avoiding-computational-underflow-when-using-plot3d/23033/1 "2023-10-31T01:46:08Z")

</div>

I get a surface when using Plot3d that is incomplete. The error message says that some numbers  
could not be handled because of underflow. How can I avoid underflow and get a complete surface?  
Thank you.

Bob Frenkel frenkelfamily@hotmail,com

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/2cfdde6f-6d5b-4a45-9d05-c33fde8901a3)

[Rev29Oct.nb](https://community.wolfram.com/uploads/short-url/g8nzn6hXjL45im7upzpDfaFvFNe.nb) (197 KB)

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [October 31, 2023, 8:16am UTC](https://community.wolfram.com/t/avoiding-computational-underflow-when-using-plot3d/23033/2 "2023-10-31T08:16:49Z")

</div>

The underflow would be a problem if you had to multiply it by an overflow. It doesn’t seem to be your case.

---

<div class="post-metadata">

**Author:** ![frenkelfamily](https://avatars.discourse-cdn.com/v4/letter/f/439d5e/32.png) [@frenkelfamily](https://community.wolfram.com/u/frenkelfamily)\
**Post date:** [November 1, 2023, 11:14pm UTC](https://community.wolfram.com/t/avoiding-computational-underflow-when-using-plot3d/23033/3 "2023-11-01T23:14:30Z")

</div>

Thanks Gianluca, I now have the solution.

---

<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:** [November 3, 2023, 12:51pm UTC](https://community.wolfram.com/t/avoiding-computational-underflow-when-using-plot3d/23033/4 "2023-11-03T12:51:33Z")

</div>

If you want a nicer plot, try scaling:

```
Plot3D[(1/(2*Pi))*(1/0.2)*(1/0.5)*(1/
    6)*(Exp[-(0.5/0.04)*(x + 2.0)^2]*Exp[-(0.5/0.25)*(y - 1.2)^2] + 
    Exp[-(0.5/0.04)*(x + 0.5)^2]*Exp[-(0.5/0.25)*(y - 1.5)^2] + 
    Exp[-(0.5/0.04)*(x - 1.4)^2]*Exp[-(0.5/0.25)*(y - 2.9)^2] + 
    Exp[-(0.5/0.04)*(x - 3.1)^2]*Exp[-(0.5/0.25)*(y - 3.1)^2] + 
    Exp[-(0.5/0.04)*(x - 4.3)^2]*Exp[-(0.5/0.25)*(y - 3.3)^2] + 
    Exp[-(0.5/0.04)*(x - 5.7)^2]*
     Exp[-(0.5/0.25)*(y - 4.2)^2]), {x, -4, 8}, {y, -4, 8},
 PlotRange -> {0, 0.5}, ScalingFunctions -> {10^4 # &, #/10^4 &}]

```

---

<div class="post-metadata">

**Author:** ![russell](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/russell/32/19742_2.png) [@russell](https://community.wolfram.com/u/russell)\
**Post date:** [November 5, 2023, 12:07pm UTC](https://community.wolfram.com/t/avoiding-computational-underflow-when-using-plot3d/23033/5 "2023-11-05T12:07:22Z")

</div>

Even simpler: just add the option “PlotPoints-\>101” to your original code.
