# How to optimize a function with two variables such that the constraint is satisified

I have a hollow bar with outer diameter d1 and inner diameter d2. One end of the bar is fixed and the other is subjected load. Due to this load bending stress are generated in the bar and it is given by \begin{align} \sigma=\frac{M c}{I_{xx}} \label{eq:stress} \end{align} I am interested in reducing this stress for any given value of M. The form of c and Ixx is given by \begin{align*} c=\frac{d_{o}}{2};\quad I_{xx}=\frac{\pi (r_{o}^4-r_{i}^4)}{4} \end{align*} The outer and the inner radius r1 and r2 are related by below equation \begin{align} r_{o}-r_{i}=t \label{eq:const} \end{align} Now my objective is to minimize the stress σ. which I have written as f such that the constraint is satisfied \begin{align} f&=\frac{4Mr_{o}}{\pi(r_{o}^4-r_{i}^4)}\\ \end{align}

ClearAll["Global*"];
d1 = 2*r1;(*outer diameter*)
d2 = 2*r2;(*Inner diameter*)
aixx = Simplify[(π (d1^4 - d2^4))/64];
sigmax = Simplify[(M*r1)/aixx];
f = sigmax; (*opjective function*)
r1 = r2 + t;
Minimize[{f, r1}, {r2, t}]

• Your g is not a constraint, and t is not defined. – Hausdorff Aug 6 '20 at 14:50
• @Hausdorff actually r1 and r2 are related by t. and I have slightly modified the OP is that OK – acoustics Aug 6 '20 at 14:53
• You don't need the constraint anymore, you can just write Minimize[f, {r2, t}] – Hausdorff Aug 6 '20 at 14:58
• @Hausdorff I am getting wired results. I don't know whether I have framed the problem properly or not. Could you suggest any changes in the problem statement – acoustics Aug 6 '20 at 15:01
• I don't know what problem you are trying to solve, maybe you could elaborate a bit in your question. – Hausdorff Aug 6 '20 at 15:06

I am guessing you were trying to achieve:

d1 = 2*r1;
d2 = 2*r2;
aixx = Simplify[(\[Pi] (d1^4 - d2^4))/64];
sigmax = Simplify[(M*r1)/aixx];
f = sigmax
Simplify @ Minimize[{f, r1 == r2 + t && t > 0 && r2 > 0}, {r2}]


or

Simplify @ Minimize[{f, r1 == r2 + t && t > 0 && r2 > 0}, {r2, t}]
`

if you also want to minimize w.r.t. the thickness.

• Could able to interpret the obtained result. I am beginner in optimization. could you briefly tell me what to understand the result – acoustics Aug 6 '20 at 15:37
• @acoustics The result is, frankly, bogus. I think you need to re-think the problem itself because it's probably ill-defined right now. – Sjoerd Smit Aug 6 '20 at 15:42