Please help me determine positive values of s and h(s,h>0) such that L1 and L2 have opposite signs. Then print L1 and L2

L1=((s-h)*2*a3*(a1*s^2+a2*s*h+h^2))/(a12*g*s*(1+a1)*(s^2+h^2));
L2=((s-h)*2*a3*(s^2-a2*s*h+a1*h^2))/(a12*g*s*(1+a1)*(s^2+h^2));
Where :
a1=0.2494;
a2=0.75;
a3=0.01;
a12=1.699*10^-14;
g=9.8

Answers (2)

What have you tried? Look carefully at what you have. Take it apart, one piece at a time.
a1=0.2494; a2=0.75; a3=0.01; a12=1.699*10^-14; g=9.8;
syms s h positive
L1=((s-h)*2*a3*(a1*s^2+a2*s*h+h^2))/(a12*g*s*(1+a1)*(s^2+h^2));
L2=((s-h)*2*a3*(s^2-a2*s*h+a1*h^2))/(a12*g*s*(1+a1)*(s^2+h^2));
Now, look at the expressions involved. Think about what they do, and what could change the sign between the corresponding expressions.
L1
L1 = 
L2
L2 = 
First, the constant 99035203142830421991929937920000 is identical in both. As well, both have a minus sign in front. How about the denominator? Again, note that it is identically the same for both L1 and L2. Not only that, as long as s is positive, the denominator is ALWAYS strictly positive. So nothing you could do to s or h could change the signs of L1 versus L2.
Similarly, the term
h/50 - s/50
ans = 
is the same in both expressions, multiplied in both L1 and L2. So while different values of s or h could change the sign of the overall terms, they (L1 and L2) will change TOGETHER.
So we can ignore all of the crap in those expressions, to look at the parts that are different. From L1, we can extract only that internal part.
M1 = h^2 + 3*h*s + 1247*s^2/5000
M1 = 
Do you see this expression (A quadratic expression in h and s) is ALWAYS POSITIVE? As long as both h and s are positive, it is too since all coefficients are themselves positive. Now look at L2. Can the corresponding term ever be negative? If not then L1 and L2 will ALWAYS have the same signs.
M2 = 1247*h^2/50 - 3*h*s/4 + s^2
M2 = 
M2 is a quadratic form. A fairly simple one, in fact. It looks to be positive everywhere.
fsurf(M2)
We can find the minimum of that quadratic surface of course.
gradient(M2)
ans = struct with fields:
h: [0×1 sym] s: [0×1 sym]
solve(gradient(M2))
And no solution esists. Why not, since the gradient is purely linear? No solutino exists, because the unique solution lies at s=h=0, and I specified that s and h are strictly positive. And at the point which is a global minimum of M2, it is zero anyway. It never goes negative.
Regardless of what values you choose for s and h, L2 will always have identically the same sign as L1. Your question has no solution.

3 Comments

a1=0.2494; a2=0.75; a3=0.01; a12=1.699*10^-14; g=9.8;
syms s h positive
L1=((s-h)*2*a3*(a1*s^2+a2*s*h+h^2))/(a12*g*s*(1+a1)*(s^2+h^2));
L2=((s-h)*2*a3*(s^2-a2*s*h+a1*h^2))/(a12*g*s*(1+a1)*(s^2+h^2));
Or we could have started with the easy approach and asked Symbolic Math Toolbox if it can prove that they have the same sign.
isAlways(sign(L1) == sign(L2))
ans = logical
1
If it couldn't, it would have told us.
isAlways(s > h)
Warning: Unable to prove 'h < s'.
ans = logical
0
If the Symbolic Toolbox can tell that L1 and L2 always have the same sign, why doesn't it tell that a solution does not exist for the system of inequalities ? Or is the warning from below to be interpreted as "Solution does not exist" ?
a1=0.2494; a2=0.75; a3=0.01; a12=1.699*10^-14; g=9.8;
syms s h positive
L1=((s-h)*2*a3*(a1*s^2+a2*s*h+h^2))/(a12*g*s*(1+a1)*(s^2+h^2));
L2=((s-h)*2*a3*(s^2-a2*s*h+a1*h^2))/(a12*g*s*(1+a1)*(s^2+h^2));
solve([L1>0,L2<0],[s,h])
Warning: Unable to find explicit solution. For options, see help.
ans = struct with fields:
s: [0×1 sym] h: [0×1 sym]
Systems of inequalities are always problematic. Solve seems to look for specific solutions in general. Anyway, your query:
solve([L1>0,L2<0],[s,h])
may conceivably have had the wrong signs for L1 and L2. Probably better would have been to ask
solve(L1/L2 < 0,[s,h])
which at least allows either possibility, and which does cancel the spare sub-terms in the two expressions.
In any case, it still leaves you with asking solve to deal with one equation in two unknowns, something solve has always had difficulties doing. Making it an inequality is even more problematic. However, that solve failed to find a solution does not tell you no solution exists, only that solve failed to find one, why isAlways may be a better choice here.
isAlways(L1/L2 >= 0)
ans =
logical
1

Sign in to comment.

For L1 and L2 to have opposite sign, you can remove equal multiplicative factors in both L1 and L2.
So L1d and L2d in
L1d=a1*s^2+a2*s*h+h^2;
L2d=a1*h^2-a2*s*h+s^2;
must have opposite sign.
L1d is always non-negative ; thus L2d must be negative.
But
a1*h^2-a2*s*h+s^2 =
a1*(h^2-a2/a1*s*h+s^2/a1) =
a1*((h-a2*s/(2*a1))^2 + (1/a1-a2^2/(4*a1^2))*s^2) =
a1*(h-a2*s/(2*a1))^2 + (1-a2^2/(4*a1))*s^2
and
a1=0.2494; a2=0.75;
1-a2^2/(4*a1)
ans = 0.4361
is positive, thus
a1*(h-a2*s/(2*a1))^2 + (1-a2^2/(4*a1))*s^2
is non-negative for all s and h.

Asked:

on 24 Jul 2026

Commented:

on 24 Jul 2026

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!