topic Re: Unable to find the correct minima in PTC Mathcad
https://community.ptc.com/t5/PTC-Mathcad/Unable-to-find-the-correct-minima/m-p/739692#M196690
<BLOCKQUOTE><HR />for theta between 90 deg and 270 deg, solution should be 90 deg
<P class="1626970346159"> </P>
</BLOCKQUOTE>
<P>You asked for minima! At 90° there is no minimum but a maximum!</P>
<P>BETWEEN 90° and 180° there is no extrema at all, but in the range FROM 90° TO 180° there is a max at 90° and a min at 180°.</P>
<P> </P>
<P>How about using the zeros of the first derivative to get the extrema? You may use the "root" function where you can provide a range to search for the zero within. The function values at the endpoints of that range must be of opposite sign, though.</P>Thu, 22 Jul 2021 16:20:10 GMTWerner_E2021-07-22T16:20:10ZUnable to find the correct minima
https://community.ptc.com/t5/PTC-Mathcad/Unable-to-find-the-correct-minima/m-p/739642#M196683
<P>Hi,</P>
<P>I am trying to optimize the solution of minimization function depending on the intial guess values. Surprisingly, my solutions are independent of initial guess values even though the function has several local minima. I am attaching the Mathcad 15 worksheet for the refrence. Any help will be highly appreciated!</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sunny_0-1626954748719.png" style="width: 400px;"><img src="https://community.ptc.com/t5/image/serverpage/image-id/44231iB36C866A2511DCFF/image-size/medium?v=v2&px=400" role="button" title="Sunny_0-1626954748719.png" alt="Sunny_0-1626954748719.png" /></span></P>
<P> </P>
<P> </P>
<P>Many thanks</P>
<P>S</P>Thu, 22 Jul 2021 11:53:51 GMThttps://community.ptc.com/t5/PTC-Mathcad/Unable-to-find-the-correct-minima/m-p/739642#M196683Sunny2021-07-22T11:53:51ZRe: Unable to find the correct minima
https://community.ptc.com/t5/PTC-Mathcad/Unable-to-find-the-correct-minima/m-p/739646#M196685
<P>Apparently Minimize doesn't require a guess value...</P>
<P>You may need an extra constraint to force Minimize to find another than the first minimum:</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LucMeekes_0-1626955730658.png" style="width: 400px;"><img src="https://community.ptc.com/t5/image/serverpage/image-id/44234i1EA3FA87196DAE13/image-size/medium?v=v2&px=400" role="button" title="LucMeekes_0-1626955730658.png" alt="LucMeekes_0-1626955730658.png" /></span></P>
<P> </P>
<P>Success!<BR />Luc</P>
<P> </P>Thu, 22 Jul 2021 12:09:00 GMThttps://community.ptc.com/t5/PTC-Mathcad/Unable-to-find-the-correct-minima/m-p/739646#M196685LucMeekes2021-07-22T12:09:00ZRe: Unable to find the correct minima
https://community.ptc.com/t5/PTC-Mathcad/Unable-to-find-the-correct-minima/m-p/739650#M196686
<P>Alright! However, what is the way to dynamically optimize the constraint. This is beacuse I would like to find the local minima as a function of theta (region of interest). For example if theta is less than 90 deg the solution should be 0 deg, for theta between 90 deg and 270 deg, solution should be 90 deg and so on. Please not that in this case the constrains are very well discretized but in general it may not be.</P>
<P> </P>
<P>Thanks</P>
<P>S</P>Thu, 22 Jul 2021 12:26:51 GMThttps://community.ptc.com/t5/PTC-Mathcad/Unable-to-find-the-correct-minima/m-p/739650#M196686Sunny2021-07-22T12:26:51ZRe: Unable to find the correct minima
https://community.ptc.com/t5/PTC-Mathcad/Unable-to-find-the-correct-minima/m-p/739692#M196690
<BLOCKQUOTE><HR />for theta between 90 deg and 270 deg, solution should be 90 deg
<P class="1626970346159"> </P>
</BLOCKQUOTE>
<P>You asked for minima! At 90° there is no minimum but a maximum!</P>
<P>BETWEEN 90° and 180° there is no extrema at all, but in the range FROM 90° TO 180° there is a max at 90° and a min at 180°.</P>
<P> </P>
<P>How about using the zeros of the first derivative to get the extrema? You may use the "root" function where you can provide a range to search for the zero within. The function values at the endpoints of that range must be of opposite sign, though.</P>Thu, 22 Jul 2021 16:20:10 GMThttps://community.ptc.com/t5/PTC-Mathcad/Unable-to-find-the-correct-minima/m-p/739692#M196690Werner_E2021-07-22T16:20:10ZRe: Unable to find the correct minima
https://community.ptc.com/t5/PTC-Mathcad/Unable-to-find-the-correct-minima/m-p/739699#M196691
<P>My bad...a typo. I meant minima at 180 deg when input theta is between 90deg and 270 deg.<BR /><BR />Indeed, derivative might work in this case. However, I was interested in a more general case with a multivariable function where analytical derivative is cumbersome. A numerical derivate may be an alternative. Then I wondered it should be possible directly with Minimize function (Conjugate gradient or Quasi Newton algorithm).</P>
<P> </P>
<P>Thanks</P>
<P>S</P>Thu, 22 Jul 2021 16:54:38 GMThttps://community.ptc.com/t5/PTC-Mathcad/Unable-to-find-the-correct-minima/m-p/739699#M196691Sunny2021-07-22T16:54:38ZRe: Unable to find the correct minima
https://community.ptc.com/t5/PTC-Mathcad/Unable-to-find-the-correct-minima/m-p/739798#M196698
<P>The guess value can influence the outcome of "minimize", but its not always obvious which guess results in which minimum.</P>
<P>Furthermore I have no clue why the vertical displacement (a very tiny one is all thats needed) shown in function g(x) makes that big a difference for the outcome of minimize.</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_0-1626989872766.png" style="width: 999px;"><img src="https://community.ptc.com/t5/image/serverpage/image-id/44278i27D37637FD907977/image-size/large?v=v2&px=999" role="button" title="Werner_E_0-1626989872766.png" alt="Werner_E_0-1626989872766.png" /></span></P>
<P> </P>Thu, 22 Jul 2021 21:39:16 GMThttps://community.ptc.com/t5/PTC-Mathcad/Unable-to-find-the-correct-minima/m-p/739798#M196698Werner_E2021-07-22T21:39:16ZRe: Unable to find the correct minima
https://community.ptc.com/t5/PTC-Mathcad/Unable-to-find-the-correct-minima/m-p/739808#M196699
<P>Thanks a lot! It is indeed bit strange that a small offset makes a huge difference. However, it solved my problem, so I couldn't bother more now.</P>
<P> </P>Thu, 22 Jul 2021 23:33:13 GMThttps://community.ptc.com/t5/PTC-Mathcad/Unable-to-find-the-correct-minima/m-p/739808#M196699Sunny2021-07-22T23:33:13Z