1
$\begingroup$

I have the following function.

 c[n_, k_, z_] := Sum[(-1)^j*(z^(n*j + k)/(n*j + k)!), {j, 0, Infinity}]

I'd like to find roots of the equation

 c[3,1,z]==0

And so I set up a table to determine approximate values using the FindRoot function;

 Table[FindRoot[c[3, 1, z] == 0, {z, i}], {i, 0, 25}] // TableForm

And when I do this, I get a list of 26 values that z is approaching. These are not exact, and the results are truncated decimals that approximate the solutions near the real values of the first 26 nonnegative integers. How can I get Mathematica to

1) Expand the length of the decimal approximations. I've tried to use the N[exp,#] in the above tables expression but this did not work. I'll also note that Mathematica can not find the exact roots of this equation.

2) Enter the decimal approximation of these roots with no repeated values into a list without having to type them all out by hand

$\endgroup$
3
$\begingroup$
$Version

(* "12.0.0 for Mac OS X x86 (64-bit) (April 7, 2019)" *)

Clear["Global`*"]

c[n_, k_, z_] := Sum[(-1)^j*(z^(n*j + k)/(n*j + k)!), {j, 0, Infinity}]

f[z_] = c[3, 1, z]

(* 1/3 E^-z (-1 + 2 E^(3 z/2) Sin[1/6 (π + 3 Sqrt[3] z)]) *)

For a bounded range, Solve will provide exact results expressed as Root objects

(sol1 = Solve[{f[z] == 0, -1 < z < 26}, z]);

The approximate results are

sol1 // N

(* {{z -> 0.}, {z -> 3.01674}, {z -> 6.65062}, {z -> 10.2782}, {z -> 
   13.9058}, {z -> 17.5334}, {z -> 21.161}, {z -> 24.7886}} *)

A typical root looks like

sol1[[2]] // InputForm

(* {z -> Root[{-1/2 + E^((3*#1)/2)*
       Sin[(Pi + 3*Sqrt[3]*#1)/6] & , 3.01674421208407851\
792853936992618024693`20.30243982725732}]} *)

The last argument of the Root is the approximate numerical value of the root along with the precision of the approximate value

Verifying the results,

f[z] /. sol1 // FullSimplify

(* {0, 0, 0, 0, 0, 0, 0, 0} *)

Alternatively, use NSolve with a bounded range of interest. Use arbitrary-precision by setting the WorkingPrecision option

(sol2 = NSolve[{f[z] == 0, -1 < z < 26}, z, WorkingPrecision -> 20])

(* {{z -> 0}, {z -> 3.0167442120840785179}, {z -> 6.6506245189075155822}, {z -> 
   10.278196280969976183}, {z -> 13.905795126299895029}, {z -> 
   17.533393854261920871}, {z -> 21.160992582732551059}, {z -> 
   24.788591311200977250}} *)

Verifying the quality of the results,

f[z] /. sol2

(* {0, 0.*10^-20, 0.*10^-18, 0.*10^-17, 0.*10^-17, 0.*10^-16, 0.*10^-15, 
 0.*10^-14} *)

Use a Plot to get good initial values for FindRoot

Plot[f[z], {z, -2, 26}, PlotRange -> {-3, 3}]

enter image description here

Use arbitrary-precision by setting the WorkingPrecision option

sol3 = FindRoot[f[z] == 0, {z, #},
    WorkingPrecision -> 20] & /@
  {0, 3, 7, 10, 14, 18, 21, 25}

enter image description here

(* {{z -> 3.7007434154171882626*10^-17}, {z -> 3.0167442120840785179}, {z -> 
   6.6506245189075155822}, {z -> 10.278196280969976183}, {z -> 
   13.905795126299895029}, {z -> 17.533393854261920871}, {z -> 
   21.160992582732551059}, {z -> 24.788591311200977250}} *)

Verifying the quality of the results,

f[z] /. sol3

(* {3.7007434154171882626*10^-17, 0.*10^-20, 0.*10^-18, 0.*10^-17, 0.*10^-17, 
 0.*10^-16, 0.*10^-15, 0.*10^-14} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.