
(FPCore (x y z) :precision binary64 :pre TRUE (/ (* x (- y z)) y))
double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
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)) / y
end function
public static double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
def code(x, y, z): return (x * (y - z)) / y
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $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)) / y END code
\frac{x \cdot \left(y - z\right)}{y}
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 :pre TRUE (/ (* x (- y z)) y))
double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
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)) / y
end function
public static double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
def code(x, y, z): return (x * (y - z)) / y
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $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)) / y END code
\frac{x \cdot \left(y - z\right)}{y}
(FPCore (x y z) :precision binary64 :pre TRUE (* (copysign 1.0 x) (if (<= (fabs x) 1.8648747152849905e-81) (/ (* (fabs x) (- y z)) y) (- (fabs x) (* (fabs x) (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (fabs(x) <= 1.8648747152849905e-81) {
tmp = (fabs(x) * (y - z)) / y;
} else {
tmp = fabs(x) - (fabs(x) * (z / y));
}
return copysign(1.0, x) * tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (Math.abs(x) <= 1.8648747152849905e-81) {
tmp = (Math.abs(x) * (y - z)) / y;
} else {
tmp = Math.abs(x) - (Math.abs(x) * (z / y));
}
return Math.copySign(1.0, x) * tmp;
}
def code(x, y, z): tmp = 0 if math.fabs(x) <= 1.8648747152849905e-81: tmp = (math.fabs(x) * (y - z)) / y else: tmp = math.fabs(x) - (math.fabs(x) * (z / y)) return math.copysign(1.0, x) * tmp
function code(x, y, z) tmp = 0.0 if (abs(x) <= 1.8648747152849905e-81) tmp = Float64(Float64(abs(x) * Float64(y - z)) / y); else tmp = Float64(abs(x) - Float64(abs(x) * Float64(z / y))); end return Float64(copysign(1.0, x) * tmp) end
function tmp_2 = code(x, y, z) tmp = 0.0; if (abs(x) <= 1.8648747152849905e-81) tmp = (abs(x) * (y - z)) / y; else tmp = abs(x) - (abs(x) * (z / y)); end tmp_2 = (sign(x) * abs(1.0)) * tmp; end
code[x_, y_, z_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x], $MachinePrecision], 1.8648747152849905e-81], N[(N[(N[Abs[x], $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[Abs[x], $MachinePrecision] - N[(N[Abs[x], $MachinePrecision] * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 1.8648747152849905 \cdot 10^{-81}:\\
\;\;\;\;\frac{\left|x\right| \cdot \left(y - z\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;\left|x\right| - \left|x\right| \cdot \frac{z}{y}\\
\end{array}
if x < 1.8648747152849905e-81Initial program 84.1%
if 1.8648747152849905e-81 < x Initial program 84.1%
Applied rewrites96.4%
(FPCore (x y z) :precision binary64 :pre TRUE (* (copysign 1.0 x) (if (<= (fabs x) 1.8648747152849905e-81) (/ (* (fabs x) (- y z)) y) (* (fabs x) (/ (- y z) y)))))
double code(double x, double y, double z) {
double tmp;
if (fabs(x) <= 1.8648747152849905e-81) {
tmp = (fabs(x) * (y - z)) / y;
} else {
tmp = fabs(x) * ((y - z) / y);
}
return copysign(1.0, x) * tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (Math.abs(x) <= 1.8648747152849905e-81) {
tmp = (Math.abs(x) * (y - z)) / y;
} else {
tmp = Math.abs(x) * ((y - z) / y);
}
return Math.copySign(1.0, x) * tmp;
}
def code(x, y, z): tmp = 0 if math.fabs(x) <= 1.8648747152849905e-81: tmp = (math.fabs(x) * (y - z)) / y else: tmp = math.fabs(x) * ((y - z) / y) return math.copysign(1.0, x) * tmp
function code(x, y, z) tmp = 0.0 if (abs(x) <= 1.8648747152849905e-81) tmp = Float64(Float64(abs(x) * Float64(y - z)) / y); else tmp = Float64(abs(x) * Float64(Float64(y - z) / y)); end return Float64(copysign(1.0, x) * tmp) end
function tmp_2 = code(x, y, z) tmp = 0.0; if (abs(x) <= 1.8648747152849905e-81) tmp = (abs(x) * (y - z)) / y; else tmp = abs(x) * ((y - z) / y); end tmp_2 = (sign(x) * abs(1.0)) * tmp; end
code[x_, y_, z_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x], $MachinePrecision], 1.8648747152849905e-81], N[(N[(N[Abs[x], $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[Abs[x], $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 1.8648747152849905 \cdot 10^{-81}:\\
\;\;\;\;\frac{\left|x\right| \cdot \left(y - z\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;\left|x\right| \cdot \frac{y - z}{y}\\
\end{array}
if x < 1.8648747152849905e-81Initial program 84.1%
if 1.8648747152849905e-81 < x Initial program 84.1%
Applied rewrites96.4%
(FPCore (x y z) :precision binary64 :pre TRUE (* x (/ (- y z) y)))
double code(double x, double y, double z) {
return x * ((y - z) / y);
}
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) / y)
end function
public static double code(double x, double y, double z) {
return x * ((y - z) / y);
}
def code(x, y, z): return x * ((y - z) / y)
function code(x, y, z) return Float64(x * Float64(Float64(y - z) / y)) end
function tmp = code(x, y, z) tmp = x * ((y - z) / y); end
code[x_, y_, z_] := N[(x * N[(N[(y - z), $MachinePrecision] / y), $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) / y) END code
x \cdot \frac{y - z}{y}
Initial program 84.1%
Applied rewrites96.4%
(FPCore (x y z) :precision binary64 :pre TRUE (* x 1.0))
double code(double x, double y, double z) {
return x * 1.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 * 1.0d0
end function
public static double code(double x, double y, double z) {
return x * 1.0;
}
def code(x, y, z): return x * 1.0
function code(x, y, z) return Float64(x * 1.0) end
function tmp = code(x, y, z) tmp = x * 1.0; end
code[x_, y_, z_] := N[(x * 1.0), $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 * (1) END code
x \cdot 1
Initial program 84.1%
Applied rewrites96.4%
Taylor expanded in y around inf
Applied rewrites50.9%
herbie shell --seed 2026092
(FPCore (x y z)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
:precision binary64
(/ (* x (- y z)) y))