Opened 10 months ago

Last modified 3 months ago

#31401 new defect

Segmentation fault when calculating the taylor series of a specific function

Reported by: gh-frcl Owned by:
Priority: major Milestone: sage-9.5
Component: calculus Keywords: maxima, taylor series
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Reported upstream. No feedback yet. Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by slelievre)

The following code evaluated in Sage 9.2 leads to a segmentation fault

sin(4*arctan(1/(sqrt(3) + 2))-x).taylor(x, 0, 1)

The error message is

;;;
;;; Detected access to protected memory, also known as 'bus or segmentation fault'.
;;; Jumping to the outermost toplevel prompt
;;;

Changing the constant slightly gives the desired result, e.g.

sin(4*arctan(1/(sqrt(3) + 1))-x).taylor(x, 0, 1)

evaluates to

-x*cos(4*arctan(1/2*sqrt(3) - 1/2)) + sin(4*arctan(1/2*sqrt(3) - 1/2))

Upstream report:

Change History (7)

comment:1 follow-up: Changed 10 months ago by gh-DaveWitteMorris

  • Keywords maxima taylor series added

This is a maxima bug:

(%i1) taylor(sin(atan(1/(sqrt(3) + 2)) - x), x, 0, 1);

      Message from maxima's stderr stream: INFO: Control stack guard page unprotected
      Control stack guard page temporarily disabled: proceed with caution
      Control stack guard page temporarily disabled: proceed with caution
      Maxima encountered a Lisp error:
       Control stack exhausted (no more space for function call frames).
      This is probably due to heavily nested or infinitely recursive function
      calls, or a tail call that SBCL cannot or has not optimized away.

I tested with some other nonzero integers a and b in the place of 3 and 2. It seems that the crash happens whenever a < b^2 (including all cases where a < 0).

comment:2 in reply to: ↑ 1 Changed 10 months ago by gh-frcl

Replying to gh-DaveWitteMorris:

I tested with some other nonzero integers a and b in the place of 3 and 2. It seems that the crash happens whenever a < b^2 (including all cases where a < 0).

This seems to be the case, except if a is a square number. I guess the sqrt is evaluated first in that case. This implies that the sqrt is somehow involved in triggering the bug.

I will file a bug report on the maxima bug tracker. Should I close the ticket here?

comment:3 Changed 10 months ago by gh-DaveWitteMorris

Thanks for volunteering to report the bug to maxima (and for clarifying that a should not be a square).

Please keep this ticket open. The "Report Upstream" field of this ticket should be set to "Reported upstream. No feedback yet", and that field can be updated as the situation progresses. It would also be helpful if you can add a comment here with a link to the maxima bug report, so it is easy for sage trac followers to check on the status in maxima.

comment:4 Changed 10 months ago by gh-DaveWitteMorris

PS If you need a workaround for the bug, you can replace 2 with a variable, and then substitute at the end:

sage: var('a');
sage: sin(4*arctan(1/(sqrt(3) + a))-x).taylor(x, 0, 1).subs(a=2)
-x*cos(4*arctan(1/(sqrt(3) + 2))) + sin(4*arctan(1/(sqrt(3) + 2)))

comment:5 Changed 10 months ago by slelievre

  • Description modified (diff)
  • Report Upstream changed from N/A to Reported upstream. No feedback yet.

Upstream ticket in the Maxima bug tracker:

comment:6 Changed 7 months ago by mkoeppe

  • Milestone changed from sage-9.3 to sage-9.4

Moving to 9.4, as 9.3 has been released.

comment:7 Changed 3 months ago by mkoeppe

  • Milestone changed from sage-9.4 to sage-9.5
Note: See TracTickets for help on using tickets.