Fwd: inverselliptic2.m

10 views
Skip to first unread message

Igor Moiseev

unread,
Jan 5, 2014, 4:03:07 PM1/5/14
to pell...@googlegroups.com

---------- Forwarded message ----------
From: Nen Huynh
Date: 2014/1/5
Subject: inverselliptic2.m
To: moisee...@gmail.com


Hi,
I have a project that requires the use of your elliptic functions project. Thanks for that. I do have a suggestion:
- Consider using atan2 instead of atan for the inverselliptic2.m because it's more stable and you won't need the eps for the denominator.
- My project required plugging in large numbers in the inverselliptic2.m function, which won't work because there's only 4 iterations. So I'd recommend using a while loop:
        [~, E] = elliptic12(invE(:),m,tol);
        dinvE = (E - z)./sqrt( 1-m.*sin(invE(:)).^2 );
        while max(abs(dinvE)) > tol
            invE(:) = invE(:)-dinvE;
            [~, E] = elliptic12(invE(:),m,tol);
            dinvE = (E - z)./sqrt( 1-m.*sin(invE(:)).^2 );
        end
        invE(:) = invE(:)-dinvE;

    instead of:
        for iter=1:4
            [~, E] = elliptic12(invE(:),m,tol);
            invE(:) = invE(:)-(E - z)./sqrt( 1-m.*sin(invE(:)).^2 );
        end

- Also, have you considered using the Matlab function "integral" to evaluate the elliptic functions? It has the benefit of not needing a tolerance parameter.

Thanks, again.

Igor Moiseev

unread,
Jan 5, 2014, 4:09:35 PM1/5/14
to pell...@googlegroups.com, nvhu...@gmail.com
Hi Neh Huynh!
Thank you for a valuable suggestions and I glad it was useful for your research! 

The four iterations approach is the more stable option, if something goes wrong and it may go wrong in singularities and special values ;)
To embrace precision and stability we may apply both approaches 

1. while for precision 
2. and iteration control, let say step<10

I've opened the issue 12 for this request

Igor Moiseev


 
---------- Forwarded message ----------
From: Nen Huynh
Date: 2014/1/5
Subject: inverselliptic2.m


Reply all
Reply to author
Forward
0 new messages