# Help to plot a surface plot with infinite roots?

**URL:** <https://discourse.julialang.org/t/help-to-plot-a-surface-plot-with-infinite-roots/98291>\
**Category:** Visualization\
**Tags:** plotting, visualization, roots\
**Created:** [May 4, 2023, 3:00am UTC](https://discourse.julialang.org/t/help-to-plot-a-surface-plot-with-infinite-roots/98291 "2023-05-04T03:00:38Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [May 6, 2023, 8:34pm UTC](https://discourse.julialang.org/t/help-to-plot-a-surface-plot-with-infinite-roots/98291/6 "2023-05-06T20:34:11Z")

</div>

For future reference, it’s really difficult to debug something based on “it’s not working” and separate pieces of code that I don’t know how to stitch together. [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757).

One thing I see immediately is that the surface plot takes the arguments in the order `x, y, Z`. But when I run your code, `u_real` is all `NaN`, so it’s probably not going to be a very pretty plot.

Here’s a rewrite from the math:

```julia
using Roots, Plots
B = 1
Λ_s = 0
N = 20

v(y, t; B, α, Λ_s) = (B*y + 1)/(B + 1) - 2*sum(α_k -> sin(α_k*(1-y))/(α_k*(1 + cos(α_k)^2/(B*(1-Λ_s*α_k^2)) + 2*B*Λ_s*sin(α_k)^2))*exp(-α_k^2*t), α)
f(x) = tan(x) + x/(B*(1-Λ_s*x^2))
α = zeros(N)
for k in 1:N
   α[k] = find_zero(f, (nextfloat(π*(k-3//2)), prevfloat(π*(k-1//2))))
end
plot(α)
plot(range(0,2,100), range(0,1,100), (y,t)->v(y, t; B, α, Λ_s); seriestype=:surface)

```

---

_[View the full topic](https://discourse.julialang.org/t/help-to-plot-a-surface-plot-with-infinite-roots/98291)._
