4

I am trying to find the arc length for

enter image description here

using

n = 2; f[x_] := -2 Re[ExpIntegralEi[(ZetaZero[n]) Log[x]]] Log[x]/ Sqrt[x]
a = Quiet[FindMinimum[f[x], {x, 1.4}]];
b = Quiet[FindMaximum[f[x], {x, 1.7}]];
Plot[f[x], {x, (x /. a[[2]]) - 0.1, (x /. b[[2]]) + 0.1}, 
Epilog -> {Red, PointSize[Medium], Point[{{x /. a[[2]], a[[1]]},
{x /. b[[2]], b[[1]]}}]}, ImageSize -> 300]

arc = NIntegrate[ Sqrt[1 + D[f[x], x]^2], {x, (x /. a[[2]]), (x /. b[[2]])}]

Am I doing something silly?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
martin
  • 8,678
  • 4
  • 23
  • 70

4 Answers4

5

Based on @RunnyKine's comment the trouble is with Re. It seems there should be a more elegant way to do this, but moving the Re outside the differential does the job:

 da[x_] = Sqrt[1 +
     (Re@D[(-2 (ExpIntegralEi[(ZetaZero[n]) Log[x]]) Log[x]/Sqrt[x]),x])^2  ]
 NIntegrate[da[x], {x, x /. a[[2]], x /. b[[2]]}]

.308277

Also, yet another line measure approach:

 Total[Norm /@ 
     Differences@
          Table[{x, f[x]}, {x, (x /. a[[2]]), (x /. b[[2]]), .0001}]]

0.308216

george2079
  • 38,913
  • 1
  • 43
  • 110
4

If you just plot the region of the graph you're interested in:

pl = Plot[f[x], {x, (x /. a[[2]]), (x /. b[[2]])}, 
  Epilog -> {Red, PointSize[Medium], Point[{{x /. a[[2]], a[[1]]}, {x /. b[[2]], b[[1]]}}]}, 
  ImageSize -> 300, PlotPoints -> 500]

Mathematica graphics

Then, you can do:

ArcLength @ DiscretizeGraphics @ pl

0.30827679

RunnyKine
  • 33,088
  • 3
  • 109
  • 176
3

Or Create an interpolation function from the plot and calculate its arc length. Note that I have modified the definitions of a and b.

n = 2; f[x_] := -2 Re[ExpIntegralEi[(ZetaZero[n]) Log[x]]] Log[x]/Sqrt[x]
a = FindArgMin[f[x], {x, 1.4}][[1]] // Quiet;
b = FindArgMax[f[x], {x, 1.7}][[1]] // Quiet;

plt = Plot[f[x], {x, a, b}];

f2 = Interpolation[
   Cases[plt, Line[pts_] :> pts, Infinity][[1]]];

arc = NIntegrate[Sqrt[1 + f2'[x]^2], {x, a, b}]

0.308277

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
1

In general, one may find the arc length of a graph of f[x] with ArcLength[{x, f[x]}, {x, a, b}] since V10.0, although its robustness improves (hopefully) with age. In this case, the difficulty is Re[] in f[x], and Re[z] is not a differentiable function of a complex variable. However, Re[g[x]] can be a differentiable function of a real variable x. The next problem is that ComplexExpand does not work in this case, as recommended in the documentation for Re (see "Possible Issues"). Thus, I am thrown back onto basic principles, namely, use the definition of the derivative, which will be found defining fp[x] below. Now we have to get ArcLength to use it. To do this, we need to prevent f[x] from evaluating. It would be nice if it were defined as f[x_?NumericQ]; however, while that's convenient for this purpose, it is often inconvenient for other purposes. But we can easily temporarily redefine f[] this way as done below, while also defining the derivative of f[x]. (The limit could be done inside Block; but (1) I wanted to show the result and (2) since it takes so long, it's nice to do it once and save the result. Actually, the result is partially cached, so recomputing gets faster.)

fp[x_] = (* takes 13+ sec. *)
 Limit[(f[x + h] - f[x])/h, h -> 0, Assumptions -> x > 0] // 
  FullSimplify
(*
x^(-(3/2) - ZetaZero[2]) *
  (-x - x^(2 ZetaZero[2]) + 
   x^ZetaZero[2] (-2 + Log[x]) Re[ExpIntegralEi[Log[x] ZetaZero[2]]])
*)

Block[{f, y = f[x]}, f /: HoldPattern[D[f[x], x]] = fp[x]; f[x_?NumericQ] = y; ArcLength[{x, f[x]}, {x, (x /. a[[2]]), (x /. b[[2]])}] ]

(* 0.308277 *)

Michael E2
  • 235,386
  • 17
  • 334
  • 747