The expression to code is: (z complex, m some positive integer)(adsbygoogle = window.adsbygoogle || []).push({});

z^m ( ln(z/(z-1)) - sum( 1/(k z^k), {k=1,m} ) )

The way I code is (in fortran) (in case z<2)

Z_1=1.0_q/Z

ZV1=LOG(Z/(Z-1))

ZK=1.0_q

DO K=1,M; ZK=ZK*Z_1

ZV1=ZV1-ZK/K

ENDDO

ZV1=ZV1/ZK

But it gives quite big error by this bruteforce way of coding. Can anybody help me out to suggest a better way to code it?

Thanks,

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# How to code the expression with least roundoff error

Tags:

**Physics Forums | Science Articles, Homework Help, Discussion**