1
$\begingroup$

So I got this expression here (written in pure text):

sol = -((2 r3 (-120000 r1 r2+36000 d1 r1 r2+3600 d2 r1 r2+360 d3 r1 r2+36 d4 r1 r2-580000 r2^2+198000 d1 r2^2+19800 d2 r2^2+1980 d3 r2^2+198 d4 r2^2-540000 r1 r3+162000 d1 r1 r3+16200 d2 r1 r3+1620 d3 r1 r3+162 d4 r1 r3-3230000 r2 r3+1089000 d1 r2 r3+108900 d2 r2 r3+10890 d3 r2 r3+1089 d4 r2 r3))/(-1320000 r1 r2+396000 d1 r1 r2+39600 d2 r1 r2+3960 d3 r1 r2+396 d4 r1 r2-6380000 r2^2+2178000 d1 r2^2+217800 d2 r2^2+21780 d3 r2^2+2178 d4 r2^2-7260000 r1 r3+2178000 d1 r1 r3+217800 d2 r1 r3+21780 d3 r1 r3+2178 d4 r1 r3-43550000 r2 r3+14641000 d1 r2 r3+1464100 d2 r2 r3+146410 d3 r2 r3+14641 d4 r2 r3));

I need to run this command:

Minimize[sol, {r1, r2, r3}]

It's taking forever on my weak PC (never finishes). Can somebody tell me how to optimize this so it actually finishes?

Here are a a few more constraints:

r1 > 0 && r2 > 0 && r3 > 0 && d1 ≥ 0 && d2 ≥ 0 && d3 ≥ 0 && d4 ≥ 0 && d1 ≤ 9 && d2 ≤ 9 && d3 ≤ 9 && d4 ≤ 9 && sol > 0

-- adding these constraints really help in getting it done, still takes forever.

$\endgroup$
3
  • 1
    $\begingroup$ Since you want to minimize sol and you want sol>0 that hints solutions to sol==0 might be very close to what you are looking for. Reduce[FullSimplify[sol] == 0 && r1>0 && r2>0 && r3>0 && 0<=d1<=9 && 0<=d2<=9 && 0<=d3<=9 && 0<=d4<=9, {r1, r2, r3, d1, d2, d3, d4}, Backsubstitution->True] finds LOTS of solutions in four seconds. p.s. Thank you for not turning your expression into desktop published latex, as is it was much easier to past into Mathematica. $\endgroup$
    – Bill
    Commented Jan 16, 2016 at 3:20
  • $\begingroup$ @Bill That's probably as a good answer as the question allows $\endgroup$ Commented Jan 16, 2016 at 3:26
  • $\begingroup$ @Bill: Huh... I tried running that in my weak PC. Tried several variations, such as tightening constraints for narrower test fields to broadening it by dropping variables to be solved. Still takes a long while in my PC... $\endgroup$
    – Dehbop
    Commented Jan 16, 2016 at 11:20

1 Answer 1

1
$\begingroup$

Since your objective function (sol) is continuously differentiable and you consider an open set for the optimization variables $r_1,r_2,r_3$, if a minimum of sol exists, it must satisfy the first-order necessary conditions. That is, the gradient of sol with respect to $\{r_1,r_2,r_3\}$ must be zero at the minimum. Therefore, we can solve a system of (in this case, polynomial) equations in order to find the optimal variables, instead of directly minimizing sol. (Of course, the resulting solution(s) are only guaranteed to be stationary points and they should be checked in order to identify the minimum - if one exists.)

Simplifying the system (without any constraints on variables and parameters) gives the following

Reduce[Thread[(D[sol, {{r1, r2, r3}}] // FullSimplify) == 0]]
r2 == -((9 r3)/2) && r1 == -((99 r3)/4) && 
 d1 == (310000 - 9900 d2 - 990 d3 - 99 d4)/99000 && r3 != 0

This result suggests that

  1. A stationary point cannot exist for arbitrary values of parameters $\{d_i\}$,
  2. There are no $r_1,r_2,r_3>0$ that satisfy the first-order conditions, irrespective of $\{d_i\}$.
$\endgroup$
5
  • $\begingroup$ I guess the function I've been looking for is "Thread".... Anyways, along the way, did you make the constraint that d4 is an integer? Coz I've for known solutions (there are, trust me) noticed that d4 is hardly ever an integer. $\endgroup$
    – Dehbop
    Commented Jan 17, 2016 at 5:37
  • $\begingroup$ Also, sol being a polynomial reciprocal function, I don't see the reason for taking the derivative and asking for the 0. That only gives us the negative and positive infinity, won't it? $\endgroup$
    – Dehbop
    Commented Jan 17, 2016 at 5:43
  • $\begingroup$ The only instances that one can use derivative to find a minimum (that is the root) is when using a Newton-Rhapson method or a similar algorithm. $\endgroup$
    – Dehbop
    Commented Jan 17, 2016 at 5:48
  • $\begingroup$ @Badadeeboop Thanks for the accept. Replying to your comments: (1) No constraint was imposed on any variable/parameter (I don't see why you thought so). (2, 3) The only requirement for applying the first-order necessary conditions is that the objective function is differentiable (and, of course, a rational polynomial function is). This is a fundamental theorem of differential calculus (which all numerical methods - not only Newton-Rhapson - exploit) $\endgroup$
    – Stelios
    Commented Jan 17, 2016 at 8:28
  • $\begingroup$ I meant "polynomial rational function" $\endgroup$
    – Dehbop
    Commented Jan 18, 2016 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.