# Is an analytic optimization solution possible?

**URL:** <https://community.wolfram.com/t/is-an-analytic-optimization-solution-possible/19271>\
**Category:** Questions\
**Tags:** optimization, symbolic-computations\
**Created:** [December 19, 2021, 9:34pm UTC](https://community.wolfram.com/t/is-an-analytic-optimization-solution-possible/19271 "2021-12-19T21:34:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![poincianapoinciana](https://avatars.discourse-cdn.com/v4/letter/p/a87d85/32.png) [@poincianapoinciana](https://community.wolfram.com/u/poincianapoinciana)\
**Post date:** [December 19, 2021, 9:34pm UTC](https://community.wolfram.com/t/is-an-analytic-optimization-solution-possible/19271/1 "2021-12-19T21:34:09Z")

</div>

Is an analytic solution possible for this problem: find an expression for maximum of p subject to constraints f=0, g=0, h=0? The feasible range is: T1, T2, R, Rthhot, Rthcold, and Z\>0.

I know how to solve it using either FindMaximum or Langrage multiplier if I assign numerical values to T1, T2, R, Rthhot, Rthcold, and Z. I’d like to know if it’s possible to find an analytic solution if I leave T1, T2, R, Rthhot, Rthcold and Z as parameters.

```
p[X_, Y_, Rload_, Rth_, S_] := S^2*(X - Y)^2*Rload/(R + Rload)^2;

f[X_, Y_, Rload_, Rth_, S_] := -(T1 - X)/Rthhot + (X - Y)/Rth + S^2*X*(X - Y)/(R + Rload) - 
0.5*S^2*Rload*(X - Y)^2/(R + Rload)^2;

g[X_, Y_, Rload_, Rth_, S_] := (Y - T2)/Rthcold - (X - Y)/Rth - S^2*Y*(X - Y)/(R + Rload) - 
0.5*S^2*Rload*(X - Y)^2/(R + Rload)^2;

h[X_, Y_, Rload_, Rth_, S_] := S^2*Rth/R - Z;

```

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [December 20, 2021, 4:03pm UTC](https://community.wolfram.com/t/is-an-analytic-optimization-solution-possible/19271/2 "2021-12-20T16:03:12Z")

</div>

This may be a start:

```
jacobian = D[{p[X, Y, Rload, Rth, S], f[X, Y, Rload, Rth, S],
    g[X, Y, Rload, Rth, S], h[X, Y, Rload, Rth, S]},
   {{X, Y, Rload, Rth, S}}];
eqs = Minors[jacobian, 4] // First // Simplify
sol34 = Solve[
   eqs[[3]] == 0 && eqs[[4]] == 0 &&
    S != 0 && Rth != 0 && 
    Rload != 0] // FullSimplify
Simplify[eqs /. sol34]
fgh = FullSimplify[{f[X, Y, Rload, Rth, S], g[X, Y, Rload, Rth, S],
     h[X, Y, Rload, Rth, S]} /. sol34];
Solve[fgh[[1]] == 0]
Solve[fgh[[2]] == 0]

```

---

<div class="post-metadata">

**Author:** ![anon21378091](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@anon21378091](https://community.wolfram.com/u/anon21378091)\
**Post date:** [December 23, 2021, 8:31am UTC](https://community.wolfram.com/t/is-an-analytic-optimization-solution-possible/19271/3 "2021-12-23T08:31:06Z")

</div>

I tried the code, but it was unsuccessful.

Perhaps I should pose the question differently:

This is the problem: the parameters are T1, T2, R, Rthhot, Rthcold, and Z with feasible range \>0. The variables are Rth and Rload.

X and Y are functions of Rload and Rth given by the 2 equations:

```
0=-(T1 - X)/Rthhot + (X - Y)/Rth + S^2*X*(X - Y)/(R + Rload) + (-1)*0.5*S^2*Rload*(X - Y)^2/(R + Rload)^2

0=(Y - T2)/Rthcold - (X - Y)/Rth - S^2*Y*(X - Y)/(R + Rload) + (-1)*0.5*S^2*Rload*(X - Y)^2/(R + Rload)^2;

```

and S is a function of Rth is given by:

```
0=S^2*Rth/R - Z;

```

I am trying to maximize power as a function of Rload and Rth:

```
Power=S^2*(X - Y)^2*Rload/(R + Rload)^2;

```

I know how to solve it using either FindMaximum or Langrage multiplier if I assign numerical values to T1, T2, R, Rthhot, Rthcold, and Z. I’d like to know if it’s possible to find an analytic solution if I leave T1, T2, R, Rthhot, Rthcold and Z as parameters. Here is an example of my code:

```
T1 = 310; 
T2 = 300;  
Rthhot = 0.1; 
Rthcold = 6; 
R = 6; 
Z = 1/305 ;

Solve[{-(T1 - X)/Rthhot + (X - Y)/Rth + S^2*X*(X - Y)/(R + Rload) - 
0.5*S^2*Rload*(X - Y)^2/(R + Rload)^2 ==0, (Y - T2)/Rthcold - (X - Y)/Rth - S^2*Y*(X - Y)/(R + 
Rload) - 0.5*S^2*Rload*(X - Y)^2/(R + Rload)^2 == 0,
S^2*Rth/R - Z == 0, 
Grad[S^2*(X - Y)^2*Rload/(R + Rload)^2, {X, Y, Rload, Rth, S}] == 
lambda1 Grad[-(T1 - X)/Rthhot + (X - Y)/Rth + 
   S^2*X*(X - Y)/(R + Rload) - 
   0.5*S^2*Rload*(X - Y)^2/(R + Rload)^2, {X, Y, Rload, Rth, S}] +
lambda2 Grad[(Y - T2)/Rthcold - (X - Y)/Rth - 
   S^2*Y*(X - Y)/(R + Rload) - 
   0.5*S^2*Rload*(X - Y)^2/(R + Rload)^2, {X, Y, Rload, Rth, S}] +
lambda3 Grad[S^2*Rth/R - Z, {X, Y, Rload, Rth, S}]}]

```

And this code works fine. But if I leave T1, T2, R, Rthhot, Rthcold, and Z as parameters it keeps running for a few days without finding a solution.

---

<div class="post-metadata">

**Author:** ![neils](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/neils/32/20595_2.png) [@neils](https://community.wolfram.com/u/neils)\
**Post date:** [December 23, 2021, 1:59pm UTC](https://community.wolfram.com/t/is-an-analytic-optimization-solution-possible/19271/4 "2021-12-23T13:59:29Z")

</div>

[@Frank Kampas](https://community.wolfram.com/web/fkampas) posted [some code](https://wolfram.discourse.group/t/12953/1) years ago that may help you.

Regards.
