MATLAB: How to find the first 3 roots of sin(x)+0.5=0 bigger than zero? (Multiple roots)
multiple rootsperiodic function
Without using fzero function and without plotting the sin(x)+0.5 to find where the plot coincides with the x-axis, is there another way to obtain the first 3 roots of sin(x)+0.5=0?
Thanks Efe
Best Answer
Efe, that looks like a trick question...sin(x)+5 cannot be equal to zero, sincesin(x) is between -1 and +1.
The key to this problem is that there is one root in each interval [n*pi,(n+1)*pi]. I'm going to assume that L > 1, otherwise the region near the origin is a special case.
function beta = find_beta(L,nRoots)
f = @(x) x*cot(x)+L-1;
beta = zeros(nRoots,1);
% A small offset is needed to avoid the asymptotes.
Best Answer