Rajeev, I have done a little work with the sympy print/rendering package. Unfortunately, this looks like something that needs to adapt those mechanisms. Initially, I would suggest a specialized wrapper that determines the proper powers and then sends an adapted expression to the pretty_print package. Depending on how the vector printing works you may have to send strings not specialized symbols. I am not sure the pretty_print code itself could be adapted to what you want and still be compatible with everything else.
Jonathan On Tuesday, February 8, 2022 at 12:02:19 AM UTC-6 Rajeev wrote: > Thanks Jonathan, > > Perhaps the following example explains what I want to do. Using pretty > print we get - > > In [5]: Bx = 2e-4 * cos(1e5 * t) * sin(1e-3 * y) > > In [6]: Bx > Out[6]: 0.0002⋅sin(0.001⋅y_C)⋅cos(100000.0⋅t) > > In [7]: Bx = 2 * ten**(-4) * cos(ten**5 * t) * sin(ten**(-3) * y) > > In [8]: Bx > Out[8]: > ⎛y_C⎞ ⎛ 5 ⎞ > 2⋅sin⎜───⎟⋅cos⎝10 ⋅t⎠ > ⎜ 3⎟ > ⎝10 ⎠ > ───────────────────── > 4 > 10 > > Is there a better way to achieve the last behaviour to improve readability > in the terminal with pretty print? > > Also using this hack messes up pretty print if used with sympy.vector > objects, which is perhaps a bug. > > Best wishes, > Rajeev > > > > On Mon, 7 Feb 2022 at 19:06, [email protected] <[email protected]> wrote: > >> I'm not sure of your exact use case, but maybe what I do when rounding >> numbers to match their errors will give you some ideas. >> https://github.com/gutow/round_using_error. In this case I end up >> determining the power of ten for the scientific notation using log base 10. >> >> Jonathan >> >> On Monday, February 7, 2022 at 4:55:47 AM UTC-6 Rajeev wrote: >> >>> Dear group, >>> >>> What would be the best way to get numbers in the form 10^{...} while >>> using pretty print or latex? The following hack works - >>> >>> ten = symbols("10", positive=True) >>> eps, mu = 4*pi*ten**(-11), ten**(-5) >>> >>> but is messing up pretty print when used with sympy.vector objects. >>> Couldn't find anything on this in the mail archives. >>> >>> Best wishes, >>> Rajeev >>> >> -- >> 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 [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/sympy/64c23a71-7773-42f1-b4a6-92e230849508n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/sympy/64c23a71-7773-42f1-b4a6-92e230849508n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/2c97419c-3105-4470-8125-c524edcd8c52n%40googlegroups.com.
