Newton's Method Involving Elliptic Integrals
8 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
David Hill
on 11 Mar 2021
Edited: David Hill
on 11 Mar 2021
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 Comments
David Hill
on 11 Mar 2021
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
on 12 Mar 2021
If you a satisfied with the answer, you should accept it to close out the question.
More Answers (0)
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!