0

I have to solve an inequality but it is too hard to do it by hand. Therefore, I would like to use Matlab. Let a = [(k-3)*sqrt(v)]/s and b = 1.08148*a^2-epsilon, where epsilon = 10^(-6). The inequality that needs to be solved is:

q(a,b) < s*sqrt(v)

where s and v are known. More precisely I want to solve the above inequality for k (which occurs in a and b). Now, the problem is that q(a,b) is the greatest real root of the quartic polynomial:

(48*a^2+16*b)*x^4 - (40*a^3+168*a*b)*x^3+(-45*a^4+225*a^2*b+72*b)*x^3+(27*a^2*b-162*a*b^2)*x+27*b^3

I tried to run this:

syms x z
  av = ((x-3)*sqrt(v))/s;
 Q = max(roots([48*z^2+16*(1.08148*z-eps), -40*z^3-168*z*(1.08148*z-eps), -45*z^4+225*z^2*(1.08148*z-eps)+72*(1.08148*z-eps)^2, 27*z^3*(1.08148*z-eps)-162*z*(1.08148*z-eps)^2, 27*(1.08148*z-eps)^3]));
 F = compose(Q,av);
solve(F-skew*sqrt(var)<0, x)

but Matlab keeps giving the following error:

Error using sym/max (line 97) Input arguments must be convertible to floating-point numbers.

Error in Testt (line 13) R = max(roots([2048, -6912*((x-3)sqrt(var)/skew)^2, 8088((x-3)sqrt(var)/skew)^4, -3600((x-3)sqrt(var)/skew)^6, 375((x-3)*sqrt(var)/skew)^8]));

Perhaps someone has a better idea to solve it? The best way would be if I had an explicit expression for the greatest real root q of the quartic in function of a and b. However, this explicit expression is too lengthy to use.

Suever
  • 64,497
  • 14
  • 82
  • 101
Cavents
  • 135
  • 6
  • I'm not sure why you need to be using symbolic math as opposed to doing it numerically. The `max` function is [ill-defined for symbolic expressions](http://www.mathworks.com/matlabcentral/answers/102485-why-are-symbolic-variables-not-allowed-when-using-the-functions-max-min-in-the-symbolic-math-toolbox) that can't be reduced numerically. There are potentially ways around this but the code in your question isn't really runnable ... and you seem to have solved the problem. – horchler Mar 17 '16 at 17:57

1 Answers1

0

The error information seemed to say the max() function do not support sym x z.

Because the returned result of roots() includes x and z.But Matlab doesn't know the value of x and z,so it can't calculate the value of the roots and then can't compare them.

Maybe you should improve your algorithm.

Sixm.W
  • 16
  • 4
  • Thanks! However, I keep getting the same error. Maybe its due to the roots function, but I do not see another way to solve the inequality. – Cavents Mar 17 '16 at 13:47
  • I have edited my answer. You will get only four roots,so you can compare them by hands or calculate the inequality for each root and then decide which one is true solution by hands.@Siron – Sixm.W Mar 17 '16 at 14:16