Renaming variables in FriCAS sandbox output

90 Views Asked by At

I'm playing with FriCAS in sandbox and the problem is, When asked to find indefinite integral (as well as in many other cases), FriCAS outputs auto-generated variables in a rather unsightly manner, for example,

integrate(x^x, x) 

outputs $\int_{}^x\%A^{\%A}\mathbb{d}\%A$ which is quite ugly.

The question is, is there a way to prettify the output? How can I substitute $\%A$ with $t$, for example?

1

There are 1 best solutions below

0
On BEST ANSWER

Okay, so I contacted the guys at the fricas google group, as IV_ suggested in his comment to the question. Thanks again for pointing me there!

Waldek Hebisch posted the following code that solves my problem:

)expose OutputFormTools

subst_of(f, ls, lf) ==
    symbol?(f) =>
        s := symbol(f)
        k := position(s, ls)
        k > 0 => lf(k)
        f
    atom?(f) => f
    la := arguments(f)
    nla := [subst_of(fi, ls, lf) for fi in la]
    construct(operator(f), nla)$OutputFormTools

It would perform the necessary dummy variable substitution when used like this:

iif := integrate(x^x, x)::OutputForm;
subst_of(iif, [%A], [t]) 

Which will produce a much cleaner answer, $\int_{}^{x}t^t\mathbb{d}t$, and that was precisely what I was looking for.