# How can I make sure that there are real roots for the given function? Can I trust the plot only?

I have this function $$f(x)=(\pi -2 x)^2 \sin \left(\frac{\pi ^2}{2 x-2 \pi }+\frac{1}{2} \csc ^{-1}\left(\frac{4 \pi (\pi -x) \csc \left(\frac{\pi ^2}{x-\pi }\right)}{4 (\pi -x)^2+\pi ^2}\right)\right)\\+(3 \pi -2 x)^2 \sin \left(\frac{1}{2} \left(\pi \left(\frac{\pi }{\pi -x}+4\right)+\csc ^{-1}\left(\frac{4 \pi (\pi -x) \csc \left(\frac{\pi ^2}{x-\pi }\right)}{4 (\pi -x)^2+\pi ^2}\right)\right)\right)$$

and I want to check if it has real roots in the interval $$x\in(0,4)$$. Using Plot as

 Plot[(π - 2 x)^2 Sin[π^2/(-2 π + 2 x) + 1/2 ArcCsc[( 4 π (π - x) Csc[π^2/(-π + x)])/(π^2 + 4 (π - x)^2)]] + (3 π - 2 x)^2 Sin[ 1/2 (π (4 + π/(π - x)) + ArcCsc[(4 π (π - x) Csc[π^2/(-π+ x)])/(π^2 + 4 (π - x)^2)])], {x, 0, 4},  PlotPoints -> 1000, AxesLabel -> Automatic]



I get a picture like this

By increasing the number of PlotPoints I see that the curves may cross the $$x$$ axis. Can I trust this result and conclude that there are real roots for this function in the given interval? If so, is it possible to find a closed-form expression for the roots of $$f(x)$$?

• why do you want to use Plot for this? Why not first find all roots in this interval and check if they are all real or not? Mathematica has tools to find roots and ways to check if something is real or not. Sep 23 at 23:30
• @Nasser This was the only option that came to my mind. What command should I use to obtain all the roots? Sep 23 at 23:34
• @Nasser I use x /. Solve[ f == 0 && 0 < x < 4] but Mathematica says : "Solve::nsmet: This system cannot be solved with the methods available to Solve" and "ReplaceAll::reps: {Solve[Plus[<<2>>]^2 Sin[Times[<<2>>]]+Plus[<<2>>]^2 Sin[Plus[<<2>>]]==0&&0<x<4]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing." Sep 23 at 23:42
• if you can identify intervals in which the function is real-valued and continuous (by taking $x\neq\pi$ and examining the argument of $\csc^{-1}$), and can find positive and negative values in those intervals, you can conclude a zero exists by IVT; so maybe seeing for what arguments $csc^{-1}$ is well-defined is a place to start? Sep 23 at 23:44
• haha, maybe. there also might be some technicalities; the region $1<x<2$ looks promising! but then plotting the argument to $\csc^{-1}$ reveals that the argument blows up at $x = \pi/2$, which seems to be exactly when your function hits 0. So then the question of whether you consider your function to be 0 or undefined there depends on the situation! Sep 23 at 23:57

eq[x_] = (\[Pi] - 2 x)^2 Sin[\[Pi]^2/(-2 \[Pi] + 2 x) +
1/2 ArcCsc[(4 \[Pi] (\[Pi] -
x) Csc[\[Pi]^2/(-\[Pi] + x)])/(\[Pi]^2 +
4 (\[Pi] - x)^2)]] + (3 \[Pi] - 2 x)^2 Sin[
1/2 (\[Pi] (4 + \[Pi]/(\[Pi] - x)) +
ArcCsc[(4 \[Pi] (\[Pi] -
x) Csc[\[Pi]^2/(-\[Pi] + x)])/(\[Pi]^2 +
4 (\[Pi] - x)^2)])]

sol=NSolve[eq[x] == 0 && x >= 0 && x <= 4, x, Reals]
{{x->1.5708},{x->1.5708},{x->2.35619},{x->2.61799},{x->2.74889},{x->2.82743},{x->2.87979},{x->2.91719},{x->3.15944},{x->3.19226},{x->3.19576},{x->3.19977},{x->3.36599},{x->3.40339},{x->3.45575},{x->3.53429},{x->3.66519},{x->3.92699}}

