Thanks,
--Connor
Is this just a printing issue? And a way to create new integers?
Ondrej
In [31]: int(hex, 16)
Out[31]: 60982
In [32]: int(hex[0], 16)
Out[32]: 14
In [34]: int(hex[2], 16)
Out[34]: 3
I would like to be able to do that with any base, so I could say:
base1000 = base(1000, 34987563294875623489756324576)
if int(base1000[0], 1000) > 900: Do_Stuff()
...
I was doing a bunch of iterations using divmod to pull apart the
integers, but then I realized that conceptually what I was doing was
just change of base operations with really large bases, and so I think
I can really clean up my code a *lot* if I can figure out a way to do
this. As far as printing goes, it isn't that important to me, because
once the base goes over 52 or so, things would start to get
incomprehensible (i.e.
e'k"rw12""34yf'4vw'e1234rkhfv'b124214"".124'5gew""rgsfv X 1000^-31)
Thanks,
--Connor
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
>
>
I do not think this is currently implemented in SymPy. If you would like to implement it, that would be great! Basically, you just have to extend the current Integer() to handle the base argument of int() (SymPy's Integer() is already a wrapper around int()), and maybe add some methods to do whatever things you need (change of base, etc.), and probably some kind of printer so you don't get confused.
By the way, for what it's worth, gmpy's mpz type supports multiple bases too:
In [7]: from gmpy import mpz
In [8]: mpz("ee36", 16)
Out[8]: 60982
Aaron Meurer
is there a way to simplify
(x**2)**(3*numbers.One()/2)
to
x**3
?
It is not that important for me but the expressions would look cleaner.
Thanks,
Bastian.
In [1]: x = Symbol("x", positive=True)
In [2]: (x**2)**(3*numbers.One()/2)
Out[2]:
3
x
for real x, it simplifies to absolute value
In [3]: x = Symbol("x", real=True)
In [4]: (x**2)**(3*numbers.One()/2)
Out[4]:
3
│x│
Best regards
Stepan
thanks for the quick and good answer.
Greetings,
Bastian.
Uff. I did not knew about that. Thank you very much for the advice.
Also thanks for the explanation with the 2-norm. In principle I know
that (x**2)**(3/2) == x**3 is only valid for non-negative x. But I
forgot to inform sympy about the implicit assumptions I had in mind.
Regards,
Bastian.
Aaron Meurer