
(FPCore (x y z) :precision binary64 (/ (- x y) (- z y)))
double code(double x, double y, double z) {
return (x - y) / (z - y);
}
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 - 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 - y) / Float64(z - y)) end
function tmp = code(x, y, z) tmp = (x - y) / (z - y); end
code[x_, y_, z_] := N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (- x y) (- z y)))
double code(double x, double y, double z) {
return (x - y) / (z - y);
}
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 - 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 - y) / Float64(z - y)) end
function tmp = code(x, y, z) tmp = (x - y) / (z - y); end
code[x_, y_, z_] := N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - y}
\end{array}
(FPCore (x y z) :precision binary64 (/ (- x y) (- z y)))
double code(double x, double y, double z) {
return (x - y) / (z - y);
}
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 - 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 - y) / Float64(z - y)) end
function tmp = code(x, y, z) tmp = (x - y) / (z - y); end
code[x_, y_, z_] := N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - y}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -2.5e+15)
t_0
(if (<= y 4.2e-58)
(/ x z)
(if (or (<= y 1.1e+35) (not (<= y 3.05e+57))) t_0 (/ (- y) z))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -2.5e+15) {
tmp = t_0;
} else if (y <= 4.2e-58) {
tmp = x / z;
} else if ((y <= 1.1e+35) || !(y <= 3.05e+57)) {
tmp = t_0;
} else {
tmp = -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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
if (y <= (-2.5d+15)) then
tmp = t_0
else if (y <= 4.2d-58) then
tmp = x / z
else if ((y <= 1.1d+35) .or. (.not. (y <= 3.05d+57))) then
tmp = t_0
else
tmp = -y / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -2.5e+15) {
tmp = t_0;
} else if (y <= 4.2e-58) {
tmp = x / z;
} else if ((y <= 1.1e+35) || !(y <= 3.05e+57)) {
tmp = t_0;
} else {
tmp = -y / z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -2.5e+15: tmp = t_0 elif y <= 4.2e-58: tmp = x / z elif (y <= 1.1e+35) or not (y <= 3.05e+57): tmp = t_0 else: tmp = -y / z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -2.5e+15) tmp = t_0; elseif (y <= 4.2e-58) tmp = Float64(x / z); elseif ((y <= 1.1e+35) || !(y <= 3.05e+57)) tmp = t_0; else tmp = Float64(Float64(-y) / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -2.5e+15) tmp = t_0; elseif (y <= 4.2e-58) tmp = x / z; elseif ((y <= 1.1e+35) || ~((y <= 3.05e+57))) tmp = t_0; else tmp = -y / z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.5e+15], t$95$0, If[LessEqual[y, 4.2e-58], N[(x / z), $MachinePrecision], If[Or[LessEqual[y, 1.1e+35], N[Not[LessEqual[y, 3.05e+57]], $MachinePrecision]], t$95$0, N[((-y) / z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -2.5 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{-58}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+35} \lor \neg \left(y \leq 3.05 \cdot 10^{+57}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-y}{z}\\
\end{array}
\end{array}
if y < -2.5e15 or 4.19999999999999975e-58 < y < 1.0999999999999999e35 or 3.04999999999999988e57 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 75.4%
div-sub75.4%
*-inverses75.4%
Simplified75.4%
if -2.5e15 < y < 4.19999999999999975e-58Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 72.8%
if 1.0999999999999999e35 < y < 3.04999999999999988e57Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in y around 0 100.0%
neg-mul-1100.0%
distribute-neg-frac100.0%
Simplified100.0%
Final simplification74.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -4e+35)
t_0
(if (<= y 2e-54)
(/ x (- z y))
(if (or (<= y 1.75e+34) (not (<= y 2.25e+57))) t_0 (/ (- y) z))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -4e+35) {
tmp = t_0;
} else if (y <= 2e-54) {
tmp = x / (z - y);
} else if ((y <= 1.75e+34) || !(y <= 2.25e+57)) {
tmp = t_0;
} else {
tmp = -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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
if (y <= (-4d+35)) then
tmp = t_0
else if (y <= 2d-54) then
tmp = x / (z - y)
else if ((y <= 1.75d+34) .or. (.not. (y <= 2.25d+57))) then
tmp = t_0
else
tmp = -y / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -4e+35) {
tmp = t_0;
} else if (y <= 2e-54) {
tmp = x / (z - y);
} else if ((y <= 1.75e+34) || !(y <= 2.25e+57)) {
tmp = t_0;
} else {
tmp = -y / z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -4e+35: tmp = t_0 elif y <= 2e-54: tmp = x / (z - y) elif (y <= 1.75e+34) or not (y <= 2.25e+57): tmp = t_0 else: tmp = -y / z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -4e+35) tmp = t_0; elseif (y <= 2e-54) tmp = Float64(x / Float64(z - y)); elseif ((y <= 1.75e+34) || !(y <= 2.25e+57)) tmp = t_0; else tmp = Float64(Float64(-y) / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -4e+35) tmp = t_0; elseif (y <= 2e-54) tmp = x / (z - y); elseif ((y <= 1.75e+34) || ~((y <= 2.25e+57))) tmp = t_0; else tmp = -y / z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4e+35], t$95$0, If[LessEqual[y, 2e-54], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.75e+34], N[Not[LessEqual[y, 2.25e+57]], $MachinePrecision]], t$95$0, N[((-y) / z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -4 \cdot 10^{+35}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-54}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{elif}\;y \leq 1.75 \cdot 10^{+34} \lor \neg \left(y \leq 2.25 \cdot 10^{+57}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-y}{z}\\
\end{array}
\end{array}
if y < -3.9999999999999999e35 or 2.0000000000000001e-54 < y < 1.74999999999999999e34 or 2.24999999999999998e57 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 76.7%
div-sub76.7%
*-inverses76.7%
Simplified76.7%
if -3.9999999999999999e35 < y < 2.0000000000000001e-54Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
clear-num99.1%
inv-pow99.1%
Applied egg-rr99.1%
Taylor expanded in x around inf 82.4%
associate-*r/82.4%
neg-mul-182.4%
neg-sub082.4%
associate--r-82.4%
neg-sub082.4%
Simplified82.4%
Taylor expanded in x around 0 82.8%
if 1.74999999999999999e34 < y < 2.24999999999999998e57Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in y around 0 100.0%
neg-mul-1100.0%
distribute-neg-frac100.0%
Simplified100.0%
Final simplification79.9%
(FPCore (x y z)
:precision binary64
(if (<= y -8.8e+36)
1.0
(if (<= y 1.45e-55)
(/ x z)
(if (<= y 5.5e+34) 1.0 (if (<= y 9.5e+57) (/ (- y) z) 1.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.8e+36) {
tmp = 1.0;
} else if (y <= 1.45e-55) {
tmp = x / z;
} else if (y <= 5.5e+34) {
tmp = 1.0;
} else if (y <= 9.5e+57) {
tmp = -y / z;
} else {
tmp = 1.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) :: tmp
if (y <= (-8.8d+36)) then
tmp = 1.0d0
else if (y <= 1.45d-55) then
tmp = x / z
else if (y <= 5.5d+34) then
tmp = 1.0d0
else if (y <= 9.5d+57) then
tmp = -y / z
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -8.8e+36) {
tmp = 1.0;
} else if (y <= 1.45e-55) {
tmp = x / z;
} else if (y <= 5.5e+34) {
tmp = 1.0;
} else if (y <= 9.5e+57) {
tmp = -y / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.8e+36: tmp = 1.0 elif y <= 1.45e-55: tmp = x / z elif y <= 5.5e+34: tmp = 1.0 elif y <= 9.5e+57: tmp = -y / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.8e+36) tmp = 1.0; elseif (y <= 1.45e-55) tmp = Float64(x / z); elseif (y <= 5.5e+34) tmp = 1.0; elseif (y <= 9.5e+57) tmp = Float64(Float64(-y) / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8.8e+36) tmp = 1.0; elseif (y <= 1.45e-55) tmp = x / z; elseif (y <= 5.5e+34) tmp = 1.0; elseif (y <= 9.5e+57) tmp = -y / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.8e+36], 1.0, If[LessEqual[y, 1.45e-55], N[(x / z), $MachinePrecision], If[LessEqual[y, 5.5e+34], 1.0, If[LessEqual[y, 9.5e+57], N[((-y) / z), $MachinePrecision], 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.8 \cdot 10^{+36}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{-55}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{+34}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+57}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -8.80000000000000002e36 or 1.45e-55 < y < 5.4999999999999996e34 or 9.4999999999999997e57 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 59.8%
if -8.80000000000000002e36 < y < 1.45e-55Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 71.2%
if 5.4999999999999996e34 < y < 9.4999999999999997e57Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in y around 0 100.0%
neg-mul-1100.0%
distribute-neg-frac100.0%
Simplified100.0%
Final simplification65.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.52) (not (<= x 3.4e+81))) (/ x (- z y)) (/ y (- y z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.52) || !(x <= 3.4e+81)) {
tmp = x / (z - y);
} else {
tmp = y / (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 ((x <= (-1.52d0)) .or. (.not. (x <= 3.4d+81))) then
tmp = x / (z - y)
else
tmp = y / (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.52) || !(x <= 3.4e+81)) {
tmp = x / (z - y);
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.52) or not (x <= 3.4e+81): tmp = x / (z - y) else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.52) || !(x <= 3.4e+81)) tmp = Float64(x / Float64(z - y)); else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.52) || ~((x <= 3.4e+81))) tmp = x / (z - y); else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.52], N[Not[LessEqual[x, 3.4e+81]], $MachinePrecision]], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.52 \lor \neg \left(x \leq 3.4 \cdot 10^{+81}\right):\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if x < -1.52 or 3.40000000000000003e81 < x Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 80.9%
associate-*r/80.9%
neg-mul-180.9%
neg-sub080.9%
associate--r-80.9%
neg-sub080.9%
Simplified80.9%
Taylor expanded in x around 0 81.2%
if -1.52 < x < 3.40000000000000003e81Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 76.0%
Final simplification78.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.52e-15) (not (<= z 1.1e+52))) (/ (- x y) z) (- 1.0 (/ x y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.52e-15) || !(z <= 1.1e+52)) {
tmp = (x - y) / z;
} else {
tmp = 1.0 - (x / y);
}
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.52d-15)) .or. (.not. (z <= 1.1d+52))) then
tmp = (x - y) / z
else
tmp = 1.0d0 - (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.52e-15) || !(z <= 1.1e+52)) {
tmp = (x - y) / z;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.52e-15) or not (z <= 1.1e+52): tmp = (x - y) / z else: tmp = 1.0 - (x / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.52e-15) || !(z <= 1.1e+52)) tmp = Float64(Float64(x - y) / z); else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.52e-15) || ~((z <= 1.1e+52))) tmp = (x - y) / z; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.52e-15], N[Not[LessEqual[z, 1.1e+52]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.52 \cdot 10^{-15} \lor \neg \left(z \leq 1.1 \cdot 10^{+52}\right):\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if z < -1.52000000000000005e-15 or 1.1e52 < z Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
clear-num99.2%
associate-/r/99.6%
Applied egg-rr99.6%
Taylor expanded in z around inf 81.1%
associate-*r/81.1%
sub-neg81.1%
mul-1-neg81.1%
distribute-lft-in81.1%
neg-mul-181.1%
neg-mul-181.1%
mul-1-neg81.1%
remove-double-neg81.1%
+-commutative81.1%
unsub-neg81.1%
Simplified81.1%
if -1.52000000000000005e-15 < z < 1.1e52Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 79.7%
div-sub79.7%
*-inverses79.7%
Simplified79.7%
Final simplification80.4%
(FPCore (x y z) :precision binary64 (if (<= y -4e+35) 1.0 (if (<= y 1.4e-54) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -4e+35) {
tmp = 1.0;
} else if (y <= 1.4e-54) {
tmp = x / z;
} else {
tmp = 1.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) :: tmp
if (y <= (-4d+35)) then
tmp = 1.0d0
else if (y <= 1.4d-54) then
tmp = x / z
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4e+35) {
tmp = 1.0;
} else if (y <= 1.4e-54) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4e+35: tmp = 1.0 elif y <= 1.4e-54: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4e+35) tmp = 1.0; elseif (y <= 1.4e-54) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4e+35) tmp = 1.0; elseif (y <= 1.4e-54) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4e+35], 1.0, If[LessEqual[y, 1.4e-54], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{+35}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-54}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.9999999999999999e35 or 1.4000000000000001e-54 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 57.9%
if -3.9999999999999999e35 < y < 1.4000000000000001e-54Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 71.2%
Final simplification63.7%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 35.9%
Final simplification35.9%
(FPCore (x y z) :precision binary64 (- (/ x (- z y)) (/ y (- z y))))
double code(double x, double y, double z) {
return (x / (z - y)) - (y / (z - y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x / (z - y)) - (y / (z - y))
end function
public static double code(double x, double y, double z) {
return (x / (z - y)) - (y / (z - y));
}
def code(x, y, z): return (x / (z - y)) - (y / (z - y))
function code(x, y, z) return Float64(Float64(x / Float64(z - y)) - Float64(y / Float64(z - y))) end
function tmp = code(x, y, z) tmp = (x / (z - y)) - (y / (z - y)); end
code[x_, y_, z_] := N[(N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision] - N[(y / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z - y} - \frac{y}{z - y}
\end{array}
herbie shell --seed 2024027
(FPCore (x y z)
:name "Graphics.Rasterific.Shading:$sgradientColorAt from Rasterific-0.6.1"
:precision binary64
:herbie-target
(- (/ x (- z y)) (/ y (- z y)))
(/ (- x y) (- z y)))