Opened 8 years ago

Closed 7 years ago

#12303 closed defect (duplicate)

leave beta symbolic for exact complex inputs

Reported by: ktkohl Owned by: burcin
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: symbolics Keywords: beta special function
Cc: benjaminfjones, kcrisman Merged in:
Authors: Reviewers: Burcin Erocal
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

Ticket #9130 implements access to the beta function. But exact complex inputs result in a numerical output from ginac.

beta(2,1+5*I)
-0.0305039787798408 - 0.0198938992042440*I

Change History (8)

comment:1 Changed 8 years ago by benjaminfjones

  • Cc benjaminfjones added

comment:2 follow-up: Changed 8 years ago by benjaminfjones

How is a Ginac function called to do numerical evaluation? I thought this would work as a custom _eval_ method for beta:

    def _eval_(self, y, z):
        if not isinstance(y, Expression) and not isinstance(z, Expression) and \
                (is_inexact(y) or is_inexact(z)):
            coercion_model = sage.structure.element.get_coercion_model()
            y, z = coercion_model.canonical_coercion(y, z)
            return GinacFunction.__call__(self, y, z)
        return None

But GinacFunction.__call__ ends up calling the custom _eval_ and I get an infinite recursion. I'm having trouble using the debugger to determine how, for example, beta(4.0, 5.0) is calculated. Is this because Pynac is mostly in Cython?

comment:3 in reply to: ↑ 2 Changed 8 years ago by burcin

  • Authors set to Burcin Erocal
  • Dependencies 9130 deleted
  • Milestone changed from sage-5.0 to sage-5.1

Pynac 0.2.4 from #12950 contains a fix for this. There is a patch with a doctest attached to that ticket. We should close this when that is merged.

Replying to benjaminfjones:

How is a Ginac function called to do numerical evaluation? I thought this would work as a custom _eval_ method for beta:

    def _eval_(self, y, z):
        if not isinstance(y, Expression) and not isinstance(z, Expression) and \
                (is_inexact(y) or is_inexact(z)):
            coercion_model = sage.structure.element.get_coercion_model()
            y, z = coercion_model.canonical_coercion(y, z)
            return GinacFunction.__call__(self, y, z)
        return None

But GinacFunction.__call__ ends up calling the custom _eval_ and I get an infinite recursion. I'm having trouble using the debugger to determine how, for example, beta(4.0, 5.0) is calculated. Is this because Pynac is mostly in Cython?

Pynac is mostly C++. You should use GDB to trace the code.

The short answer to your question is: I haven't thought of this use case, so there isn't an easy way to call the evaluation method defined in Pynac from your _eval_(). The custom methods can only overwrite the ones defined in C++, they don't follow any inheritance principles from OOP.

This could be done by calling beta_eval() defined in ginac/inifcns_gamma.cpp directly from Cython, but that would be really messy. :)

comment:4 Changed 8 years ago by benjaminfjones

Ok, that makes sense. Thanks. I'll have a look at #12950.

comment:5 Changed 8 years ago by kcrisman

  • Cc kcrisman added

comment:6 Changed 7 years ago by burcin

  • Authors Burcin Erocal deleted
  • Milestone changed from sage-5.1 to sage-duplicate/invalid/wontfix
  • Reviewers set to Burcin Erocal
  • Status changed from new to needs_review

This can be closed since #12950 was merged.

comment:7 Changed 7 years ago by burcin

  • Status changed from needs_review to positive_review

comment:8 Changed 7 years ago by jdemeyer

  • Keywords beta added
  • Resolution set to duplicate
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.