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 - The Fusion of Science and Community**

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:

Loading...

Similar Threads - code expression least | Date |
---|---|

What should be the rules to write excellent code? | Mar 12, 2018 |

Converting a DFA to efficient code? | Mar 11, 2018 |

Python How can I run Python by getting values from Matlab | Mar 7, 2018 |

PID Codes | Feb 22, 2018 |

Boolean Algebra - Simplifying to two different expressions | Jan 18, 2017 |

**Physics Forums - The Fusion of Science and Community**