xlist=(x /. sol)/\[Pi]
{0.5,0.5,0.75,0.833333,0.875,0.9,0.916667,0.928571,1.00568,1.01613,1.01724,1.01852,1.07143,1.08333,1.1,1.125,1.16667,1.25}


Looks like you can pick closed form fractions of Pi from that list.

We can verify some of these with:

eq[Pi/2]

eq[3 Pi/4]

eq[5 Pi/6]

eq[7 Pi/8]


etc. All return zero

We can automate the roots with

Rationalize[xlist]*Pi
(*{\[Pi]/2, 1.5708, (3 \[Pi])/4, (5 \[Pi])/6, (7 \[Pi])/8, (
9 \[Pi])/10, (11 \[Pi])/12, (13 \[Pi])/14, (177 \[Pi])/176, (
63 \[Pi])/62, (59 \[Pi])/58, (55 \[Pi])/54, (15 \[Pi])/14, (
13 \[Pi])/12, (11 \[Pi])/10, (9 \[Pi])/8, (7 \[Pi])/6, (5 \[Pi])/4}*)


Plug these into eq[x] to show they are roots.

eq[%]
(*{0, 1.45041*10^-14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}*)


I'm not sure why the second element did not rationalize, but the others work.

• Thanks. Excuse me that I ask this since I am neither mathematician nor good at Mathematica :): does your answer verify that there are definitely real roots for this function? @Bill Watts Sep 23 at 23:52
• Yes, the values given are all real. Sep 24 at 0:33
• Take a look at RootApproximant, i.e., sol2 = sol /. x_Real :> RootApproximant[x/Pi]*Pi Sep 24 at 4:07
• @BobHanlon Works very well. I wasn't aware of that function. Thanks Sep 26 at 6:35

This expression has infinitly many roots. A plot implies, roots are at rational multiples of Pi.

f = (\[Pi] - 2 x)^2 Sin[\[Pi]^2/(-2 \[Pi] + 2 x) +
1/2 ArcCsc[(4 \[Pi] (\[Pi] -
x) Csc[\[Pi]^2/(-\[Pi] + x)])/(\[Pi]^2 +
4 (\[Pi] - x)^2)]] + (3 \[Pi] - 2 x)^2 Sin[
1/2 (\[Pi] (4 + \[Pi]/(\[Pi] - x)) +
ArcCsc[(4 \[Pi] (\[Pi] -
x) Csc[\[Pi]^2/(-\[Pi] + x)])/(\[Pi]^2 +
4 (\[Pi] - x)^2)])];

Manipulate[
Plot[f, {x, a, a + .2}, PlotPoints -> 1000,
GridLines -> {Table[i, {i, 0, 4, Pi/3/96}], Automatic},
Ticks -> {Table[i, {i, 0, 4, Pi/3/96}], Automatic},
ImageSize -> 500, PlotStyle -> Red, PlotRange -> 1], {a, 0, 3.8,
Appearance -> "Labeled"}]

f2[xx_] = f /. x -> xx Pi // Simplify[#, xx \[Element] Rationals] &

sols = Cases[
Flatten[Table[{a/b, f2[a/b]}, {a, 1, 200}, {b, 1, 200}], 1], {_,
0}] // Quiet // Union


.

