How to perform function transformations in a semi-log environment?

30 Views Asked by At

Generally, say I have a function $f(x)$.

I would like to transform $f(x)$ to $\hat f(x)$ such that $\hat f(x)$ when plotted on a semi-log plot (x-axis log, function axis linear) has the same shape as $f(x)$ on a linear plot.

For my specific problem, I would like to transform $f(x, a) = \tanh (x+a)$ (where $a$ is some horizontal transformation) such that, regardless of $a$, $\hat f(x, a)$, "looks" like $f(x, a)$.

1

There are 1 best solutions below

0
On

The issue I ran into was that you had to take the log of $x$ and $a$ separately.

So if $f(x) = \tanh(x + a)$ then $\hat f(x) = \tanh(\log(x) + \log(a))$.

If you want to stretch the the function using a parameter $s$, then you must multiply the entire input:

$$ \hat f(x) = \tanh[s(\log(x) + \log(a))]$$

enter image description here

Python source code:

x = np.geomspace(1E-3, 1E4, 1000)
f1 = np.tanh(np.log(x))
f2 = np.tanh(np.log(x) - np.log(1E2))
f3 = np.tanh(2*(np.log(x) - np.log(1E2)))

fig, ax = plt.subplots()
ax.plot(x, f1, label=r'$\tanh(\log(x))$')
ax.plot(x, f2, label=r'$\tanh(\log(x) + \log(2))$')
ax.plot(x, f3, label=r'$\tanh \left[2(\log(x) + \log(2)) \right ]$')
ax.legend(loc='upper left')
ax.set_xscale('log')