Opened 9 years ago

Closed 9 years ago

#13096 closed defect (duplicate)

find_maximum_on_interval fails when used with a sage function

Reported by: aginiewicz Owned by: jason, jkantor
Priority: minor Milestone: sage-duplicate/invalid/wontfix
Component: numerical Keywords:
Cc: Merged in:
Authors: Reviewers: Andrzej Giniewicz
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

The function find_maximum_on_interval fails when used with a sage function that is passed as an argument:

sage: f(x) = sin(x)
sage: find_maximum_on_interval(f, 0, 2*pi)
Traceback (click to the left of this block for traceback)
...
RuntimeError: ECL says: THROW: The catch MACSYMA-QUIT is undefined.

while all of:

sage: find_minimum_on_interval(f, 0, 2*pi)
(-1.0, 4.7123889815323858)
sage: f.find_minimum_on_interval(0, 2*pi)
(-1.0, 4.7123889815323858)
sage: f.find_maximum_on_interval(0, 2*pi)
(1.0, 1.570796325647202)

works. This was kind of unexpected, esp that documentation says about providing a function as an argument.

Change History (5)

comment:1 Changed 9 years ago by aginiewicz

I believe this is because find_maximum_on_interval is calling find_minimum_on_interval with lambda z: -f(z) as argument (sage/numerical/optimize.py:127) and doing

     try:
         return f.find_maximum_on_interval(a=a, b=b, tol=tol,maxfun=maxfun)
     except AttributeError:
         pass

just before that should work. Am I right? This might be also related to #3955 (quite old ticket but looks like it proposes a better solution, were there some issues with it, or just no one got into it yet?). If I find enough time to make patch I will post it, but I have to recreate my build environment first (since sage 5.0 does not work with my version of gcc I switched to distribution provided package that is already patched).

comment:2 Changed 9 years ago by nbruin

  • Milestone changed from sage-5.1 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review

Dup of #12032

comment:3 Changed 9 years ago by novoselt

  • Status changed from needs_review to positive_review

See #2607 also.

comment:4 Changed 9 years ago by aginiewicz

I looked at both of those before openning this ticket, but though #12032 is more general and not that easily fixed, and #2607 is about name/docs instead of working vs non-working. Anyway, I agree that this ticket is a duplicate (of #3955). I uploaded patch based on comment:1 there.

comment:5 Changed 9 years ago by jdemeyer

  • Resolution set to duplicate
  • Reviewers set to Andrzej Giniewicz
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.