Get the analytical solution of inequalities in Matlab.

Hello,
x + 2 y + 3 c + 4 d == 3/2 && x + y + c + d == 2 && x >= 2 &&
y < 2 && c < 3 && d > 5
How to solve this inequations to get the solution of x, y, c, and d in Matlab?
Best regards.

답변 (2개)

Walter Roberson
Walter Roberson 2023년 9월 3일

1 개 추천

댓글 수: 6

syms x y c d
eqns = [x + 2 * y + 3 * c + 4 * d == 3/2
x + y + c + d == 2
x >= 2
y < 2
c < 3
d > 5]
eqns = 
sol = solve(eqns, 'returnconditions', true)
sol = struct with fields:
c: 13/2 - 2*z1 - 3*z d: 2*z + z1 - 9/2 x: z y: z1 parameters: [z z1] conditions: 7 < 6*z + 4*z1 & 19 < 4*z + 2*z1 & z1 < 2 & 2 <= z
%now try to find the boundaries
parts = children(sol.conditions)
parts = 1×4 cell array
{[7 < 6*z + 4*z1]} {[19 < 4*z + 2*z1]} {[z1 < 2]} {[2 <= z]}
sol2 = solve([lhs(parts{1})==rhs(parts{1}), lhs(parts{2})==rhs(parts{2})])
sol2 = struct with fields:
z: 31/2 z1: -43/2
subs(sol, sol2)
ans = struct with fields:
c: 3 d: 5 x: 31/2 y: -43/2 parameters: [31/2 -43/2] conditions: 7 < 7 & 19 < 19 & -43/2 < 2 & 2 <= 31/2
After that you have to explore which side of the bounds the values need to be on
Note that z effectively stands in for x and z1 effectively stands in for y -- that once you have particular x and y values then the c and d are pinned down.
The output of this way is still too complicate. Is there another way just like Maple of Julia do?
Can you describe your expectation of the results? There are 4 variables but only 2 equations.
This one:
((15/4 < x <= 31/2 && 1/2 (19 - 4 x) < y < 2 &&
c == 1/2 (13 - 6 x - 4 y)) || (x > 31/2 &&
1/4 (7 - 6 x) < y < 2 && c == 1/2 (13 - 6 x - 4 y))) &&
d == 1/8 (3 - 6 c - 2 x - 4 y)
Or this one
{[{31/2 < x}, {y < 2, 7/4 - (3*x)/2 < y}, {c = 13/2 - 3*x - 2*y}, {d = -9/2 + 2*x + y}], [{x <= 31/2, 15/4 < x}, {y < 2, 19/2 - 2*x < y}, {c = 13/2 - 3*x - 2*y}, {d = -9/2 + 2*x + y}]}
The Maple output looks like this

댓글을 달려면 로그인하십시오.

Bruno Luong
Bruno Luong 2023년 9월 3일
편집: Bruno Luong 2023년 9월 3일
The real question is how would you get as formal decription of the so called "solution" of the equality linear system?
There is no mathematical semantic AFAIK to describe the solution beside what is similar to you question, a set S that satisfies
A*x <= b
Aeq*x = beq
lo <= x <= up
One can show to linear transform the variables x to y so as the above can be reduced to the so called canonical form of
C*y = d
y <= 0
but there is no way to express it shorter.
Another way is if the region S is bounded, it is a polytope and one can express as a "sub-convex" combination of a finite set of vertexes.
S = sum wi * Vi
sum wi <= 1
In other word a convex hull where the vetices are {Vi}. There is a numerical method in FEX made by Matt J. It works OK for toy dimension of 2-3, but I wouldn't trust it for dimension >= 10.
In short the most convenient to "solve" linear inequalitues is to let it as it is. You want to know a point is a solution? Just replace and check it.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2023a

태그

질문:

2023년 9월 3일

편집:

2023년 9월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by