I have these three equations:
f = a*b*(a + b - 4*x - 2*y - z) + x*(x + y)*(2*x + y + z);
g = (a*b*((a + b)*(a + b - 4*x - 2*y - z)^2 + x*(x + y)*(2*x + y + z) - 12*c*d*(a + b - c - d - 4*x - 2*y - z)) - x*(x + y)*(2*x + y + z)*(5*x*(x + y) + 2*x*z + y^2 + y*z))/12;
h = 2*(c + d) + 4*x + 2*y + z
I want to get values for x
, y
, and z
in terms of a
, b
, c
, d
, and dMax
under the following circumstances:
- the variables
a
,b
,c
,d
, anddMax
stand for arbitrary positive real numbers x
,y
, andz
are positive real numbersf == 0
g == dMax
h
is minimized (a positive real number as close to zero as possible)
How would I input this in Wolfram Language? The documentation for Minimize[]
seems to say that it only works on one function at a time, and Solve[]
doesn't seem to handle minimization unless I'm missing something.
EDIT
Based on @Michael E2's comments and @Ulrich Neumann's answer I tried entering the following:
$PrePrint = InputForm;
f = a*b*(a + b - 4*x - 2*y - z) + x*(x + y)*(2*x + y + z);
g = (a*b*((a + b)*(a + b - 4*x - 2*y - z)^2 + x*(x + y)*(2*x + y + z) - 12*c*d*(a + b - c - d - 4*x - 2*y - z)) - x*(x + y)*(2*x + y + z)*(5*x*(x + y) + 2*x*z + y^2 + y*z))/12;
h = 2*(c + d) + 4*x + 2*y + z;
mini[a_, b_, c_, d_, dMax_] := Minimize[{h, {f == 0, g == dMax, a > 0, b > 0, c > 0, d > 0}}, {x, y, z}];
mini[a, b, c, d, dMax]
The program sits at around 70-90% CPU usage for hours without resolving. Is there a better way to do this? Or is there anything obvious I can do to the input equations to make the computation more efficient?
C
andD
which areProtected
system symbols. $\endgroup$C
andD
cause any problems in this specific case? $\endgroup$Quiet[]
to suppress error messages, so just because there were no errors does not rule out a problem. That there are no errors is substantial evidence thatC
andD
are not the issue, but you can't be completely certain. For instance, if Mma tries to assignC
orD
a value, then there would probably be a problem (try outBlock[{D = 4}, D[x^2, x]]
, and no error message). I tried Ulrich's code or one similar (he didn't distinguishD
/d
) and it did not finish in a reasonable amount of time. $\endgroup$d
todMax
, as it seems like multi-character variable names are allowed. Are there any other best-practices I should be aware of? $\endgroup$=
for variable assignments such asf = x^2
and:=
for function assignments such asf[x_] := x^3;
is common. (So the '=' you had originally is fine.) The list I linked earlier has grown to have excessively many pieces of advice. But it was originally meant to be a first resource for new users. The 2nd & 3rd groups are mostly important; if you use numerical methods, theNumericQ
one is important. $\endgroup$