I got x as a result of the symbolic equation solver!
3 views (last 30 days)
Show older comments
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
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'.
Answers (1)
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)
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)
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
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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!