# How to find the zero of a function?

I want to find out when a function has a real root.

I first made a RegionPlot3D when the function is zero.

Manipulate[
RegionPlot3D[(A*x)^(1 - s) -
NSum[B^(n)*(x^((1 - s)*z^n))*
Exp[(1 - z^(2 n))*(1 - s)^2*v^2/(2*(1 - z^2))], {n, 1, Infinity}] -
NSum[B^(n)*(y^((1 - s)*q^n))*
Exp[(1 - q^(2 n))*(1 - s)^2*p^2/(2*(1 - q^2))], {n, 1, Infinity}] == 0,
{x, 0.95, 1.05}, {y, 0.95, 1.05}, {z, 0.95, 0.99}],
{q, {0.95}},
{v,{0.0035}},
{p, {0.0035}},
{s,{2}},
{B,{0.95}},
{A,{0.96}}]


I got a blank cubic.

As a check I plotted the function in 2D. However, the 2D plot shows that the function has a zero when M = x =0.9528 and K = y = 1.0396.

Manipulate[
Plot[(A*M)^(1 - s) +
NSum[(B^n*(K^((1 - s)*(q)^n))*
Exp[(1 - (q)^(2*n))*((p)^2)*(1 - s)^2/(2*(1 - (q)^2))]), {n, 1, Infinity}] -
NSum[(B^n*(M^((1 - s)*r^n))*
Exp[(1 - r^(2*n))*(v^2)*(1 - s)^2/(2*(1 - r^2))]), {n, 1, Infinity}] ,
{r, 0.95, 0.99}],
{q, {0.95}},
{M, {0.9528}},
{K, {1.0396}},
{v,{0.0035}},
{p, {0.0035}},
{s, {2}},
{B, {0.95}},
{A, {0.96}}]


Further, I tried to zoom into the area where the 2D plot shows that a zero may exist and found that it is no longer a monotonic function (its zigzag and crosses the horizontal axis many times).

What do I make of this? Does it mean that a zero exists in the complex plane?

• It would help greatly if you kept a unified notation in the two functions you are plotting (the 2d and 3d). Now the symbols are all different and the symbol B seems to be raised to a different pawer in the sum between the two expressions. – gpap Aug 2 '13 at 9:24

Not an answer, but too long for a comment. First off I'd define the function (f) you are manipulating :

sum[b_?NumericQ, v_?NumericQ, s_?NumericQ, x_?NumericQ, z_?NumericQ] :=
NSum[b^(n) (x^((1-s) z^n)) Exp[(1-z^(2 n)) (1-s)^2 v^2/(2 (1-z^2))], {n, 1, Infinity}]

f[q_?NumericQ, v_?NumericQ, p_?NumericQ, s_?NumericQ, b_?NumericQ, a_?NumericQ,
x_?NumericQ, y_?NumericQ, z_?NumericQ] :=
(a x)^(1 - s) - sum[b, v, s, x, z] - sum[b, p, s, y, q]


For your initial choice of parameters in Manipulate :

NMinimize[{f[0.95, 0.0035, 0.0035, 2, 0.95, 0.96, x, y, z],
0.95 <= x <= 1.05, 0.95 <= y <= 1.05, 0.95 <= z <= 0.99}, {x, y, z}]
(* {-38.224, {x -> 0.95, y -> 0.950009, z -> 0.99}} *)

NMaximize[{f[0.95, 0.0035, 0.0035, 2, 0.95, 0.96, x, y, z],
0.95 <= x <= 1.05, 0.95 <= y <= 1.05, 0.95 <= z <= 0.99}, {x, y, z}]
(* {-35.8105, {x -> 1.05, y -> 1.05, z -> 0.99}} *)


so there are no zeros (first blank plot). In general the function is quite complicated and it's not clear what your variables are. You can get a particular class of zeros if a->0.