# Speeding up the calculations by Reduce and NSolve

I have a non-linear system of equations with numeric parameter values as shown below. I first tried FindRoot with given initial values and it did not converge. Then I tried Reduce with Reals solutions, but it runs for ever, and finally, I tried NSolve. I face the never ending calculation. This Forum is my last resort to solve the following simple system, which can be easily solved by hand. The following system is a simple Applied General Equilibrium Model, where the coefficients have been calibrated using a Social Accounting Matrix.

NSolve[{
QA1 == 3.33 QF11^0.48 QF21^0.52,
QA2 == 2.904 QF12^0.39 QF22^0.67,
WF1 == (0.48 PVA1 QA1)/QF11,
WF1 == (0.39 PVA2 QA2)/QF12,
WF2 == (0.52 PVA1 QA1)/QF21,
WF2 == (0.61 PVA2 QA2)/QF22,
QINT11 == 0.24 QA1,
QINT12 == 0.13 QA2,
QINT21 == 0.16 QA1,
QINT22 == 0.19 QA2,
PA1 == P1,
PA2 == P2,
PVA1 == (-0.24 P1 - 0.16 P2) PA1,
PVA2 == (-0.13 P1 - 0.19 P2) PA2,
Q1 == QA1, Q2 == QA2,
YF11 == 0.52 (QF11 WF1 + QF12 WF1),
YF12 == 0.59 (QF21 WF2 + QF22 WF2),
YF21 == 0.47 (QF11 WF1 + QF12 WF1),
YF22 == 0.41 (QF21 WF2 + QF22 WF2),
YH1 == YF11 + YF12,
YH2 == YF21 + YF22,
QH11 == (0.25 YH1)/P1,
QH12 == (0.48 YH2)/P1,
QH21 == (0.5 YH1)/P2,
QH22 == (0.32 YH2)/P2,
QF11 + QF12 == 152,
QF21 + QF22 == 203,
Q1 == QH11 (QINT11 + QINT12) + QH12 (QINT11 + QINT12) + QINV1,
Q2 == QH21 (QINT21 + QINT22) + QH22 (QINT21 + QINT22) + QINV2,
0.45 P1 + 0.55 P2 == 1
},
{
IADJ, P1, P2, PA1, PA2, WF1, WF2, PVA1, PVA2, Q1, Q2, QA1, QA2, YH1, YH2,
QF11, QF12, QF21, QF22, QH11, QH12, QH21, QH22, QINT11, QINT12, QINT21,
QINT22, QINV1, QINV2, YF11, YF12, YF21, YF22
}, Reals]


Try

NMinimize[
Abs[(QA1 - 3.33 QF11^0.48 QF21^0.52)^2+ (QA2 - 2.904 QF12^0.39 QF22^0.67)^2+
(WF1 - (0.48 PVA1 QA1)/QF11)^2+ (WF1 - (0.39 PVA2 QA2)/QF12)^2+
(WF2 - (0.52 PVA1 QA1)/QF21)^2+ (WF2 - (0.61 PVA2 QA2)/QF22)^2+
(QINT11 - 0.24 QA1)^2+ (QINT12 - 0.13 QA2)^2+ (QINT21 - 0.16 QA1)^2+
(QINT22 - 0.19 QA2)^2+ (PA1 - P1)^2+ (PA2 - P2)^2+
(PVA1 - (-0.24 P1 - 0.16 P2) PA1)^2+ (PVA2 - (-0.13 P1 - 0.19 P2) PA2)^2+
(Q1 - QA1)^2+ (Q2 - QA2)^2+ (YF11 - 0.52 (QF11 WF1 + QF12 WF1))^2+
(YF12 - 0.59 (QF21 WF2 + QF22 WF2))^2+ (YF21 - 0.47 (QF11 WF1 + QF12 WF1))^2+
(YF22 - 0.41 (QF21 WF2 + QF22 WF2))^2+ (YH1 - (YF11 + YF12))^2+
(YH2 - (YF21 + YF22))^2+ (QH11 - (0.25 YH1)/P1)^2+ (QH12 - (0.48 YH2)/P1)^2+
(QH21 - (0.5 YH1)/P2)^2+ (QH22 - (0.32 YH2)/P2)^2+ (QINV1 - 25 IADJ)^2+
(QINV2 - 55 IADJ)^2+ (QF11 + QF12 - 152)^2+ (QF21 + QF22 - 203)^2+
(Q1 - (QH11 (QINT11 + QINT12) + QH12 (QINT11 + QINT12) + QINV1))^2+
(Q2 - (QH21 (QINT21 + QINT22) + QH22 (QINT21 + QINT22) + QINV2))^2+
(0.45 P1 + 0.55 P2 - 1)^2],
{IADJ, P1, P2, PA1, PA2, WF1, WF2, PVA1, PVA2, Q1, Q2, QA1, QA2, YH1, YH2,
QF11, QF12, QF21, QF22, QH11, QH12, QH21, QH22, QINT11, QINT12, QINT21,
QINT22, QINV1, QINV2, YF11, YF12, YF21, YF22
},Method->"RandomSearch"]
(*{5.7775*^-7, {
IADJ -> 0.1214, P1 -> 2.6261, P2 -> -0.0970, PA1 -> 1.0693, PA2 -> -1.0494,
WF1 -> 0.4897, WF2 -> -0.0530, PVA1 -> -0.1688, PVA2 -> 0.1288, Q1 -> 121.4575,
Q2 -> 129.4453, QA1 -> 6.4105, QA2 -> 63.0275, YH1 -> 1.5555, YH2 -> -3.3309,
QF11 -> -15.9671, QF12 -> 37.2110, QF21 -> 229.2080, QF22 -> -2.6510,
QH11 -> 3.4675, QH12 -> 4.4966, QH21 -> 2.1913, QH22 -> 0.6491, QINT11 -> 14.3196,
QINT12 -> 1.2188, QINT21 -> 8.6762, QINT22 -> 13.9195, QINV1 -> 6.3872,
QINV2 -> 5.6378, YF11 -> -2.1439, YF12 -> -1.8319, YF21 -> 2.7253, YF22 -> 2.8725}}*)

• I understand the strategy you propose: a zero for the sum of squares of the model equations would imply that the system is in equilibrium. How can I impose Positive values for the equilibrium values? – Tugrul Temel Apr 18 '19 at 17:11
• I added the constraints in the way you indicate above, and as you said I face the infinite problem and now I am stuck there because I do not know how to get rid of this infinite expression (division of 1 by zero). Can you tell me how to get rid of it? Do you just multiply the relevant constraints by their denominators? – Tugrul Temel Apr 18 '19 at 18:12
• Yes, I have done the adjustment (as you suggested) and I get a solution but it is not really the equilibrium in the sense that the solution values of the endogenous variables do not confirm the associated values in the Social Accounting Matrix. I say this with confidence because I tried the Abs[] with a model with a convergent equilibrium. This NMinimize is not doing what I am expecting it to do maybe because the solution obtained by NMinimize is a local suboptimal solution. – Tugrul Temel Apr 18 '19 at 20:13
• Yes, you are right. I will tighten the constraints around the known solution values and let you know. Thanks a lot. – Tugrul Temel Apr 18 '19 at 21:35
• I tried with tightened constraints. It works, meaning that the tighter the constraints, the closer the solutions to the known equilibrium values. But this method is apparently not so efficient because I will make scenario analysis and for each scenario I do not know the expected results to adjust the constraints. If I know the reasons for why the original system of nonlinear equations do not work, then I will try to solve it. do you have any idea about why the system does not yield solutions. – Tugrul Temel Apr 18 '19 at 22:04