MATLAB: Solving Inequalitis in Matlab

advanced symbolicsinequalitySymbolic Math Toolbox

Hello everyone.
I apologize for the question which maybe looks stupid but I have problems in solving inequalities with Matlab.
For instance, how can I solve this:
x^2 > 5 ?
If I write:
syms x
solve(x^2 > 5, x)
is not correct:(
Moreover, if I have more parameters and I have to specify the conditions of them, e.g a>0, b>0, n<1 with the inequality given by: 2*a^n +5b^2 -4*a + 2*b > 9,
how can I solve it, for instance, with respect to a?
I tried
syms a b n
solve(2*a^n +5b^2 -4*a + 2*b > 9, a>0, b>0, n<1, a)
but didn't work
Thank you for any kind help

Best Answer

  • I'm not sure what you mean that the solution to x^2 > 5 "is not correct". When I do
    syms x
    solve(x^2 > 5,x)
    I get that x is in the intervals (sqrt(5),Inf) or (-Inf,-sqrt(5)), which looks correct to me. If you want to add restrictions, such as x > 0, you can use assume:
    assume(x > 0)
    solve(x^2 > 5,x)
    Now it just says (sqrt(5),Inf).
    The problem with your more complicated example is that it's just too complicated! If you plug in specific values for n and b it works fine. It can even handle
    assume(a > 0)
    assume(b > 0)
    solve(2*a^2 + 5*b^2 - 4*a + 2*b > 9, a)
    But it thought long and hard about
    solve(2*a^(1/3) + 5*b^2 - 4*a + 2*b > 9, a)
    before saying that it couldn't find an explicit solution. Math is hard, sorry.