Mathics3 / mathics-core

An open-source Mathematica. This repository contains the Python modules for WL Built-in functions, variables, core primitives, e.g. Symbol, a parser to create Expressions, and an evaluator to execute them.
https://mathics.org
Other
782 stars 48 forks source link

Revival of crash during `FullSimplify` #1156

Closed aravindh-krishnamoorthy closed 1 week ago

aravindh-krishnamoorthy commented 2 weeks ago

Description

When using the following on GitHub built Mathics v7.0.0, a crash is observed.

(mathics) $ mathics

Mathics 7.0.0
on CPython 3.11.10 | packaged by conda-forge | (main, Oct 16 2024, 01:27:36) [GCC 13.3.0]
using SymPy 1.12.1, mpmath 1.3.0, numpy 2.1.3, cython Not installed

Copyright (C) 2011-2024 The Mathics Team.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions.
See the documentation for the full license.

Quit by evaluating Quit[] or by pressing CONTROL-D.

In[1]:= A = Array[a, {2,2}]; Eigenvalues[A.ConjugateTranspose[A]] // FullSimplify
Traceback (most recent call last):
More ```python File "~/.conda/envs/mathics/bin/mathics", line 33, in sys.exit(load_entry_point('Mathics3==7.0.0', 'console_scripts', 'mathics')()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/main.py", line 497, in main result = evaluation.evaluate(query, timeout=settings.TIMEOUT) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/evaluation.py", line 295, in evaluate result = run_with_timeout_and_stack(evaluate, timeout, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/evaluation.py", line 111, in run_with_timeout_and_stack return request() ^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/evaluation.py", line 268, in evaluate self.last_eval = query.evaluate(self) ^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/expression.py", line 506, in evaluate expr, reevaluate = expr.rewrite_apply_eval_step(evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/expression.py", line 1311, in rewrite_apply_eval_step result = rule.apply(new, evaluation, fully=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/rules.py", line 106, in apply self.pattern.match(yield_match, expression, {}, evaluation, fully=fully) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 466, in match self.head.match(yield_head, expression.get_head(), vars, evaluation) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 304, in match_symbol yield_func(vars, None) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 456, in yield_head self.get_pre_choices( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 647, in get_pre_choices yield_choice(vars) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 434, in yield_choice self.match_element( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 862, in match_element self.get_wrappings( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 691, in get_wrappings yield_func(sequence) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 851, in yield_wrapping element.match( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/patterns.py", line 1027, in match self.pattern.match(yield_func, expression, new_vars, evaluation) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/patterns.py", line 1350, in match yield_func(vars, None) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 848, in match_yield yield_func(new_vars, items_rest) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/rules.py", line 78, in yield_match new_expression = self.do_replace(expression, vars, options, evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/rules.py", line 269, in do_replace return self.function(evaluation=evaluation, **vars_noctx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/procedural.py", line 186, in eval result = expr.evaluate(evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/expression.py", line 506, in evaluate expr, reevaluate = expr.rewrite_apply_eval_step(evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/list.py", line 154, in rewrite_apply_eval_step new = new.evaluate_elements(evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/list.py", line 103, in evaluate_elements new_value = element.evaluate(evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/expression.py", line 506, in evaluate expr, reevaluate = expr.rewrite_apply_eval_step(evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/expression.py", line 1311, in rewrite_apply_eval_step result = rule.apply(new, evaluation, fully=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/rules.py", line 106, in apply self.pattern.match(yield_match, expression, {}, evaluation, fully=fully) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 466, in match self.head.match(yield_head, expression.get_head(), vars, evaluation) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 304, in match_symbol yield_func(vars, None) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 456, in yield_head self.get_pre_choices( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 647, in get_pre_choices yield_choice(vars) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 434, in yield_choice self.match_element( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 862, in match_element self.get_wrappings( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 680, in get_wrappings yield_func(items[0]) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 851, in yield_wrapping element.match( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/patterns.py", line 1027, in match self.pattern.match(yield_func, expression, new_vars, evaluation) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/patterns.py", line 1241, in match yield_func(vars, None) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 832, in match_yield self.match_element( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 862, in match_element self.get_wrappings( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 691, in get_wrappings yield_func(sequence) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 851, in yield_wrapping element.match( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/patterns.py", line 1661, in match yield_func(new_vars, None) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 848, in match_yield yield_func(new_vars, items_rest) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 825, in element_yield yield_func( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/rules.py", line 78, in yield_match new_expression = self.do_replace(expression, vars, options, evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/rules.py", line 267, in do_replace return self.function(evaluation=evaluation, options=options, **vars_noctx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/numbers/algebra.py", line 1602, in eval return self.do_apply(expr, evaluation, options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/numbers/algebra.py", line 1623, in do_apply elements = [ ^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/numbers/algebra.py", line 1624, in Expression(symbol_name, element).evaluate(evaluation) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/expression.py", line 506, in evaluate expr, reevaluate = expr.rewrite_apply_eval_step(evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/expression.py", line 1311, in rewrite_apply_eval_step result = rule.apply(new, evaluation, fully=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/rules.py", line 106, in apply self.pattern.match(yield_match, expression, {}, evaluation, fully=fully) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 466, in match self.head.match(yield_head, expression.get_head(), vars, evaluation) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 304, in match_symbol yield_func(vars, None) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 456, in yield_head self.get_pre_choices( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 647, in get_pre_choices yield_choice(vars) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 434, in yield_choice self.match_element( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 862, in match_element self.get_wrappings( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 680, in get_wrappings yield_func(items[0]) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 851, in yield_wrapping element.match( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/patterns.py", line 1027, in match self.pattern.match(yield_func, expression, new_vars, evaluation) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/patterns.py", line 1241, in match yield_func(vars, None) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 832, in match_yield self.match_element( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 862, in match_element self.get_wrappings( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 691, in get_wrappings yield_func(sequence) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 851, in yield_wrapping element.match( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/patterns.py", line 1661, in match yield_func(new_vars, None) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 848, in match_yield yield_func(new_vars, items_rest) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 825, in element_yield yield_func( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/rules.py", line 78, in yield_match new_expression = self.do_replace(expression, vars, options, evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/rules.py", line 267, in do_replace return self.function(evaluation=evaluation, options=options, **vars_noctx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/numbers/algebra.py", line 1602, in eval return self.do_apply(expr, evaluation, options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/numbers/algebra.py", line 1657, in do_apply sympy_result = sympy.simplify(sympy_expr, measure=complexity_function) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/simplify.py", line 615, in simplify expr = expr.replace( ^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/core/basic.py", line 1666, in replace rv = walk(self, rec_replace) ^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/core/basic.py", line 1641, in walk newargs = tuple([walk(a, F) for a in args]) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/core/basic.py", line 1641, in newargs = tuple([walk(a, F) for a in args]) ^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/core/basic.py", line 1651, in walk rv = F(rv) ^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/core/basic.py", line 1659, in rec_replace v = _value(expr, result) ^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/core/basic.py", line 1625, in _value = lambda expr, result: value(expr) ^^^^^^^^^^^ ```
  File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/simplify.py", line 623, in <lambda>
    lambda x: x.func(*[simplify(i, **kwargs) for i in x.args]),
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/convert/sympy.py", line 163, in __new__
    return SympyExpression(self.expr)
                           ^^^^^^^^^
