I have to perform many minimizations of a function, so I want to do it quickly. Here is the problem: given different values of T, the minimization should find L = ((g*T^2)/(2*pi))*tanh(2*pi*D/L) where g and D are constants. Below is how I am doing it, but is there a faster way?
g = 9.8066 ;D = 50 ; periodList = linspace(3, 15, 100) ;fh = @(L,T) (L-((g*T.^2)/(2*pi))*tanh(2*pi*D/L)) ; % Handle to L as a function of T
for iPeriod = 1:length(periodList) T = periodList(iPeriod) ; guessL = g*(T^2)/(2*pi) ; % Initial guess at L
L(iPeriod) = fzero(@(L) fh(L, T), guessL) ;end
Since this problem is finding the wavelength L of water waves given the wave period T and water depth D, there are some constraints on the problem: L must always be positive with a nominal solution accuracy of +/-1 meter, the period T will lie between 0 and ~20 seconds, and the water depth D ranges from ~10 to 1000 meters. g is the acceleration due to gravity, so it will always be 9.8066 m/s^2.
Best Answer