%% Solve Inequalities
% The solve function can solve inequalities and return solutions that satisfy the inequalities. Solve the following inequalities.
% x>0
% y>0
% x^2 + y^2 + xy < 1
% Set 'ReturnConditions' to true to return any parameters in the solution and conditions on the solution.

syms x y
eqn1 = x > 0;
eqn2 = y > 0;
eqn3 = x^2 + y^2 + x*y < 1;
eqns = [eqn1 eqn2 eqn3];

S = solve(eqns,[x y],'ReturnConditions',true);
S.x
S.y
S.parameters
S.conditions

% The parameters u and v do not exist in MATLAB® workspace and must be accessed using S.parameters.
% Check if the values u = 7/2 and v = 1/2 satisfy the condition using subs and isAlways.

condWithValues = subs(S.conditions, S.parameters, [7/2,1/2]);
isAlways(condWithValues)

% isAlways returns logical 1 (true) indicating that these values satisfy the condition. Substitute these parameter values into S.x and S.y to find a solution for x and y.

xSol = subs(S.x, S.parameters, [7/2,1/2])
ySol = subs(S.y, S.parameters, [7/2,1/2])

%
% Copyright 2006-2019 The MathWorks, Inc.