(*   {{1/2, 0}, {3/4, 0}, {5/6, 0}, {7/8, 0}, {9/10, 0},
{11/12, 0}, {13/14, 0}, {15/16, 0}, {17/18, 0},
{19/20, 0}, {21/22, 0}, {23/24, 0}, {25/26, 0},
{27/28, 0}, {29/30, 0}, {31/32, 0}, {33/34, 0},
{35/36, 0}, {37/38, 0}, {39/40, 0}, {41/42, 0},
{43/44, 0}, {45/46, 0}, {47/48, 0}, {49/50, 0},
{51/52, 0}, {53/54, 0}, {55/56, 0}, {57/58, 0},
{59/60, 0}, {61/62, 0}, {63/64, 0}, {65/66, 0},
{67/68, 0}, {69/70, 0}, {71/72, 0}, {73/74, 0},
{75/76, 0}, {77/78, 0}, {79/80, 0}, {81/82, 0},
{83/84, 0}, {85/86, 0}, {87/88, 0}, {89/90, 0},
{91/92, 0}, {93/94, 0}, {95/96, 0}, {97/98, 0},
{99/100, 0}, {101/102, 0}, {103/104, 0}, {105/106, 0},
{107/108, 0}, {109/110, 0}, {111/112, 0}, {113/114, 0},
{115/116, 0}, {117/118, 0}, {119/120, 0}, {121/122, 0},
{123/124, 0}, {125/126, 0}, {127/128, 0}, {129/130, 0},
{131/132, 0}, {133/134, 0}, {135/136, 0}, {137/138, 0},
{139/140, 0}, {141/142, 0}, {143/144, 0}, {145/146, 0},
{147/148, 0}, {149/150, 0}, {151/152, 0}, {153/154, 0},
{155/156, 0}, {157/158, 0}, {159/160, 0}, {161/162, 0},
{163/164, 0}, {165/166, 0}, {167/168, 0}, {169/170, 0},
{171/172, 0}, {173/174, 0}, {175/176, 0}, {177/178, 0},
{179/180, 0}, {181/182, 0}, {183/184, 0}, {185/186, 0},
{187/188, 0}, {189/190, 0}, {191/192, 0}, {193/194, 0},
{195/196, 0}, {197/198, 0}, {199/200, 0}, {199/198, 0},
{197/196, 0}, {195/194, 0}, {193/192, 0}, {191/190, 0},
{189/188, 0}, {187/186, 0}, {185/184, 0}, {183/182, 0},
{181/180, 0}, {179/178, 0}, {177/176, 0}, {175/174, 0},
{173/172, 0}, {171/170, 0}, {169/168, 0}, {167/166, 0},
{165/164, 0}, {163/162, 0}, {161/160, 0}, {159/158, 0},
{157/156, 0}, {155/154, 0}, {153/152, 0}, {151/150, 0},
{149/148, 0}, {147/146, 0}, {145/144, 0}, {143/142, 0},
{141/140, 0}, {139/138, 0}, {137/136, 0}, {135/134, 0},
{133/132, 0}, {131/130, 0}, {129/128, 0}, {127/126, 0},
{125/124, 0}, {123/122, 0}, {121/120, 0}, {119/118, 0},
{117/116, 0}, {115/114, 0}, {113/112, 0}, {111/110, 0},
{109/108, 0}, {107/106, 0}, {105/104, 0}, {103/102, 0},
{101/100, 0}, {99/98, 0}, {97/96, 0}, {95/94, 0},
{93/92, 0}, {91/90, 0}, {89/88, 0}, {87/86, 0},
{85/84, 0}, {83/82, 0}, {81/80, 0}, {79/78, 0},
{77/76, 0}, {75/74, 0}, {73/72, 0}, {71/70, 0},
{69/68, 0}, {67/66, 0}, {65/64, 0}, {63/62, 0},
{61/60, 0}, {59/58, 0}, {57/56, 0}, {55/54, 0},
{53/52, 0}, {51/50, 0}, {49/48, 0}, {47/46, 0},
{45/44, 0}, {43/42, 0}, {41/40, 0}, {39/38, 0},
{37/36, 0}, {35/34, 0}, {33/32, 0}, {31/30, 0},
{29/28, 0}, {27/26, 0}, {25/24, 0}, {23/22, 0},
{21/20, 0}, {19/18, 0}, {17/16, 0}, {15/14, 0},
{13/12, 0}, {11/10, 0}, {9/8, 0}, {7/6, 0}, {5/4, 0},
{3/2, 0}}   *)


Indicates all rationals with (2 a + 1)/(2 a) and (2 a - 1)/(2 a) are solutions.

f2[(2 a + 1)/(2 a)] //
FullSimplify[#, {a \[Element] Integers, a > 1}] &


yields zero (error message can be ignored).

f2[(10^7 + 13)/(10^7 + 12)]

(*   0   *)


I leave it to you to examine whether this are all solutions.