Forcing no rewrite when creating expression

16 views
Skip to first unread message

Bracket Master

unread,
Apr 27, 2020, 5:22:26 AM4/27/20
to sympy
Hello all,
Say I have the following:

```python
>>> sin(x)*cos(x)*cos(x)
sin(x)*cos(x)**2
```

How can I have sympy not rewrite/simplify when creating and expression.
That is, I want this:


```python
>>> sin(x)*cos(x)*cos(x)
sin(x)*cos(x)*cos(x)
```

about term rewriting, but I would like to turn it off.

Basically, my use case is, I'm working with phasors, and I don't want
sympy distributing the magnitude into the expression.

Aaron Meurer

unread,
Apr 28, 2020, 2:15:37 PM4/28/20
to sympy
You want evaluate=False, like Mul(sin(x), cos(x), cos(x), evaluate=False), or

with evaluate(False):
sin(x)*cos(x)*cos(x)

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/ab11114c-25c9-47a1-b774-077a0696fed7%40googlegroups.com.

David Bailey

unread,
Apr 28, 2020, 4:42:52 PM4/28/20
to sy...@googlegroups.com
On 28/04/2020 19:15, Aaron Meurer wrote:
You want evaluate=False, like Mul(sin(x), cos(x), cos(x), evaluate=False), or

with evaluate(False):
    sin(x)*cos(x)*cos(x)

Yes, but my feeling is that he still wants SymPy to do something for him - not just return what he types in, so

he needs to supply a more realistic example of what he is trying to do.

David

Reply all
Reply to author
Forward
0 new messages