0
$\begingroup$

i need the "a" value from this solver and it isnt working. i know a should be between 0 and 5, most likely around 1. The other values im not as sure of but y20 and y10 should be negative numbers around .5... also x10 and x20 should be positive between 0 and 1.

    \[Mu]m = .085/.05; l1 = .61; l2 = .595; x2 = .968;
NMinimize[{Norm[
1 - (a \[Mu]m (Sinh[(x10 - xm)/a] + Sinh[(xm - x20)/a]))] + 
Norm[a Cosh[-x10/a] + y10] + Norm[a Cosh[(x2 - x20)/a] + y20] + 
Norm[l1 - a Sinh[(xm - x10)/a]] + 
Norm[l2 - a (Sinh[(x2 - x20)/a] - Sinh[(xm - x20)/a])] + 
Norm[a Cosh[(xm - x10)/a] + y10 - (a Cosh[(x20 - xm)/a] + y20)], 
0 < a < 1.5 && -.7 < y20 < 0 && -.7 < y10 < 0 && -.5 < x10 < .5 && 
0 < x20 < 1.5}, {x10, x20, xm, y10, y20, a}, 
Method -> "RandomSearch", MaxIterations -> 10^4]
$\endgroup$
2

3 Answers 3

2
$\begingroup$

The Norm of a scalar is its absolute value. Look at

Plot[Norm[x], {x, -1, 1}]

enter image description here

or

Assuming[Element[x, Reals], Norm[x] == Abs[x] // Simplify]

(* True *)

Rationalize all of the input values so you can freely set the WorkingPrecision within NMinimize

μm = 17/10; l1 = 61/100; l2 = 119/200; x2 = 121/125;

SeedRandom[0]

NMinimize[{Norm[1 - (a μm (Sinh[(x10 - xm)/a] + Sinh[(xm - x20)/a]))] + 
   Norm[a Cosh[-x10/a] + y10] + Norm[a Cosh[(x2 - x20)/a] + y20] + 
   Norm[l1 - a Sinh[(xm - x10)/a]] + 
   Norm[l2 - a (Sinh[(x2 - x20)/a] - Sinh[(xm - x20)/a])] + 
   Norm[a Cosh[(xm - x10)/a] + y10 - (a Cosh[(x20 - xm)/a] + y20)], 
  0 < a < 3/2 && -7/10 < y20 < 0 && -7/10 < y10 < 0 && -1/2 < x10 < 1/2 && 
   0 < x20 < 3/2}, {x10, x20, xm, y10, y20, a}, Method -> "RandomSearch", 
 MaxIterations -> 10^4, WorkingPrecision -> 15]

(* {1.39865516132942, {x10 -> 0.309535491165357, x20 -> 0.209668869240626, 
  xm -> 0.780022142278469, y10 -> -0.505720397617272, 
  y20 -> -0.700000000000000, a -> 0.367452643220535}} *)

Note that the value of y20 is on the boundary of the specified region which suggests the boundary should be extended.

SeedRandom[0]

NMinimize[{Norm[1 - (a μm (Sinh[(x10 - xm)/a] + Sinh[(xm - x20)/a]))] + 
   Norm[a Cosh[-x10/a] + y10] + Norm[a Cosh[(x2 - x20)/a] + y20] + 
   Norm[l1 - a Sinh[(xm - x10)/a]] + 
   Norm[l2 - a (Sinh[(x2 - x20)/a] - Sinh[(xm - x20)/a])] + 
   Norm[a Cosh[(xm - x10)/a] + y10 - (a Cosh[(x20 - xm)/a] + y20)], 
  0 < a < 3/2 && -2 < y20 < 0 && -7/10 < y10 < 0 && -1/2 < x10 < 1/2 && 
   0 < x20 < 3/2}, {x10, x20, xm, y10, y20, a}, Method -> "RandomSearch", 
 MaxIterations -> 10^4, WorkingPrecision -> 15]

(* {0.555324594222433, {x10 -> 0.437309657997211, x20 -> 0.259460028813828, 
  xm -> 0.860835239258215, y10 -> -0.699888088071041, 
  y20 -> -1.27035142037279, a -> 0.277340960805850}} *)

The minimum is still far from zero so there does not appear to be a root of your equations in the specified region.

$\endgroup$
1
$\begingroup$

Can you try this

\[Mu]m=400;l1=1;l2=1;x2=1;
NMinimize[{
  Norm[1-(a \[Mu]m (Sinh[(x10 - xm)/a] + Sinh[(xm - x20)/a]))]+
  Norm[a Cosh[-x10/a] + y10]+ Norm[a Cosh[(x2 - x20)/a] + y20]+
  Norm[l1-a Sinh[(xm - x10)/a]]+
  Norm[l2-a (Sinh[(x2 - x20)/a] - Sinh[(xm - x20)/a])]+
  Norm[a Cosh[(xm - x10)/a] + y10-(a Cosh[(x20 - xm)/a] + y20)],
  0<a<5&&-5<y20<0&&-5<y10<0&&0<x10<1&&0<x20<1},
  {x10, x20, xm, y10, y20, a},Method->"RandomSearch",MaxIterations->10^4]

(*{1.2065, {x10->0.0337, x20->0.0312, xm->0.1626, y10->-2.4356, y20->-2.4339, a -> 2.4354}}*)

Now 1.2065 is a very poor approximation of a zero minimum but you might be able to play with your constraints on your six variables and get it to find a zero or you might get fairly strong feelings that there is no zero in the region you suggest.

$\endgroup$
9
  • $\begingroup$ little confused. you want me to play with the constraints and try to get the 1.2065 to zero? $\endgroup$ Commented Dec 17, 2018 at 4:42
  • $\begingroup$ yes makes more sense now, im trying 0 < a < 2 && -1 < y20 < 0 && -1 < y10 < 0 && -1 < x10 < .5 && 0 < x20 < 2} now $\endgroup$ Commented Dec 17, 2018 at 5:00
  • $\begingroup$ but im trying to get the 1.2065 to go to zero right ? $\endgroup$ Commented Dec 17, 2018 at 5:01
  • $\begingroup$ i have updated the code in the question. can you show me what you mean by adding Abs? Im confused because there is already a Norm there $\endgroup$ Commented Dec 17, 2018 at 5:09
  • $\begingroup$ using the new code in the question $\endgroup$ Commented Dec 17, 2018 at 5:10
