horizontal transformation of functions

Observe two functions, translated by some factor but otherwise identical:

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{arrows.meta}
%
\definecolor{firstfunctioncolor}{HTML}{8A5CF5}
\definecolor{secondfunctioncolor}{HTML}{E0DE71} % lighter
% \definecolor{secondfunctioncolor}{HTML}{E0AC00} % darker
%
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        width=10cm,
        height=10cm,
        axis lines = left,
        enlargelimits=0.05,
        xticklabels = {\empty},
        yticklabels = {\empty},
        legend pos = north west,
        legend image post style = -,
        legend cell align = left,
        xtick = {-4,-3,-2,-1,...,6,7,8,9},
        ytick = {-52,-27,0,27,52},
        ]
	%
    \addplot [
        Latex-Latex,
        domain=-5:5, 
        samples=101, 
        color=firstfunctioncolor,
        very thick,
        ]
        {x^3};
    \addlegendentry{\(f(x)\)}
	%
    \addplot [
        Latex-Latex,
        domain=0:10, 
        samples=101, 
        color=secondfunctioncolor,
        very thick,
        ]
        {(x-5)^3)};
    \addlegendentry{\(g(x)=f(x-h)\)}
	%
    \draw [dashed] (axis cs:10,27) -- (axis cs:0.5,27) node[left] {\(f(d-h)=g(d)\)};
    \draw [dashed] (axis cs:-5,-27) -- (axis cs:3.5,-27) node[right] {\(f(c)=g(c+h)\)};
	%
    \begin{scope}[every node/.style={circle, fill, inner sep=1.5pt}]
        \node[color=firstfunctioncolor, pin={[pin edge={firstfunctioncolor!50}]105:\small $d-h$}] at (axis cs:3,27) {};
        \node[color=firstfunctioncolor, pin={[pin edge={firstfunctioncolor!50}]285:\small $c$}] at (axis cs:-3,-27) {};
        \node[color=secondfunctioncolor, pin={[pin edge={secondfunctioncolor!50}]105:\small $d$}] at (axis cs:8,27) {};
        \node[color=secondfunctioncolor, pin={[pin edge={secondfunctioncolor!50}]285:\small $c+h$}] at (axis cs:2,-27) {};
    \end{scope}
	%
    % \node at (axis cs:5.5,14) {\(h\)};
    % \node at (axis cs:-0.5,-14) {\(h\)};
	%
    \end{axis}
\end{tikzpicture}
\end{document}

But why, when shifting f(x) h units to the right, is it f(xh)? Why is it minus if the shift is positive?

First, let f(x) be our main function, and let g(x) be the function f shifted to the right by h. Then, for each point (x,y) in f, where y=f(x), our shifted function g has the same output at an input shift of h; in other words, (x+h,y) is in g, i.e. g(x+h)=y=f(x).
This can be interpreted as:

f(c)=g(c+h) Whenever I input some value c into f, I have to input a value h more than c into g to get the same output.
Whenever I input some value d into g, I have to input a value h less than d into f to get the same output. g(d)=f(dh)
That 'less' is why we see a minus sign when we move a function to the right. It's because we are relating the 'new' function back to the original function.

In fact, when we have a function y=f(x), we typically see a translational shift expressed as y=f(xh)+k, where a positive k means a shift in the positive y direction. However, using some algebraic manipulation, it's clear to see that an equivalent interpretation of a general translation is

(yk)=f(xh)

where k is the shift in the positive y direction and h is the shift in the positive x direction. The reasoning for why k has a minus sign is exactly the same as the reasoning above for why h has a minus sign: we are relating the 'new' function back to the original function.

Powered by Forestry.md