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, anddMaxstand for arbitrary positive real numbers x,y, andzare positive real numbersf == 0g == dMaxhis 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?
CandDwhich areProtectedsystem symbols. – Michael E2 May 28 '23 at 21:51CandDcause any problems in this specific case? – Lawton May 29 '23 at 20:07Quiet[]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 thatCandDare not the issue, but you can't be completely certain. For instance, if Mma tries to assignCorDa 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. – Michael E2 May 29 '23 at 20:34dtodMax, as it seems like multi-character variable names are allowed. Are there any other best-practices I should be aware of? – Lawton May 29 '23 at 22:28=for variable assignments such asf = x^2and:=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, theNumericQone is important. – Michael E2 May 29 '23 at 22:46gfunction started out over 2700 characters long before extensive work in cancelling and noticing that a subset of its terms contained a factor of theffunction (which will be set to zero) and could thus be cut out. I'll keep working on it though. – Lawton May 30 '23 at 01:00f:=...,g:=...,h:=...tof=...,g=...,h=..as proposed by MichaelE2 – Ulrich Neumann May 30 '23 at 08:06