expanding trig function calls into radicals

32 views
Skip to first unread message

Joe Wezorek

unread,
Jun 24, 2020, 6:56:35 PM6/24/20
to syme...@googlegroups.com
How do I get symengine to expand expressions that involve calls to trig functions where there is a closed form representation of the expression using radicals?

for example

    auto test = se::Expression("sin((3 / 10) * pi)");
    se::Expression out = se::trig_to_sqrt(test);

does not work. Im not sure what trig_simplify does but seems like not this.

Also is there a call similar to eval_double but instead evaluates to a multiprecision/arbitrary precision representation of the value? What I would like to be able to do is use expression trees in my code unless they get too deep at which point switch to multiprecision numeric value.

Joe

Isuru Fernando

unread,
Jun 24, 2020, 7:17:03 PM6/24/20
to symengine
Hi,

3*pi/10 is not simplified and there's no way to do it yet. SymEngine only simplifies k*pi/12 because usually other expressions are complex.
Can you open an issue about this?


> Also is there a call similar to eval_double but instead evaluates to a multiprecision/arbitrary precision representation of the value?

Yes, there's `evalf`.

Isuru



--
You received this message because you are subscribed to the Google Groups "symengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to symengine+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/symengine/CAKpXZPft-tMf%2B8rP3BtNkZXkPkBW8EoZh76txaPzy%2BZbjBsYsA%40mail.gmail.com.

Joe Wezorek

unread,
Jun 25, 2020, 9:49:00 AM6/25/20
to syme...@googlegroups.com
Looks like there already is an open issue:
https://github.com/symengine/symengine/issues/672 

evalf iwhen the number of bits argument is higher than 53, is crashing for me for some reason but I think that is an artifact of having built on Windows and messing something up, not sure.

Is there a way to determine the depth or size of an expression tree?  

Isuru Fernando

unread,
Jun 25, 2020, 1:03:02 PM6/25/20
to symengine
On Thu, Jun 25, 2020 at 8:49 AM Joe Wezorek <jwez...@gmail.com> wrote:
Looks like there already is an open issue:
https://github.com/symengine/symengine/issues/672 

evalf iwhen the number of bits argument is higher than 53, is crashing for me for some reason but I think that is an artifact of having built on Windows and messing something up, not sure.

Did you compile symengine with MPFR and MPC? Otherwise the program will crash with an Exception.

Is there a way to determine the depth or size of an expression tree?  

For size you can use the count_ops operation. Note that this gives the total number including repetitions for common subexpressions.

Isuru
Reply all
Reply to author
Forward
0 new messages