f
x_
:=Sin[x]Cot
x
+Cos
x
∧
2
+0.5;
a=-2.; b=12.;
zeros=Reap
soln=y
x
/.First
NDSolve
y
′
x
==Evaluate
D
f
x
,x
,y
b
==
(
f
b
)
}
,y
x
,
{
x,a,b
}
,
Method->
{
"EventLocator","Event"->y
x
,
"EventAction":>Sow
x,y
x
2,1
;
initialPoints=Sort
Flatten
Take
zeros,Length
zeros
,1
Algorithm 1