AttributeError: 'SympyExpression' object has no attribute 'expr'
(mathics) $

How to Reproduce

$ mathics -e 'A = Array[a, {2,2}]; Eigenvalues[A.ConjugateTranspose[A]] // FullSimplify'

Output Given

Crash, please see above.

Expected behavior

Simplified expressions for eigenvalues; likely the result obtained in the Workarounds section below.

Your Environment

Mathics 7.0.0 on CPython 3.11.10 | packaged by conda-forge | (main, Oct 16 2024, 01:27:36) [GCC 13.3.0] using SymPy 1.12.1, mpmath 1.3.0, numpy 2.1.3, cython Not installed

OS: Windows 11 WSL

Workarounds

By changing the line (of v7.0.0 code) from: https://github.com/Mathics3/mathics-core/blob/6a0b3f04484994168cec5582a83434535d8d1d14/mathics/builtin/numbers/algebra.py#L1656

to

+        try:
-        sympy_result = sympy.simplify(sympy_expr, measure=complexity_function)
+            sympy_result = sympy.simplify(sympy_expr, measure=complexity_function)
+        except Exceptions:
+            return expr

analogous to #238, the following output is obtained:

{-Sqrt[(a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]]) ^ 2 - 4 a[1, 1] a[2, 2] Conjugate[a[1, 1]] Conjugate[a[2, 2]] - 4 a[1, 2] a[2, 1] Conjugate[a[1, 2]] Conjugate[a[2, 1]] + 4 a[1, 1] a[2, 2] Conjugate[a[1, 2]] Conjugate[a[2, 1]] + 4 a[1, 2] a[2, 1] Conjugate[a[1, 1]] Conjugate[a[2, 2]]] / 2 + a[1, 1] Conjugate[a[1, 1]] / 2 + a[1, 2] Conjugate[a[1, 2]] / 2 + a[2, 1] Conjugate[a[2, 1]] / 2 + a[2, 2] Conjugate[a[2, 2]] / 2, Sqrt[(a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]]) ^ 2 - 4 a[1, 1] a[2, 2] Conjugate[a[1, 1]] Conjugate[a[2, 2]] - 4 a[1, 2] a[2, 1] Conjugate[a[1, 2]] Conjugate[a[2, 1]] + 4 a[1, 1] a[2, 2] Conjugate[a[1, 2]] Conjugate[a[2, 1]] + 4 a[1, 2] a[2, 1] Conjugate[a[1, 1]] Conjugate[a[2, 2]]] / 2 + a[1, 1] Conjugate[a[1, 1]] / 2 + a[1, 2] Conjugate[a[1, 2]] / 2 + a[2, 1] Conjugate[a[2, 1]] / 2 + a[2, 2] Conjugate[a[2, 2]] / 2}

which is likely correct. Note that the above code is restructured a bit (and modified) in the latest commit as of now:

https://github.com/Mathics3/mathics-core/blob/c5a922709e0df1bf37ecff0b7bf88bc9b16dd492/mathics/eval/numbers/algebra/simplify.py#L85

Priority

Programmable workaround exists.

Additional context

In case the workaround is fine, I can submit a PR. Otherwise, I can also help with a good fix under instructions as I'm new to Mathics.

aravindh-krishnamoorthy commented 2 weeks ago

Unfortunately, another instance, this time stemming from mathics/builtin/numbers/linalg.py:

$  mathics -e 'A = Array[a, {3,3}]; Eigenvalues[A.ConjugateTranspose[A]]'

[...]

File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/numbers/linalg.py", line 171, in eval
    eigenvalues = list(sympy_matrix.eigenvals().items())
                       ^^^^^^^^^^^^^^^^^^^^^^^^

[...]

