2

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?

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
imeisteri
  • 21
  • 1
  • 3
  • I assume there is no solution but without having the input it's impossible to say. – Daniel Mar 21 '15 at 12:38
  • I did not use the Input here, since I thought it would be easier to solve symbolically first. Can't Matlab just solve the first equation for beta1, then plug in in the second, solve for beta2 and finally plot all in beta 3? – imeisteri Mar 21 '15 at 12:46
  • Why do you think that this system has an analytic solution? It almost certainly does not, especially when you take multiple things to an arbitrary power `gamma` (a bad choice for a variable name too since its the name of a commonly used function). – horchler Mar 21 '15 at 17:33

1 Answers1

1

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.

horchler
  • 18,384
  • 4
  • 37
  • 73