Numerical solvers are not guaranteed to find all roots of an expression. That's what's happening here. The algorithm vpasolve is using doesn't "notice" the root near 0.0659. If your start/end range bracketed that value, it would find it however:
>> vpasolve(freq,B, [.99,1.01]*0.0659)
ans =
0.06590835809882684726711430520395
Unless you can find a way to bracket each root like this, you'll never be 100% sure to catch all of them. One option to increase the likelihood of finding every root is to start with a small bracket, then gradually increase the upper bound until you find a root, then shift your bracket over. So for example, if you instead make your FindBeta function something like:
function Bet = FindBeta(FrequencyEquation, StartAt, EndAt, NumberOfBetas)
Bet = zeros(NumberOfBetas,1);
syms B
incStrt = 1e-9;
incEnd = 1e-2;
StrtRg = StartAt;
for i = 1:NumberOfBetas
EndRg = StrtRg + incEnd;
NoRoot = true;
while NoRoot
Beti = vpasolve(FrequencyEquation,B, [StrtRg; EndRg]);
if isempty(Beti)
if EndRg > EndAt
Beti = NaN;
NoRoot = false;
end
EndRg = EndRg + incEnd;
else
if Beti > EndRg
Beti = NaN;
end
NoRoot = false;
end
end
if isnan(Beti)
Bet(i:end) = NaN;
return;
else
Bet(i) = Beti;
StrtRg = Beti + incStrt;
end
end
end
Then:
Beta =
0.00285611175750407
0.0279531203899501
0.0435503148892885
0.0659083580988268
The parameter incEnd is a key one that must be tuned somehow. Smaller values make it more likely that you'll find all the roots, but at the cost of increasing the amount of time it takes to do so.
0 Comments
Sign in to comment.