
(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
(let* ((t_0 (+ (- y z) 1.0)))
(if (<= (/ (* x t_0) z) 5e-93)
(/ 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) <= 5e-93) {
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) <= 5d-93) 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) <= 5e-93) {
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) <= 5e-93: 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) <= 5e-93) 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) <= 5e-93) 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], 5e-93], 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 5 \cdot 10^{-93}:\\
\;\;\;\;\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) < 4.99999999999999994e-93Initial program 89.9%
associate-/l*99.2%
Simplified99.2%
if 4.99999999999999994e-93 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 83.8%
associate-/l*95.5%
Simplified95.5%
Taylor expanded in x around 0 83.8%
associate--l+83.8%
+-commutative83.8%
associate-*l/99.9%
+-commutative99.9%
associate--l+99.9%
Simplified99.9%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -1.5e+71)
(- x)
(if (<= z -1.8e-50)
t_0
(if (<= z -4.5e-130)
(/ x z)
(if (<= z -4.8e-180)
t_0
(if (<= z 5e-235) (/ x z) (if (<= z 1.15e+39) t_0 (- x)))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -1.5e+71) {
tmp = -x;
} else if (z <= -1.8e-50) {
tmp = t_0;
} else if (z <= -4.5e-130) {
tmp = x / z;
} else if (z <= -4.8e-180) {
tmp = t_0;
} else if (z <= 5e-235) {
tmp = x / z;
} else if (z <= 1.15e+39) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y * (x / z)
if (z <= (-1.5d+71)) then
tmp = -x
else if (z <= (-1.8d-50)) then
tmp = t_0
else if (z <= (-4.5d-130)) then
tmp = x / z
else if (z <= (-4.8d-180)) then
tmp = t_0
else if (z <= 5d-235) then
tmp = x / z
else if (z <= 1.15d+39) then
tmp = t_0
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -1.5e+71) {
tmp = -x;
} else if (z <= -1.8e-50) {
tmp = t_0;
} else if (z <= -4.5e-130) {
tmp = x / z;
} else if (z <= -4.8e-180) {
tmp = t_0;
} else if (z <= 5e-235) {
tmp = x / z;
} else if (z <= 1.15e+39) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -1.5e+71: tmp = -x elif z <= -1.8e-50: tmp = t_0 elif z <= -4.5e-130: tmp = x / z elif z <= -4.8e-180: tmp = t_0 elif z <= 5e-235: tmp = x / z elif z <= 1.15e+39: tmp = t_0 else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (z <= -1.5e+71) tmp = Float64(-x); elseif (z <= -1.8e-50) tmp = t_0; elseif (z <= -4.5e-130) tmp = Float64(x / z); elseif (z <= -4.8e-180) tmp = t_0; elseif (z <= 5e-235) tmp = Float64(x / z); elseif (z <= 1.15e+39) tmp = t_0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x / z); tmp = 0.0; if (z <= -1.5e+71) tmp = -x; elseif (z <= -1.8e-50) tmp = t_0; elseif (z <= -4.5e-130) tmp = x / z; elseif (z <= -4.8e-180) tmp = t_0; elseif (z <= 5e-235) tmp = x / z; elseif (z <= 1.15e+39) tmp = t_0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.5e+71], (-x), If[LessEqual[z, -1.8e-50], t$95$0, If[LessEqual[z, -4.5e-130], N[(x / z), $MachinePrecision], If[LessEqual[z, -4.8e-180], t$95$0, If[LessEqual[z, 5e-235], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.15e+39], t$95$0, (-x)]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -1.5 \cdot 10^{+71}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -1.8 \cdot 10^{-50}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -4.5 \cdot 10^{-130}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq -4.8 \cdot 10^{-180}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 5 \cdot 10^{-235}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{+39}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.50000000000000006e71 or 1.15000000000000006e39 < z Initial program 67.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around inf 88.2%
neg-mul-188.2%
Simplified88.2%
if -1.50000000000000006e71 < z < -1.7999999999999999e-50 or -4.5e-130 < z < -4.79999999999999959e-180 or 4.9999999999999998e-235 < z < 1.15000000000000006e39Initial program 98.7%
associate-/l*94.8%
Simplified94.8%
Taylor expanded in y around inf 64.1%
associate-/l*68.1%
Simplified68.1%
clear-num68.1%
associate-/r/68.1%
clear-num68.1%
Applied egg-rr68.1%
if -1.7999999999999999e-50 < z < -4.5e-130 or -4.79999999999999959e-180 < z < 4.9999999999999998e-235Initial program 99.9%
associate-/l*98.2%
Simplified98.2%
Taylor expanded in z around 0 98.2%
Taylor expanded in y around 0 77.4%
Final simplification78.1%
(FPCore (x y z)
:precision binary64
(if (<= z -1.5e+71)
(- x)
(if (<= z -3.2e+20)
(* x (/ (+ y 1.0) z))
(if (<= z -12000000.0)
(- (/ x z) x)
(if (<= z 8e+38) (/ (+ x (* x y)) z) (- x))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.5e+71) {
tmp = -x;
} else if (z <= -3.2e+20) {
tmp = x * ((y + 1.0) / z);
} else if (z <= -12000000.0) {
tmp = (x / z) - x;
} else if (z <= 8e+38) {
tmp = (x + (x * y)) / 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 <= (-1.5d+71)) then
tmp = -x
else if (z <= (-3.2d+20)) then
tmp = x * ((y + 1.0d0) / z)
else if (z <= (-12000000.0d0)) then
tmp = (x / z) - x
else if (z <= 8d+38) then
tmp = (x + (x * y)) / z
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.5e+71) {
tmp = -x;
} else if (z <= -3.2e+20) {
tmp = x * ((y + 1.0) / z);
} else if (z <= -12000000.0) {
tmp = (x / z) - x;
} else if (z <= 8e+38) {
tmp = (x + (x * y)) / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.5e+71: tmp = -x elif z <= -3.2e+20: tmp = x * ((y + 1.0) / z) elif z <= -12000000.0: tmp = (x / z) - x elif z <= 8e+38: tmp = (x + (x * y)) / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.5e+71) tmp = Float64(-x); elseif (z <= -3.2e+20) tmp = Float64(x * Float64(Float64(y + 1.0) / z)); elseif (z <= -12000000.0) tmp = Float64(Float64(x / z) - x); elseif (z <= 8e+38) tmp = Float64(Float64(x + Float64(x * y)) / z); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.5e+71) tmp = -x; elseif (z <= -3.2e+20) tmp = x * ((y + 1.0) / z); elseif (z <= -12000000.0) tmp = (x / z) - x; elseif (z <= 8e+38) tmp = (x + (x * y)) / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.5e+71], (-x), If[LessEqual[z, -3.2e+20], N[(x * N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -12000000.0], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[z, 8e+38], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], (-x)]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+71}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -3.2 \cdot 10^{+20}:\\
\;\;\;\;x \cdot \frac{y + 1}{z}\\
\mathbf{elif}\;z \leq -12000000:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{elif}\;z \leq 8 \cdot 10^{+38}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.50000000000000006e71 or 7.99999999999999982e38 < z Initial program 67.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around inf 88.2%
neg-mul-188.2%
Simplified88.2%
if -1.50000000000000006e71 < z < -3.2e20Initial program 90.9%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in z around 0 82.9%
clear-num83.0%
associate-/r/83.0%
clear-num83.3%
+-commutative83.3%
Applied egg-rr83.3%
if -3.2e20 < z < -1.2e7Initial program 99.6%
associate-/l*100.0%
Simplified100.0%
clear-num100.0%
associate-/r/99.6%
clear-num100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 99.6%
sub-neg99.6%
+-commutative99.6%
distribute-rgt1-in99.6%
cancel-sign-sub-inv99.6%
div-sub100.0%
associate-*l/100.0%
*-inverses100.0%
*-lft-identity100.0%
Simplified100.0%
if -1.2e7 < z < 7.99999999999999982e38Initial program 99.8%
distribute-lft-in99.8%
fma-def99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in z around 0 96.4%
Final simplification92.8%
(FPCore (x y z) :precision binary64 (if (<= z -2.2e+72) (- x) (if (<= z 1.4e+39) (/ x (/ z (+ y 1.0))) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.2e+72) {
tmp = -x;
} else if (z <= 1.4e+39) {
tmp = x / (z / (y + 1.0));
} 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 <= (-2.2d+72)) then
tmp = -x
else if (z <= 1.4d+39) then
tmp = x / (z / (y + 1.0d0))
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.2e+72) {
tmp = -x;
} else if (z <= 1.4e+39) {
tmp = x / (z / (y + 1.0));
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.2e+72: tmp = -x elif z <= 1.4e+39: tmp = x / (z / (y + 1.0)) else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.2e+72) tmp = Float64(-x); elseif (z <= 1.4e+39) tmp = Float64(x / Float64(z / Float64(y + 1.0))); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.2e+72) tmp = -x; elseif (z <= 1.4e+39) tmp = x / (z / (y + 1.0)); else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.2e+72], (-x), If[LessEqual[z, 1.4e+39], N[(x / N[(z / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{+72}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{+39}:\\
\;\;\;\;\frac{x}{\frac{z}{y + 1}}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -2.2e72 or 1.40000000000000001e39 < z Initial program 67.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around inf 88.2%
neg-mul-188.2%
Simplified88.2%
if -2.2e72 < z < 1.40000000000000001e39Initial program 99.2%
associate-/l*96.2%
Simplified96.2%
Taylor expanded in z around 0 89.8%
Final simplification89.2%
(FPCore (x y z) :precision binary64 (if (<= z -1.32e+129) (- x) (* (/ x z) (- (+ y 1.0) z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.32e+129) {
tmp = -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 <= (-1.32d+129)) then
tmp = -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 <= -1.32e+129) {
tmp = -x;
} else {
tmp = (x / z) * ((y + 1.0) - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.32e+129: tmp = -x else: tmp = (x / z) * ((y + 1.0) - z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.32e+129) tmp = Float64(-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 <= -1.32e+129) tmp = -x; else tmp = (x / z) * ((y + 1.0) - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.32e+129], (-x), N[(N[(x / z), $MachinePrecision] * N[(N[(y + 1.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.32 \cdot 10^{+129}:\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(\left(y + 1\right) - z\right)\\
\end{array}
\end{array}
if z < -1.32e129Initial program 64.3%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around inf 93.7%
neg-mul-193.7%
Simplified93.7%
if -1.32e129 < z Initial program 92.2%
associate-/l*97.2%
Simplified97.2%
Taylor expanded in x around 0 92.2%
associate--l+92.2%
+-commutative92.2%
associate-*l/95.4%
+-commutative95.4%
associate--l+95.4%
Simplified95.4%
Final simplification95.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -85000000.0) (not (<= y 6.5e+79))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -85000000.0) || !(y <= 6.5e+79)) {
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 <= (-85000000.0d0)) .or. (.not. (y <= 6.5d+79))) 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 <= -85000000.0) || !(y <= 6.5e+79)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -85000000.0) or not (y <= 6.5e+79): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -85000000.0) || !(y <= 6.5e+79)) 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 <= -85000000.0) || ~((y <= 6.5e+79))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -85000000.0], N[Not[LessEqual[y, 6.5e+79]], $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 -85000000 \lor \neg \left(y \leq 6.5 \cdot 10^{+79}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -8.5e7 or 6.49999999999999954e79 < y Initial program 89.8%
associate-/l*93.8%
Simplified93.8%
Taylor expanded in y around inf 77.3%
associate-/l*78.7%
Simplified78.7%
clear-num78.7%
associate-/r/78.7%
clear-num78.7%
Applied egg-rr78.7%
if -8.5e7 < y < 6.49999999999999954e79Initial program 85.9%
associate-/l*99.9%
Simplified99.9%
clear-num99.6%
associate-/r/99.8%
clear-num99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 80.3%
sub-neg80.3%
+-commutative80.3%
distribute-rgt1-in80.3%
cancel-sign-sub-inv80.3%
div-sub80.3%
associate-*l/94.3%
*-inverses94.3%
*-lft-identity94.3%
Simplified94.3%
Final simplification88.5%
(FPCore (x y z) :precision binary64 (if (<= y -17500000.0) (* y (/ x z)) (if (<= y 1.35e+80) (- (/ x z) x) (/ y (/ z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -17500000.0) {
tmp = y * (x / z);
} else if (y <= 1.35e+80) {
tmp = (x / z) - x;
} else {
tmp = y / (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 <= (-17500000.0d0)) then
tmp = y * (x / z)
else if (y <= 1.35d+80) then
tmp = (x / z) - x
else
tmp = y / (z / x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -17500000.0) {
tmp = y * (x / z);
} else if (y <= 1.35e+80) {
tmp = (x / z) - x;
} else {
tmp = y / (z / x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -17500000.0: tmp = y * (x / z) elif y <= 1.35e+80: tmp = (x / z) - x else: tmp = y / (z / x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -17500000.0) tmp = Float64(y * Float64(x / z)); elseif (y <= 1.35e+80) tmp = Float64(Float64(x / z) - x); else tmp = Float64(y / Float64(z / x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -17500000.0) tmp = y * (x / z); elseif (y <= 1.35e+80) tmp = (x / z) - x; else tmp = y / (z / x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -17500000.0], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e+80], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -17500000:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+80}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\end{array}
\end{array}
if y < -1.75e7Initial program 94.1%
associate-/l*93.6%
Simplified93.6%
Taylor expanded in y around inf 79.1%
associate-/l*81.0%
Simplified81.0%
clear-num81.0%
associate-/r/81.0%
clear-num81.1%
Applied egg-rr81.1%
if -1.75e7 < y < 1.34999999999999991e80Initial program 85.9%
associate-/l*99.9%
Simplified99.9%
clear-num99.6%
associate-/r/99.8%
clear-num99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 80.3%
sub-neg80.3%
+-commutative80.3%
distribute-rgt1-in80.3%
cancel-sign-sub-inv80.3%
div-sub80.3%
associate-*l/94.3%
*-inverses94.3%
*-lft-identity94.3%
Simplified94.3%
if 1.34999999999999991e80 < y Initial program 85.1%
associate-/l*94.1%
Simplified94.1%
Taylor expanded in y around inf 75.3%
associate-/l*76.1%
Simplified76.1%
Final simplification88.5%
(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(x * Float64(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[(x * N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\left(y - z\right) + 1}{z}
\end{array}
Initial program 87.3%
associate-/l*97.7%
Simplified97.7%
clear-num97.4%
associate-/r/96.8%
clear-num96.9%
Applied egg-rr96.9%
Final simplification96.9%
(FPCore (x y z) :precision binary64 (if (<= z -960.0) (- x) (if (<= z 1.25) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -960.0) {
tmp = -x;
} else if (z <= 1.25) {
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 <= (-960.0d0)) then
tmp = -x
else if (z <= 1.25d0) 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 <= -960.0) {
tmp = -x;
} else if (z <= 1.25) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -960.0: tmp = -x elif z <= 1.25: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -960.0) tmp = Float64(-x); elseif (z <= 1.25) tmp = Float64(x / z); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -960.0) tmp = -x; elseif (z <= 1.25) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -960.0], (-x), If[LessEqual[z, 1.25], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -960:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1.25:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -960 or 1.25 < z Initial program 73.4%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 77.4%
neg-mul-177.4%
Simplified77.4%
if -960 < z < 1.25Initial program 99.8%
associate-/l*95.6%
Simplified95.6%
Taylor expanded in z around 0 94.9%
Taylor expanded in y around 0 57.3%
Final simplification66.8%
(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.3%
associate-/l*97.7%
Simplified97.7%
Taylor expanded in z around inf 38.2%
neg-mul-138.2%
Simplified38.2%
Final simplification38.2%
(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 2023223
(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))