File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/convert/sympy.py", line 163, in __new__
return SympyExpression(self.expr)
^^^^^^^^^
AttributeError: 'SympyExpression' object has no attribute 'expr'
Full traceback ``` Traceback (most recent call last): File "~/.conda/envs/mathics/bin/mathics", line 33, in sys.exit(load_entry_point('Mathics3==7.0.0', 'console_scripts', 'mathics')()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/main.py", line 497, in main result = evaluation.evaluate(query, timeout=settings.TIMEOUT) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/evaluation.py", line 295, in evaluate result = run_with_timeout_and_stack(evaluate, timeout, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/evaluation.py", line 111, in run_with_timeout_and_stack return request() ^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/evaluation.py", line 268, in evaluate self.last_eval = query.evaluate(self) ^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/expression.py", line 506, in evaluate expr, reevaluate = expr.rewrite_apply_eval_step(evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/expression.py", line 1311, in rewrite_apply_eval_step result = rule.apply(new, evaluation, fully=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/rules.py", line 106, in apply self.pattern.match(yield_match, expression, {}, evaluation, fully=fully) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 466, in match self.head.match(yield_head, expression.get_head(), vars, evaluation) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 304, in match_symbol yield_func(vars, None) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 456, in yield_head self.get_pre_choices( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 647, in get_pre_choices yield_choice(vars) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 434, in yield_choice self.match_element( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 862, in match_element self.get_wrappings( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 680, in get_wrappings yield_func(items[0]) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 851, in yield_wrapping element.match( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/patterns.py", line 1027, in match self.pattern.match(yield_func, expression, new_vars, evaluation) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/patterns.py", line 1303, in match yield_func(vars, None) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 848, in match_yield yield_func(new_vars, items_rest) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/rules.py", line 78, in yield_match new_expression = self.do_replace(expression, vars, options, evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/rules.py", line 269, in do_replace return self.function(evaluation=evaluation, **vars_noctx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/atomic/strings.py", line 979, in eval result = query.evaluate(evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/expression.py", line 506, in evaluate expr, reevaluate = expr.rewrite_apply_eval_step(evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/expression.py", line 1139, in rewrite_apply_eval_step eval_elements() File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/expression.py", line 1125, in eval_elements eval_range(range(len(elements))) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/expression.py", line 1093, in eval_range new_value = element.evaluate(evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/expression.py", line 506, in evaluate expr, reevaluate = expr.rewrite_apply_eval_step(evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/expression.py", line 1311, in rewrite_apply_eval_step result = rule.apply(new, evaluation, fully=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/rules.py", line 106, in apply self.pattern.match(yield_match, expression, {}, evaluation, fully=fully) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 466, in match self.head.match(yield_head, expression.get_head(), vars, evaluation) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 304, in match_symbol yield_func(vars, None) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 456, in yield_head self.get_pre_choices( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 647, in get_pre_choices yield_choice(vars) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 434, in yield_choice self.match_element( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 862, in match_element self.get_wrappings( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 680, in get_wrappings yield_func(items[0]) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 851, in yield_wrapping element.match( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/patterns.py", line 1027, in match self.pattern.match(yield_func, expression, new_vars, evaluation) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/patterns.py", line 1241, in match yield_func(vars, None) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 832, in match_yield self.match_element( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 862, in match_element self.get_wrappings( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 691, in get_wrappings yield_func(sequence) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 851, in yield_wrapping element.match( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/patterns.py", line 1661, in match yield_func(new_vars, None) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 848, in match_yield yield_func(new_vars, items_rest) File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/pattern.py", line 825, in element_yield yield_func( File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/rules.py", line 78, in yield_match new_expression = self.do_replace(expression, vars, options, evaluation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/rules.py", line 267, in do_replace return self.function(evaluation=evaluation, options=options, **vars_noctx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/numbers/linalg.py", line 171, in eval eigenvalues = list(sympy_matrix.eigenvals().items()) ^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/matrices/matrices.py", line 376, in eigenvals return _eigenvals(self, error_when_incomplete=error_when_incomplete, **flags) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/matrices/eigen.py", line 173, in _eigenvals return _eigenvals_dict( ^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/matrices/eigen.py", line 252, in _eigenvals_dict charpoly = block.charpoly() ^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/matrices/matrices.py", line 119, in charpoly return _charpoly(self, x=x, simplify=simplify) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/matrices/determinant.py", line 414, in _charpoly return PurePoly([simplify(a) for a in berk_vector], x) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/matrices/determinant.py", line 414, in return PurePoly([simplify(a) for a in berk_vector], x) ^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/matrices/utilities.py", line 72, in _simplify return simplify(expr) ^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/simplify.py", line 725, in simplify short = shorter(powsimp(expr, combine='exp', deep=True), powsimp(expr), expr) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 117, in powsimp expr = expr.func(*[recurse(w) for w in expr.args]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 117, in expr = expr.func(*[recurse(w) for w in expr.args]) ^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 108, in recurse return powsimp(arg, _deep, _combine, _force, _measure) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 117, in powsimp expr = expr.func(*[recurse(w) for w in expr.args]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 117, in expr = expr.func(*[recurse(w) for w in expr.args]) ^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 108, in recurse return powsimp(arg, _deep, _combine, _force, _measure) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 117, in powsimp expr = expr.func(*[recurse(w) for w in expr.args]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 117, in expr = expr.func(*[recurse(w) for w in expr.args]) ^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 108, in recurse return powsimp(arg, _deep, _combine, _force, _measure) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 117, in powsimp expr = expr.func(*[recurse(w) for w in expr.args]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 117, in expr = expr.func(*[recurse(w) for w in expr.args]) ^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 108, in recurse return powsimp(arg, _deep, _combine, _force, _measure) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 117, in powsimp expr = expr.func(*[recurse(w) for w in expr.args]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 117, in expr = expr.func(*[recurse(w) for w in expr.args]) ^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 108, in recurse return powsimp(arg, _deep, _combine, _force, _measure) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 117, in powsimp expr = expr.func(*[recurse(w) for w in expr.args]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 117, in expr = expr.func(*[recurse(w) for w in expr.args]) ^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 108, in recurse return powsimp(arg, _deep, _combine, _force, _measure) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 117, in powsimp expr = expr.func(*[recurse(w) for w in expr.args]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/convert/sympy.py", line 163, in __new__ return SympyExpression(self.expr) ^^^^^^^^^ AttributeError: 'SympyExpression' object has no attribute 'expr' ```

Seems like this problem needs a good, long-term solution.

rocky commented 2 weeks ago

$ mathics -e 'A = Array[a, {2,2}]; Eigenvalues[A.ConjugateTranspose[A]] // FullSimplify'

This does not crash in the current master branch:

