fricas icon indicating copy to clipboard operation
fricas copied to clipboard

Internal Error: Unexpected error in call to system function compColon

Open nsajko opened this issue 4 years ago • 1 comments

Moving on from the mailing list, since now I stumbled upon an actual bug in Fricas. This is the diagnostic produced by )compile:

   compiling local trunc_taylor_integral : (Expression Integer,Expression Integer) -> Expression Integer
   Internal Error
   Unexpected error in call to system function compColon

This is the code:

)abbrev package GGLC GeographicLibCoefficients
GeographicLibCoefficients() : Exports == Implementation where

        SYM ==> Symbol

        L ==> List
        I ==> Integer
        P ==> PositiveInteger

        EXPR ==> Expression(I)

        RAT ==> Fraction(I)
        PLY ==> Polynomial(RAT)
        UPLY(var) ==> UnivariatePolynomial(var, RAT)
        RATFUNC ==> Fraction(PLY)
        TAY(var) ==> UnivariateTaylorSeries(EXPR, var, 0)

        Exports ==> with

                tau1_m_sigma: () -> EXPR

        Implementation ==> add

                maxpow(): P == 8

                trunc_taylor_integral(integrand: EXPR, factor: EXPR): EXPR ==
                        subs_eq: Equation(EXPR) := 'k2::SYM::EXPR = 4 * 'eps::SYM::EXPR /
                                                                     (1 - 'eps::SYM::EXPR)^2
                        inte: EXPR := subst(integrand, subs_eq) * factor
                        tay: TAY('eps::SYM) := taylor(inte, 'eps:SYM = 0)
                        Inte: TAY('eps::SYM) := integrate(tay, 'sigma::SYM)
                        reduce(_+, [coefficient(Inte, n) * ('eps::SYM::EXPR)^n for n in 0..maxpow()])

                del_sigma(e: EXPR): UPLY('eps::SYM) ==
                        simplify(subst(e, 'sigma::SYM = 2*%pi) / (2*%pi))

                tau1_m_sigma(): EXPR ==
                        integrand: EXPR := sqrt(1 + 'k2::SYM::EXPR * sin('sigma::SYM::EXPR)^2)
                        I1_truncated: EXPR := trunc_taylor_integral(integrand,
                                                                          1 - 'eps::SYM::EXPR)
                        A1: UPLY('eps::SYM) := del_sigma(I1_truncated)
                        tau1: EXPR := I1_truncated / A1::EXPR
                        tau1 - 'sigma::SYM::EXPR

EDIT: the error is the same with this change:

                trunc_taylor_integral(integrand: EXPR, factor: EXPR): EXPR ==
                        subs_eq: Equation(EXPR) := 'k2::SYM::EXPR = 4 * 'eps::SYM::EXPR /
                                                                     (1 - 'eps::SYM::EXPR)^2
                        inte: EXPR := subst(integrand, subs_eq) * factor
                        terms: L(EXPR) := [coefficient(taylor(inte, 'eps:SYM = 0), n) *
                                             ('eps::SYM::EXPR)^n for n in 0..maxpow()]
                        tay: EXPR := reduce(_+, terms)
                        integrate(tay, 'sigma::SYM)

nsajko avatar Aug 05 '21 18:08 nsajko

You wrote:

tay: TAY('eps::SYM) := taylor(inte, 'eps:SYM = 0)

Perhaps you meant to write:

tay: TAY('eps::SYM) := taylor(inte, 'eps::SYM::EXPR = 0)

i.e. double colon and coercion.

But you are right that "Internal Error" suggests that the compiler should have given a more meaningful error message.

On Thu, Aug 5, 2021 at 2:23 PM Neven Sajko @.***> wrote:

Moving on from the mailing list, since now I stumbled upon an actual bug in Fricas. This is the diagnostic produced by )compile:

compiling local trunc_taylor_integral : (Expression Integer,Expression Integer) -> Expression Integer Internal Error Unexpected error in call to system function compColon

This is the code:

)abbrev package GGLC GeographicLibCoefficients GeographicLibCoefficients() : Exports == Implementation where

    SYM ==> Symbol

    L ==> List
    I ==> Integer
    P ==> PositiveInteger

    EXPR ==> Expression(I)

    RAT ==> Fraction(I)
    PLY ==> Polynomial(RAT)
    UPLY(var) ==> UnivariatePolynomial(var, RAT)
    RATFUNC ==> Fraction(PLY)
    TAY(var) ==> UnivariateTaylorSeries(EXPR, var, 0)

    Exports ==> with

            tau1_m_sigma: () -> EXPR

    Implementation ==> add

            maxpow(): P == 8

            trunc_taylor_integral(integrand: EXPR, factor: EXPR): EXPR ==
                    inte: EXPR := subst(integrand, 'k2::SYM::EXPR = 4 * 'eps::SYM::EXPR /
                                                           (1 - 'eps::SYM::EXPR)^2) *
                                         factor
                    tay: TAY('eps::SYM) := taylor(inte, 'eps:SYM = 0)
                    I: TAY('eps::SYM) := integrate(tay, 'sigma::SYM)
                    reduce(_+, [coefficient(I, n) * ('eps::SYM::EXPR)^n for n in 0..maxpow()])

            del_sigma(e: EXPR): UPLY('eps::SYM) ==
                    simplify(subst(e, 'sigma::SYM = 2*%pi) / (2*%pi))

            tau1_m_sigma(): EXPR ==
                    integrand: EXPR := sqrt(1 + 'k2::SYM::EXPR * sin('sigma::SYM::EXPR)^2)
                    I1_truncated: EXPR := trunc_taylor_integral(integrand,
                                                                      1 - 'eps::SYM::EXPR)
                    A1: UPLY('eps::SYM) := del_sigma(I1_truncated)
                    tau1: EXPR := I1_truncated / A1::EXPR
                    tau1 - 'sigma::SYM::EXPR

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fricas/fricas/issues/62, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGCUQDFHBCKPNSWUXTA5VDT3LJLTANCNFSM5BUMJB6A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

billpage avatar Aug 05 '21 22:08 billpage