
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= z -4e+63) (not (<= z 5.8e+15))) (- (* x (/ y z)) x) (* (/ x z) (- (+ y 1.0) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4e+63) || !(z <= 5.8e+15)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) * ((y + 1.0) - z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-4d+63)) .or. (.not. (z <= 5.8d+15))) then
tmp = (x * (y / z)) - x
else
tmp = (x / z) * ((y + 1.0d0) - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4e+63) || !(z <= 5.8e+15)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) * ((y + 1.0) - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4e+63) or not (z <= 5.8e+15): tmp = (x * (y / z)) - x else: tmp = (x / z) * ((y + 1.0) - z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4e+63) || !(z <= 5.8e+15)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(x / z) * Float64(Float64(y + 1.0) - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4e+63) || ~((z <= 5.8e+15))) tmp = (x * (y / z)) - x; else tmp = (x / z) * ((y + 1.0) - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4e+63], N[Not[LessEqual[z, 5.8e+15]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(N[(y + 1.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4 \cdot 10^{+63} \lor \neg \left(z \leq 5.8 \cdot 10^{+15}\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(\left(y + 1\right) - z\right)\\
\end{array}
\end{array}
if z < -4.00000000000000023e63 or 5.8e15 < z Initial program 72.4%
Simplified86.8%
Taylor expanded in y around inf 86.8%
associate-/l*96.3%
associate-/r/99.9%
Simplified99.9%
if -4.00000000000000023e63 < z < 5.8e15Initial program 99.2%
associate-/l*94.2%
Simplified94.2%
Taylor expanded in x around 0 99.2%
associate-*l/99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- y z) 1.0)))
(if (<= (/ (* x t_0) z) 2e-15)
(/ x (/ z t_0))
(* (/ x z) (- (+ y 1.0) z)))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (((x * t_0) / z) <= 2e-15) {
tmp = x / (z / t_0);
} else {
tmp = (x / z) * ((y + 1.0) - z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (y - z) + 1.0d0
if (((x * t_0) / z) <= 2d-15) then
tmp = x / (z / t_0)
else
tmp = (x / z) * ((y + 1.0d0) - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (((x * t_0) / z) <= 2e-15) {
tmp = x / (z / t_0);
} else {
tmp = (x / z) * ((y + 1.0) - z);
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if ((x * t_0) / z) <= 2e-15: tmp = x / (z / t_0) else: tmp = (x / z) * ((y + 1.0) - z) return tmp
function code(x, y, z) t_0 = Float64(Float64(y - z) + 1.0) tmp = 0.0 if (Float64(Float64(x * t_0) / z) <= 2e-15) tmp = Float64(x / Float64(z / t_0)); else tmp = Float64(Float64(x / z) * Float64(Float64(y + 1.0) - z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if (((x * t_0) / z) <= 2e-15) tmp = x / (z / t_0); else tmp = (x / z) * ((y + 1.0) - z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], 2e-15], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(N[(y + 1.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;\frac{x \cdot t_0}{z} \leq 2 \cdot 10^{-15}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(\left(y + 1\right) - z\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 2.0000000000000002e-15Initial program 90.0%
associate-/l*98.3%
Simplified98.3%
if 2.0000000000000002e-15 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 80.8%
associate-/l*93.6%
Simplified93.6%
Taylor expanded in x around 0 80.8%
associate-*l/99.8%
Simplified99.8%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -8.0) (not (<= y 7.2e-7))) (- (* x (/ y z)) x) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8.0) || !(y <= 7.2e-7)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) - x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-8.0d0)) .or. (.not. (y <= 7.2d-7))) then
tmp = (x * (y / z)) - x
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -8.0) || !(y <= 7.2e-7)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8.0) or not (y <= 7.2e-7): tmp = (x * (y / z)) - x else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8.0) || !(y <= 7.2e-7)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -8.0) || ~((y <= 7.2e-7))) tmp = (x * (y / z)) - x; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8.0], N[Not[LessEqual[y, 7.2e-7]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \lor \neg \left(y \leq 7.2 \cdot 10^{-7}\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -8 or 7.19999999999999989e-7 < y Initial program 84.1%
Simplified87.5%
Taylor expanded in y around inf 87.5%
associate-/l*96.6%
associate-/r/92.7%
Simplified92.7%
if -8 < y < 7.19999999999999989e-7Initial program 90.1%
Simplified100.0%
Taylor expanded in y around 0 99.5%
Final simplification96.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -8.0) (not (<= y 7.2e-7))) (- (/ y (/ z x)) x) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8.0) || !(y <= 7.2e-7)) {
tmp = (y / (z / x)) - x;
} else {
tmp = (x / z) - x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-8.0d0)) .or. (.not. (y <= 7.2d-7))) then
tmp = (y / (z / x)) - x
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -8.0) || !(y <= 7.2e-7)) {
tmp = (y / (z / x)) - x;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8.0) or not (y <= 7.2e-7): tmp = (y / (z / x)) - x else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8.0) || !(y <= 7.2e-7)) tmp = Float64(Float64(y / Float64(z / x)) - x); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -8.0) || ~((y <= 7.2e-7))) tmp = (y / (z / x)) - x; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8.0], N[Not[LessEqual[y, 7.2e-7]], $MachinePrecision]], N[(N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \lor \neg \left(y \leq 7.2 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{y}{\frac{z}{x}} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -8 or 7.19999999999999989e-7 < y Initial program 84.1%
Simplified87.5%
Taylor expanded in y around inf 87.5%
associate-/l*96.6%
Simplified96.6%
if -8 < y < 7.19999999999999989e-7Initial program 90.1%
Simplified100.0%
Taylor expanded in y around 0 99.5%
Final simplification98.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -34000000000.0) (not (<= z 20000000000.0))) (- (* x (/ y z)) x) (/ (+ x (* x y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -34000000000.0) || !(z <= 20000000000.0)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x + (x * y)) / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-34000000000.0d0)) .or. (.not. (z <= 20000000000.0d0))) then
tmp = (x * (y / z)) - x
else
tmp = (x + (x * y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -34000000000.0) || !(z <= 20000000000.0)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x + (x * y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -34000000000.0) or not (z <= 20000000000.0): tmp = (x * (y / z)) - x else: tmp = (x + (x * y)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -34000000000.0) || !(z <= 20000000000.0)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(x + Float64(x * y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -34000000000.0) || ~((z <= 20000000000.0))) tmp = (x * (y / z)) - x; else tmp = (x + (x * y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -34000000000.0], N[Not[LessEqual[z, 20000000000.0]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -34000000000 \lor \neg \left(z \leq 20000000000\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\
\end{array}
\end{array}
if z < -3.4e10 or 2e10 < z Initial program 74.4%
Simplified87.4%
Taylor expanded in y around inf 87.3%
associate-/l*96.5%
associate-/r/99.8%
Simplified99.8%
if -3.4e10 < z < 2e10Initial program 99.9%
distribute-lft-in99.9%
fma-def99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in z around 0 99.2%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -7e+104) (not (<= y 310000000000.0))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7e+104) || !(y <= 310000000000.0)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-7d+104)) .or. (.not. (y <= 310000000000.0d0))) then
tmp = y * (x / z)
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -7e+104) || !(y <= 310000000000.0)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7e+104) or not (y <= 310000000000.0): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7e+104) || !(y <= 310000000000.0)) tmp = Float64(y * Float64(x / z)); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7e+104) || ~((y <= 310000000000.0))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7e+104], N[Not[LessEqual[y, 310000000000.0]], $MachinePrecision]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+104} \lor \neg \left(y \leq 310000000000\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -7.0000000000000003e104 or 3.1e11 < y Initial program 83.0%
associate-/l*92.6%
Simplified92.6%
Taylor expanded in y around inf 69.0%
associate-/r/73.9%
Applied egg-rr73.9%
if -7.0000000000000003e104 < y < 3.1e11Initial program 90.1%
Simplified99.3%
Taylor expanded in y around 0 95.1%
Final simplification85.9%
(FPCore (x y z) :precision binary64 (if (<= z -3.45e+44) (- x) (if (<= z 29000000000.0) (* y (/ x z)) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.45e+44) {
tmp = -x;
} else if (z <= 29000000000.0) {
tmp = y * (x / z);
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-3.45d+44)) then
tmp = -x
else if (z <= 29000000000.0d0) then
tmp = y * (x / z)
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.45e+44) {
tmp = -x;
} else if (z <= 29000000000.0) {
tmp = y * (x / z);
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.45e+44: tmp = -x elif z <= 29000000000.0: tmp = y * (x / z) else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.45e+44) tmp = Float64(-x); elseif (z <= 29000000000.0) tmp = Float64(y * Float64(x / z)); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.45e+44) tmp = -x; elseif (z <= 29000000000.0) tmp = y * (x / z); else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.45e+44], (-x), If[LessEqual[z, 29000000000.0], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.45 \cdot 10^{+44}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 29000000000:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -3.4499999999999999e44 or 2.9e10 < z Initial program 73.9%
Simplified87.6%
Taylor expanded in z around inf 81.3%
neg-mul-181.3%
Simplified81.3%
if -3.4499999999999999e44 < z < 2.9e10Initial program 99.2%
associate-/l*93.9%
Simplified93.9%
Taylor expanded in y around inf 48.5%
associate-/r/59.4%
Applied egg-rr59.4%
Final simplification69.9%
(FPCore (x y z) :precision binary64 (if (<= z -34000000000.0) (- x) (if (<= z 20000000000.0) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -34000000000.0) {
tmp = -x;
} else if (z <= 20000000000.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-34000000000.0d0)) then
tmp = -x
else if (z <= 20000000000.0d0) then
tmp = x / z
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -34000000000.0) {
tmp = -x;
} else if (z <= 20000000000.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -34000000000.0: tmp = -x elif z <= 20000000000.0: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -34000000000.0) tmp = Float64(-x); elseif (z <= 20000000000.0) tmp = Float64(x / z); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -34000000000.0) tmp = -x; elseif (z <= 20000000000.0) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -34000000000.0], (-x), If[LessEqual[z, 20000000000.0], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -34000000000:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 20000000000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -3.4e10 or 2e10 < z Initial program 74.4%
Simplified87.4%
Taylor expanded in z around inf 79.2%
neg-mul-179.2%
Simplified79.2%
if -3.4e10 < z < 2e10Initial program 99.9%
Simplified99.9%
Taylor expanded in y around 0 56.0%
Taylor expanded in z around 0 55.5%
Final simplification67.4%
(FPCore (x y z) :precision binary64 (- x))
double code(double x, double y, double z) {
return -x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -x
end function
public static double code(double x, double y, double z) {
return -x;
}
def code(x, y, z): return -x
function code(x, y, z) return Float64(-x) end
function tmp = code(x, y, z) tmp = -x; end
code[x_, y_, z_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 87.0%
Simplified93.6%
Taylor expanded in z around inf 41.5%
neg-mul-141.5%
Simplified41.5%
Final simplification41.5%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 87.0%
Taylor expanded in z around inf 31.1%
associate-*r*31.1%
neg-mul-131.1%
Simplified31.1%
expm1-log1p-u25.4%
expm1-udef8.2%
associate-/l*14.8%
div-inv15.5%
add-sqr-sqrt7.6%
sqrt-unprod5.2%
sqr-neg5.2%
sqrt-unprod4.2%
add-sqr-sqrt5.3%
clear-num5.3%
Applied egg-rr5.3%
expm1-def5.3%
expm1-log1p9.2%
associate-*r/2.8%
associate-*l/2.9%
*-inverses2.9%
*-lft-identity2.9%
Simplified2.9%
Final simplification2.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (+ 1.0 y) (/ x z)) x)))
(if (< x -2.71483106713436e-162)
t_0
(if (< x 3.874108816439546e-197)
(* (* x (+ (- y z) 1.0)) (/ 1.0 z))
t_0))))
double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 + y) * (x / z)) - x
if (x < (-2.71483106713436d-162)) then
tmp = t_0
else if (x < 3.874108816439546d-197) then
tmp = (x * ((y - z) + 1.0d0)) * (1.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 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((1.0 + y) * (x / z)) - x tmp = 0 if x < -2.71483106713436e-162: tmp = t_0 elif x < 3.874108816439546e-197: tmp = (x * ((y - z) + 1.0)) * (1.0 / z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(1.0 + y) * Float64(x / z)) - x) tmp = 0.0 if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) * Float64(1.0 / z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((1.0 + y) * (x / z)) - x; tmp = 0.0; if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = (x * ((y - z) + 1.0)) * (1.0 / z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[Less[x, -2.71483106713436e-162], t$95$0, If[Less[x, 3.874108816439546e-197], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\
\mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\
\;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
herbie shell --seed 2023224
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))
(/ (* x (+ (- y z) 1.0)) z))