1 year ago
#368476
Nick
Matlab Erroneously Adds +1 at End of Inequality
I am using Matlab to solve the inequality VR2>VR1 in terms of k. The equations are
When solve the inequality by hand, I get an answer of 2αy > k.
When I use Matlab, I get 2αy+1 > k or empty depending on what I do. I have searched the Matlab forums and StackOverflow for a similar problem but I cannot find an explanation. I have also looked at the Matlab manual for the solve() function. I am relatively new to Matlab so any help would be greatly appreciated.
Empty Sym Here is a broken down example of the code. I set all of the symbols and their assumptions. I then write the two equations and use solve() to find the inequality.
%% Symbols Set Up
clear
syms delta y d alpha h lambda pi b k p VRR1 VRL1
assume(alpha > 0 & alpha < 1)
assume(delta > 0 & delta < 1)
assume(pi > 0 & pi < 1)
assume(lambda > 0 & lambda < pi)
assume(y, 'positive')
assume(h, 'positive')
assume(d, 'positive')
assume(k, 'positive')
assume([alpha,delta,pi,lambda,y,h,d,k], 'Real')
UR_A1_GR_RNN_LNN_Y1Z0 = (1-delta)*(h*(pi-lambda)-y*alpha-y)+delta*(pi-lambda)*VRR1+delta*(1-pi+lambda)*VRL1;
UR_A1_GR_RNC_LNN_Y1Z0 = (1-delta)*(h*(pi-lambda)+y*alpha-y-k)+delta*(pi-lambda)*VRR1+delta*(1-pi+lambda)*VRL1;
prop1_R_DevA1_RNN_RNC = simplify(solve(UR_A1_GR_RNC_LNN_Y1Z0>UR_A1_GR_RNC_LNN_Y1Z0,k),3000)
This returns "Empty sym:0-by-1." I have tried reordering the inequalities but that does not affect the results. However, if I switch the operator to "==" I get 2αy.
2αy+1
This result is part of a longer system of equations related to this project. If I use the solutions from that system of equations, the code looks like this
%% Symbols Set Up
clear
syms delta y d alpha h lambda pi b k p VRR1 VRL1
assume(alpha > 0 & alpha < 1)
assume(delta > 0 & delta < 1)
assume(pi > 0 & pi < 1)
assume(lambda > 0 & lambda < pi)
assume(y, 'positive')
assume(h, 'positive')
assume(d, 'positive')
assume(k, 'positive')
assume([alpha,delta,pi,lambda,y,h,d,k], 'Real')
UR_A1_GR_RNN_LNN_Y1Z0 = (1-delta)*(h*(pi-lambda)-y*alpha-y)+delta*(pi-lambda)*VRR1+delta*(1-pi+lambda)*VRL1==VRR1;
UR_A1_GL_RNN_LNN_Y1Z0 = (1-delta)*(h*(1-pi+lambda)-y*alpha-y)+delta*(pi-lambda)*VRL1+delta*(1-pi+lambda)*VRR1==VRL1;
UR_A1_RNN_LNN_Y1Z0 = solve(UR_A1_GL_RNN_LNN_Y1Z0,UR_A1_GR_RNN_LNN_Y1Z0,VRR1,VRL1);
UR_A1_GR_RNN_LNN_Y1Z0 = simplify(UR_A1_RNN_LNN_Y1Z0.VRR1,1000);
UR_A1_GL_RNN_LNN_Y1Z0 = simplify(UR_A1_RNN_LNN_Y1Z0.VRL1,1000);
UR_A1_GR_RNC_LNN_Y1Z0 = (1-delta)*(h*(pi-lambda)+y*alpha-y-k)+delta*(pi-lambda)*UR_A1_RNN_LNN_Y1Z0.VRR1+delta*(1-pi+lambda)*UR_A1_RNN_LNN_Y1Z0.VRL1;
prop1_R_DevA1_RNN_RNC = simplify(solve(UR_A1_GR_RNC_LNN_Y1Z0==UR_A1_RNN_LNN_Y1Z0.VRR1,k),3000)
This returns 2αy+1>k. I want to know why Matlab adds the +1 when using the inequality. Again, if I switch the operator to "==" I get 2αy. I would use "==", but this becomes more difficult for later inequalities and I want to ensure I understand the error here before continuing to use inequality operators in Matlab. Any help in understanding this issue would be greatly appreciated.
matlab
symbolic-math
inequality
0 Answers
Your Answer