I am trying to use pgfmath to convert frequencies in hertz to the mel scale. I'm trying to implement a formula for which I have a Java source and which I have previously implemented with success in XSLT. My attempt with pgfmath yields the results which I would expect up to 1000, afterwards the decimal place is three places to the right of what I would expect. A small latex file demonstrating the problem follows. It includes Java and XSLT versions of the formula. I am new to pgfmath (but regularly use pgf) and my numerical math skills have languished for many years, so I am rather clueless at this point.
Example:
\documentclass{article}
\usepackage{pgfmath}
\usepackage{pgffor}
% java code borrowed from sphinx4 MelFrequencyFilterBank.java:
% (2595.0 * (Math.log(1.0 + inputFreq / 700.0) / Math.log(10.0)))
% Implemented in XSLT as follows:
% <xsl:function name="local:hz2mel">
% <xsl:param name="inputFreq" as="xs:double"/>
% <xsl:value-of select="2595.0 * (math:log(1.0 + $inputFreq div 700.0)) div math:log(10.0)"/>
% </xsl:function>
% Attempt to implement in pgfmath
\newcommand{\hztomel}[1]{%
\pgfmathparse{2595.0*ln(1+#1/700)/ln(10)}%
\pgfmathresult%
}
\begin{document}
\noindent
\foreach \x in {0, 200, 400, 1000, 1001, 2000, 5000,10000}
{\x{} $\rightarrow$ \hztomel{\x}\\}
\end{document}
log10function is defined. – percusse Feb 3 at 13:12\listfilescommand somewhere in the preamble and reading the log output. – percusse Feb 3 at 13:19