%% Numerically Solve Equations
% When solve cannot symbolically solve an equation, it tries to find a numeric solution using vpasolve. The vpasolve function returns the first solution found.
% Try solving the following equation. solve returns a numeric solution because it cannot find a symbolic solution.

syms x
eqn = sin(x) == x^2 - 1;
S = solve(eqn,x)

% Plot the left and the right sides of the equation. Observe that the equation also has a positive solution.

fplot([lhs(eqn) rhs(eqn)], [-2 2])

% Find the other solution by directly calling the numeric solver vpasolve and specifying the interval.

V = vpasolve(eqn,x,[0 2])

%
% Copyright 2006-2019 The MathWorks, Inc.