1

I have the following 3 piecewise functions and I would like to have the threshold of the upper envelope.

a = Piecewise[{{0.125 (0.1 + 0.1 (11.5 - 1 \[Beta])), 
    8 < \[Beta] < (11.4)}}]
b = Piecewise[{{0.375 (0.1 + 0.1 (10.5 - 1 \[Beta])), 
    8 < \[Beta] < (10.4)}}]
c = Piecewise[{{0.375 ((10.5 - 1 \[Beta])), (10.4) < \[Beta] < 12}}]

enter image description here

In other words I would like to obtain the list {10.4,10.431}, Where 10.4 is the threshold between b and c (here there is no intersection between b and c) and 10.431 is the threshold between a and c (their intersection).

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
user63612
  • 103
  • 5

1 Answers1

3

You can use Solve for the intersection for each pair of functions:

intersections = Quiet @ N @ Solve[Equal[##] && 8 < β < 12, β, Reals] & @@@
      Subsets[Rationalize /@ {a, b, c}, {2}];

Grid[Transpose[{Subsets[{"a", "b", "c"}, {2}], intersections}], 
  Dividers -> All] // TeXForm

$\begin{array}{|c|c|} \hline \{\text{a},\text{b}\} & \{\{\}\} \\ \hline \{\text{a},\text{c}\} & \{\{\beta \to 10.431\}\} \\ \hline \{\text{b},\text{c}\} & \{\{\beta \to 10.4\},\{\beta \to 10.5\}\} \\ \hline \end{array}$

d = FullSimplify[PiecewiseExpand[Max[a, b, c]], 0 <= β <= 12];

Plot[{a, b, c, d}, {β, 9, 12}, Frame -> True, Axes -> False, 
  PlotStyle -> {Automatic, Automatic, Automatic, 
   Directive[AbsoluteThickness[5], CapForm["Round"], JoinForm["Round"], Opacity[.5, Red]]},
 GridLines -> {Flatten @ Cases[{__?NumericQ}][β /. intersections], None}, 
 PlotLegends -> "Expressions", ImageSize -> Large]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896
  • Thank you! However, here 10.5 is a useless intersection for the envelope. Is there a way to exclude these cases automatically? What do you think to keep just the points of beta where d is not linear? – user63612 Aug 17 '19 at 15:52
  • 1
    I use the last answer to this topic ([link] https://mathematica.stackexchange.com/questions/91190/how-to-efficiently-get-breakpoints-of-piecewise-functions), by using: breaks = Cases[ Last /@ (Min[d] // PiecewiseExpand)[[1]], _?NumericQ, {2}] // Union , gives as result {8, 10.4, 10.431}, it is exactly what I need, but I'm not sure what this command does. @kglr – user63612 Aug 17 '19 at 16:12