(FPCore (k) :precision binary64 (+ (/ (* (- k 273.15) 9.0) 5.0) 32.0))
double code(double k) { return (((k - 273.15) * 9.0) / 5.0) + 32.0; }
real(8) function code(k) real(8), intent (in) :: k code = (((k - 273.15d0) * 9.0d0) / 5.0d0) + 32.0d0 end function
public static double code(double k) { return (((k - 273.15) * 9.0) / 5.0) + 32.0; }
def code(k): return (((k - 273.15) * 9.0) / 5.0) + 32.0
function code(k) return Float64(Float64(Float64(Float64(k - 273.15) * 9.0) / 5.0) + 32.0) end
function tmp = code(k) tmp = (((k - 273.15) * 9.0) / 5.0) + 32.0; end
code[k_] := N[(N[(N[(N[(k - 273.15), $MachinePrecision] * 9.0), $MachinePrecision] / 5.0), $MachinePrecision] + 32.0), $MachinePrecision]
\begin{array}{l} \\ \frac{\left(k - 273.15\right) \cdot 9}{5} + 32 \end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (k) :precision binary64 (+ (/ (* (- k 273.15) 9.0) 5.0) 32.0))
double code(double k) { return (((k - 273.15) * 9.0) / 5.0) + 32.0; }
real(8) function code(k) real(8), intent (in) :: k code = (((k - 273.15d0) * 9.0d0) / 5.0d0) + 32.0d0 end function
public static double code(double k) { return (((k - 273.15) * 9.0) / 5.0) + 32.0; }
def code(k): return (((k - 273.15) * 9.0) / 5.0) + 32.0
function code(k) return Float64(Float64(Float64(Float64(k - 273.15) * 9.0) / 5.0) + 32.0) end
function tmp = code(k) tmp = (((k - 273.15) * 9.0) / 5.0) + 32.0; end
code[k_] := N[(N[(N[(N[(k - 273.15), $MachinePrecision] * 9.0), $MachinePrecision] / 5.0), $MachinePrecision] + 32.0), $MachinePrecision]
\begin{array}{l} \\ \frac{\left(k - 273.15\right) \cdot 9}{5} + 32 \end{array}
(FPCore (k) :precision binary64 (fma 1.8 k -459.66999999999996))
double code(double k) { return fma(1.8, k, -459.66999999999996); }
function code(k) return fma(1.8, k, -459.66999999999996) end
code[k_] := N[(1.8 * k + -459.66999999999996), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(1.8, k, -459.66999999999996\right) \end{array}
Initial program 100.0%
Taylor expanded in k around 0
metadata-eval
N/A
rgt-mult-inverse
N/A
associate-*r*
N/A
*-commutative
N/A
unsub-neg
N/A
distribute-rgt-neg-out
N/A
*-commutative
N/A
lower-fma.f64
N/A
distribute-lft-neg-in
N/A
associate-*l*
N/A
metadata-eval
N/A
lft-mult-inverse
N/A
metadata-eval
100.0
Applied rewrites100.0%
(FPCore (k) :precision binary64 -459.66999999999996)
double code(double k) { return -459.66999999999996; }
real(8) function code(k) real(8), intent (in) :: k code = -459.66999999999996d0 end function
public static double code(double k) { return -459.66999999999996; }
def code(k): return -459.66999999999996
function code(k) return -459.66999999999996 end
function tmp = code(k) tmp = -459.66999999999996; end
code[k_] := -459.66999999999996
\begin{array}{l} \\ -459.66999999999996 \end{array}
Initial program 100.0%
Taylor expanded in k around 0
Applied rewrites97.4%
herbie shell --seed 1
(FPCore (k)
:name "(k-273.15)*9/5+32"
:precision binary64
:pre (and (<= 0.0 k) (<= k 1000.0))
(+ (/ (* (- k 273.15) 9.0) 5.0) 32.0))