Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault when calculating the taylor series of a specific function #31401

Open
frcl mannequin opened this issue Feb 15, 2021 · 9 comments
Open

Segmentation fault when calculating the taylor series of a specific function #31401

frcl mannequin opened this issue Feb 15, 2021 · 9 comments

Comments

@frcl
Copy link
Mannequin

frcl mannequin commented Feb 15, 2021

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:

Upstream: Reported upstream. No feedback yet.

Component: calculus

Keywords: maxima, taylor series

Issue created by migration from https://trac.sagemath.org/ticket/31401

@frcl frcl mannequin added this to the sage-9.3 milestone Feb 15, 2021
@frcl frcl mannequin added c: calculus labels Feb 15, 2021
@DaveWitteMorris
Copy link
Member

comment:1

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).

@DaveWitteMorris
Copy link
Member

Changed keywords from none to maxima, taylor series

@frcl
Copy link
Mannequin Author

frcl mannequin commented Feb 16, 2021

comment:2

Replying to @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?

@DaveWitteMorris
Copy link
Member

comment:3

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.

@DaveWitteMorris
Copy link
Member

comment:4

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)))

@slel
Copy link
Member

slel commented Feb 16, 2021

Upstream: Reported upstream. No feedback yet.

@slel
Copy link
Member

slel commented Feb 16, 2021

comment:5

Upstream ticket in the Maxima bug tracker:

@slel

This comment has been minimized.

@mkoeppe
Copy link
Member

mkoeppe commented May 10, 2021

comment:6

Moving to 9.4, as 9.3 has been released.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 May 10, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Aug 22, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 May 3, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Sep 19, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants