3
$\begingroup$

Assume that I have three one-variable non-periodic functions $f(x),g(x),h(x)$ for $x>0$. The question is: is it possible to ask Mathematica to obtain the function describing the upper and lower boundaries of these three functions (I am not sure if it is called enveloping function)? Something like the red curves in the second picture attached (I plot it manually); I am looking for an analytic expression for the function describing these red curves.

f[x_] = 2 x Sin[x];
g[x_] = x Cos[x];
h[x_] = x + Sin[3 x];

Plot[{ f[x], g[x], h[x]}, {x, 0, 20}, PlotLegends -> "Expressions"]

P.S. This is just a simple example, my real functions are much more complicated than the given ones; I just wanted to know if there is any hope to do that.

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ This might be a start mathematica.stackexchange.com/q/49043/8822 . BTW, if you look for envelope on this site you will find many more similar Q&A. $\endgroup$
    – mattiav27
    Commented Jul 19, 2023 at 17:37
  • $\begingroup$ @mattiav27 Thanks; but my question is if it is possible to obtain the analytic expression for the envelope function; is it possible? $\endgroup$
    – math2021
    Commented Jul 19, 2023 at 20:47

1 Answer 1

6
$\begingroup$

Something like:

f[x_] = 2 x Sin[x];
g[x_] = x Cos[x];
h[x_] = x + Sin[3 x];
min[x_] = Min[f[x], g[x], h[x]];
max[x_] = Max[f[x], g[x], h[x]];
Plot[{f[x], g[x], h[x], min[x], max[x]}, {x, 0, 20}, 
 PlotLegends -> "Expressions", 
 PlotStyle -> {Blue, Brown, Orange, Green, Green}]

enter image description here

$\endgroup$
6
  • $\begingroup$ Yep... straightforward. ($+1$) $\endgroup$ Commented Jul 19, 2023 at 19:53
  • $\begingroup$ Thank you very much. My question was if t is possible to obtain the analytic expression for the function describing your green curves; is it possible? $\endgroup$
    – math2021
    Commented Jul 19, 2023 at 20:45
  • $\begingroup$ @math2021: In general these functions will be discontinuous and hence best expressed using the min or max functions. $\endgroup$ Commented Jul 19, 2023 at 21:14
  • $\begingroup$ @DavidG.Stork But each function (upper and lower) is continuous; so, do you mean that it is not possible to determine the functions describing them? $\endgroup$
    – math2021
    Commented Jul 19, 2023 at 21:51
  • 1
    $\begingroup$ I should have said "discontinuous derivative." What kind of answer could you even imagine for the "simple" case of $f_1(x) = x, f_2(x) = x^2 - 1$? $\endgroup$ Commented Jul 19, 2023 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.