%% Specify Ranges of Solutions
% You can specify ranges of solutions of an equation. For example, if you want to restrict your search to only real solutions, you cannot use assumptions because vpasolve ignores assumptions. Instead, specify a search interval. For the following equation, if you do not specify ranges, the numeric solver returns all six solutions of the equation.

syms x
S = vpasolve(x^6 - x^2 == 3, x)

% Suppose you need only real solutions of this equation. You cannot use assumptions on variables because vpasolve ignores them.

assume(x,'real')
S = vpasolve(x^6 - x^2 == 3, x)

% Specify the search range to restrict the returned results to particular ranges. For example, to return only real solutions of this equation, specify the search interval as [-Inf Inf].

S = vpasolve(x^6 - x^2 == 3, x, [-Inf Inf])

% To return nonnegative solutions, specify the search interval as [0 Inf].

S = vpasolve(x^6 - x^2 == 3, x, [0 Inf])

% The search range can also contain complex numbers, such as [-1, 1+2i]. In this case, vpasolve uses a rectangular search area in the complex plane where -1 specifies the bottom-left corner of the search area and 1+2i specifies the top-right corner of that area.

S = vpasolve(x^6 - x^2 == 3, x, [-1 1+2i])

%
% Copyright 2012-2019 The MathWorks, Inc.