As easy as that! Thank you, that's essentially exactly what I wanted to do.
cheers
Richard
On Thursday, 5 November 2015 02:21:46 UTC+13, Jason Moore wrote:
>
> This should be:
>
> class MyPrinter(CCodePrinter):
> def _print_Symbol(self, expr):
> name = super(MyPrinter,
Thank you.
On Wednesday, November 4, 2015 at 9:25:17 PM UTC+2, Aaron Meurer wrote:
>
> You can generally do this sort of thing using replace().
> Unfortunately, the pattern matcher doesn't recognize rational numbers
> as a/b, so you have to do a more manual check. This should work:
>
>
Hi everyone
There have been cases with me while solving bugs in SmyPy in certain cases
that i feel the need to follow certain rules for writing cases. I think
that there are no hard and fast rules to write test cases for everything in
genral for `new implementation`(for any software). For
So, there is no way to do it using subs and/or some manipulations?
real_root(-1, 3) is of no help, because I can have arbitrary expression.
On Wednesday, November 4, 2015 at 6:29:29 PM UTC+2, Aaron Meurer wrote:
>
> You need to use real_root, like
>
> In [3]: real_root(-1, 3)
> Out[3]: -1
>
>
You can generally do this sort of thing using replace().
Unfortunately, the pattern matcher doesn't recognize rational numbers
as a/b, so you have to do a more manual check. This should work:
e.replace(lambda i: i.is_Pow and i.base == x and i.exp.is_Rational,
lambda i: real_root(-1,
You need to use real_root, like
In [3]: real_root(-1, 3)
Out[3]: -1
In [4]: real_root(-1, 3)**2
Out[4]: 1
SymPy, like most math libraries, uses complex roots (i.e., principal
roots) because they have nicer mathematical properties.
Aaron Meurer
On Wed, Nov 4, 2015 at 3:30 AM, Paul Royik
Yes, for now, Mul automatically distributes constants, so you have to
use evaluate=False to factor out something like -1.
Aaron Meurer
On Wed, Nov 4, 2015 at 5:13 AM, Hugh <7141...@gmail.com> wrote:
> Thanks Aaron for pointing out the simplification section of the tutorial.
>
> Actually,
Okay. Thanks again for your help.
On Thursday, 5 November 2015 00:36:46 UTC+8, Aaron Meurer wrote:
>
> Yes, for now, Mul automatically distributes constants, so you have to
> use evaluate=False to factor out something like -1.
>
> Aaron Meurer
>
> On Wed, Nov 4, 2015 at 5:13 AM, Hugh
I have the following expresssion:
f=x**(Rational(2,3))
How can I get 1, when substituting (-1) instead of complex number?
For now, I got complex number when run f.subs(x,-1).evalf()
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from
Thanks Aaron for pointing out the simplification section of the tutorial.
Actually, collect(expr1, [x11, x12, x13]) does almost what I wanted. I
still need to factor a -1 from x12( -x21x33 + x23x31). How would you do it
using replace() like what I did? I also tried putting (x12*a).factor() as
Thanks Mateusz for sharing the code. I thought it was a clever solution to
solve my problem.
On Wednesday, 4 November 2015 07:35:45 UTC+8, Mateusz Paprocki wrote:
>
> Hi,
>
> On 3 November 2015 at 21:47, Hugh <714...@gmail.com > wrote:
> > import sympy
> > sympy.init_session()
> >
> >
> >
11 matches
Mail list logo