python sympy print command scientific exponential prefix formatting

27 views Asked by At

I use python with scientific libraries for electrical engineering studies at university. I want to format output of print command with 3 step scientific exponential prefix notation. I solve an equation and substitute values in it.

Example:

import sympy as smp
import numpy as np
from sympy import *
eqn = Eq(Z, (G1/(G1**2 + (w*C)**2)) + R2)
a = solve(eqn, C)
x = a[0]
z = round(x.subs([(G1, 2.5e-3), (Z, 200), (w, 2*np.pi*800), (R2, 80)]).evalf(), 20)
print("%.4le" %z)

Output:

7.5973e-07

I use printf formatting from c language.

Prefix Power
milli e-03
micro e-06
nano e-09

My question is how can I format exponent in print output in 3 step scientific prefix notation like figure above?

Output should be like:

759.73e-09

Can anybody show me code to fix that? It is clear for me that I can change notation by myself but I want handle it with computer so I avoid calculate.

0

There are 0 answers