Solve function with equations and inequations
古いコメントを表示
Dear all, I'm using the solve function to determine a function out of several conditions (location of maxima,fixed points, etc.). I thought about using the solve function but struggle with using equations and inequations simultaneously.
syms x_1 x_2 x_3 x_4 x_max
eqns= [3* x_1 * (x_max)^2 + 2 * x_2 * x_max + x_3 ==0 , ...
1/4 * 100^4 * x_1 + 1/3 * 100^3 * x_2 + 1/2 * 100^2 * x_3 + 100 * x_4 == 1, ...
5^3 * x_1 + 5^2 * x_2 + 5 *x_3 + x_4 ==0 , ...
100^3 * x_1 + 100^2 * x_2 + 100 * x_3 + x_4 > 2.3 ];
S =solve(eqns, [x_1 x_2 x_3 x_4 x_max]);
I now would like to insert any x_max value to receive specific values for every parameter. How can I implement this, or first: How can I solve these functions? Does anyone has an idea?
Best, Jan
採用された回答
その他の回答 (4 件)
KSSV
2018 年 9 月 19 日
How about this approach?
A = rand(10,1) ; % your x_max values
x = zeros(4,length(A)) ;
for i = 1:length(A)
x_max = A(i) ;
A = [3*(x_max)^2 2*x_max 1 0 ;
1/4*100^4 1/3*100^3 1/2 * 100^2 100 ;
5^3 5^2 5 1 ;
100^3 100^2 100 1 ] ;
b = [0 ; 1 ; 0 ; 2.3 ];
x(:,i) = A\b ;
end
3 件のコメント
Jan GimpelHenning
2018 年 9 月 19 日
Bruno Luong
2018 年 9 月 19 日
編集済み: Bruno Luong
2018 年 9 月 19 日
No, just choose b(4) anything greater than 2.3 as I and Walter told you in our respective answers.
KSSV
2018 年 9 月 19 日
Yes..all the equations considered here are equality.
Bruno Luong
2018 年 9 月 19 日
If you fix x_max and replace the last inequality by the equation
100^3 * x_1 + 100^2 * x_2 + 100 * x_3 + x_4 = 3 % (or any rhs > 2.3) (eqt4bis)
you'll get linear system of 4 unknown and 4 equations. Generally it gives a unique solution (using "\" operator).
So for each x_max, you'll get infinity solutions (x_1, ...x_4) by changing RHS of (eqt4bis) continuously from 2.3 to infinity.
Walter Roberson
2018 年 9 月 19 日
Convert to an equality.
syms x_1 x_2 x_3 x_4 x_max real
syms delta
assume(delta>0);
eqns= [3* x_1 * (x_max)^2 + 2 * x_2 * x_max + x_3 == 0, ...
1/4 * 100^4 * x_1 + 1/3 * 100^3 * x_2 + 1/2 * 100^2 * x_3 + 100 * x_4 == 1, ...
5^3 * x_1 + 5^2 * x_2 + 5 *x_3 + x_4 == 0, ...
100^3 * x_1 + 100^2 * x_2 + 100 * x_3 + x_4 == 2.3 + delta ];
S = solve(eqns, [x_1 x_2 x_3 x_4 x_max]);
x_1, x_2, and x_4 will come out in terms of delta, with x_3 and x_max coming out 0.
You can then make delta positive and arbitrarily close to 0 or as large and positive as you want
>> subs([S.x_1 S.x_2 S.x_3 S.x_4 S.x_max], delta, 10)
ans =
[ 697378134818815959/14008751663786663333750, -42103925179940864/11207001331029330667, 0, 9828603160166400041/112070013310293306670, 0]
>> subs(eqns, [x_1 x_2 x_3 x_4 x_max], ans)
ans =
[ 0 == 0, 1 == 1, 0 == 0, 123/10 == delta + 23/10]
The last of those expressions shows you that the value that would be calculated by the left side of the inequality would be 123/10, which is greater than 23/10 on the right hand side of the inequality, with the difference being the 10 that was substituted for delta
Alex Sha
2019 年 10 月 11 日
0 投票
There are too many numerical solutions:
1:
x_1: 0.0219289963140093
x_2: -1.20176285580936
x_3: -33.4147964294915
x_4: 194.37692900344
x_max: -10.7432904127419
2:
x_1: 0.0314801209421686
x_2: -4.09612586532522
x_3: 126.339211496887
x_4: -533.227925969075
x_max: 20.0613135430092
3:
x_1: 0.101969454491413
x_2: -11.5043706885438
x_3: 279.570790819788
x_4: -1122.99086869677
x_max: 59.9768924098454
....
カテゴリ
ヘルプ センター および File Exchange で Common Operations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!