Opened 7 years ago

Closed 7 years ago

#19256 closed defect (wontfix)

inconsistent numerics with RR/CC/CDF(pi,sqrt(2))

Reported by: rws Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: symbolics Keywords:
Cc: Merged in:
Authors: Ralf Stephan Reviewers:
Report Upstream: N/A Work issues:
Branch: u/rws/inconsistent_numerics_with_rr_cc_cdf_pi_sqrt_2__ (Commits, GitHub, GitLab) Commit: ca2ce549de5caf18a5173253de8b2b78cfe001ba
Dependencies: Stopgaps:

Status badges

Description (last modified by rws)

sage: RR(sqrt(2))
1.41421356237310
sage: CC(sqrt(2))
1.41421356237309

sage: (CC(pi)-pi).n()
-3.10862446895044e-15
sage: (RR(pi)-pi).n()
0.000000000000000
sage: (CC(sqrt(2))-sqrt(2)).n()
-5.10702591327572e-15
sage: (RR(sqrt(2))-sqrt(2)).n()
0.000000000000000

sage: (ComplexField(54)(pi)-pi).n()
-3.10862446895044e-15
sage: (ComplexField(55)(pi)-pi).n()
0.000000000000000
sage: (ComplexField(60)(sqrt(2))-sqrt(2)).n()
-2.22044604925031e-16
sage: (ComplexField(61)(sqrt(2))-sqrt(2)).n()
0.000000000000000

Change History (9)

comment:1 Changed 7 years ago by rws

  • Description modified (diff)

comment:2 Changed 7 years ago by rws

  • Description modified (diff)

comment:3 Changed 7 years ago by rws

I'm not complaining about the problems with limited precision. I just think they should be consistent between RR and CC.

comment:4 Changed 7 years ago by rws

  • Description modified (diff)

comment:5 Changed 7 years ago by rws

OK, both RR(sqrt(2)) and CC(sqrt(2)) lead to Pynac calling PyNumber_Power(2.00000000000000,1/2) but the first returns 1.41...10 and the second 1.41...09.

EDIT:

sage: RR(2)^(1/2)
1.41421356237310
sage: CC(2)^(1/2)
1.41421356237309

So the reason is because CC.__pow__ uses the generic exp(log(a)*b) instead of mpfr_pow as in RR.__pow__.

Last edited 7 years ago by rws (previous) (diff)

comment:6 Changed 7 years ago by rws

  • Branch set to u/rws/inconsistent_numerics_with_rr_cc_cdf_pi_sqrt_2__

comment:7 Changed 7 years ago by rws

  • Authors set to Ralf Stephan
  • Commit set to ca2ce549de5caf18a5173253de8b2b78cfe001ba
  • Status changed from new to needs_review

Let's see what the patchbot says.


New commits:

ca2ce5419256: inconsistent numerics with RR/CC/CDF(pi,sqrt(2))

comment:8 Changed 7 years ago by rws

  • Milestone changed from sage-6.9 to sage-duplicate/invalid/wontfix
  • Status changed from needs_review to positive_review

No, this is ridiculous. Can't be fixed.

comment:9 Changed 7 years ago by vbraun

  • Resolution set to wontfix
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.