Newton's Method Involving Elliptic Integrals
8 次查看(过去 30 天)
显示 更早的评论
Hi,
I'm trying to find the root of a function involving elliptic integrals using Newton's Method to be used in another code. I based my code off of Be Matlabi's answer here: https://www.mathworks.com/matlabcentral/answers/441561-newton-s-method-in-matlab . I'm not too familiar with symbolic toolbox. I keep running into a "Conversion to logical from sym is not possible" error and I'm not sure how to combat this. I already have an idea of what the answer (x) is like, but I need the proper experimental value to replicate a set of plots. The x value will be incredibly close to 1 and the plots I have developed that look similiar have x values like x = 0.999999 (J=1), and x = 997999 (J=2). I really just need help developing this code to give me the proper experimental value for x. The derivative of that function should be correct, but I did do it by hand, so feel free to double-check me if you want to go the extra mile. I also got the derivatives of each elliptic integral from Wolfram's website. Thanks!
clear all
syms f(x) g(x) x
% Constants
B = 1/(2*(1-x)*x);
gN = 625;
J = 2;
tol = 1e-9;
% Functions
[K,E] = ellipke(x);
f(x) = K^2 - K*E - (gN/(8*J^2));
g(x) = B * (3*K*E - E^2 - 3*K^2 - (K^2)*x);
x(1)=0.99; % Initial Point
% Workshop
for i=1:1000 %it should be stopped when tolerance is reached
x(i+1) = x(i) - f(x(i))/g(x(i));
if( abs(f(x(i+1)))<tol) % tolerance
disp(double(x(i+1)));
break;
end
end
0 个评论
采纳的回答
David Hill
2021-3-11
编辑:David Hill
2021-3-11
y=fzero(@nonLinear,[.999,.99999999999999]);
function f=nonLinear(x)
[k(1),k(2)]=ellipke(x);
gN = 625;
J = 2;
f = k(1).^2 - k(1).*k(2) - (gN/(8*J^2));
end
3 个评论
David Hill
2021-3-11
fzero() finds the root of the function nonLinear between the two values (.999 and .99999999999999). You can look at matlab's help file.
help fzero
David Hill
2021-3-12
If you a satisfied with the answer, you should accept it to close out the question.
更多回答(0 个)
另请参阅
类别
在 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!