Thanks Jonathan,

I guess I will stick with my approach for now. The behavior of sympy.vector
may actually be a bug as this trick puts the unit vector in the middle of
the expression -

In [6]: vecB = Bx * C.i

In [7]: vecB
Out[7]:
⎛     ⎛y_C⎞    ⎛  5  ⎞⎞
⎜2⋅sin⎜───⎟ i_C⋅cos⎝10 ⋅t⎠⎟
⎜     ⎜  3⎟           ⎟
⎜     ⎝10 ⎠           ⎟
⎜─────────────────────⎟
⎜           4         ⎟
⎝         10          ⎠


Perhaps sympy may consider displaying large and small numbers using this
notation, something like https://github.com/gutow/round_using_error, by
default for latex and pretty print. I think mathematica does something
similar.

Best wishes,
Rajeev


On Tue, 8 Feb 2022, 7:13 p.m. [email protected], <[email protected]> wrote:

> 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
> <https://groups.google.com/d/msgid/sympy/2c97419c-3105-4470-8125-c524edcd8c52n%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/CAABz-z87%3DOw2%2B4Ha1%2BUj-Y1o9tFmyEs6e5foWto_jhf-aTx6-Q%40mail.gmail.com.

Reply via email to