mathics -e 'A = Array[a, {2,2}]; Eigenvalues[A.ConjugateTranspose[A]] // FullSimplify'
{-Sqrt[(a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]]) ^ 2 - 4 a[1, 1] a[2, 2] Conjugate[a[1, 1]] Conjugate[a[2, 2]] - 4 a[1, 2] a[2, 1] Conjugate[a[1, 2]] Conjugate[a[2, 1]] + 4 a[1, 1] a[2, 2] Conjugate[a[1, 2]] Conjugate[a[2, 1]] + 4 a[1, 2] a[2, 1] Conjugate[a[1, 1]] Conjugate[a[2, 2]]] / 2 + a[1, 1] Conjugate[a[1, 1]] / 2 + a[1, 2] Conjugate[a[1, 2]] / 2 + a[2, 1] Conjugate[a[2, 1]] / 2 + a[2, 2] Conjugate[a[2, 2]] / 2, Sqrt[(a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]]) ^ 2 - 4 a[1, 1] a[2, 2] Conjugate[a[1, 1]] Conjugate[a[2, 2]] - 4 a[1, 2] a[2, 1] Conjugate[a[1, 2]] Conjugate[a[2, 1]] + 4 a[1, 1] a[2, 2] Conjugate[a[1, 2]] Conjugate[a[2, 1]] + 4 a[1, 2] a[2, 1] Conjugate[a[1, 1]] Conjugate[a[2, 2]]] / 2 + a[1, 1] Conjugate[a[1, 1]] / 2 + a[1, 2] Conjugate[a[1, 2]] / 2 + a[2, 1] Conjugate[a[2, 1]] / 2 + a[2, 2] Conjugate[a[2, 2]] / 2}

Unfortunately, another instance, this time stemming from mathics/builtin/numbers/linalg.py:

$  mathics -e 'A = Array[a, {3,3}]; Eigenvalues[A.ConjugateTranspose[A]]'

[...]

File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/builtin/numbers/linalg.py", line 171, in eval
    eigenvalues = list(sympy_matrix.eigenvals().items())
                       ^^^^^^^^^^^^^^^^^^^^^^^^

[...]

File "~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/convert/sympy.py", line 163, in __new__
return SympyExpression(self.expr)
^^^^^^^^^
AttributeError: 'SympyExpression' object has no attribute 'expr'

Full traceback

I am not seeing this crash in the current master on github:

