Repository: sympy/sympy

Issue:
Eigenvalues of a 4 by 4 matrix return as {nan: 4}
Consider the matrix 
```
>>> C = Matrix([
[ 0, 10,      10,       0],
[10,  0,       0,      10],
[10,  0, 2 - 5*I,      10],
[ 0, 10,      10, 2 - 5*I]])
```
SymPy can find its eigenvalues with `C.eigenvals()` without difficulty.  But if C is multiplied by I, the method fails:
```
>>> CI = (I*C).expand()
>>> CI.eigenvals()
{nan: 4}
```
My guess is that the problem is in SymPy's refusal to multiply concrete complex numbers together, and consequently failing to detect that the result of a computation is zero.  

Based on a [Stack Overflow post](https://stackoverflow.com/questions/49314361/sympy-dsolve-for-system-of-coupled-differential-equations-with-complex-values). 

Discussion:

Patch:
diff --git a/sympy/integrals/rubi/parsetools/header.py.txt b/sympy/integrals/rubi/parsetools/header.py.txt
deleted file mode 100644
index 0a8ed01495..0000000000
--- a/sympy/integrals/rubi/parsetools/header.py.txt
+++ /dev/null
@@ -1,126 +0,0 @@
-from sympy.external import import_module
-matchpy = import_module("matchpy")
-from sympy.utilities.decorator import doctest_depends_on
-
-if matchpy:
-    from matchpy import Pattern, ReplacementRule, CustomConstraint
-    from sympy.integrals.rubi.utility_function import (
-        sympy_op_factory, Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ,
-        ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ,
-        PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ,
-        ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ,
-        NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart,
-        FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest,
-        SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient,
-        Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart,
-        IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan,
-        ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec,
-        ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less,
-        Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ,
-        PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ,
-        ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ,
-        Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ,
-        SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator,
-        NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ,
-        InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ,
-        EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree,
-        PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts,
-        TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ,
-        NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll,
-        ExpandLinearProduct, GCD, ContentFactor, NumericFactor,
-        NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst,
-        ExpandExpression, Apart, SmartApart, MatchQ,
-        PolynomialQuotientRemainder, FreeFactors, NonfreeFactors,
-        RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms,
-        ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup,
-        AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor,
-        RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon,
-        MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ,
-        GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList,
-        PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ,
-        RationalFunctionFactors, NonrationalFunctionFactors, Reverse,
-        RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand,
-        SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree,
-        CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree,
-        GeneralizedBinomialParts, GeneralizedTrinomialDegree,
-        GeneralizedTrinomialParts, MonomialQ, MonomialSumQ,
-        MinimumMonomialExponent, MonomialExponent, LinearMatchQ,
-        PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ,
-        TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ,
-        QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms,
-        NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial,
-        PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD,
-        AlgebraicFunctionFactors, NonalgebraicFunctionFactors,
-        QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ,
-        Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors,
-        NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop,
-        CombineExponents, FactorInteger, FactorAbsurdNumber,
-        SubstForInverseFunction, SubstForFractionalPower,
-        SubstForFractionalPowerOfQuotientOfLinears,
-        FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ,
-        SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ,
-        FractionalPowerSubexpressionQ, Apply, FactorNumericGcd,
-        MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ,
-        TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest,
-        OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors,
-        PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn,
-        PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree,
-        FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify,
-        FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand,
-        NormalizeIntegrandAux, NormalizeIntegrandFactor,
-        NormalizeIntegrandFactorBase, NormalizeTogether,
-        NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors,
-        SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm,
-        TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum,
-        UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear,
-        PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ,
-        IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor,
-        FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ,
-        FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator,
-        SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand,
-        SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM,
-        SubstForFractionalPowerOfLinear, FractionalPowerOfLinear,
-        InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig,
-        FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ,
-        PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ,
-        KnownTangentIntegrandQ, KnownCotangentIntegrandQ,
-        KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst,
-        AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand,
-        ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp,
-        ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ,
-        FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ,
-        PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ,
-        FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ,
-        FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ,
-        FunctionOfLog, PowerVariableExpn, PowerVariableDegree,
-        PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic,
-        SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ,
-        Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ,
-        SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2,
-        ConstantFactor, SameQ, ReplacePart, CommonFactors,
-        MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential,
-        FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux,
-        FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev,
-        rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent,
-        RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct,
-        SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma,
-        FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ,
-        _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify,
-        _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum,
-        _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux,
-        TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist
-    )
-    from sympy import Integral, S, sqrt
-    from sympy.integrals.rubi.symbol import WC
-    from sympy.core.symbol import symbols, Symbol
-    from sympy.functions import (log, sin, cos, tan, cot, csc, sec, sqrt, erf, exp, log)
-    from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch)
-    from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec)
-    from sympy import pi as Pi
-
-    A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz']
-    a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']]
-
-    _UseGamma = False
-
-def {}(rubi):
diff --git a/sympy/integrals/rubi/parsetools/parse.py b/sympy/integrals/rubi/parsetools/parse.py
index d3ec8ba25f..b2581062ba 100644
--- a/sympy/integrals/rubi/parsetools/parse.py
+++ b/sympy/integrals/rubi/parsetools/parse.py
@@ -9,18 +9,6 @@
 expression using `sstr`. This replaces `And`, `Mul`, 'Pow' by their respective
 symbols.
 
-Mathematica
-===========
-
-To get the full form from Wolfram Mathematica, type:
-```
-ShowSteps = False
-Import["RubiLoader.m"]
-Export["output.txt", ToString@FullForm@DownValues@Int]
-```
-
-The file ``output.txt`` will then contain the rules in parseable format.
-
 References
 ==========
 [1] http://reference.wolfram.com/language/ref/FullForm.html
