
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / 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 - x))) / z
end function
public static double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
def code(x, y, z): return (x + (y * (z - x))) / z
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y \cdot \left(z - x\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 x))) z))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / 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 - x))) / z
end function
public static double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
def code(x, y, z): return (x + (y * (z - x))) / z
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y \cdot \left(z - x\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (if (<= y 4e+30) (- y (/ x (/ z (+ y -1.0)))) (* y (- 1.0 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4e+30) {
tmp = y - (x / (z / (y + -1.0)));
} else {
tmp = y * (1.0 - (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 <= 4d+30) then
tmp = y - (x / (z / (y + (-1.0d0))))
else
tmp = y * (1.0d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4e+30) {
tmp = y - (x / (z / (y + -1.0)));
} else {
tmp = y * (1.0 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4e+30: tmp = y - (x / (z / (y + -1.0))) else: tmp = y * (1.0 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4e+30) tmp = Float64(y - Float64(x / Float64(z / Float64(y + -1.0)))); else tmp = Float64(y * Float64(1.0 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4e+30) tmp = y - (x / (z / (y + -1.0))); else tmp = y * (1.0 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4e+30], N[(y - N[(x / N[(z / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{+30}:\\
\;\;\;\;y - \frac{x}{\frac{z}{y + -1}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < 4.0000000000000001e30Initial program 91.6%
Taylor expanded in y around 0 95.0%
Taylor expanded in z around -inf 96.7%
mul-1-neg96.7%
unsub-neg96.7%
distribute-rgt-out96.7%
metadata-eval96.7%
sub-neg96.7%
associate-/l*99.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
if 4.0000000000000001e30 < y Initial program 77.1%
Taylor expanded in y around 0 88.6%
Taylor expanded in y around inf 100.0%
Final simplification99.4%
(FPCore (x y z)
:precision binary64
(if (<= y 5.2e+79)
(+ y (/ x z))
(if (or (<= y 1.6e+187) (not (<= y 8.5e+281)))
(* y (/ (- x) z))
(- y (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.2e+79) {
tmp = y + (x / z);
} else if ((y <= 1.6e+187) || !(y <= 8.5e+281)) {
tmp = y * (-x / z);
} else {
tmp = y - (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 <= 5.2d+79) then
tmp = y + (x / z)
else if ((y <= 1.6d+187) .or. (.not. (y <= 8.5d+281))) then
tmp = y * (-x / z)
else
tmp = y - (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 5.2e+79) {
tmp = y + (x / z);
} else if ((y <= 1.6e+187) || !(y <= 8.5e+281)) {
tmp = y * (-x / z);
} else {
tmp = y - (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5.2e+79: tmp = y + (x / z) elif (y <= 1.6e+187) or not (y <= 8.5e+281): tmp = y * (-x / z) else: tmp = y - (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5.2e+79) tmp = Float64(y + Float64(x / z)); elseif ((y <= 1.6e+187) || !(y <= 8.5e+281)) tmp = Float64(y * Float64(Float64(-x) / z)); else tmp = Float64(y - Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 5.2e+79) tmp = y + (x / z); elseif ((y <= 1.6e+187) || ~((y <= 8.5e+281))) tmp = y * (-x / z); else tmp = y - (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5.2e+79], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.6e+187], N[Not[LessEqual[y, 8.5e+281]], $MachinePrecision]], N[(y * N[((-x) / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.2 \cdot 10^{+79}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+187} \lor \neg \left(y \leq 8.5 \cdot 10^{+281}\right):\\
\;\;\;\;y \cdot \frac{-x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z}\\
\end{array}
\end{array}
if y < 5.20000000000000029e79Initial program 90.7%
Taylor expanded in y around 0 95.3%
Taylor expanded in z around -inf 96.9%
mul-1-neg96.9%
unsub-neg96.9%
distribute-rgt-out96.9%
metadata-eval96.9%
sub-neg96.9%
associate-/l*99.2%
sub-neg99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in y around 0 88.1%
neg-mul-188.1%
distribute-frac-neg88.1%
Simplified88.1%
Taylor expanded in y around 0 88.1%
+-commutative88.1%
Simplified88.1%
if 5.20000000000000029e79 < y < 1.59999999999999997e187 or 8.5000000000000006e281 < y Initial program 82.9%
Taylor expanded in y around 0 85.6%
Taylor expanded in y around inf 99.9%
Taylor expanded in x around inf 73.0%
associate-*r/73.0%
mul-1-neg73.0%
distribute-rgt-neg-in73.0%
associate-*r/81.5%
Simplified81.5%
if 1.59999999999999997e187 < y < 8.5000000000000006e281Initial program 73.2%
Taylor expanded in y around 0 85.7%
Taylor expanded in z around -inf 95.2%
mul-1-neg95.2%
unsub-neg95.2%
distribute-rgt-out95.2%
metadata-eval95.2%
sub-neg95.2%
associate-/l*86.1%
sub-neg86.1%
metadata-eval86.1%
Simplified86.1%
Taylor expanded in y around 0 52.7%
neg-mul-152.7%
distribute-frac-neg52.7%
Simplified52.7%
*-un-lft-identity52.7%
*-commutative52.7%
div-inv52.7%
add-cube-cbrt52.7%
associate-*l*52.7%
prod-diff52.7%
Applied egg-rr53.8%
Simplified68.1%
Final simplification85.9%
(FPCore (x y z)
:precision binary64
(if (<= y 3e+79)
(+ y (/ x z))
(if (<= y 2.9e+187)
(* y (/ (- x) z))
(if (<= y 6e+282) (- y (/ x z)) (* x (/ (- y) z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3e+79) {
tmp = y + (x / z);
} else if (y <= 2.9e+187) {
tmp = y * (-x / z);
} else if (y <= 6e+282) {
tmp = y - (x / z);
} else {
tmp = 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 (y <= 3d+79) then
tmp = y + (x / z)
else if (y <= 2.9d+187) then
tmp = y * (-x / z)
else if (y <= 6d+282) then
tmp = y - (x / z)
else
tmp = x * (-y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3e+79) {
tmp = y + (x / z);
} else if (y <= 2.9e+187) {
tmp = y * (-x / z);
} else if (y <= 6e+282) {
tmp = y - (x / z);
} else {
tmp = x * (-y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3e+79: tmp = y + (x / z) elif y <= 2.9e+187: tmp = y * (-x / z) elif y <= 6e+282: tmp = y - (x / z) else: tmp = x * (-y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3e+79) tmp = Float64(y + Float64(x / z)); elseif (y <= 2.9e+187) tmp = Float64(y * Float64(Float64(-x) / z)); elseif (y <= 6e+282) tmp = Float64(y - Float64(x / z)); else tmp = Float64(x * Float64(Float64(-y) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3e+79) tmp = y + (x / z); elseif (y <= 2.9e+187) tmp = y * (-x / z); elseif (y <= 6e+282) tmp = y - (x / z); else tmp = x * (-y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3e+79], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.9e+187], N[(y * N[((-x) / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6e+282], N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x * N[((-y) / z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3 \cdot 10^{+79}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+187}:\\
\;\;\;\;y \cdot \frac{-x}{z}\\
\mathbf{elif}\;y \leq 6 \cdot 10^{+282}:\\
\;\;\;\;y - \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-y}{z}\\
\end{array}
\end{array}
if y < 2.99999999999999974e79Initial program 90.7%
Taylor expanded in y around 0 95.3%
Taylor expanded in z around -inf 96.9%
mul-1-neg96.9%
unsub-neg96.9%
distribute-rgt-out96.9%
metadata-eval96.9%
sub-neg96.9%
associate-/l*99.2%
sub-neg99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in y around 0 88.1%
neg-mul-188.1%
distribute-frac-neg88.1%
Simplified88.1%
Taylor expanded in y around 0 88.1%
+-commutative88.1%
Simplified88.1%
if 2.99999999999999974e79 < y < 2.9000000000000001e187Initial program 87.2%
Taylor expanded in y around 0 86.6%
Taylor expanded in y around inf 99.9%
Taylor expanded in x around inf 74.4%
associate-*r/74.4%
mul-1-neg74.4%
distribute-rgt-neg-in74.4%
associate-*r/87.1%
Simplified87.1%
if 2.9000000000000001e187 < y < 5.99999999999999994e282Initial program 73.2%
Taylor expanded in y around 0 85.7%
Taylor expanded in z around -inf 95.2%
mul-1-neg95.2%
unsub-neg95.2%
distribute-rgt-out95.2%
metadata-eval95.2%
sub-neg95.2%
associate-/l*86.1%
sub-neg86.1%
metadata-eval86.1%
Simplified86.1%
Taylor expanded in y around 0 52.7%
neg-mul-152.7%
distribute-frac-neg52.7%
Simplified52.7%
*-un-lft-identity52.7%
*-commutative52.7%
div-inv52.7%
add-cube-cbrt52.7%
associate-*l*52.7%
prod-diff52.7%
Applied egg-rr53.8%
Simplified68.1%
if 5.99999999999999994e282 < y Initial program 72.1%
Taylor expanded in x around inf 69.5%
associate-/l*67.7%
associate-/r/67.7%
mul-1-neg67.7%
unsub-neg67.7%
Simplified67.7%
Taylor expanded in y around inf 67.7%
neg-mul-167.7%
distribute-neg-frac67.7%
Simplified67.7%
Final simplification85.9%
(FPCore (x y z)
:precision binary64
(if (<= y 1.5e+81)
(+ y (/ x z))
(if (<= y 3.4e+187)
(* y (/ (- x) z))
(if (<= y 1.25e+273) (- y (/ x z)) (/ (* y (- x)) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.5e+81) {
tmp = y + (x / z);
} else if (y <= 3.4e+187) {
tmp = y * (-x / z);
} else if (y <= 1.25e+273) {
tmp = y - (x / z);
} else {
tmp = (y * -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.5d+81) then
tmp = y + (x / z)
else if (y <= 3.4d+187) then
tmp = y * (-x / z)
else if (y <= 1.25d+273) then
tmp = y - (x / z)
else
tmp = (y * -x) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.5e+81) {
tmp = y + (x / z);
} else if (y <= 3.4e+187) {
tmp = y * (-x / z);
} else if (y <= 1.25e+273) {
tmp = y - (x / z);
} else {
tmp = (y * -x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.5e+81: tmp = y + (x / z) elif y <= 3.4e+187: tmp = y * (-x / z) elif y <= 1.25e+273: tmp = y - (x / z) else: tmp = (y * -x) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.5e+81) tmp = Float64(y + Float64(x / z)); elseif (y <= 3.4e+187) tmp = Float64(y * Float64(Float64(-x) / z)); elseif (y <= 1.25e+273) tmp = Float64(y - Float64(x / z)); else tmp = Float64(Float64(y * Float64(-x)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.5e+81) tmp = y + (x / z); elseif (y <= 3.4e+187) tmp = y * (-x / z); elseif (y <= 1.25e+273) tmp = y - (x / z); else tmp = (y * -x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.5e+81], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.4e+187], N[(y * N[((-x) / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.25e+273], N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(y * (-x)), $MachinePrecision] / z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.5 \cdot 10^{+81}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+187}:\\
\;\;\;\;y \cdot \frac{-x}{z}\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{+273}:\\
\;\;\;\;y - \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \left(-x\right)}{z}\\
\end{array}
\end{array}
if y < 1.49999999999999999e81Initial program 90.7%
Taylor expanded in y around 0 95.3%
Taylor expanded in z around -inf 96.9%
mul-1-neg96.9%
unsub-neg96.9%
distribute-rgt-out96.9%
metadata-eval96.9%
sub-neg96.9%
associate-/l*99.2%
sub-neg99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in y around 0 88.1%
neg-mul-188.1%
distribute-frac-neg88.1%
Simplified88.1%
Taylor expanded in y around 0 88.1%
+-commutative88.1%
Simplified88.1%
if 1.49999999999999999e81 < y < 3.4e187Initial program 87.2%
Taylor expanded in y around 0 86.6%
Taylor expanded in y around inf 99.9%
Taylor expanded in x around inf 74.4%
associate-*r/74.4%
mul-1-neg74.4%
distribute-rgt-neg-in74.4%
associate-*r/87.1%
Simplified87.1%
if 3.4e187 < y < 1.2499999999999999e273Initial program 73.2%
Taylor expanded in y around 0 85.7%
Taylor expanded in z around -inf 95.2%
mul-1-neg95.2%
unsub-neg95.2%
distribute-rgt-out95.2%
metadata-eval95.2%
sub-neg95.2%
associate-/l*86.1%
sub-neg86.1%
metadata-eval86.1%
Simplified86.1%
Taylor expanded in y around 0 52.7%
neg-mul-152.7%
distribute-frac-neg52.7%
Simplified52.7%
*-un-lft-identity52.7%
*-commutative52.7%
div-inv52.7%
add-cube-cbrt52.7%
associate-*l*52.7%
prod-diff52.7%
Applied egg-rr53.8%
Simplified68.1%
if 1.2499999999999999e273 < y Initial program 72.1%
Taylor expanded in x around inf 69.5%
associate-/l*67.7%
associate-/r/67.7%
mul-1-neg67.7%
unsub-neg67.7%
Simplified67.7%
Taylor expanded in y around inf 67.7%
neg-mul-167.7%
distribute-neg-frac67.7%
Simplified67.7%
Taylor expanded in y around 0 69.5%
mul-1-neg69.5%
associate-*l/67.7%
distribute-rgt-neg-out67.7%
associate-*l/69.5%
Simplified69.5%
Final simplification86.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -24000000.0) (not (<= y 4.8e-27))) (* y (- 1.0 (/ x z))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -24000000.0) || !(y <= 4.8e-27)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (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 <= (-24000000.0d0)) .or. (.not. (y <= 4.8d-27))) then
tmp = y * (1.0d0 - (x / z))
else
tmp = y + (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -24000000.0) || !(y <= 4.8e-27)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -24000000.0) or not (y <= 4.8e-27): tmp = y * (1.0 - (x / z)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -24000000.0) || !(y <= 4.8e-27)) tmp = Float64(y * Float64(1.0 - Float64(x / z))); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -24000000.0) || ~((y <= 4.8e-27))) tmp = y * (1.0 - (x / z)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -24000000.0], N[Not[LessEqual[y, 4.8e-27]], $MachinePrecision]], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -24000000 \lor \neg \left(y \leq 4.8 \cdot 10^{-27}\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -2.4e7 or 4.80000000000000004e-27 < y Initial program 76.4%
Taylor expanded in y around 0 94.2%
Taylor expanded in y around inf 99.0%
if -2.4e7 < y < 4.80000000000000004e-27Initial program 99.9%
Taylor expanded in y around 0 93.2%
Taylor expanded in z around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
distribute-rgt-out100.0%
metadata-eval100.0%
sub-neg100.0%
associate-/l*100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.6%
neg-mul-199.6%
distribute-frac-neg99.6%
Simplified99.6%
Taylor expanded in y around 0 99.6%
+-commutative99.6%
Simplified99.6%
Final simplification99.3%
(FPCore (x y z) :precision binary64 (if (<= y -24000000.0) (/ y (/ z (- z x))) (if (<= y 4.8e-27) (+ y (/ x z)) (* y (- 1.0 (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -24000000.0) {
tmp = y / (z / (z - x));
} else if (y <= 4.8e-27) {
tmp = y + (x / z);
} else {
tmp = y * (1.0 - (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 <= (-24000000.0d0)) then
tmp = y / (z / (z - x))
else if (y <= 4.8d-27) then
tmp = y + (x / z)
else
tmp = y * (1.0d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -24000000.0) {
tmp = y / (z / (z - x));
} else if (y <= 4.8e-27) {
tmp = y + (x / z);
} else {
tmp = y * (1.0 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -24000000.0: tmp = y / (z / (z - x)) elif y <= 4.8e-27: tmp = y + (x / z) else: tmp = y * (1.0 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -24000000.0) tmp = Float64(y / Float64(z / Float64(z - x))); elseif (y <= 4.8e-27) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y * Float64(1.0 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -24000000.0) tmp = y / (z / (z - x)); elseif (y <= 4.8e-27) tmp = y + (x / z); else tmp = y * (1.0 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -24000000.0], N[(y / N[(z / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.8e-27], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -24000000:\\
\;\;\;\;\frac{y}{\frac{z}{z - x}}\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{-27}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -2.4e7Initial program 71.5%
Taylor expanded in y around inf 70.9%
associate-/l*99.4%
Simplified99.4%
if -2.4e7 < y < 4.80000000000000004e-27Initial program 99.9%
Taylor expanded in y around 0 93.2%
Taylor expanded in z around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
distribute-rgt-out100.0%
metadata-eval100.0%
sub-neg100.0%
associate-/l*100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.6%
neg-mul-199.6%
distribute-frac-neg99.6%
Simplified99.6%
Taylor expanded in y around 0 99.6%
+-commutative99.6%
Simplified99.6%
if 4.80000000000000004e-27 < y Initial program 81.0%
Taylor expanded in y around 0 89.0%
Taylor expanded in y around inf 98.7%
Final simplification99.3%
(FPCore (x y z) :precision binary64 (if (<= z -1.75e+83) y (if (<= z 9.5e+55) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.75e+83) {
tmp = y;
} else if (z <= 9.5e+55) {
tmp = x / z;
} else {
tmp = 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.75d+83)) then
tmp = y
else if (z <= 9.5d+55) then
tmp = x / z
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.75e+83) {
tmp = y;
} else if (z <= 9.5e+55) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.75e+83: tmp = y elif z <= 9.5e+55: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.75e+83) tmp = y; elseif (z <= 9.5e+55) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.75e+83) tmp = y; elseif (z <= 9.5e+55) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.75e+83], y, If[LessEqual[z, 9.5e+55], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.75 \cdot 10^{+83}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{+55}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if z < -1.74999999999999989e83 or 9.49999999999999989e55 < z Initial program 72.6%
Taylor expanded in x around 0 76.4%
if -1.74999999999999989e83 < z < 9.49999999999999989e55Initial program 99.3%
Taylor expanded in y around 0 55.5%
Final simplification63.8%
(FPCore (x y z) :precision binary64 (if (<= y 4.8e-27) (+ y (/ x z)) (* z (/ y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.8e-27) {
tmp = y + (x / z);
} else {
tmp = z * (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 (y <= 4.8d-27) then
tmp = y + (x / z)
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4.8e-27) {
tmp = y + (x / z);
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.8e-27: tmp = y + (x / z) else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.8e-27) tmp = Float64(y + Float64(x / z)); else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4.8e-27) tmp = y + (x / z); else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.8e-27], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.8 \cdot 10^{-27}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 4.80000000000000004e-27Initial program 91.2%
Taylor expanded in y around 0 95.3%
Taylor expanded in z around -inf 96.6%
mul-1-neg96.6%
unsub-neg96.6%
distribute-rgt-out96.6%
metadata-eval96.6%
sub-neg96.6%
associate-/l*99.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in y around 0 89.8%
neg-mul-189.8%
distribute-frac-neg89.8%
Simplified89.8%
Taylor expanded in y around 0 89.8%
+-commutative89.8%
Simplified89.8%
if 4.80000000000000004e-27 < y Initial program 81.0%
Taylor expanded in x around 0 34.1%
associate-/l*50.0%
associate-/r/55.7%
Applied egg-rr55.7%
Final simplification81.3%
(FPCore (x y z) :precision binary64 (if (<= y 4.8e-27) (+ y (/ x z)) (- y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.8e-27) {
tmp = y + (x / z);
} else {
tmp = y - (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 <= 4.8d-27) then
tmp = y + (x / z)
else
tmp = y - (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4.8e-27) {
tmp = y + (x / z);
} else {
tmp = y - (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.8e-27: tmp = y + (x / z) else: tmp = y - (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.8e-27) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y - Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4.8e-27) tmp = y + (x / z); else tmp = y - (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.8e-27], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.8 \cdot 10^{-27}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z}\\
\end{array}
\end{array}
if y < 4.80000000000000004e-27Initial program 91.2%
Taylor expanded in y around 0 95.3%
Taylor expanded in z around -inf 96.6%
mul-1-neg96.6%
unsub-neg96.6%
distribute-rgt-out96.6%
metadata-eval96.6%
sub-neg96.6%
associate-/l*99.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in y around 0 89.8%
neg-mul-189.8%
distribute-frac-neg89.8%
Simplified89.8%
Taylor expanded in y around 0 89.8%
+-commutative89.8%
Simplified89.8%
if 4.80000000000000004e-27 < y Initial program 81.0%
Taylor expanded in y around 0 89.0%
Taylor expanded in z around -inf 94.0%
mul-1-neg94.0%
unsub-neg94.0%
distribute-rgt-out94.0%
metadata-eval94.0%
sub-neg94.0%
associate-/l*92.0%
sub-neg92.0%
metadata-eval92.0%
Simplified92.0%
Taylor expanded in y around 0 49.3%
neg-mul-149.3%
distribute-frac-neg49.3%
Simplified49.3%
*-un-lft-identity49.3%
*-commutative49.3%
div-inv49.3%
add-cube-cbrt49.3%
associate-*l*49.3%
prod-diff49.3%
Applied egg-rr50.8%
Simplified61.8%
Final simplification82.8%
(FPCore (x y z) :precision binary64 y)
double code(double x, double y, double z) {
return y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y
end function
public static double code(double x, double y, double z) {
return y;
}
def code(x, y, z): return y
function code(x, y, z) return y end
function tmp = code(x, y, z) tmp = y; end
code[x_, y_, z_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 88.6%
Taylor expanded in x around 0 40.8%
Final simplification40.8%
(FPCore (x y z) :precision binary64 (- (+ y (/ x z)) (/ y (/ z x))))
double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y + (x / z)) - (y / (z / x))
end function
public static double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
def code(x, y, z): return (y + (x / z)) - (y / (z / x))
function code(x, y, z) return Float64(Float64(y + Float64(x / z)) - Float64(y / Float64(z / x))) end
function tmp = code(x, y, z) tmp = (y + (x / z)) - (y / (z / x)); end
code[x_, y_, z_] := N[(N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}}
\end{array}
herbie shell --seed 2023242
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:herbie-target
(- (+ y (/ x z)) (/ y (/ z x)))
(/ (+ x (* y (- z x))) z))