How to mix two functions for calculating the rate of change?

38 Views Asked by At

Imagine we have two functions for calculating the rate (say the internet for investment) as

$$y = 1 + \operatorname{erf}(x-2); 0 < x < 4\\ y = 1 + 1.5 + \operatorname{erf} (x-6); 4 < x < 8 $$

Is it possible to mix these two function into one to be valid for $0<x<8$?

1

There are 1 best solutions below

0
On BEST ANSWER

One can write a piecewise function using a unit step function. The unit step function is itself a piecewise function but it allows one to write other piecewise functions as a single expression.

$$ U(x)=\begin{cases}0\text{ for }x<0\\1\text{ for }x\ge0\end{cases} $$

Then given

$$ f(x)=\begin{cases} y_1\text{ for } x< x_1\\ y_2\text{ for }x_1\le x<x_2\\ y_3\text{ for }x_2\le x<x_3\\ \vdots\\ y_{n}\text{ for }x_{n-1}\le x<x_n\\ y_{n+1}\text{ for }x\ge x_n \end{cases} $$

one may write

$$ f(x)=y_1+(y_2-y_1)U(x-x_1)+(y_3-y_2)U(x-x_2)+\cdots+(y_{n+1}-y_n)U(x-x_n) $$

In your example, define $y$ for $0<x<8$ as

$$ y=1+\operatorname{erf}(x-2)+\left[1.5+\operatorname{erf}(x-6)-\operatorname{erf}(x-2)\right]U(x-4) $$