You could also write a custom StrPrinter subclass that prints floats
how you want. May be more robust than regular expressions.
>
>
> the problem is that c21 and r are O(1) and they are being multiplied by huge
> numbers and then divided by huge numbers. I've tried expand and several
> other options but I can't seem to figure out an automatic way to get sympy
> to give me more reasonable double precision coefficients. I can do it
> "manually" by splitting the expression into the numerator and denominator
> and then taking the large constant and in the denominator and normalizing
> the numerator with it before gluing the expression back together but I'm
> hoping there's a better way.
That's how I would do it. Does dividing by the leading coefficient work?
In [11]: p, q = a.as_numer_denom()
In [12]: print(p/LC(q)/(q/LC(q)))
(0.00190347316193054*c21*r**10 + 0.0265323009071318*c21*r**9 +
0.142400942214203*c21*r**8 + 0.577357887691594*c21*r**7 +
1.81396415813505*c21*r**6 + 2.87371756833687*c21*r**5 +
1.05734327889046*c21*r**4 - 2.09230365684889*c21*r**3 -
3.34536039693279*c21*r**2 - 1.99333333333333*c21*r +
0.00177617400892096*r**10 + 0.0247578921576817*r**9 +
0.132877551134054*r**8 + 0.461334714633707*r**7 +
1.00644379883558*r**6 + 0.726243872289311*r**5 -
0.917270436496146*r**4 - 2.87315317491866*r**3 + 3.70038570233136*r**2
- 3.15956893348198*r + 0.301851851851852)/(1.0*r**5 +
6.27222222222221*r**4 + 10.3*r**3 - 3.3388888888889*r**2 -
18.3333333333333*r - 9.96666666666667)
Aaron Meurer
>
>
> Here's what I get if do the splitting manually:
>
>
> (0.342625169147496617*c21*r**10 + 4.77581416328371673*c21*r**9 +
> 25.632169598556608*c21*r**8 + 103.924419784486855*c21*r**7 +
> 326.513548464309187*c21*r**6 + 517.269162300637267*c21*r**5 +
> 190.321790200281699*c21*r**4 - 376.614658232800258*c21*r**3 -
> 602.164871447902571*c21*r**2 - 358.8*c21*r + 0.319711321605773568*r**10 +
> 4.45642058838269934*r**9 + 23.9179592041297048*r**8 +
> 83.0402486340673783*r**7 + 181.159883790403722*r**6 +
> 130.723897012075825*r**5 - 165.108678569306389*r**4 -
> 517.167571485358666*r**3 + 666.069426419644693*r**2 - 568.722408026755853*r
> + 54.3333333333333333)/((r + 1.0)*(180.0*r**4 + 949.0*r**3 + 905.0*r**2 -
> 1506.0*r - 1794.0))
>
>
> Is there a better way?
>
>
>
> --
> 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 post to this group, send email to
sy...@googlegroups.com.
> Visit this group at
https://groups.google.com/group/sympy.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/sympy/ee10ecaf-bd9f-4b21-98e5-68bdf2640a5b%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.