Re: Simple Doppler effect
- To: mathgroup at smc.vnet.net
- Subject: [mg120981] Re: Simple Doppler effect
- From: Bert Aerts <bert.ram.aerts at gmail.com>
- Date: Sat, 20 Aug 2011 06:16:52 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
This is an answer to the message of Dana DeLouis. Thanks for the simple examples like: f = 440; z = Integrate[2*Pi*f, t]; Play[Sin[z], {t, 0, 10}] And f = 400 - 40*t; z = Integrate[2*Pi*f, t]; Play[Sin[z], {t, 0, 10}] I learned that the phase is the indefinite integral of the instantaneous frequency. So now the Doppler one: vSound = 343;(*speed of sound*) vSource = 50;(*speed of source*) xObserver = 300;(*x coord of observer*) yObserver = 100;(*y coord of observer*) fSource = 440;(*frequency of source*) x[t_] := vSource*t fDoppler[t_] := Module[{xPosn, r}, xPosn = x[t]; r = Sqrt[(xObserver - xPosn)^2 + yObserver^2]; fSource*vSound/(vSound - vSource*(xObserver - xPosn)/r)] Plot[fDoppler[t], {t, 0, 12}] phase = Integrate[2 Pi fDoppler[t], t, Assumptions -> {t \[Element] Reals, t >= 0, t <= 12}] This delivers a complex result, but an indefinite integral has infinite solutions, all different on another constant, as the derivative of a constant is zero. So lets state that the phase at t=0 must be zero. phase0 = phase /. t -> 0 Plot[Re[phase - phase0], {t, 0, 12}] Plot[Im[phase - phase0], {t, 0, 12}] The imaginary part is smaller than 1E-12. So subtracting the complex constant makes our indefinite integral solution real! Play[Sin[ Re[phase - phase0] ], {t, 0, 12}] This gives the expected Doppler sound. As a check, we calculate the instantaneous frequency again: deriv = D[phase/(2 Pi) , t] N[deriv /. t -> 6] Plot[deriv, {t, 0, 12}] Another way to calculate the Doppler frequency is via Cos and ArcTan: fDopplerBert[t_] := fSource*vSound/(vSound - vSource*Cos[ArcTan[(xObserver - x[t]), yObserver]]) Plot[fDopplerBert[t], {t, 0, 12}] phaseBert[t_] = Integrate[2 Pi fDopplerBert[t], t] phaseBert0 = phaseBert[0] But we get in trouble at t=6 phaseBert[6] - phaseBert0 gives Indeterminate because of division by zero. We can avoid this by Play[Sin[If[t == 6, 0, Re[phaseBert[t] - phaseBert0]]], {t, 0, 12}] The solution without ArcTan is more elegant. Kind regards, Bert $Version 8.0 for Linux x86 (64-bit) (February 23, 2011)