%% Find Multiple Solutions for Nonpolynomial Equation
% By default, vpasolve returns the same solution on every call. To find more than one solution for nonpolynomial equations, set 'Random' to true. This makes vpasolve use a random initial guess which can lead to different solutions on successive calls.
% If 'Random' is not specified, vpasolve returns the same solution on every call.

syms x
f = x-tan(x);
for n = 1:3
    S = vpasolve(f,x)
end

% When 'Random' is set to true, vpasolve returns a distinct solution on every call.

for n = 1:3
    S = vpasolve(f,x,'Random',true)
end

% The 'Random' option can be used in conjunction with a search range.

S = vpasolve(f,x,[10 12],'Random',true)

%
% Copyright 2012-2019 The MathWorks, Inc.