We use cookies to personalise content and advertisements and to analyse access to our website. Furthermore, our partners for online advertising receive pseudonymised information about your use of our website. cookie policy and privacy policy.

I called these ranges strict because limit the given numbers. If x is greater or less than the limit, the function will return the limit.

I created these mathematical functions because I think that math is faster that lines of code.


Strict range (Less).

x cannot be less than s


if x is less than s will be returned s


Strict range (Greater).

x cannot be greater than s


if x is greater than s will be returned s


Strict range (Greater and less).

x cannot be greater than m

x cannot be less than i

\(lg(m,x, i) = g(m, l(i, x))\)

All in a heap:



lg function can be less. Thanks to @heureka (see comments below).



Look at this in Desmos: https://www.desmos.com/calculator/shusnvnxzo

 Sep 22, 2019
edited by JoshuaGreen  Sep 24, 2019
edited by JoshuaGreen  Oct 22, 2019

Strict ranges (number can't be more/less than...)


I assume:


\(\begin{array}{|rcll|} \hline l(s,x) &=& \max(s,x) \\ g(s,x) &=& \min(s,x) \\ \hline lg(m,x,i) &=& g(m, l(i, x)) \\ \mathbf{lg(m,x,i)}&=& \mathbf{ \min(m,\max(i,x)) } \\ \hline \end{array}\)


hint: \(\boxed{\max(s,x) - \min(s,x) = |s-x|}\)



 Sep 23, 2019
edited by heureka  Sep 23, 2019
edited by heureka  Sep 23, 2019

You're right. I did not know that the lg (all in one heap) function could be so small. I didn't know that \(\max\left(a,b\right)-\min\left(a,b\right)=\left|a-b\right|\). Thank you.

JoshuaGreen  Sep 23, 2019

12 Online Users