Opened 6 years ago

Last modified 17 months ago

#16202 new enhancement

implement the agm(x,y) function

Reported by: rws Owned by:
Priority: major Milestone: sage-8.2
Component: calculus Keywords:
Cc: mforets Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by rws)

https://en.wikipedia.org/wiki/Arithmetic-geometric_mean

Pari has a numeric implementation:

? 1/agm(1,sqrt(2))
%1 = 0.83462684167407318628142973279904680900

but Wikipedia provides a closed form integral expression, and if we had the "complete elliptic integral of the first kind" this would be even simpler.

Numerically there is sage.rings.real_mpfr.RealNumber.

Change History (8)

comment:1 Changed 6 years ago by kcrisman

Do you mean elliptic_kc? This is indeed in Maxima, though not yet a "Sage symbolic function". See also the symbolics page on Trac where a few things about this are mentioned.

Oh, I see what you mean about the elliptic - like this Rosetta stone. Anyway, I would think that we can do this fairly easily - also note mpmath has the agm and the elliptic integral in question, and mpmath is probably a go-to for numerical evaluation of our most recent implementations of special functions.

comment:2 Changed 6 years ago by kcrisman

Sorry, to clarify - if we implement elliptic_kc as a symbolic function, you could do this easily as you say, or we can try to combine this with mpmath as well.

comment:3 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:4 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:5 Changed 5 years ago by rws

  • Description modified (diff)

comment:6 Changed 2 years ago by mforets

  • Cc mforets added
  • Milestone changed from sage-6.4 to sage-8.2

comment:7 Changed 18 months ago by chapoton

There is already

sage: a=CDF(1)
sage: b=CDF(sqrt(2))
sage: 1/a.agm(b)
0.834626841674073

comment:8 Changed 17 months ago by rws

Also

            sage: RBF(sqrt(2)).agm(1)^(-1)
            [0.83462684167407 +/- 3.9...e-15]
Note: See TracTickets for help on using tickets.