@@ -28,8 +16,6 @@
 [3] https://gist.github.com/Upabjojr/bc07c49262944f9c1eb0
 '''
 import re
-import os
-import inspect
 from sympy import sympify, Function, Set, Symbol
 from sympy.printing import sstr, StrPrinter
 
@@ -411,10 +397,30 @@ def rubi_rule_parser(fullform, header=None, module_name='rubi_object'):
     '''
     StrPrinter._print_Not = lambda self, expr: "Not(%s)" % self._print(expr.args[0])
 
-    if header == None:  # use default header values
-        path_header = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
-        header = open(os.path.join(path_header, "header.py.txt"), "r").read()
-        header = header.format(module_name)
+    if header == None: # use default header values
+        header = '''
+from sympy.external import import_module
+matchpy = import_module("matchpy")
+from sympy.utilities.decorator import doctest_depends_on
+
+if matchpy:
+    from matchpy import Pattern, ReplacementRule, CustomConstraint
+    from sympy.integrals.rubi.utility_function import (sympy_op_factory, Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist)
+    from sympy import Integral, S, sqrt
+    from sympy.integrals.rubi.symbol import WC
+    from sympy.core.symbol import symbols, Symbol
+    from sympy.functions import (log, sin, cos, tan, cot, csc, sec, sqrt, erf, exp, log)
+    from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch)
+    from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec)
+    from sympy import pi as Pi
+
+    A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz']
+    a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']]
+
+    _UseGamma = False
+
+def {}(rubi):
+'''.format(module_name)
 
     # Temporarily rename these variables because it
     # can raise errors while sympifying
diff --git a/sympy/polys/polyroots.py b/sympy/polys/polyroots.py
index d1e95515eb..038415e2a6 100644
--- a/sympy/polys/polyroots.py
+++ b/sympy/polys/polyroots.py
@@ -6,7 +6,7 @@
 
 from sympy.core.symbol import Dummy, Symbol, symbols
 from sympy.core import S, I, pi
-from sympy.core.compatibility import ordered
+from sympy.core.compatibility import ordered, range, reduce
 from sympy.core.mul import expand_2arg, Mul
 from sympy.core.power import Pow
 from sympy.core.relational import Eq
@@ -14,6 +14,7 @@
 from sympy.core.numbers import Rational, igcd, comp
 from sympy.core.exprtools import factor_terms
 from sympy.core.logic import fuzzy_not
+from sympy.core.function import _mexpand
 
 from sympy.ntheory import divisors, isprime, nextprime
 from sympy.functions import exp, sqrt, im, cos, acos, Piecewise
@@ -29,8 +30,6 @@
 from sympy.simplify import simplify, powsimp
 from sympy.utilities import public
 
-from sympy.core.compatibility import reduce, range
-
 
 def roots_linear(f):
     """Returns a list of roots of a linear polynomial."""
@@ -230,7 +229,7 @@ def _roots_quartic_euler(p, q, r, a):
     x = Symbol('x')
     eq = 64*x**3 + 32*p*x**2 + (4*p**2 - 16*r)*x - q**2
     xsols = list(roots(Poly(eq, x), cubics=False).keys())
-    xsols = [sol for sol in xsols if sol.is_rational]
+    xsols = [sol for sol in xsols if sol.is_rational and sol.is_nonzero]
     if not xsols:
         return None
     R = max(xsols)
@@ -310,8 +309,8 @@ def roots_quartic(f):
     else:
         a2 = a**2
         e = b - 3*a2/8
-        f = c + a*(a2/8 - b/2)
-        g = d - a*(a*(3*a2/256 - b/16) + c/4)
+        f = _mexpand(c + a*(a2/8 - b/2))
+        g = _mexpand(d - a*(a*(3*a2/256 - b/16) + c/4))
         aon4 = a/4
 
         if f is S.Zero:


Test patch:
diff --git a/sympy/matrices/tests/test_matrices.py b/sympy/matrices/tests/test_matrices.py
index c6d54d59e5..1ac0327b28 100644
--- a/sympy/matrices/tests/test_matrices.py
+++ b/sympy/matrices/tests/test_matrices.py
@@ -3090,3 +3090,14 @@ def test_issue_14489():
 
     assert Mod(A, 3) == Matrix([2, 1, 2])
     assert Mod(B, 4) == Matrix([2, 0, 1])
+
+def test_issue_14517():
+    M = Matrix([
+        [   0, 10*I,    10*I,       0],
+        [10*I,    0,       0,    10*I],
+        [10*I,    0, 5 + 2*I,    10*I],
+        [   0, 10*I,    10*I, 5 + 2*I]])
+    ev = M.eigenvals()
+    # test one random eigenvalue, the computation is a little slow
+    test_ev = random.choice(list(ev.keys()))
+    assert (M - test_ev*eye(4)).det() == 0
diff --git a/sympy/polys/tests/test_polyroots.py b/sympy/polys/tests/test_polyroots.py
index 15c8e4d285..41865ef98d 100644
--- a/sympy/polys/tests/test_polyroots.py
+++ b/sympy/polys/tests/test_polyroots.py
@@ -103,6 +103,12 @@ def test_issue_13340():
     assert len(roots_d) == 3
 
 
+def test_issue_14522():
+    eq = Poly(x**4 + x**3*(16 + 32*I) + x**2*(-285 + 386*I) + x*(-2824 - 448*I) - 2058 - 6053*I, x)
+    roots_eq = roots(eq)
+    assert all(eq(r) == 0 for r in roots_eq)
+
+
 def test_roots_cubic():
     assert roots_cubic(Poly(2*x**3, x)) == [0, 0, 0]
     assert roots_cubic(Poly(x**3 - 3*x**2 + 3*x - 1, x)) == [1, 1, 1]