Fourier Transformed a signal $f(t) = \cos(2\pi*4t)*5\cos(2\pi*0.4t)$ but did not get expected results. What went wrong? I created a signal with two sinusoidal components by specifying

$$
f(t) = \cos(2\pi*4t)*5\cos(2\pi*0.4t)
$$

I expected with I used MatLab's fft function on this that signal that I would see a peak of amplitude $1$ at a position of 4Hz in the spectrum corresponding to the 'fast' signal which has frequency $4$, and a peak of amplitude $5$ at a position of 0.4Hz in the spectrum corresponding to the 'slow' signal which has frequency $0.4$.

In my code below, subplots 3 and 4 are the fft plots, 3 is the unshifted one, and 4 is the shifted one. As you can see from running the code, I do not get the results I expected!

It seems I have peaks at $4+0.4=4.4$ Hz and $4-0.4=3.6$ Hz, and although the scaling is off with the amplitude, both peaks are the same height.

I thought the Fourier Transform would pick up the oscillations at 4Hz and 0.4Hz individually, and display them with their correct (relative) amplitudes? What has gone wrong?

function FFT_4()
clc
clear all
close all

sigFreq = 4;
f = @(t) cos(2*pi*sigFreq*t)*5.*cos(2*pi*0.1*sigFreq*t);

%% Calculation for samFreq &gt; 2*sigFreq: Higher resolution
samFreq = 12;
[t,S,omega,power,fshift,powershift] = CalcFFT(f, samFreq);
plotSignalandFFTSignal(4,t,S,omega,power,fshift,powershift)

end

function [t,S,omega,power,omegashift,powershift] = CalcFFT(f, samFreq)
t = 0:(1/samFreq):(10-1/samFreq); % time vector
S = f(t);
n = length(S);
X = fft(S);
Y = fftshift(X);
omega = (0:n-1)*(samFreq/n);     %frequency range
power = abs(X).^2/n;    %power
omegashift = (-n/2:n/2-1)*(samFreq/n); % zero-centered frequency range
powershift = abs(Y).^2/n;
end

function plotSignalandFFTSignal(figNum,t,S,f,power,fshift,powershift)
figure(figNum)
subplot(2,2,1); plot(t,S); % xlim([0,1])
subplot(2,2,2); plot(power)
subplot(2,2,3); plot(f,power)
subplot(2,2,4); plot(fshift,powershift)
end
Fourier Transform is linear transform. It is mean that Fourier Transforms of sum of functions will be sum of Fourier Transforms of each function. It is not valid for multiply of function.

Your example. There is very well known formula (see 7c in this link):
$$
\cos(\alpha) * cos(\beta) = 1/2 (\cos(\alpha+\beta) + \cos(\alpha-\beta))
$$
use this formula  to transform your function:
$$ 
f(t) = \cos(2\pi*4t)*5\cos(2\pi*0.4t) = 5/2*(\cos(2\pi*4t - 2\pi*0.4t) + \cos(2\pi*4t - 2\pi*0.4t)) = 5/2*(\cos(2\pi*3.6t) + \cos(2\pi*4.4t))
$$
So Matlab results is correct - you have 2 peaks equal amplitude with 3.6 and 4.4 frequency.