Reputation: 21
I would like to solve a system of equations symbolically for beta1
, beta2
, and beta3
. I defined variables as follows and set up the equation system:
w1 = sym('w1', 'real');
w2 = sym('w2', 'real');
me1 = sym('me1', 'real');
me2 = sym('me2', 'real');
btm1 = sym('btm1', 'real');
btm2 = sym('btm2', 'real');
mom1 = sym('mom1', 'real');
mom2 = sym('mom2', 'real');
gamma = sym('gamma', 'real');
T = sym('T', 'real');
beta1 = sym('beta1', 'real');
beta2 = sym('beta2', 'real');
beta3 = sym('beta3', 'real');
Nt = sym('Nt', 'real');
r1 = sym('r1', 'real');
r2 = sym('r2', 'real');
syms e1 e2 e3 real
b = [1/T * (1 + ( w1 + 1/Nt * beta1 * me1 + beta2 * btm1 + beta3 * mom1 ) *r1 ) ^(-gamma) * ( 1/Nt * me1 * r1 ) + 1/T * (1 + ( w2 + 1/Nt * beta1 * me2 + beta2 * btm2 + beta3 * mom2 ) *r2 ) ^(-gamma) * ( 1/Nt * me2 * r2 )
1/T * (1 + ( w1 + 1/Nt * beta1 * me1 + beta2 * btm1 + beta3 * mom1 ) *r1 ) ^(-gamma) * ( 1/Nt * btm1 * r1 ) + 1/T * (1 + ( w2 + 1/Nt * beta1 * me2 + beta2 * btm2 + beta3 * mom2 ) *r2 ) ^(-gamma) * ( 1/Nt * btm2 * r2 )
1/T * (1 + ( w1 + 1/Nt * beta1 * me1 + beta2 * btm1 + beta3 * mom1 ) *r1 ) ^(-gamma) * ( 1/Nt * mom1 * r1 ) + 1/T * (1 + ( w2 + 1/Nt * beta1 * me2 + beta2 * btm2 + beta3 * mom2 ) *r2 ) ^(-gamma) * ( 1/Nt * mom2 * r2 )];
Now I want my result and always get Empty sym: 0-by-1
:
res = solve(b-[e1 e2 e3]', beta1, beta2, beta3, 'IgnoreAnalyticConstraints', true);
simplify(res.beta1)
ans =
Empty sym: 0-by-1
I expected to solve this issue by using 'IgnoreAnalyticConstraints'
as proposed in this StackOverflow question. Can anyone help me?
Upvotes: 2
Views: 8744
Reputation: 18484
The 'IgnoreAnalyticConstraints'
option is not magic that allows one to solve any symbolic system analytically. You didn't mention it in your question (a good idea in the future), but running your code in R2015a also result in a warning message:
Warning: Cannot find explicit solution.
From the documentation for solve
:
If solve returns an empty object, then no solutions exist. If solve returns an empty object with a warning, solutions might exist but solve did not find any solutions.
It is very unlikely that general analytic solutions exist for your system with all arbitrary parameters. If you explicitly set some of your parameters to specific values (e.g., small integers) you may find a few solutions. Using assumptions
can also help sometimes.
Upvotes: 1