Applying Newton's Method to Sound Level Equation
1 次查看(过去 30 天)
显示 更早的评论
I am trying to apply Newton's root-finding method to the following equation that measures sound level (in decibels) at a distance r meters from a source: L= L_0 - 20log10(r) - beta*r
Since we can't solve this directly, how can I find the derivative of the equation with the new function below? I'd like to print the root too. Am I able to use a function on MatLab to do both of these?
syms r
f(r) = L0 - 20 .* log10(r) - beta .* r - L;
% Given
L0 = 80;
beta = 0.00115;
L = 20;
tol = 0.000001;
This is Newton's Method from one of my previous assignments :
% Function file
function [c] = newtonsMethod(f,der,x0,tol)
% Inputs: f = function; der = derivative of function; x0 = initial guess; tol = error tolerance
err = 3*tol;
c=x0;
while err>tol
% Newton's method
c=c-f(c)/der(c);
err=abs(f(c));
end
end
0 个评论
回答(1 个)
John D'Errico
2021-4-7
Since we cannot solve it directly.... Are you absolutely positive of that?
L0 = 80;
beta = 32.2;
L = 20;
syms r
solve(L0 - 20 .* log10(r) - beta .* r - L == 0,r)
ans =
(100*lambertw(0, 1610*log(10)))/(161*log(10))
I suppose, if you say no solution exists, I could just believe you. But then why is MATLAB wrong, in claiming a solution exists? ;-) Admittedly, the solution uses the lambertw function.
help lambertw
My guess is, you are still supposed to use Newton's method. Do you mean you cannot differentiate?
diff(L0 - 20 .* log10(r) - beta .* r - L,r)
ans =
- 20/(r*log(10)) - 161/5
I'm a bit confused where the problem lies.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!