
(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 9 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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ x (- z y))))
(if (<= x -2.4e+53)
t_0
(if (<= x 490000.0)
(/ y (- y z))
(if (or (<= x 6.1e+71) (not (<= x 9.4e+104))) t_0 (- 1.0 (/ x y)))))))
double code(double x, double y, double z) {
double t_0 = x / (z - y);
double tmp;
if (x <= -2.4e+53) {
tmp = t_0;
} else if (x <= 490000.0) {
tmp = y / (y - z);
} else if ((x <= 6.1e+71) || !(x <= 9.4e+104)) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x / (z - y)
if (x <= (-2.4d+53)) then
tmp = t_0
else if (x <= 490000.0d0) then
tmp = y / (y - z)
else if ((x <= 6.1d+71) .or. (.not. (x <= 9.4d+104))) then
tmp = t_0
else
tmp = 1.0d0 - (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x / (z - y);
double tmp;
if (x <= -2.4e+53) {
tmp = t_0;
} else if (x <= 490000.0) {
tmp = y / (y - z);
} else if ((x <= 6.1e+71) || !(x <= 9.4e+104)) {
tmp = t_0;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y, z): t_0 = x / (z - y) tmp = 0 if x <= -2.4e+53: tmp = t_0 elif x <= 490000.0: tmp = y / (y - z) elif (x <= 6.1e+71) or not (x <= 9.4e+104): tmp = t_0 else: tmp = 1.0 - (x / y) return tmp
function code(x, y, z) t_0 = Float64(x / Float64(z - y)) tmp = 0.0 if (x <= -2.4e+53) tmp = t_0; elseif (x <= 490000.0) tmp = Float64(y / Float64(y - z)); elseif ((x <= 6.1e+71) || !(x <= 9.4e+104)) tmp = t_0; else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x / (z - y); tmp = 0.0; if (x <= -2.4e+53) tmp = t_0; elseif (x <= 490000.0) tmp = y / (y - z); elseif ((x <= 6.1e+71) || ~((x <= 9.4e+104))) tmp = t_0; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.4e+53], t$95$0, If[LessEqual[x, 490000.0], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 6.1e+71], N[Not[LessEqual[x, 9.4e+104]], $MachinePrecision]], t$95$0, N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z - y}\\
\mathbf{if}\;x \leq -2.4 \cdot 10^{+53}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 490000:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;x \leq 6.1 \cdot 10^{+71} \lor \neg \left(x \leq 9.4 \cdot 10^{+104}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if x < -2.4e53 or 4.9e5 < x < 6.1000000000000003e71 or 9.40000000000000034e104 < x Initial program 99.9%
Taylor expanded in x around inf 85.0%
if -2.4e53 < x < 4.9e5Initial program 100.0%
Taylor expanded in x around 0 80.4%
neg-mul-180.4%
distribute-neg-frac280.4%
sub-neg80.4%
+-commutative80.4%
distribute-neg-in80.4%
remove-double-neg80.4%
sub-neg80.4%
Simplified80.4%
if 6.1000000000000003e71 < x < 9.40000000000000034e104Initial program 99.8%
Taylor expanded in z around 0 86.2%
associate-*r/86.2%
neg-mul-186.2%
sub-neg86.2%
+-commutative86.2%
distribute-neg-in86.2%
remove-double-neg86.2%
sub-neg86.2%
div-sub86.4%
*-inverses86.4%
Simplified86.4%
Final simplification82.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (- x y) z)))
(if (<= z -9.5e-8)
t_0
(if (<= z -4.1e-100)
(/ y (- y z))
(if (<= z -7.6e-126)
(/ x (- z y))
(if (<= z 2.1e+29) (- 1.0 (/ x y)) t_0))))))
double code(double x, double y, double z) {
double t_0 = (x - y) / z;
double tmp;
if (z <= -9.5e-8) {
tmp = t_0;
} else if (z <= -4.1e-100) {
tmp = y / (y - z);
} else if (z <= -7.6e-126) {
tmp = x / (z - y);
} else if (z <= 2.1e+29) {
tmp = 1.0 - (x / y);
} 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 = (x - y) / z
if (z <= (-9.5d-8)) then
tmp = t_0
else if (z <= (-4.1d-100)) then
tmp = y / (y - z)
else if (z <= (-7.6d-126)) then
tmp = x / (z - y)
else if (z <= 2.1d+29) then
tmp = 1.0d0 - (x / y)
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 (z <= -9.5e-8) {
tmp = t_0;
} else if (z <= -4.1e-100) {
tmp = y / (y - z);
} else if (z <= -7.6e-126) {
tmp = x / (z - y);
} else if (z <= 2.1e+29) {
tmp = 1.0 - (x / y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x - y) / z tmp = 0 if z <= -9.5e-8: tmp = t_0 elif z <= -4.1e-100: tmp = y / (y - z) elif z <= -7.6e-126: tmp = x / (z - y) elif z <= 2.1e+29: tmp = 1.0 - (x / y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x - y) / z) tmp = 0.0 if (z <= -9.5e-8) tmp = t_0; elseif (z <= -4.1e-100) tmp = Float64(y / Float64(y - z)); elseif (z <= -7.6e-126) tmp = Float64(x / Float64(z - y)); elseif (z <= 2.1e+29) tmp = Float64(1.0 - Float64(x / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - y) / z; tmp = 0.0; if (z <= -9.5e-8) tmp = t_0; elseif (z <= -4.1e-100) tmp = y / (y - z); elseif (z <= -7.6e-126) tmp = x / (z - y); elseif (z <= 2.1e+29) tmp = 1.0 - (x / y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[z, -9.5e-8], t$95$0, If[LessEqual[z, -4.1e-100], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -7.6e-126], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.1e+29], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - y}{z}\\
\mathbf{if}\;z \leq -9.5 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -4.1 \cdot 10^{-100}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;z \leq -7.6 \cdot 10^{-126}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{+29}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -9.50000000000000036e-8 or 2.1000000000000002e29 < z Initial program 100.0%
Taylor expanded in z around inf 79.1%
if -9.50000000000000036e-8 < z < -4.0999999999999999e-100Initial program 99.9%
Taylor expanded in x around 0 70.0%
neg-mul-170.0%
distribute-neg-frac270.0%
sub-neg70.0%
+-commutative70.0%
distribute-neg-in70.0%
remove-double-neg70.0%
sub-neg70.0%
Simplified70.0%
if -4.0999999999999999e-100 < z < -7.5999999999999997e-126Initial program 100.0%
Taylor expanded in x around inf 86.2%
if -7.5999999999999997e-126 < z < 2.1000000000000002e29Initial program 100.0%
Taylor expanded in z around 0 85.5%
associate-*r/85.5%
neg-mul-185.5%
sub-neg85.5%
+-commutative85.5%
distribute-neg-in85.5%
remove-double-neg85.5%
sub-neg85.5%
div-sub85.5%
*-inverses85.5%
Simplified85.5%
(FPCore (x y z) :precision binary64 (if (<= y -2.7e+83) 1.0 (if (<= y -2.46e-42) (/ y (- z)) (if (<= y 0.00024) (/ x z) 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+83) {
tmp = 1.0;
} else if (y <= -2.46e-42) {
tmp = y / -z;
} else if (y <= 0.00024) {
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 <= (-2.7d+83)) then
tmp = 1.0d0
else if (y <= (-2.46d-42)) then
tmp = y / -z
else if (y <= 0.00024d0) 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 <= -2.7e+83) {
tmp = 1.0;
} else if (y <= -2.46e-42) {
tmp = y / -z;
} else if (y <= 0.00024) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.7e+83: tmp = 1.0 elif y <= -2.46e-42: tmp = y / -z elif y <= 0.00024: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.7e+83) tmp = 1.0; elseif (y <= -2.46e-42) tmp = Float64(y / Float64(-z)); elseif (y <= 0.00024) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.7e+83) tmp = 1.0; elseif (y <= -2.46e-42) tmp = y / -z; elseif (y <= 0.00024) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.7e+83], 1.0, If[LessEqual[y, -2.46e-42], N[(y / (-z)), $MachinePrecision], If[LessEqual[y, 0.00024], N[(x / z), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+83}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -2.46 \cdot 10^{-42}:\\
\;\;\;\;\frac{y}{-z}\\
\mathbf{elif}\;y \leq 0.00024:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.70000000000000007e83 or 2.40000000000000006e-4 < y Initial program 100.0%
Taylor expanded in y around inf 63.0%
if -2.70000000000000007e83 < y < -2.45999999999999989e-42Initial program 99.9%
Taylor expanded in x around 0 51.2%
neg-mul-151.2%
distribute-neg-frac251.2%
sub-neg51.2%
+-commutative51.2%
distribute-neg-in51.2%
remove-double-neg51.2%
sub-neg51.2%
Simplified51.2%
Taylor expanded in y around 0 36.2%
associate-*r/36.2%
neg-mul-136.2%
Simplified36.2%
if -2.45999999999999989e-42 < y < 2.40000000000000006e-4Initial program 100.0%
Taylor expanded in y around 0 66.2%
Final simplification61.5%
(FPCore (x y z) :precision binary64 (if (<= y -3.4e+82) 1.0 (if (<= y -7.6e-35) (/ x (- y)) (if (<= y 1.1e-5) (/ x z) 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.4e+82) {
tmp = 1.0;
} else if (y <= -7.6e-35) {
tmp = x / -y;
} else if (y <= 1.1e-5) {
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 <= (-3.4d+82)) then
tmp = 1.0d0
else if (y <= (-7.6d-35)) then
tmp = x / -y
else if (y <= 1.1d-5) 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 <= -3.4e+82) {
tmp = 1.0;
} else if (y <= -7.6e-35) {
tmp = x / -y;
} else if (y <= 1.1e-5) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.4e+82: tmp = 1.0 elif y <= -7.6e-35: tmp = x / -y elif y <= 1.1e-5: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.4e+82) tmp = 1.0; elseif (y <= -7.6e-35) tmp = Float64(x / Float64(-y)); elseif (y <= 1.1e-5) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.4e+82) tmp = 1.0; elseif (y <= -7.6e-35) tmp = x / -y; elseif (y <= 1.1e-5) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.4e+82], 1.0, If[LessEqual[y, -7.6e-35], N[(x / (-y)), $MachinePrecision], If[LessEqual[y, 1.1e-5], N[(x / z), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{+82}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -7.6 \cdot 10^{-35}:\\
\;\;\;\;\frac{x}{-y}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-5}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.39999999999999994e82 or 1.1e-5 < y Initial program 100.0%
Taylor expanded in y around inf 62.5%
if -3.39999999999999994e82 < y < -7.6000000000000002e-35Initial program 99.9%
Taylor expanded in z around 0 52.4%
associate-*r/52.4%
neg-mul-152.4%
sub-neg52.4%
+-commutative52.4%
distribute-neg-in52.4%
remove-double-neg52.4%
sub-neg52.4%
div-sub52.4%
*-inverses52.4%
Simplified52.4%
Taylor expanded in x around inf 40.6%
mul-1-neg40.6%
distribute-frac-neg240.6%
Simplified40.6%
if -7.6000000000000002e-35 < y < 1.1e-5Initial program 100.0%
Taylor expanded in y around 0 64.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -5e-82) (not (<= y 0.000116))) (- 1.0 (/ x y)) (/ x (- z y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5e-82) || !(y <= 0.000116)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (z - 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 ((y <= (-5d-82)) .or. (.not. (y <= 0.000116d0))) then
tmp = 1.0d0 - (x / y)
else
tmp = x / (z - y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5e-82) || !(y <= 0.000116)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (z - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5e-82) or not (y <= 0.000116): tmp = 1.0 - (x / y) else: tmp = x / (z - y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5e-82) || !(y <= 0.000116)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / Float64(z - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5e-82) || ~((y <= 0.000116))) tmp = 1.0 - (x / y); else tmp = x / (z - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5e-82], N[Not[LessEqual[y, 0.000116]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-82} \lor \neg \left(y \leq 0.000116\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z - y}\\
\end{array}
\end{array}
if y < -4.9999999999999998e-82 or 1.16e-4 < y Initial program 100.0%
Taylor expanded in z around 0 72.8%
associate-*r/72.8%
neg-mul-172.8%
sub-neg72.8%
+-commutative72.8%
distribute-neg-in72.8%
remove-double-neg72.8%
sub-neg72.8%
div-sub72.9%
*-inverses72.9%
Simplified72.9%
if -4.9999999999999998e-82 < y < 1.16e-4Initial program 100.0%
Taylor expanded in x around inf 84.3%
Final simplification77.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.2e-124) (not (<= y 2.6e-92))) (- 1.0 (/ x y)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.2e-124) || !(y <= 2.6e-92)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / 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 ((y <= (-1.2d-124)) .or. (.not. (y <= 2.6d-92))) then
tmp = 1.0d0 - (x / y)
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.2e-124) || !(y <= 2.6e-92)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.2e-124) or not (y <= 2.6e-92): tmp = 1.0 - (x / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.2e-124) || !(y <= 2.6e-92)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.2e-124) || ~((y <= 2.6e-92))) tmp = 1.0 - (x / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.2e-124], N[Not[LessEqual[y, 2.6e-92]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{-124} \lor \neg \left(y \leq 2.6 \cdot 10^{-92}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -1.19999999999999996e-124 or 2.6e-92 < y Initial program 100.0%
Taylor expanded in z around 0 69.8%
associate-*r/69.8%
neg-mul-169.8%
sub-neg69.8%
+-commutative69.8%
distribute-neg-in69.8%
remove-double-neg69.8%
sub-neg69.8%
div-sub69.8%
*-inverses69.8%
Simplified69.8%
if -1.19999999999999996e-124 < y < 2.6e-92Initial program 100.0%
Taylor expanded in y around 0 79.0%
Final simplification72.6%
(FPCore (x y z) :precision binary64 (if (<= y -2.55e-74) 1.0 (if (<= y 3.1e-7) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.55e-74) {
tmp = 1.0;
} else if (y <= 3.1e-7) {
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 <= (-2.55d-74)) then
tmp = 1.0d0
else if (y <= 3.1d-7) 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 <= -2.55e-74) {
tmp = 1.0;
} else if (y <= 3.1e-7) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.55e-74: tmp = 1.0 elif y <= 3.1e-7: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.55e-74) tmp = 1.0; elseif (y <= 3.1e-7) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.55e-74) tmp = 1.0; elseif (y <= 3.1e-7) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.55e-74], 1.0, If[LessEqual[y, 3.1e-7], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.55 \cdot 10^{-74}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.5499999999999998e-74 or 3.1e-7 < y Initial program 100.0%
Taylor expanded in y around inf 53.7%
if -2.5499999999999998e-74 < y < 3.1e-7Initial program 100.0%
Taylor expanded in y around 0 68.0%
(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%
Taylor expanded in y around inf 35.3%
(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 2024110
(FPCore (x y z)
:name "Graphics.Rasterific.Shading:$sgradientColorAt from Rasterific-0.6.1"
:precision binary64
:alt
(- (/ x (- z y)) (/ y (- z y)))
(/ (- x y) (- z y)))