'ReturnConditions' creates error in 'solve'

Hi! I am trying to solve the following system of equations analytically. Matlab can't solve the general case (in which phi is not specified) so I set its value to -1.
syms i1 i2 gamma phi w r
firstfoc=( (2+r)*w/(1+r) ) * ...
(gamma*i1^phi + (1-gamma)*i2^phi)^(1/phi)*gamma*i1^(phi-1)==1+r
secondfoc=((2+r)*w/(1+r) ) * ...
(gamma*i1^phi + (1-gamma)*i2^phi)^(1/phi)*(1-gamma)*i2^(phi-1)==1
firstfoc=subs(firstfoc,phi,-1)
secondfoc=subs(firstfoc,phi,-1)
[i1sol, i2sol]=solve(firstfoc, secondfoc, i1, i2)
[i1sol, i2sol]=solve(firstfoc, secondfoc, i1, i2,'ReturnConditions',true)
As you can see, the first call to "solve" returns an answer, but warns that it's parameter-dependent and advises setting 'ReturnConditions' to true. However, doing so causes a rather opaque error. What's going on here, and is there an easy way to tell over what regions in the (gamma, w, r) parameter space there is a solution?
Any help would be greatly appreciated!

 Respuesta aceptada

Provide output variables, and outputs to return the parameters and conditions:
syms i1 i2 gamma phi w r
firstfoc=( (2+r)*w/(1+r) ) * ...
(gamma*i1^phi + (1-gamma)*i2^phi)^(1/phi)*gamma*i1^(phi-1)==1+r
firstfoc = 
secondfoc=((2+r)*w/(1+r) ) * ...
(gamma*i1^phi + (1-gamma)*i2^phi)^(1/phi)*(1-gamma)*i2^(phi-1)==1
secondfoc = 
firstfoc=subs(firstfoc,phi,-1)
firstfoc = 
secondfoc=subs(firstfoc,phi,-1)
secondfoc = 
[i1sol, i2sol]=solve(firstfoc, secondfoc, i1, i2)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
i1sol = 
i2sol = 
[isol1, isol2, parms, condx]=solve(firstfoc, secondfoc, [i1,i2], 'ReturnConditions',true)
isol1 = 
isol2 = 
parms = 
z
condx = 
.

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.

Productos

Versión

R2020a

Preguntada:

el 22 de Jun. de 2021

Respondida:

el 22 de Jun. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by