Skip to content

Inverting symbolic matrix from NumPy complex array raises MACSYMA-QUIT error #42608

Description

@vivek41-glitch

Steps To Reproduce

import numpy as np

a = np.zeros((5, 5), dtype="complex")
np.fill_diagonal(a, 1)

x = var("x")

b = x * a
c = matrix(b)

c.inverse()

Expected Behavior

The inverse should be returned successfully.

[1/x   0    0    0    0]
[0   1/x    0    0    0]
[0     0  1/x    0    0]
[0     0    0  1/x    0]
[0     0    0    0  1/x]

Actual Behavior

Instead, Sage raises

RuntimeError: ECL says: THROW: The catch MACSYMA-QUIT is undefined.

During handling of the above exception, another exception occurred:

TypeError: ECL says: THROW: The catch MACSYMA-QUIT is undefined.
Full traceback
Paste the complete traceback here.

Additional Information

Working Alternative

Converting the NumPy array to a Sage matrix before symbolic multiplication avoids the problem.

import numpy as np

a = np.zeros((5, 5), dtype="complex")
np.fill_diagonal(a, 1)

x = var("x")

b = matrix(a)
c = x * b

c.inverse()

Output

[1/x   0    0    0    0]
[0   1/x    0    0    0]
[0     0  1/x    0    0]
[0     0    0  1/x    0]
[0     0    0    0  1/x]

Observations

The only difference is the order of operations.

Fails

matrix(x * numpy_array)

Works

x * matrix(numpy_array)

This suggests the failure occurs while converting a symbolic NumPy complex array into a Sage matrix.


Possible Cause

NumPy represents the imaginary unit using Python's 1j, whereas Sage represents it as I.

When a symbolic NumPy complex array is converted into a Sage matrix, Maxima appears unable to interpret the mixed representation correctly, eventually leading to the MACSYMA-QUIT error during symbolic inversion.


Environment

  • OS: Ubuntu 22.04
  • Sage Version: 9.2 – 10.10.beta6
  • Python: 3.x

Related Discussion

https://ask.sagemath.org/question/56850/issue-with-inversion-of-complex-symbolic-array-initialized

Activity

vivek41-glitch commented on Jul 31, 2026

@vivek41-glitch
ContributorAuthor

I'm working on this issue

added 2 commits that reference this issue on Aug 3, 2026
added a commit that references this issue on Aug 23, 2026
added a commit that references this issue on Aug 23, 2026
145405d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions