
(FPCore () :precision binary64 (- 20 (- (exp PI) PI)))
double code() {
return 20.0 - (exp(((double) M_PI)) - ((double) M_PI));
}
public static double code() {
return 20.0 - (Math.exp(Math.PI) - Math.PI);
}
def code(): return 20.0 - (math.exp(math.pi) - math.pi)
function code() return Float64(20.0 - Float64(exp(pi) - pi)) end
function tmp = code() tmp = 20.0 - (exp(pi) - pi); end
code[] := N[(20 - N[(N[Exp[Pi], $MachinePrecision] - Pi), $MachinePrecision]), $MachinePrecision]
20 - \left(e^{\pi} - \pi\right)
Herbie found 1 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore () :precision binary64 (- 20 (- (exp PI) PI)))
double code() {
return 20.0 - (exp(((double) M_PI)) - ((double) M_PI));
}
public static double code() {
return 20.0 - (Math.exp(Math.PI) - Math.PI);
}
def code(): return 20.0 - (math.exp(math.pi) - math.pi)
function code() return Float64(20.0 - Float64(exp(pi) - pi)) end
function tmp = code() tmp = 20.0 - (exp(pi) - pi); end
code[] := N[(20 - N[(N[Exp[Pi], $MachinePrecision] - Pi), $MachinePrecision]), $MachinePrecision]
20 - \left(e^{\pi} - \pi\right)
(FPCore () :precision binary64 (let* ((t_0 (* -1/20 (exp PI)))) (+ (* (* (+ 1 (/ 1 t_0)) t_0) 20) PI)))
double code() {
double t_0 = -0.05 * exp(((double) M_PI));
return (((1.0 + (1.0 / t_0)) * t_0) * 20.0) + ((double) M_PI);
}
public static double code() {
double t_0 = -0.05 * Math.exp(Math.PI);
return (((1.0 + (1.0 / t_0)) * t_0) * 20.0) + Math.PI;
}
def code(): t_0 = -0.05 * math.exp(math.pi) return (((1.0 + (1.0 / t_0)) * t_0) * 20.0) + math.pi
function code() t_0 = Float64(-0.05 * exp(pi)) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / t_0)) * t_0) * 20.0) + pi) end
function tmp = code() t_0 = -0.05 * exp(pi); tmp = (((1.0 + (1.0 / t_0)) * t_0) * 20.0) + pi; end
code[] := Block[{t$95$0 = N[(-1/20 * N[Exp[Pi], $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(1 + N[(1 / t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * 20), $MachinePrecision] + Pi), $MachinePrecision]]
\begin{array}{l}
t_0 := \frac{-1}{20} \cdot e^{\pi}\\
\left(\left(1 + \frac{1}{t\_0}\right) \cdot t\_0\right) \cdot 20 + \pi
\end{array}
Initial program 77.8%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6478.3%
Applied rewrites78.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-evalN/A
mult-flipN/A
lower-*.f64N/A
metadata-eval80.6%
Applied rewrites80.6%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift--.f64N/A
associate--r-N/A
distribute-lft-inN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
lift-PI.f64N/A
add-log-expN/A
lift-PI.f64N/A
lift-exp.f64N/A
log-pow-revN/A
metadata-evalN/A
pow-flipN/A
inv-powN/A
lift-exp.f64N/A
lift-PI.f64N/A
add-cube-cbrtN/A
Applied rewrites80.6%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f64N/A
metadata-eval83.9%
Applied rewrites83.9%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore ()
:name "xkcd217 (a numerical coincidence)"
:precision binary64
(- 20 (- (exp PI) PI)))