
(FPCore (x y z) :precision binary64 :pre TRUE (+ (* x (+ y z)) (* z 5.0)))
double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * (y + z)) + (z * 5.0d0)
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
def code(x, y, z): return (x * (y + z)) + (z * 5.0)
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) + Float64(z * 5.0)) end
function tmp = code(x, y, z) tmp = (x * (y + z)) + (z * 5.0); end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] + N[(z * 5.0), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (x * (y + z)) + (z * (5)) END code
x \cdot \left(y + z\right) + z \cdot 5
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 :pre TRUE (+ (* x (+ y z)) (* z 5.0)))
double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * (y + z)) + (z * 5.0d0)
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
def code(x, y, z): return (x * (y + z)) + (z * 5.0)
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) + Float64(z * 5.0)) end
function tmp = code(x, y, z) tmp = (x * (y + z)) + (z * 5.0); end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] + N[(z * 5.0), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (x * (y + z)) + (z * (5)) END code
x \cdot \left(y + z\right) + z \cdot 5
(FPCore (x y z) :precision binary64 :pre TRUE (fma z (- x -5.0) (* y x)))
double code(double x, double y, double z) {
return fma(z, (x - -5.0), (y * x));
}
function code(x, y, z) return fma(z, Float64(x - -5.0), Float64(y * x)) end
code[x_, y_, z_] := N[(z * N[(x - -5.0), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (z * (x - (-5))) + (y * x) END code
\mathsf{fma}\left(z, x - -5, y \cdot x\right)
Initial program 99.9%
Applied rewrites98.8%
(FPCore (x y z) :precision binary64 :pre TRUE (fma x y (* z (+ 5.0 x))))
double code(double x, double y, double z) {
return fma(x, y, (z * (5.0 + x)));
}
function code(x, y, z) return fma(x, y, Float64(z * Float64(5.0 + x))) end
code[x_, y_, z_] := N[(x * y + N[(z * N[(5.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (x * y) + (z * ((5) + x)) END code
\mathsf{fma}\left(x, y, z \cdot \left(5 + x\right)\right)
Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites98.9%
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (* x (+ y z))))
(if (<= x -14298.649587223466)
t_0
(if (<= x 0.00053302600741813) (fma x y (* z 5.0)) t_0))))double code(double x, double y, double z) {
double t_0 = x * (y + z);
double tmp;
if (x <= -14298.649587223466) {
tmp = t_0;
} else if (x <= 0.00053302600741813) {
tmp = fma(x, y, (z * 5.0));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x * Float64(y + z)) tmp = 0.0 if (x <= -14298.649587223466) tmp = t_0; elseif (x <= 0.00053302600741813) tmp = fma(x, y, Float64(z * 5.0)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -14298.649587223466], t$95$0, If[LessEqual[x, 0.00053302600741813], N[(x * y + N[(z * 5.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET t_0 = (x * (y + z)) IN LET tmp_1 = IF (x <= (533026007418130050134752462298592945444397628307342529296875e-63)) THEN ((x * y) + (z * (5))) ELSE t_0 ENDIF IN LET tmp = IF (x <= (-14298649587223466369323432445526123046875e-36)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x \cdot \left(y + z\right)\\
\mathbf{if}\;x \leq -14298.649587223466:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 0.00053302600741813:\\
\;\;\;\;\mathsf{fma}\left(x, y, z \cdot 5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -14298.649587223466 or 5.3302600741813005e-4 < x Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites88.5%
Taylor expanded in x around inf
Applied rewrites64.7%
if -14298.649587223466 < x < 5.3302600741813005e-4Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites75.7%
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (* x (+ y z))))
(if (<= x -2.8368855981903414e-51)
t_0
(if (<= x 8858021122195.69) (fma 5.0 z (* x z)) t_0))))double code(double x, double y, double z) {
double t_0 = x * (y + z);
double tmp;
if (x <= -2.8368855981903414e-51) {
tmp = t_0;
} else if (x <= 8858021122195.69) {
tmp = fma(5.0, z, (x * z));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x * Float64(y + z)) tmp = 0.0 if (x <= -2.8368855981903414e-51) tmp = t_0; elseif (x <= 8858021122195.69) tmp = fma(5.0, z, Float64(x * z)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.8368855981903414e-51], t$95$0, If[LessEqual[x, 8858021122195.69], N[(5.0 * z + N[(x * z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET t_0 = (x * (y + z)) IN LET tmp_1 = IF (x <= (8858021122195689453125e-9)) THEN (((5) * z) + (x * z)) ELSE t_0 ENDIF IN LET tmp = IF (x <= (-28368855981903414102920337465896913142028897505741484614367286972627935745057502704794255345263793652131194254318143559929623156480593682005064692930318415164947509765625e-220)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x \cdot \left(y + z\right)\\
\mathbf{if}\;x \leq -2.8368855981903414 \cdot 10^{-51}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 8858021122195.69:\\
\;\;\;\;\mathsf{fma}\left(5, z, x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -2.8368855981903414e-51 or 8858021122195.6895 < x Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites88.5%
Taylor expanded in x around inf
Applied rewrites64.7%
if -2.8368855981903414e-51 < x < 8858021122195.6895Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites62.4%
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (* x (+ y z))))
(if (<= x -2.8368855981903414e-51)
t_0
(if (<= x 8858021122195.69) (* z (+ 5.0 x)) t_0))))double code(double x, double y, double z) {
double t_0 = x * (y + z);
double tmp;
if (x <= -2.8368855981903414e-51) {
tmp = t_0;
} else if (x <= 8858021122195.69) {
tmp = z * (5.0 + x);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * (y + z)
if (x <= (-2.8368855981903414d-51)) then
tmp = t_0
else if (x <= 8858021122195.69d0) then
tmp = z * (5.0d0 + x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y + z);
double tmp;
if (x <= -2.8368855981903414e-51) {
tmp = t_0;
} else if (x <= 8858021122195.69) {
tmp = z * (5.0 + x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y + z) tmp = 0 if x <= -2.8368855981903414e-51: tmp = t_0 elif x <= 8858021122195.69: tmp = z * (5.0 + x) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y + z)) tmp = 0.0 if (x <= -2.8368855981903414e-51) tmp = t_0; elseif (x <= 8858021122195.69) tmp = Float64(z * Float64(5.0 + x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y + z); tmp = 0.0; if (x <= -2.8368855981903414e-51) tmp = t_0; elseif (x <= 8858021122195.69) tmp = z * (5.0 + x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.8368855981903414e-51], t$95$0, If[LessEqual[x, 8858021122195.69], N[(z * N[(5.0 + x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET t_0 = (x * (y + z)) IN LET tmp_1 = IF (x <= (8858021122195689453125e-9)) THEN (z * ((5) + x)) ELSE t_0 ENDIF IN LET tmp = IF (x <= (-28368855981903414102920337465896913142028897505741484614367286972627935745057502704794255345263793652131194254318143559929623156480593682005064692930318415164947509765625e-220)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x \cdot \left(y + z\right)\\
\mathbf{if}\;x \leq -2.8368855981903414 \cdot 10^{-51}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 8858021122195.69:\\
\;\;\;\;z \cdot \left(5 + x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -2.8368855981903414e-51 or 8858021122195.6895 < x Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites88.5%
Taylor expanded in x around inf
Applied rewrites64.7%
if -2.8368855981903414e-51 < x < 8858021122195.6895Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites62.4%
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (* x (+ y z))))
(if (<= x -2.8368855981903414e-51)
t_0
(if (<= x 9.957315309628584e-34) (* 5.0 z) t_0))))double code(double x, double y, double z) {
double t_0 = x * (y + z);
double tmp;
if (x <= -2.8368855981903414e-51) {
tmp = t_0;
} else if (x <= 9.957315309628584e-34) {
tmp = 5.0 * z;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * (y + z)
if (x <= (-2.8368855981903414d-51)) then
tmp = t_0
else if (x <= 9.957315309628584d-34) then
tmp = 5.0d0 * z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y + z);
double tmp;
if (x <= -2.8368855981903414e-51) {
tmp = t_0;
} else if (x <= 9.957315309628584e-34) {
tmp = 5.0 * z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y + z) tmp = 0 if x <= -2.8368855981903414e-51: tmp = t_0 elif x <= 9.957315309628584e-34: tmp = 5.0 * z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y + z)) tmp = 0.0 if (x <= -2.8368855981903414e-51) tmp = t_0; elseif (x <= 9.957315309628584e-34) tmp = Float64(5.0 * z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y + z); tmp = 0.0; if (x <= -2.8368855981903414e-51) tmp = t_0; elseif (x <= 9.957315309628584e-34) tmp = 5.0 * z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.8368855981903414e-51], t$95$0, If[LessEqual[x, 9.957315309628584e-34], N[(5.0 * z), $MachinePrecision], t$95$0]]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET t_0 = (x * (y + z)) IN LET tmp_1 = IF (x <= (995731530962858429324473884117268777133337992305983115666935440622549596510538661930608296535272216942757950164377689361572265625e-162)) THEN ((5) * z) ELSE t_0 ENDIF IN LET tmp = IF (x <= (-28368855981903414102920337465896913142028897505741484614367286972627935745057502704794255345263793652131194254318143559929623156480593682005064692930318415164947509765625e-220)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x \cdot \left(y + z\right)\\
\mathbf{if}\;x \leq -2.8368855981903414 \cdot 10^{-51}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9.957315309628584 \cdot 10^{-34}:\\
\;\;\;\;5 \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -2.8368855981903414e-51 or 9.9573153096285843e-34 < x Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites88.5%
Taylor expanded in x around inf
Applied rewrites64.7%
if -2.8368855981903414e-51 < x < 9.9573153096285843e-34Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites36.9%
(FPCore (x y z) :precision binary64 :pre TRUE (* 5.0 z))
double code(double x, double y, double z) {
return 5.0 * z;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 5.0d0 * z
end function
public static double code(double x, double y, double z) {
return 5.0 * z;
}
def code(x, y, z): return 5.0 * z
function code(x, y, z) return Float64(5.0 * z) end
function tmp = code(x, y, z) tmp = 5.0 * z; end
code[x_, y_, z_] := N[(5.0 * z), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (5) * z END code
5 \cdot z
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites36.9%
herbie shell --seed 2026092
(FPCore (x y z)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, C"
:precision binary64
(+ (* x (+ y z)) (* z 5.0)))