I have a time dependent function as follows: $$f(x + \delta (t)) = \cos(2\pi \cdot (x - \delta(t)) + 0.05\sin(60\pi(x - \delta(t)))$$ where $\delta(t) = 0.05t$ and $ f(x,t=0) = f(x)$.
Using the Taylor series approximation: $$ f(x+h) \approx f(x)+f′(x)h+\frac{f′′(x)}{2!}h^2+ \ldots$$
$$ f(x+\delta(t)) \approx f(x)+f′(x)\delta(t)+\frac{f′′(x)}{2!}\delta(t)^2+ \ldots$$
Actual $ f(x,t=1) = \cos(2\pi \cdot (x - 0.05) + 0.05\sin(60\pi(x - 0.05))$ and approximate $$ f(x,t=1) = f(x) - 0.05f′(x)$$ which are not matching in MATLAB (code and result below). I tried swapping the sign in the approximation but it's still not working. The higher order terms are approximately zero since $\delta(t)^n$ goes to zero.
clear; clc; close all;
x = linspace(0.2, 0.7, 1000); % x (space)
% The signal consists of a large low-frequency wave and small high-frequency ripples.
% f(x, t) = cos(2*pi*(x - b*t)) + 0.05 * sin(a*pi*(x - b*t));
% f_curr = f(x, 0); % Black: f(x, t)
% f_next = f(x, 1); % Blue: f(x, t+1)
% Generate the signal at 2 time instants {t, t+1}
a = 60;
b = 0.05;
f_curr = cos(2*pi* x ) + 0.05 * sin(a*pi* x );
f_next = cos(2*pi*(x - b)) + 0.05 * sin(a*pi*(x - b));
%% Approximation using Taylor series
dx = x(2) - x(1); % Spatial step size
df_dx = gradient(f_curr, dx); % df/dx (1st spatial derivative)
f_curr_der = -2*pi*sin(2*pi*x) + 0.05*a*pi*cos(a*pi*x);
% Verify df_dx is gradient
figure;subplot(1,2,1);plot(f_curr_der);hold on;plot(df_dx,'b--');xlabel('x (space)');ylabel('Value');title('Derivative of f(x) w.r.t x');
legend('Analytical','MATLAB function');
% 1st-order Taylor expansion around x:
% f(x,t) ≈ f(x) + delta(t) * df/dx
f_next_approx = f_curr - b*f_curr_der;
subplot(1,2,2);plot(f_next);hold on;plot(f_next_approx);xlabel('x (space)');ylabel('Value');title('f(x,1)');
legend('Actual','Approximate');return

