I got x as a result of the symbolic equation solver!

3 views (last 30 days)
Hi all, When I run the below code I got the following answer, and I don't know what does x mean:
ans =
struct with fields:
p1: x
parameters: x
conditions: x < -((lambda + v)*(delta - 2))/2 & (12*B*delta + 24*delta*x + 4*B*delta^3 + 8*delta^2*lambda…
This a part of my whole code, but in this part I am trying to find the optimal p1 which maximize the totalprofit. Obviously the function totalprofit is not quadratic but still I couldn't get the meaning of x. Can someone please help?
Thanks in advance.
syms n p1 lambda delta v N F B
n=(delta - B*delta + 2*delta*v + (4*B*delta - 4*delta - 8*delta*lambda + 8*delta*p1 - 8*delta*v - 2*B*delta^2 + 4*delta^2*lambda + 4*delta^2*v + delta^2 + B^2*delta^2 + 4)^(1/2) - 2)/(2*delta) assume(0<n & n<v & v-B/2+(B^2/4+B/2+lambda-v+1/4)^(1/2)-1/2<=n & B>0 & lambda>0 & 0<delta & delta<1) assume((delta - 1)*(B/2 - v - (B^2/4 + B/2 + lambda - v + 1/4)^(1/2) + lambda/(delta - 1) + 1/2)<p1 & p1<-((lambda + v)*(delta - 2))/2)
p2 =simplify(lambda/2 + n/2 - (n - v)^2/2 - (B*(n - v))/2)
D1=simplify(v-n)
D2=simplify(n-p2+lambda-D1^2+B*D1)
profit1=simplify(p1*(D1)-F*(lambda)^2)
profit2=simplify(p2*(D2))
totalprofit=simplify(profit1+profit2)
firstdifofp1_totalprofit=simplify(diff(totalprofit,p1))
solve(firstdifofp1_totalprofit,p1, ReturnConditions=true)
  3 Comments
melda
melda on 25 Jan 2024
I couldn't relate that one with mine.. You may right there might be no solution but in that case doesn't matlab return empty ? When I remove assumptions it give me z1 instead of x. So, I am thinking maybe it is because of the lenght of my solution?
Aquatris
Aquatris on 25 Jan 2024
Edited: Aquatris on 25 Jan 2024
As @John D'Errico explained, you have a condition under which you have a solution. The link I had in my comment solves the condition and finds the solution that satisfies the condition. However in your example it returns empty saying it cannot find explicit solution. Maybe I was not clear when I said 'no solution'. What I meant was 'no unique solution'.

Sign in to comment.

Answers (1)

John D'Errico
John D'Errico on 25 Jan 2024
Edited: John D'Errico on 25 Jan 2024
syms n p1 lambda delta v N F B
n=(delta - B*delta + 2*delta*v + (4*B*delta - 4*delta - 8*delta*lambda + 8*delta*p1 - 8*delta*v - 2*B*delta^2 + 4*delta^2*lambda + 4*delta^2*v + delta^2 + B^2*delta^2 + 4)^(1/2) - 2)/(2*delta);
assume(0<n & n<v & v-B/2+(B^2/4+B/2+lambda-v+1/4)^(1/2)-1/2<=n & B>0 & lambda>0 & 0<delta & delta<1)
assume((delta - 1)*(B/2 - v - (B^2/4 + B/2 + lambda - v + 1/4)^(1/2) + lambda/(delta - 1) + 1/2)<p1 & p1<-((lambda + v)*(delta - 2))/2)
p2 =simplify(lambda/2 + n/2 - (n - v)^2/2 - (B*(n - v))/2);
D1=simplify(v-n);
D2=simplify(n-p2+lambda-D1^2+B*D1);
profit1=simplify(p1*(D1)-F*(lambda)^2);
profit2=simplify(p2*(D2));
totalprofit=simplify(profit1+profit2);
firstdifofp1_totalprofit=simplify(diff(totalprofit,p1));
solve(firstdifofp1_totalprofit,p1, ReturnConditions=true)
ans = struct with fields:
p1: x parameters: x conditions: x < -((lambda + v)*(delta - 2))/2 & (12*B*delta + 24*delta*x + 4*B*delta^3 + 8*delta^2*lambda + 4*delta^4*lambda + 8*delta^2*v + 4*delta^4*v + 12*delta^3*x + 6*delta^2 + delta^4 +…
Simple enough.
The result is ANY number x that satisfies those bounds.
Let me create a much simpler problem as an example.
syms X
Xsol = solve((X^2 + 4*X + 4) <= 4,'returnconditions',true)
Xsol = struct with fields:
X: [2×1 sym] parameters: x conditions: [2×1 sym]
I'll plot the function
fplot((X^2 + 4*X + 4))
yline(4)
So that is true when x >= -4 AND x<=0. Do you agree? And ANY number in that interval is a valid solution. Now look back at the conditions in Xsol.
Xsol.conditions
ans = 
So much less complicated than what you got, but much the same too. In your case, the solution is any number x that satisfies those inequalities. There is no unique solution.
  1 Comment
melda
melda on 25 Jan 2024
I got it thank you. If that is the case having no unique solution is not good for my model at all.

Sign in to comment.

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!