0
$\begingroup$

I was trying to smoothen the step function (zero when $x$ is less than $2/3$ and equal to $1$ when $x$ is greater then $5/6$) as in the picture below. Trying to fit $f$ in between $2/3$ and $5/6$ using smoothstep $f(x)=3x^2- 2x^3$. Also used the stretching/contraction of $x$ axis and translation of $x$ axis but could not actually fit it.

enter image description here

$\endgroup$
  • $\begingroup$ You question is unclear to me. What do yo mean by 'Smooth' ? Where does the problem come from? $\endgroup$ – AnyAD Feb 23 '19 at 21:48
  • 1
    $\begingroup$ Sorry, actually we have a step function, darkened lines in the figure and since it is not continuous and smooth we try to make it smooth by inserting a function which is smooth at both the ends, for this it is recommended to use the function $f = 3x^2 -2x^3$, but I am finding it difficult to fit the function in between 2/3 to 5/6..en.m.wikipedia.org/wiki/Smoothstep $\endgroup$ – BAYMAX Feb 23 '19 at 21:58
  • $\begingroup$ that is because your function looks misaligned... the value at $x=\frac{2}{3}$ is not 0, when it should be... I think you just messed up while solving one of the differential equations $\endgroup$ – Hiten Feb 23 '19 at 23:07
2
$\begingroup$

The following function as in your link, $$ \texttt{SmoothStep}:[0,1]\to \mathbb R, \\ \texttt{SmoothStep}(x) = 3x^2 - 2x^3$$ interpolates between 0 and 1 while having zero derivative at the endpoints $0,1$. You want to $(A)$ squish this to an interval of length $\frac56 - \frac23 = \frac16$ and $(B)$ make the function start at $2/3$ instead of 0. Lets do these one at a time.

  • $(A)$ squishing a function horizontally amounts to making the function run through its input faster. For instance $2x$ over $x\in[0,2]$ goes from 0 to 4. If you want it to end up at 4 when $x=0.1$, you're gonna need to use $2(2x/0.1)=40x$ instead. Therefore, to accomplish $(A)$, you want to use $$ f_1(x) = \texttt{SmoothStep}(6x)$$
  • $(B)$ Moving a function to the right corresponds to moving the inputs to the left. This slight awkwardness is behind the fact that e.g. $x-3$ has root $+3$, not $-3$. So our final result is $$ f_2(x) = f_1(x-2/3) = \texttt{SmoothStep}\Big(6(x-2/3)\Big).$$

Plots to verify this is correct:

enter image description here

$\endgroup$
  • 1
    $\begingroup$ Thank you, that helps! $\endgroup$ – BAYMAX Feb 23 '19 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.