1
$\begingroup$

Norm is not a differentiable function, and it's usually better to use a sum of squares for real-valued functions:

Clear[μm, l1, l2, x2];
objOP = Norm[1 - (a μm (Sinh[(x10 - xm)/a] + Sinh[(xm - x20)/a]))] + 
   Norm[a Cosh[-x10/a] + y10] + 
   Norm[a Cosh[(x2 - x20)/a] + y20] + 
   Norm[l1 - a Sinh[(xm - x10)/a]] + 
   Norm[l2 - a (Sinh[(x2 - x20)/a] - Sinh[(xm - x20)/a])] + 
   Norm[a Cosh[(xm - x10)/a] + y10 - (a Cosh[(x20 - xm)/a] + y20)];
objSS = objOP /. Norm -> (#^2 &);

μm = .085/.05; l1 = .61; l2 = .595; x2 = .968;

NMinimize[{objOP, 
  0 < a < 5 && -5 < y20 < 0 && -5 < y10 < 0 && 0 < x10 < 1 && 0 < x20 < 1},
 {x10, x20, xm, y10, y20, a}, 
 Method -> "RandomSearch", MaxIterations -> 10^4]

{min, sol} = NMinimize[{objSS, 
   0 < a < 5 && -5 < y20 < 0 && -5 < y10 < 0 && 0 < x10 < 1 && 0 < x20 < 1},
 {x10, x20, xm, y10, y20, a}, 
  Method -> "RandomSearch", MaxIterations -> 10^4]
objOP /. sol
(*
  {0.3519, {x10 -> 0.511012, x20 -> 0.324884, xm -> 0.898573, 
    y10 -> -0.931345, y20 -> -1.51882, a -> 0.264148}}

  {2.83993*10^-19, {x10 -> 0.51201, x20 -> 0.376215, xm -> 0.885239, 
    y10 -> -1.23342, y20 -> -1.80519, a -> 0.207372}}

  1.15893*10^-9
*) 

In the OP's example, the sum-of-squares solution is much better.

$\endgroup$
2
  • $\begingroup$ +1 I believe that the equivalent to Norm is Norm -> (Sqrt[#^2]&). Although the use of Norm -> (#^2&) increases the penalty for large deviation and provides better results in this case. $\endgroup$
    – Bob Hanlon
    Commented Dec 17, 2018 at 16:30
  • $\begingroup$ @BobHanlon Thanks. Yes, I chose Norm -> (#^2&) because Newton's method, which I believe is used to process the random points when the function is differentiable, will probably behave optimally when the minima-zeros are quadratic ($f_{min} + \sum \Delta x^2 + O(\Delta x^3)$. $\endgroup$
    – Michael E2
    Commented Dec 17, 2018 at 17:15

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.