Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing wrappers in ComplexBallField #25527

Open
zimmermann6 opened this issue Jun 7, 2018 · 16 comments
Open

missing wrappers in ComplexBallField #25527

zimmermann6 opened this issue Jun 7, 2018 · 16 comments

Comments

@zimmermann6
Copy link

With Sage 8.2:

sage: C = ComplexBallField(100)
sage: C.integral(lambda x, _: cosh(x), 0, 1)
...
TypeError: no canonical coercion from Real Field with 53 bits of precision to Complex ball field with 100 bits of precision

Same with sqrt and constants:

sage: C.integral(lambda x, _: sqrt(2), 0, 1)
...
TypeError: no canonical coercion from Symbolic Ring to Complex ball field with 100 bits of precision

CC: @dimpase @fredrik-johansson @mezzarobba @slel

Component: basic arithmetic

Keywords: CBF

Issue created by migration from https://trac.sagemath.org/ticket/25527

@fredrik-johansson
Copy link
Contributor

comment:2

It looks like all the ordinary (cosh, sinh, tanh, coth) hyperbolic functions are missing.

Here is also a list of some other unwrapped functions, copied from an old email (this list is maybe slightly out of date):

  • arb_sec, arb_csc, arb_sech, arb_csch, acb_sec, acb_csc, acb_sech, acb_csch
  • acb_expm1, arb_sinc, arb_sinc_pi, acb_sinc, acb_sinc_pi
  • arb_sgn, acb_sgn, acb_csgn
  • Lambert W function
  • Everything in the acb_elliptic module
  • Everything in the arb_hypgeom module
  • can_round methods
  • Fresnel integrals
  • Different versions of incomplete gamma functions
  • Incomplete beta function
  • arb_bernoulli_poly_ui, acb_bernoulli_poly_ui + bernoulli/euler/partition numbers
  • Real matrices (I didn't see if there was an issue for this already)
  • FFT
  • A lot of power series methods
  • Maybe _acb_vec_unit_roots
  • Dirichlet L-functions
  • Interface to hypergeometric 2F1 for parameters differing by integers

Also:

  • acb_real_abs, acb_real_sgn, acb_real_heaviside, acb_real_floor, acb_real_ceil, acb_real_max, acb_real_min, acb_real_sqrtpos

@mezzarobba
Copy link
Member

Yes, there are still a number of functions missing—but I'm not sure it makes sense to open tickets about that unless you are planning to add the necessary wrappers.

However, this:

Replying to @zimmermann6:

Same with sqrt and constants:

sage: C.integral(lambda x,_:sqrt(2),0,1)
...
TypeError: no canonical coercion from Symbolic Ring to Complex ball field with 100 bits of precision

is intentional. What you should be doing is:

sage: CBF.integral(lambda x, _: CBF(2).sqrt(), 0, 1)
[1.414213562373095 +/- 2.99e-16]

of if you really want to use the global sqrt() function:

sage: CBF.integral(lambda x, _: sqrt(CBF(2)), 0, 1)
[1.414213562373095 +/- 2.99e-16]

@zimmermann6
Copy link
Author

comment:4

Marc, please could you explain why it is intentional? And for example why the constant 2 does not need to be explicitly converted to CBF in the following?

sage: CBF.integral(lambda x, _: sqrt(x+2), 0, 1)
[1.57849254104856 +/- 2.25e-15]

@mezzarobba
Copy link
Member

comment:5

Replying to @zimmermann6:

Marc, please could you explain why it is intentional? And for example why the constant 2 does not need to be explicitly converted to CBF in the following?

sage: CBF.integral(lambda x, _: sqrt(x+2), 0, 1)
[1.57849254104856 +/- 2.25e-15]

Because 2 is an element of ZZ, which coerces into CBF, so that x + 2 returns an element of CBF, and then sqrt() of an element of CBF returns an element of CBF. Whereas sqrt(2) returns an element of SR, which does not (and should not) coerce into CBF.

@fredrik-johansson
Copy link
Contributor

comment:6

That also goes for I (it would be so much nicer if such constants by default lived in QQbar or something like it instead of SymbolicRing...).

@mezzarobba
Copy link
Member

comment:7

Replying to @fredrik-johansson:

That also goes for I (it would be so much nicer if such constants by default lived in QQbar or something like it instead of SymbolicRing...).

It has been a plan for a long time to bind the global I to an element of ℚ[i] (see #18036), but there were backward compatibility concerns and perhaps other issues... I'll probably try reviving that ticket one day, though.

@slel
Copy link
Member

slel commented Nov 16, 2021

Changed keywords from none to CBF

@slel

This comment has been minimized.

@slel slel modified the milestones: sage-8.3, sage-9.5 Nov 16, 2021
@zimmermann6
Copy link
Author

comment:9

note that the first example now works with Sage 9.1 (not tried with more recent versions):

sage: C = ComplexBallField(100)
sage: C.integral(lambda x, _: cosh(x), 0, 1)
[1.1752011936438014568823818506 +/- 2.32e-29]

The second example (with sqrt) still fails with 9.1.

@dimpase
Copy link
Member

dimpase commented Nov 16, 2021

comment:10

Something like this works (with merged, but not yet in latest beta, changes):

age: C.integral(lambda x, _: CBF(sqrt(2)), 0, 1)
[1.414213562373095 +/- 5.21e-16]
sage: C.integral(lambda x, _: sqrt(x), 0, 1)
[0.67388733867904916156919930316 +/- 3.76e-30] + [+/- 2.50e-36]*I

@zimmermann6
Copy link
Author

comment:11

the examples from comment [comment:10] already work with Sage 9.1. However, the example from the description with sqrt(2) does not work.

@dimpase
Copy link
Member

dimpase commented Nov 17, 2021

comment:12

here is a similar thing (with SR instead of a lambda) that works (with #32871 - but perhaps it's not needed):

sage: CBF(integral(sqrt(2), (x, 0, 1)))
[1.414213562373095 +/- 5.21e-16]
sage: C(integral(sqrt(2), (x, 0, 1)))
[1.41421356237309504880168872421 +/- 2.41e-30]

we had a discussion about a very similar setting (with RBF in place of CBF), and Marc convinced me that having to call conversion to RBF in real_arb.pyx (resp. to CBF in complex_arb.pyx)
is not desirable - and coersion alone need not work if you go SR->RBF (or CDF).

@zimmermann6
Copy link
Author

comment:13

about the examples from comment [comment:12], since integral(sqrt(2), (x, 0, 1)) evaluates to sqrt(2), this is nothing else than CBF(sqrt(2)).

@dimpase
Copy link
Member

dimpase commented Nov 17, 2021

comment:14

well, it's rather CBF.sqrt(2), which doesn't work, and won't get fixed.

@dimpase
Copy link
Member

dimpase commented Nov 17, 2021

comment:15

if we don't even have CBF.sqrt(2) then I would not be hoping that CBF.<... some pyhthon code with SR(sqrt(2))...> would be working.

@mezzarobba
Copy link
Member

comment:16

Replying to @zimmermann6:

the examples from comment [comment:10] already work with Sage 9.1. However, the example from the description with sqrt(2) does not work.

See these comments about that example.

@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Apr 1, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Aug 31, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants