Solving for a system
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm new to Matlab and have been trying to use it to solve for symbolic variables in a series of equations. I have 9 equations and 9 variables (plus the odd parameter everynow and then). I'm looking for the solution to S, n, N, and l that will up giving me eq 4 below. I realize I'm messing up somewhere but after 4 days of looking everywhere online and trying, I've admitting ignorance and coming here.
I know it can be done, but I'm stucker than a nail and it's been a while since I dealt with any of this in college.
syms c e m n N S l d p
eq1 = 'A*(e^(a*(1-g)))*(n^((1-a)*(1-g)))*d^g - c -p*e -p*m - (e+m)*(1-q)';
eq2 = 'b*(T*(m^t) + (1-T)*N^t)^(1/t) -d';
eq3 = 'w*S + W*N - p';
eq4 = '1 - n-N-S-l';
eq5 = 'z*(e^(a(1-g)))*(n^(-a-g*(1-a)))*d^g -c';
eq6 = '(g/nu)*A*B*(1-T)*(e^(a-(1-g)))*(n^((1-a)*(1-g)))*(N^(t-1))*d^(g-t) + c*(W/w) - c';
eq7 = 'x*(p*e)^((a-1)-g*a)*n^((1-a)(1-g))*(p*d)^g +r -p';
eq8 = 'r + b*g*T*A*B*((p*e)^(a-a*g))*(n^((1-a)+(1-g)))*(p*d)^(g-t) - p';
eq9 = 'b*w*(1-l) - p';
s = solve(eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9);
l = s.l
0 comentarios
Respuestas (1)
Walter Roberson
el 28 de Feb. de 2011
There are multiple solutions. One of them is:
p = 0
r = 0
l = 1 %that's a one
n = exp((ln(c/z)-a(1-g)*ln(e)-g*ln(d))/(-a-g+g*a))
N = (-((d/b)^t-T*m^t)/(-1+T))^(1/t)
S = -W*(-((d/b)^t-T*m^t)/(-1+T))^(1/t)/w
Together with the system
-(exp(-(-ln(c/z)+a(1-g)*ln(e)+g*ln(d))/(-a-g+g*a))*w + ((-(d/b)^t+T*m^t)/(-1+T))^(1/t)*w - W*((-(d/b)^t+T*m^t)/(-1+T))^(1/t))/w = 0
-(-g*A*B*e^(a-1+g)*(exp((ln(c/z)-a(1-g)*ln(e)-g*ln(d))/(-a-g+g*a)))^((a-1)*(-1+g))*(((-(d/b)^t+T*m^t)/(-1+T))^(1/t))^t*((-(d/b)^t+T*m^t)/(-1+T))^(-1/t)*d^(g-t)*w+g*A*B*e^(a-1+g)*(exp((ln(c/z)-a(1-g)*ln(e)-g*ln(d))/(-a-g+g*a)))^((a-1)*(-1+g))*(((-(d/b)^t+T*m^t)/(-1+T))^(1/t))^t*((-(d/b)^t+T*m^t)/(-1+T))^(-1/t)*d^(g-t)*w*T-c*W*nu+c*nu*w)/(nu*w) = 0
b*(T*m^t+(((-(d/b)^t+T*m^t)/(-1+T))^(1/t))^t-(((-(d/b)^t+T*m^t)/(-1+T))^(1/t))^t*T)^(1/t)-d, z*e^a(1-g)*(exp((ln(c/z)-a(1-g)*ln(e)-g*ln(d))/(-a-g+g*a)))^(-a-g+g*a)*d^g-c = 0
A*e^(-a*(-1+g))*(exp((ln(c/z)-a(1-g)*ln(e)-g*ln(d))/(-a-g+g*a)))^((a-1)*(-1+g))*d^g-c-e+e*q-m+m*q = 0
We cannot resolve this system further as you did not indicate which symbols were variables and which were parameters.
There is a completely different branch in which "l" is not 1, a branch in which p and r would not be 0, but pursuing that would be messier; I wouldn't care to do it without knowing which were the variables.
Maple considers eq1, eq2, eq3, eq4 to be self-consistent, and eq5 and eq6 to be self-consistent, but has problems reconciling N and n between the two. Which reminds me that I did not cross-check the above solution by back-substitution.
The easiest approach is to start with equations 7 through 9, as "l" is the only target variable that appears in them. There is a complicated "l" that allows them to be self-consistent, and there is the trivial l=1 (el equals one) that leads to p = 0, r = 0, and one can work backwards from there, picking through the solution sets for {eq1, eq2, eq3, eq4} and {eq5, eq6} to isolate additional variables.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!