mathics -e 'A = Array[a, {3,3}]; Eigenvalues[A.ConjugateTranspose[A]]'
{-((-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 3 + Sqrt[(2 (-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 3 + ((a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) (-a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]]) + (-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (-a[1, 1] Conjugate[a[2, 1]] - a[1, 2] Conjugate[a[2, 2]] - a[1, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[1, 1]] - a[2, 2] Conjugate[a[1, 2]] - a[2, 3] Conjugate[a[1, 3]]) + (-a[1, 1] Conjugate[a[3, 1]] - a[1, 2] Conjugate[a[3, 2]] - a[1, 3] Conjugate[a[3, 3]]) (-a[3, 1] Conjugate[a[1, 1]] - a[3, 2] Conjugate[a[1, 2]] - a[3, 3] Conjugate[a[1, 3]]) + (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]]) (-a[3, 1] Conjugate[a[2, 1]] - a[3, 2] Conjugate[a[2, 2]] - a[3, 3] Conjugate[a[2, 3]])) (-9 a[1, 1] Conjugate[a[1, 1]] - 9 a[1, 2] Conjugate[a[1, 2]] - 9 a[1, 3] Conjugate[a[1, 3]] - 9 a[2, 1] Conjugate[a[2, 1]] - 9 a[2, 2] Conjugate[a[2, 2]] - 9 a[2, 3] Conjugate[a[2, 3]] - 9 a[3, 1] Conjugate[a[3, 1]] - 9 a[3, 2] Conjugate[a[3, 2]] - 9 a[3, 3] Conjugate[a[3, 3]]) - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) - 27 ((a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) + 27 ((a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) ^ 2 - 4 ((-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 2 - 3 (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) - 3 (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + 3 (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + 3 (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) + 3 (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]])) ^ 3] / 2 - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) / 2 - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) / 2 - 27 ((a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) / 2 - ((a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (-a[1, 1] Conjugate[a[2, 1]] - a[1, 2] Conjugate[a[2, 2]] - a[1, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (-a[1, 1] Conjugate[a[3, 1]] - a[1, 2] Conjugate[a[3, 2]] - a[1, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (-9 a[1, 1] Conjugate[a[1, 1]] - 9 a[1, 2] Conjugate[a[1, 2]] - 9 a[1, 3] Conjugate[a[1, 3]] - 9 a[2, 1] Conjugate[a[2, 1]] - 9 a[2, 2] Conjugate[a[2, 2]] - 9 a[2, 3] Conjugate[a[2, 3]] - 9 a[3, 1] Conjugate[a[3, 1]] - 9 a[3, 2] Conjugate[a[3, 2]] - 9 a[3, 3] Conjugate[a[3, 3]]) / 2 + 27 ((a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) / 2) ^ (1 / 3) / 3 - ((-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 2 - 3 (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) - 3 (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + 3 (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + 3 (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) + 3 (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]])) / (3 ((-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 3 + Sqrt[(2 (-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 3 + ((a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) (-a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]]) + (-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (-a[1, 1] Conjugate[a[2, 1]] - a[1, 2] Conjugate[a[2, 2]] - a[1, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[1, 1]] - a[2, 2] Conjugate[a[1, 2]] - a[2, 3] Conjugate[a[1, 3]]) + (-a[1, 1] Conjugate[a[3, 1]] - a[1, 2] Conjugate[a[3, 2]] - a[1, 3] Conjugate[a[3, 3]]) (-a[3, 1] Conjugate[a[1, 1]] - a[3, 2] Conjugate[a[1, 2]] - a[3, 3] Conjugate[a[1, 3]]) + (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]]) (-a[3, 1] Conjugate[a[2, 1]] - a[3, 2] Conjugate[a[2, 2]] - a[3, 3] Conjugate[a[2, 3]])) (-9 a[1, 1] Conjugate[a[1, 1]] - 9 a[1, 2] Conjugate[a[1, 2]] - 9 a[1, 3] Conjugate[a[1, 3]] - 9 a[2, 1] Conjugate[a[2, 1]] - 9 a[2, 2] Conjugate[a[2, 2]] - 9 a[2, 3] Conjugate[a[2, 3]] - 9 a[3, 1] Conjugate[a[3, 1]] - 9 a[3, 2] Conjugate[a[3, 2]] - 9 a[3, 3] Conjugate[a[3, 3]]) - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) - 27 ((a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) + 27 ((a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) ^ 2 - 4 ((-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 2 - 3 (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) - 3 (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + 3 (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + 3 (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) + 3 (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]])) ^ 3] / 2 - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) / 2 - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) / 2 - 27 ((a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) / 2 - ((a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (-a[1, 1] Conjugate[a[2, 1]] - a[1, 2] Conjugate[a[2, 2]] - a[1, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (-a[1, 1] Conjugate[a[3, 1]] - a[1, 2] Conjugate[a[3, 2]] - a[1, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (-9 a[1, 1] Conjugate[a[1, 1]] - 9 a[1, 2] Conjugate[a[1, 2]] - 9 a[1, 3] Conjugate[a[1, 3]] - 9 a[2, 1] Conjugate[a[2, 1]] - 9 a[2, 2] Conjugate[a[2, 2]] - 9 a[2, 3] Conjugate[a[2, 3]] - 9 a[3, 1] Conjugate[a[3, 1]] - 9 a[3, 2] Conjugate[a[3, 2]] - 9 a[3, 3] Conjugate[a[3, 3]]) / 2 + 27 ((a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) / 2) ^ (1 / 3)) + a[1, 1] Conjugate[a[1, 1]] / 3 + a[1, 2] Conjugate[a[1, 2]] / 3 + a[1, 3] Conjugate[a[1, 3]] / 3 + a[2, 1] Conjugate[a[2, 1]] / 3 + a[2, 2] Conjugate[a[2, 2]] / 3 + a[2, 3] Conjugate[a[2, 3]] / 3 + a[3, 1] Conjugate[a[3, 1]] / 3 + a[3, 2] Conjugate[a[3, 2]] / 3 + a[3, 3] Conjugate[a[3, 3]] / 3, -(-1 / 2 - I / 2 Sqrt[3]) ((-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 3 + Sqrt[(2 (-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 3 + ((a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) (-a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]]) + (-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (-a[1, 1] Conjugate[a[2, 1]] - a[1, 2] Conjugate[a[2, 2]] - a[1, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[1, 1]] - a[2, 2] Conjugate[a[1, 2]] - a[2, 3] Conjugate[a[1, 3]]) + (-a[1, 1] Conjugate[a[3, 1]] - a[1, 2] Conjugate[a[3, 2]] - a[1, 3] Conjugate[a[3, 3]]) (-a[3, 1] Conjugate[a[1, 1]] - a[3, 2] Conjugate[a[1, 2]] - a[3, 3] Conjugate[a[1, 3]]) + (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]]) (-a[3, 1] Conjugate[a[2, 1]] - a[3, 2] Conjugate[a[2, 2]] - a[3, 3] Conjugate[a[2, 3]])) (-9 a[1, 1] Conjugate[a[1, 1]] - 9 a[1, 2] Conjugate[a[1, 2]] - 9 a[1, 3] Conjugate[a[1, 3]] - 9 a[2, 1] Conjugate[a[2, 1]] - 9 a[2, 2] Conjugate[a[2, 2]] - 9 a[2, 3] Conjugate[a[2, 3]] - 9 a[3, 1] Conjugate[a[3, 1]] - 9 a[3, 2] Conjugate[a[3, 2]] - 9 a[3, 3] Conjugate[a[3, 3]]) - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) - 27 ((a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) + 27 ((a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) ^ 2 - 4 ((-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 2 - 3 (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) - 3 (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + 3 (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + 3 (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) + 3 (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]])) ^ 3] / 2 - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) / 2 - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) / 2 - 27 ((a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) / 2 - ((a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (-a[1, 1] Conjugate[a[2, 1]] - a[1, 2] Conjugate[a[2, 2]] - a[1, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (-a[1, 1] Conjugate[a[3, 1]] - a[1, 2] Conjugate[a[3, 2]] - a[1, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (-9 a[1, 1] Conjugate[a[1, 1]] - 9 a[1, 2] Conjugate[a[1, 2]] - 9 a[1, 3] Conjugate[a[1, 3]] - 9 a[2, 1] Conjugate[a[2, 1]] - 9 a[2, 2] Conjugate[a[2, 2]] - 9 a[2, 3] Conjugate[a[2, 3]] - 9 a[3, 1] Conjugate[a[3, 1]] - 9 a[3, 2] Conjugate[a[3, 2]] - 9 a[3, 3] Conjugate[a[3, 3]]) / 2 + 27 ((a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) / 2) ^ (1 / 3) / 3 + a[1, 1] Conjugate[a[1, 1]] / 3 + a[1, 2] Conjugate[a[1, 2]] / 3 + a[1, 3] Conjugate[a[1, 3]] / 3 + a[2, 1] Conjugate[a[2, 1]] / 3 + a[2, 2] Conjugate[a[2, 2]] / 3 + a[2, 3] Conjugate[a[2, 3]] / 3 + a[3, 1] Conjugate[a[3, 1]] / 3 + a[3, 2] Conjugate[a[3, 2]] / 3 + a[3, 3] Conjugate[a[3, 3]] / 3 - ((-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 2 - 3 (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) - 3 (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + 3 (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + 3 (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) + 3 (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]])) / (3 (-1 / 2 - I / 2 Sqrt[3]) ((-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 3 + Sqrt[(2 (-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 3 + ((a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) (-a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]]) + (-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (-a[1, 1] Conjugate[a[2, 1]] - a[1, 2] Conjugate[a[2, 2]] - a[1, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[1, 1]] - a[2, 2] Conjugate[a[1, 2]] - a[2, 3] Conjugate[a[1, 3]]) + (-a[1, 1] Conjugate[a[3, 1]] - a[1, 2] Conjugate[a[3, 2]] - a[1, 3] Conjugate[a[3, 3]]) (-a[3, 1] Conjugate[a[1, 1]] - a[3, 2] Conjugate[a[1, 2]] - a[3, 3] Conjugate[a[1, 3]]) + (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]]) (-a[3, 1] Conjugate[a[2, 1]] - a[3, 2] Conjugate[a[2, 2]] - a[3, 3] Conjugate[a[2, 3]])) (-9 a[1, 1] Conjugate[a[1, 1]] - 9 a[1, 2] Conjugate[a[1, 2]] - 9 a[1, 3] Conjugate[a[1, 3]] - 9 a[2, 1] Conjugate[a[2, 1]] - 9 a[2, 2] Conjugate[a[2, 2]] - 9 a[2, 3] Conjugate[a[2, 3]] - 9 a[3, 1] Conjugate[a[3, 1]] - 9 a[3, 2] Conjugate[a[3, 2]] - 9 a[3, 3] Conjugate[a[3, 3]]) - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) - 27 ((a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) + 27 ((a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) ^ 2 - 4 ((-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 2 - 3 (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) - 3 (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + 3 (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + 3 (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) + 3 (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]])) ^ 3] / 2 - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) / 2 - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) / 2 - 27 ((a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) / 2 - ((a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (-a[1, 1] Conjugate[a[2, 1]] - a[1, 2] Conjugate[a[2, 2]] - a[1, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (-a[1, 1] Conjugate[a[3, 1]] - a[1, 2] Conjugate[a[3, 2]] - a[1, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (-9 a[1, 1] Conjugate[a[1, 1]] - 9 a[1, 2] Conjugate[a[1, 2]] - 9 a[1, 3] Conjugate[a[1, 3]] - 9 a[2, 1] Conjugate[a[2, 1]] - 9 a[2, 2] Conjugate[a[2, 2]] - 9 a[2, 3] Conjugate[a[2, 3]] - 9 a[3, 1] Conjugate[a[3, 1]] - 9 a[3, 2] Conjugate[a[3, 2]] - 9 a[3, 3] Conjugate[a[3, 3]]) / 2 + 27 ((a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) / 2) ^ (1 / 3)), -(-1 / 2 + I / 2 Sqrt[3]) ((-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 3 + Sqrt[(2 (-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 3 + ((a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) (-a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]]) + (-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (-a[1, 1] Conjugate[a[2, 1]] - a[1, 2] Conjugate[a[2, 2]] - a[1, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[1, 1]] - a[2, 2] Conjugate[a[1, 2]] - a[2, 3] Conjugate[a[1, 3]]) + (-a[1, 1] Conjugate[a[3, 1]] - a[1, 2] Conjugate[a[3, 2]] - a[1, 3] Conjugate[a[3, 3]]) (-a[3, 1] Conjugate[a[1, 1]] - a[3, 2] Conjugate[a[1, 2]] - a[3, 3] Conjugate[a[1, 3]]) + (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]]) (-a[3, 1] Conjugate[a[2, 1]] - a[3, 2] Conjugate[a[2, 2]] - a[3, 3] Conjugate[a[2, 3]])) (-9 a[1, 1] Conjugate[a[1, 1]] - 9 a[1, 2] Conjugate[a[1, 2]] - 9 a[1, 3] Conjugate[a[1, 3]] - 9 a[2, 1] Conjugate[a[2, 1]] - 9 a[2, 2] Conjugate[a[2, 2]] - 9 a[2, 3] Conjugate[a[2, 3]] - 9 a[3, 1] Conjugate[a[3, 1]] - 9 a[3, 2] Conjugate[a[3, 2]] - 9 a[3, 3] Conjugate[a[3, 3]]) - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) - 27 ((a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) + 27 ((a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) ^ 2 - 4 ((-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 2 - 3 (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) - 3 (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + 3 (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + 3 (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) + 3 (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]])) ^ 3] / 2 - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) / 2 - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) / 2 - 27 ((a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) / 2 - ((a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (-a[1, 1] Conjugate[a[2, 1]] - a[1, 2] Conjugate[a[2, 2]] - a[1, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (-a[1, 1] Conjugate[a[3, 1]] - a[1, 2] Conjugate[a[3, 2]] - a[1, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (-9 a[1, 1] Conjugate[a[1, 1]] - 9 a[1, 2] Conjugate[a[1, 2]] - 9 a[1, 3] Conjugate[a[1, 3]] - 9 a[2, 1] Conjugate[a[2, 1]] - 9 a[2, 2] Conjugate[a[2, 2]] - 9 a[2, 3] Conjugate[a[2, 3]] - 9 a[3, 1] Conjugate[a[3, 1]] - 9 a[3, 2] Conjugate[a[3, 2]] - 9 a[3, 3] Conjugate[a[3, 3]]) / 2 + 27 ((a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) / 2) ^ (1 / 3) / 3 + a[1, 1] Conjugate[a[1, 1]] / 3 + a[1, 2] Conjugate[a[1, 2]] / 3 + a[1, 3] Conjugate[a[1, 3]] / 3 + a[2, 1] Conjugate[a[2, 1]] / 3 + a[2, 2] Conjugate[a[2, 2]] / 3 + a[2, 3] Conjugate[a[2, 3]] / 3 + a[3, 1] Conjugate[a[3, 1]] / 3 + a[3, 2] Conjugate[a[3, 2]] / 3 + a[3, 3] Conjugate[a[3, 3]] / 3 - ((-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 2 - 3 (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) - 3 (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + 3 (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + 3 (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) + 3 (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]])) / (3 (-1 / 2 + I / 2 Sqrt[3]) ((-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 3 + Sqrt[(2 (-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 3 + ((a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) (-a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]]) + (-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (-a[1, 1] Conjugate[a[2, 1]] - a[1, 2] Conjugate[a[2, 2]] - a[1, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[1, 1]] - a[2, 2] Conjugate[a[1, 2]] - a[2, 3] Conjugate[a[1, 3]]) + (-a[1, 1] Conjugate[a[3, 1]] - a[1, 2] Conjugate[a[3, 2]] - a[1, 3] Conjugate[a[3, 3]]) (-a[3, 1] Conjugate[a[1, 1]] - a[3, 2] Conjugate[a[1, 2]] - a[3, 3] Conjugate[a[1, 3]]) + (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]]) (-a[3, 1] Conjugate[a[2, 1]] - a[3, 2] Conjugate[a[2, 2]] - a[3, 3] Conjugate[a[2, 3]])) (-9 a[1, 1] Conjugate[a[1, 1]] - 9 a[1, 2] Conjugate[a[1, 2]] - 9 a[1, 3] Conjugate[a[1, 3]] - 9 a[2, 1] Conjugate[a[2, 1]] - 9 a[2, 2] Conjugate[a[2, 2]] - 9 a[2, 3] Conjugate[a[2, 3]] - 9 a[3, 1] Conjugate[a[3, 1]] - 9 a[3, 2] Conjugate[a[3, 2]] - 9 a[3, 3] Conjugate[a[3, 3]]) - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) - 27 ((a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) + 27 ((a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) ^ 2 - 4 ((-a[1, 1] Conjugate[a[1, 1]] - a[1, 2] Conjugate[a[1, 2]] - a[1, 3] Conjugate[a[1, 3]] - a[2, 1] Conjugate[a[2, 1]] - a[2, 2] Conjugate[a[2, 2]] - a[2, 3] Conjugate[a[2, 3]] - a[3, 1] Conjugate[a[3, 1]] - a[3, 2] Conjugate[a[3, 2]] - a[3, 3] Conjugate[a[3, 3]]) ^ 2 - 3 (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) - 3 (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + 3 (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + 3 (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) + 3 (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]])) ^ 3] / 2 - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[3, 1]] + a[2, 2] Conjugate[a[3, 2]] + a[2, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) / 2 - 27 ((a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) / 2 - 27 ((a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) / 2 - ((a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + a[1, 3] Conjugate[a[1, 3]]) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) (-a[1, 1] Conjugate[a[2, 1]] - a[1, 2] Conjugate[a[2, 2]] - a[1, 3] Conjugate[a[2, 3]]) + (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]]) (a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]]) (-a[1, 1] Conjugate[a[3, 1]] - a[1, 2] Conjugate[a[3, 2]] - a[1, 3] Conjugate[a[3, 3]]) + (a[3, 1] Conjugate[a[2, 1]] + a[3, 2] Conjugate[a[2, 2]] + a[3, 3] Conjugate[a[2, 3]]) (-a[2, 1] Conjugate[a[3, 1]] - a[2, 2] Conjugate[a[3, 2]] - a[2, 3] Conjugate[a[3, 3]])) (-9 a[1, 1] Conjugate[a[1, 1]] - 9 a[1, 2] Conjugate[a[1, 2]] - 9 a[1, 3] Conjugate[a[1, 3]] - 9 a[2, 1] Conjugate[a[2, 1]] - 9 a[2, 2] Conjugate[a[2, 2]] - 9 a[2, 3] Conjugate[a[2, 3]] - 9 a[3, 1] Conjugate[a[3, 1]] - 9 a[3, 2] Conjugate[a[3, 2]] - 9 a[3, 3] Conjugate[a[3, 3]]) / 2 + 27 ((a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]] + a[1, 3] Conjugate[a[2, 3]]) (a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]] + a[2, 3] Conjugate[a[1, 3]]) + (a[1, 1] Conjugate[a[3, 1]] + a[1, 2] Conjugate[a[3, 2]] + a[1, 3] Conjugate[a[3, 3]]) (a[3, 1] Conjugate[a[1, 1]] + a[3, 2] Conjugate[a[1, 2]] + a[3, 3] Conjugate[a[1, 3]])) (a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]] + a[2, 3] Conjugate[a[2, 3]] + a[3, 1] Conjugate[a[3, 1]] + a[3, 2] Conjugate[a[3, 2]] + a[3, 3] Conjugate[a[3, 3]]) / 2) ^ (1 / 3))}

Seems like this problem needs a good, long-term solution.

I don't have a good high-level understanding of what the problem is. Saying this example crashes or that example crashes, doesn't elucidate what long-term solution is needed.

rocky commented 2 weeks ago

Otherwise, I can also help with a good fix under instructions as I'm new to Mathics.

Help is always appreciated.

I think the thing most needed right now a good high-level description of what the problem is.

Is the problem in how things get translated to SymPy? If so, is this a fundamental mismatch?

The Mathics-specific TraceBuiltins[] can be used to see what Sympy instructions are run:

In[1]:= TraceEvaluation[Eigenvalues[{{1, 1, 0}, {1, 0, 1}, {0, 1, 1}}]]
    Evaluating: System`Eigenvalues[{{1,1,0},{1,0,1},{0,1,1}}]
      Evaluating: System`Eigenvalues
      Evaluating: System`sympy
    -> {2,-1,1}
Out[1]= {2, -1, 1}

There is a newer and even better way to get SymPy call information using an experimental debugger I am working on, but this probably is not yet ready for general use.

aravindh-krishnamoorthy commented 2 weeks ago

Seems like this problem needs a good, long-term solution.

I don't have a good high-level understanding of what the problem is. Saying this example crashes or that example crashes, doesn't elucidate what long-term solution is needed.

Please don't take this issue and the above statement personally. I only meant that the proposed workaround above may not be sufficient. You're doing a great job and this is a great software that I've started using for my day-to-day work as a replacement for Mathematica, and that says something about the software and its stability already.

I think the thing most needed right now a good high-level description of what the problem is.

Is the problem in how things get translated to SymPy? If so, is this a fundamental mismatch?

I tried to use pdb and this is what I have so far:

(mathics) $ mathics -e 'A = Array[a, {3,3}]; Eigenvalues[A.ConjugateTranspose[A]]'
--Return--
> ~/.conda/envs/mathics/lib/python3.11/site-packages/Mathics3-7.0.0-py3.11.egg/mathics/core/convert/sympy.py(166)__new__()->None
-> breakpoint()
(Pdb) list
161
162                 def __new__(cls, *args):
163                     try:
164                         return SympyExpression(self.expr)
165                     except Exception:
166  ->                     breakpoint()
167                     # return SympyExpression(expression.Expression(self.expr.head,
168                     # *(from_sympy(arg) for arg in args[1:])))
169
170             return SympyExpressionFunc
171
(Pdb) self
SympyExpression(_Mathics_User_Global`a, 2, 1)
(Pdb) isinstance(self, BasicSympy)
True
(Pdb) isinstance(self, Expression)
False
(Pdb) self.expr
*** AttributeError: 'SympyExpression' object has no attribute 'expr'
(Pdb)

It seems that the call

File "~/.conda/envs/mathics/lib/python3.11/site-packages/sympy/simplify/powsimp.py", line 117, in powsimp
expr = expr.func(*[recurse(w) for w in expr.args])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

is resulting in a func call on a non-Expression object. I'm new to Mathics; I'll try to take a closer look and get a feel for the code as well.

rocky commented 2 weeks ago

Please don't take this issue and the above statement personally.

Honestly, I don't

Please try the current master branch. It might not have a problem you are encountering.

The 3x3 array example runs slowly, but that is a different problem.

aravindh-krishnamoorthy commented 2 weeks ago

Please try the current master branch. It might not have a problem you are encountering.

Hello rocky, does it make sense to find the root cause of this problem? If this bug is already known then I would just switch to current master. Otherwise, I can spend some time to find the root cause... to the best of my abilities.

mmatera commented 2 weeks ago

@aravindh-krishnamoorthy, we are aware that Simplify is still buggy and would require work to make it work. It would be awesome if you were interested in working on this issue. In any case, I agree with @rocky that a first step would be to collect some test cases that fails, and try to understand what is the generality behind the failure, before trying to propose a patch. In any case, adding the try-except block around the conversion could also be a good idea.

mmatera commented 2 weeks ago

@rocky, I got the crash on my laptop, even using the master branch. Maybe this is related to a change in Sympy. In any case, it deserves research.

Mathics 7.0.1dev0 on CPython 3.8.19 | packaged by conda-forge | (default, Mar 20 2024, 12:47:35) using SymPy 1.12, mpmath 1.3.0, numpy 1.24.4, cython Not installed

mmatera commented 2 weeks ago

Indeed, I can confirm that is an issue related to Sympy 1.12, and is fixed by using Sympy 1.13

rocky commented 2 weeks ago

Indeed, I can confirm that is an issue related to Sympy 1.12, and is fixed by using Sympy 1.13

Then the simplest fix would be to require SymPy 1.13 or greater. We support back to Python 3.8 and SymPy 1.13 is supported on Python 3.8.

Thoughts?

aravindh-krishnamoorthy commented 2 weeks ago

I think I could isolate the fix to sympy commit https://github.com/sympy/sympy/commit/a545639cc08df73296db678e35e3daba713a7f6c.

Strangely conda says that my sympy version is sympy 1.12.1 pypyh2585a3b_103 conda-forge, but it does not have this fix (!) On the other hand, the GitHub tag https://github.com/sympy/sympy/tree/1.12.1 seems to have the fix in. Anyway, if I make that change on my "sympy 1.12.1" then the problem is gone.

However, I feel that there may be a deeper issue here. This is because, more and more, sympy guys are replacing x.__class___(...) with x.func(...).

In our case, the code for SympyExpression (on the most recent commit as of now) is: https://github.com/Mathics3/mathics-core/blob/94d26c2a23d8d5f84fbdac42dbd9058d0c8831a0/mathics/core/convert/sympy.py#L132-L159

So, calling x.func on any object created in https://github.com/Mathics3/mathics-core/blob/94d26c2a23d8d5f84fbdac42dbd9058d0c8831a0/mathics/core/convert/sympy.py#L145 will cause a crash because self.expr is not set: https://github.com/Mathics3/mathics-core/blob/94d26c2a23d8d5f84fbdac42dbd9058d0c8831a0/mathics/core/convert/sympy.py#L160-L170

Hence, we may have to either remove the handling for BasicSympy without .expr or set a dummy expr. However, sometimes SympyExpression is also called for "leaf nodes" (not sure what SymPy calls them) like SympyExpression(_Mathics_User_Global`a, 2, 1) which are not real expressions and do not have a function head.

It seems that that the handling for BasicSympy was introduced in https://github.com/Mathics3/mathics-core/commit/659c83fb27b732c98a15d52c5c1d599d25fde349, which possibly fixed the bug where sympy incorrectly used x.__class___(...) instead of x.func(...). However, I lack sufficient expertise in Mathics to see if the above fixes will cause other problems or if there's a third option.

rocky commented 2 weeks ago

Historically, terminology in Mathics has been weird and this causes a lot of confusion. At least to me, this fuzziness in terminology bleeds into fuzziness in intent as well.

Currently, something like "expr" refers to what would be better described as a "compound expression". In other words, an expression that contains subexpressions or is not atomic, such as the name of a variable or a literal constant. The WL term for a node in an expression tree is called an "element", and we have been slowly converting our code to use that term.

The intent of SympyExpression's expr attribute, I think, is to have an equivalent representation in Mathics for the SymPy expression. This reduces the need to convert back and forth from Mathics3 to SymPy.

If this is correct, then I think this field should be filled in to contain the corresponding Mathics object which here would be a Symbol, or more generally, some kind of Atom.

In short, if I have the above correct, the "expr" should be renamed to "element"; it should always be filled in even when the object is not a compound expression.

aravindh-krishnamoorthy commented 2 weeks ago

Historically, terminology in Mathics has been weird and this causes a lot of confusion. At least to me, this fuzziness in terminology bleeds into fuzziness in intent as well.

[...]

In short, if I have the above correct, the "expr" should be renamed to "element"; it should always be filled in even when the object is not a compound expression.

Thank you for the detailed explanation. The code in master (shown in my previous comment) presently sets obj.expr = None. I will think a bit more on this and your explanation and get back to you.

aravindh-krishnamoorthy commented 2 weeks ago

Hello @mmatera... I've made the following two comments on your commit https://github.com/Mathics3/mathics-core/commit/94d26c2a23d8d5f84fbdac42dbd9058d0c8831a0. Please add them to the code if you feel they are worthwhile.

The link to comments is here: https://github.com/Mathics3/mathics-core/commit/94d26c2a23d8d5f84fbdac42dbd9058d0c8831a0#comments

The comments are also reproduced below.

https://github.com/Mathics3/mathics-core/blob/94d26c2a23d8d5f84fbdac42dbd9058d0c8831a0/test/builtin/numbers/test_linalg.py#L230

Comment: This should likely just be eigvals // FullSimplify since the [[1]] is already included in the definition of eigvals above.

https://github.com/Mathics3/mathics-core/blob/94d26c2a23d8d5f84fbdac42dbd9058d0c8831a0/test/builtin/numbers/test_linalg.py#L242

Comment: Suggest to also add a numerical test:

In[17]:= eigvals /. a[x_, y_] -> x+I*y
Out[17]= 10 - 3 Sqrt[11]
aravindh-krishnamoorthy commented 1 week ago

Suggest to close this issue once the tests are merged.