Пример #1
0
    internal override Symbolic PreEval(Symbolic x)
    {
        Complex z = x.ToComplex();

        if (z.Re < 0 || z.Im != 0.0)
        {
            return(new Complex(JMath.log(z.Re * z.Re + z.Im * z.Im) / 2, JMath.atan2(z.Im, z.Re)));
        }
        return(new Complex(JMath.log(z.Re)));
    }
Пример #2
0
    internal override Symbolic PreEval(Symbolic x)
    {
        Complex z = x.ToComplex();

        if (z.Im == 0.0)
        {
            return(new Complex(Math.Tan(z.Re)));
        }
        return(( Symbolic )evalx(trigrule, z));
    }
Пример #3
0
    internal override Symbolic PreEval(Symbolic x)
    {
        Complex z = x.ToComplex();

        double r = JMath.exp(z.Re);

        if (z.Im != 0.0)
        {
            return(new Complex(r * Math.Cos(z.Im), r * Math.Sin(z.Im)));
        }

        return(new Complex(r));
    }
Пример #4
0
    public override bool Smaller(Symbolic x)
    {
        var xu = x.ToComplex();

        if (Re == xu.Re)
        {
            return(Im < xu.Im);
        }
        else
        {
            return(Re < xu.Re);
        }
    }
Пример #5
0
    internal override Algebraic SymEval(Algebraic f)
    {
        if (gcd.Equals(Symbolic.ZERO))
        {
            return(f);
        }
        if (f is Polynomial)
        {
            Polynomial p = (Polynomial)f;
            if (p._v is FunctionVariable && ((FunctionVariable)p._v).Name.Equals("exp") && Poly.Degree(((FunctionVariable)p._v).Var, @var) == 1)
            {
                Algebraic arg = ((FunctionVariable)p._v).Var;

                Algebraic[] new_coef = new Algebraic[2];

                new_coef[1] = gcd.ToComplex();
                new_coef[0] = Symbolic.ZERO;

                Algebraic new_arg = new Polynomial(@var, new_coef);

                Algebraic subst = FunctionVariable.Create("exp", new_arg);
                Algebraic exp   = Poly.Coefficient(arg, @var, 1) / gcd;

                if (!(exp is Symbolic) && !((Symbolic)exp).IsInteger())
                {
                    throw new JasymcaException("Not integer exponent in exponential simplification.");
                }

                subst = subst ^ (( Symbolic )exp).ToInt();

                subst = subst * FunctionVariable.Create("exp", Poly.Coefficient(arg, @var, 0));

                int n = p.Coeffs.Length;

                Algebraic r = SymEval(p[n - 1]);

                for (int i = n - 2; i >= 0; i--)
                {
                    r = r * subst + SymEval(p[i]);
                }

                return(r);
            }
        }

        return(f.Map(this));
    }
Пример #6
0
 internal override Symbolic PreEval(Symbolic x)
 {
     return(new Complex(Sfun.logGamma(x.ToComplex().Re)));
 }