Open zimmermann6 opened 6 years ago
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):
Also:
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]
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]
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 toCBF
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
.
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
...).
Replying to @fredrik-johansson:
That also goes for
I
(it would be so much nicer if such constants by default lived inQQbar
or something like it instead ofSymbolicRing
...).
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.
Changed keywords from none to CBF
Description changed:
---
+++
@@ -1,15 +1,15 @@
With Sage 8.2:
-sage: C=ComplexBallField(100) -sage: C.integral(lambda x,:cosh(x),0,1) +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) +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
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.
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
the examples from comment [comment:10] already work with Sage 9.1. However, the example from the description with sqrt(2)
does not work.
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).
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))
.
well, it's rather CBF.sqrt(2)
, which doesn't work, and won't get fixed.
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.
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.
With Sage 8.2:
Same with
sqrt
and constants:CC: @dimpase @fredrik-johansson @mezzarobba @slel
Component: basic arithmetic
Keywords: CBF
Issue created by migration from https://trac.sagemath.org/ticket/25527