I am trying to find all roots in a range, using
y /. FindRoot[Sin[y] == 0, {y, #}] & /@ Range[7]
which gives
{0., 3.14159, 3.14159, 3.14159, 9.42478, 6.28319, 6.28319}
but I would like to get
{0., 3.14159, 6.28319}
What am I doing wrong?
I am trying to find all roots in a range, using
y /. FindRoot[Sin[y] == 0, {y, #}] & /@ Range[7]
which gives
{0., 3.14159, 3.14159, 3.14159, 9.42478, 6.28319, 6.28319}
but I would like to get
{0., 3.14159, 6.28319}
What am I doing wrong?
FindRoot(e.g. because it is much faster for a large class of transcendental equations) you may exploit the technique usingRootIntervalsas in this answer First positive root and instead ofSin[x]use the first terms of its Taylor series e.g.N@First@RootIntervals[Series[Sin[x], {x, 0, 15}] // Normal]. This information is all you may need to work out the solution. – Artes Apr 21 '14 at 00:02Reduceas you suggested :) – martin Apr 21 '14 at 02:56Reduce- by looking at your answer here :) – martin Apr 21 '14 at 02:57FindRootas well even though I wouldn't use it here (Solve[Sin[x] == 0 && 0 <= x <= 2 Pi, x]works too ). For transcendental equations involving trigonometric functions as algebraic variablesReduceandSolvewill work in general (look e.g. here How to get intersection values from a parametric graph? for a simple exception ofSolve). – Artes Apr 21 '14 at 09:01NSolve[Sin[x] == 0 && 0 <= x <= 7, x]which gives the result{{x -> 0.}, {x -> 3.14159}, {x -> 6.28319}}. – Stephen Luttrell Apr 21 '14 at 11:01y /. FindRoot[Sin[y] == 0, {y, #}] & /@ Range[7] // Union– chris Apr 21 '14 at 13:15