Why the energy of electromagnetic waves is directly proportional to frequency whilst for mechanical waves this is not true?

Why the energy of electromagnetic waves is directly proportional to frequency whilst for mechanical waves this is not true?
You can still ask an expert for help

• Questions are typically answered in as fast as 30 minutes

Solve your problem for the price of one coffee

• Math expert for every subject
• Pay only if we can solve it

The difference isn't electromagnetic versus mechanical. All classical waves behave the same way, as do all quanta. The difference arises because you're treating the light as quantum and the mechanical wave as classical.
The energy of a single quantum is always proportional to $\omega$. This is true for photons, but it's also true for the quantized excitations that make up, say, classical waves on a string.
For any wave described by a generalized coordinate $\varphi \left(t\right)$ obeying the ideal wave equation and with standard normalization, the energy density of a classical plane wave at fixed amplitude is always proportional to ${\omega }^{2}$. This is true for both classical waves on a string (where the coordinate is the height $y\left(x,t\right)$) and for electromagnetic waves (where the coordinate is the vector potential $\mathbf{A}\left(\mathbf{x},t\right)$
Combining these two results shows that the density of quanta making up a classical ideal plane wave of fixed amplitude and frequency $\omega$ is proportional to $\omega$