
(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 (- y (* (/ x z) (+ y -1.0))))
double code(double x, double y, double z) {
return y - ((x / z) * (y + -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 = y - ((x / z) * (y + (-1.0d0)))
end function
public static double code(double x, double y, double z) {
return y - ((x / z) * (y + -1.0));
}
def code(x, y, z): return y - ((x / z) * (y + -1.0))
function code(x, y, z) return Float64(y - Float64(Float64(x / z) * Float64(y + -1.0))) end
function tmp = code(x, y, z) tmp = y - ((x / z) * (y + -1.0)); end
code[x_, y_, z_] := N[(y - N[(N[(x / z), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y - \frac{x}{z} \cdot \left(y + -1\right)
\end{array}
Initial program 89.6%
Taylor expanded in x around inf 95.9%
+-commutative95.9%
distribute-lft-in95.9%
*-commutative95.9%
*-commutative95.9%
associate-*r*95.9%
neg-mul-195.9%
*-rgt-identity95.9%
remove-double-neg95.9%
neg-mul-195.9%
distribute-rgt-in95.9%
neg-mul-195.9%
metadata-eval95.9%
sub-neg95.9%
associate-*r*95.9%
associate-*r/95.9%
mul-1-neg95.9%
unsub-neg95.9%
associate-/l*96.5%
associate-/r/99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (/ x z))) (t_1 (* x (/ (- y) z))))
(if (<= y -6.8e+66)
t_0
(if (<= y -1.85e+21)
t_1
(if (<= y 7.6e+18) t_0 (if (<= y 2.15e+64) t_1 (- y (/ x z))))))))
double code(double x, double y, double z) {
double t_0 = y + (x / z);
double t_1 = x * (-y / z);
double tmp;
if (y <= -6.8e+66) {
tmp = t_0;
} else if (y <= -1.85e+21) {
tmp = t_1;
} else if (y <= 7.6e+18) {
tmp = t_0;
} else if (y <= 2.15e+64) {
tmp = t_1;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y + (x / z)
t_1 = x * (-y / z)
if (y <= (-6.8d+66)) then
tmp = t_0
else if (y <= (-1.85d+21)) then
tmp = t_1
else if (y <= 7.6d+18) then
tmp = t_0
else if (y <= 2.15d+64) then
tmp = t_1
else
tmp = y - (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y + (x / z);
double t_1 = x * (-y / z);
double tmp;
if (y <= -6.8e+66) {
tmp = t_0;
} else if (y <= -1.85e+21) {
tmp = t_1;
} else if (y <= 7.6e+18) {
tmp = t_0;
} else if (y <= 2.15e+64) {
tmp = t_1;
} else {
tmp = y - (x / z);
}
return tmp;
}
def code(x, y, z): t_0 = y + (x / z) t_1 = x * (-y / z) tmp = 0 if y <= -6.8e+66: tmp = t_0 elif y <= -1.85e+21: tmp = t_1 elif y <= 7.6e+18: tmp = t_0 elif y <= 2.15e+64: tmp = t_1 else: tmp = y - (x / z) return tmp
function code(x, y, z) t_0 = Float64(y + Float64(x / z)) t_1 = Float64(x * Float64(Float64(-y) / z)) tmp = 0.0 if (y <= -6.8e+66) tmp = t_0; elseif (y <= -1.85e+21) tmp = t_1; elseif (y <= 7.6e+18) tmp = t_0; elseif (y <= 2.15e+64) tmp = t_1; else tmp = Float64(y - Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y + (x / z); t_1 = x * (-y / z); tmp = 0.0; if (y <= -6.8e+66) tmp = t_0; elseif (y <= -1.85e+21) tmp = t_1; elseif (y <= 7.6e+18) tmp = t_0; elseif (y <= 2.15e+64) tmp = t_1; else tmp = y - (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[((-y) / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.8e+66], t$95$0, If[LessEqual[y, -1.85e+21], t$95$1, If[LessEqual[y, 7.6e+18], t$95$0, If[LessEqual[y, 2.15e+64], t$95$1, N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \frac{x}{z}\\
t_1 := x \cdot \frac{-y}{z}\\
\mathbf{if}\;y \leq -6.8 \cdot 10^{+66}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.85 \cdot 10^{+21}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{+18}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.15 \cdot 10^{+64}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z}\\
\end{array}
\end{array}
if y < -6.8000000000000006e66 or -1.85e21 < y < 7.6e18Initial program 92.7%
Taylor expanded in z around inf 85.5%
Taylor expanded in x around 0 91.7%
if -6.8000000000000006e66 < y < -1.85e21 or 7.6e18 < y < 2.1499999999999999e64Initial program 91.8%
Taylor expanded in y around inf 91.8%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in z around 0 75.6%
associate-*r/83.7%
mul-1-neg83.7%
distribute-rgt-neg-in83.7%
mul-1-neg83.7%
associate-*r/83.7%
neg-mul-183.7%
Simplified83.7%
if 2.1499999999999999e64 < y Initial program 76.9%
Taylor expanded in z around inf 38.6%
Taylor expanded in x around 0 57.1%
frac-2neg57.1%
div-inv57.1%
add-sqr-sqrt29.0%
sqrt-unprod63.4%
sqr-neg63.4%
sqrt-unprod36.5%
add-sqr-sqrt69.8%
cancel-sign-sub-inv69.8%
div-inv69.8%
Applied egg-rr69.8%
Final simplification86.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (* (- z x) (/ y z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = (z - x) * (y / 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.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = (z - x) * (y / 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.0) || !(y <= 1.0)) {
tmp = (z - x) * (y / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = (z - x) * (y / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(Float64(z - x) * Float64(y / z)); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.0) || ~((y <= 1.0))) tmp = (z - x) * (y / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(N[(z - x), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;\left(z - x\right) \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 77.9%
Taylor expanded in y around inf 76.7%
associate-/l*98.6%
associate-/r/90.3%
Simplified90.3%
if -1 < y < 1Initial program 99.9%
Taylor expanded in z around inf 99.0%
Taylor expanded in x around 0 99.0%
Final simplification94.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (- y (/ x (/ z y))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = y - (x / (z / y));
} 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.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = y - (x / (z / y))
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.0) || !(y <= 1.0)) {
tmp = y - (x / (z / y));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = y - (x / (z / y)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(y - Float64(x / Float64(z / y))); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.0) || ~((y <= 1.0))) tmp = y - (x / (z / y)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(y - N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;y - \frac{x}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 77.9%
Taylor expanded in x around inf 91.2%
+-commutative91.2%
distribute-lft-in91.2%
*-commutative91.2%
*-commutative91.2%
associate-*r*91.2%
neg-mul-191.2%
*-rgt-identity91.2%
remove-double-neg91.2%
neg-mul-191.2%
distribute-rgt-in91.2%
neg-mul-191.2%
metadata-eval91.2%
sub-neg91.2%
associate-*r*91.2%
associate-*r/91.2%
mul-1-neg91.2%
unsub-neg91.2%
associate-/l*92.5%
associate-/r/99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 90.0%
associate-/l*91.3%
Simplified91.3%
if -1 < y < 1Initial program 99.9%
Taylor expanded in z around inf 99.0%
Taylor expanded in x around 0 99.0%
Final simplification95.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (/ y (/ z (- z x))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = y / (z / (z - x));
} 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.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = y / (z / (z - x))
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.0) || !(y <= 1.0)) {
tmp = y / (z / (z - x));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = y / (z / (z - x)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(y / Float64(z / Float64(z - x))); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.0) || ~((y <= 1.0))) tmp = y / (z / (z - x)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(y / N[(z / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;\frac{y}{\frac{z}{z - x}}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 77.9%
Taylor expanded in y around inf 76.7%
associate-/l*98.6%
Simplified98.6%
if -1 < y < 1Initial program 99.9%
Taylor expanded in z around inf 99.0%
Taylor expanded in x around 0 99.0%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (if (<= y -1.0) (- y (* x (/ y z))) (if (<= y 1.0) (+ y (/ x z)) (* (- z x) (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = y - (x * (y / z));
} else if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = (z - 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 <= (-1.0d0)) then
tmp = y - (x * (y / z))
else if (y <= 1.0d0) then
tmp = y + (x / z)
else
tmp = (z - x) * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = y - (x * (y / z));
} else if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = (z - x) * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.0: tmp = y - (x * (y / z)) elif y <= 1.0: tmp = y + (x / z) else: tmp = (z - x) * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.0) tmp = Float64(y - Float64(x * Float64(y / z))); elseif (y <= 1.0) tmp = Float64(y + Float64(x / z)); else tmp = Float64(Float64(z - x) * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.0) tmp = y - (x * (y / z)); elseif (y <= 1.0) tmp = y + (x / z); else tmp = (z - x) * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.0], N[(y - N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(z - x), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;y - x \cdot \frac{y}{z}\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(z - x\right) \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -1Initial program 76.8%
Taylor expanded in x around inf 96.5%
+-commutative96.5%
distribute-lft-in96.5%
*-commutative96.5%
*-commutative96.5%
associate-*r*96.5%
neg-mul-196.5%
*-rgt-identity96.5%
remove-double-neg96.5%
neg-mul-196.5%
distribute-rgt-in96.5%
neg-mul-196.5%
metadata-eval96.5%
sub-neg96.5%
associate-*r*96.5%
associate-*r/96.5%
mul-1-neg96.5%
unsub-neg96.5%
associate-/l*95.1%
associate-/r/99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
associate-*l/96.5%
clear-num96.5%
Applied egg-rr96.5%
Taylor expanded in y around inf 95.0%
associate-*r/92.0%
Simplified92.0%
if -1 < y < 1Initial program 99.9%
Taylor expanded in z around inf 99.0%
Taylor expanded in x around 0 99.0%
if 1 < y Initial program 78.9%
Taylor expanded in y around inf 78.0%
associate-/l*98.9%
associate-/r/88.7%
Simplified88.7%
Final simplification94.9%
(FPCore (x y z) :precision binary64 (if (<= y -5.4e-51) y (if (<= y 7e-57) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.4e-51) {
tmp = y;
} else if (y <= 7e-57) {
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 (y <= (-5.4d-51)) then
tmp = y
else if (y <= 7d-57) 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 (y <= -5.4e-51) {
tmp = y;
} else if (y <= 7e-57) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.4e-51: tmp = y elif y <= 7e-57: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.4e-51) tmp = y; elseif (y <= 7e-57) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.4e-51) tmp = y; elseif (y <= 7e-57) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.4e-51], y, If[LessEqual[y, 7e-57], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{-51}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-57}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -5.3999999999999994e-51 or 6.99999999999999983e-57 < y Initial program 81.7%
Taylor expanded in x around 0 56.9%
if -5.3999999999999994e-51 < y < 6.99999999999999983e-57Initial program 99.9%
Taylor expanded in y around 0 76.3%
Final simplification65.3%
(FPCore (x y z) :precision binary64 (if (<= y 1.0) (+ y (/ x z)) (- y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.0) {
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.0d0) 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.0) {
tmp = y + (x / z);
} else {
tmp = y - (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.0: tmp = y + (x / z) else: tmp = y - (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.0) 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 <= 1.0) tmp = y + (x / z); else tmp = y - (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z}\\
\end{array}
\end{array}
if y < 1Initial program 93.1%
Taylor expanded in z around inf 82.8%
Taylor expanded in x around 0 88.7%
if 1 < y Initial program 78.9%
Taylor expanded in z around inf 35.1%
Taylor expanded in x around 0 49.5%
frac-2neg49.5%
div-inv49.5%
add-sqr-sqrt24.4%
sqrt-unprod54.9%
sqr-neg54.9%
sqrt-unprod32.4%
add-sqr-sqrt62.0%
cancel-sign-sub-inv62.0%
div-inv62.0%
Applied egg-rr62.0%
Final simplification82.2%
(FPCore (x y z) :precision binary64 (+ y (/ x z)))
double code(double x, double y, double z) {
return y + (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 = y + (x / z)
end function
public static double code(double x, double y, double z) {
return y + (x / z);
}
def code(x, y, z): return y + (x / z)
function code(x, y, z) return Float64(y + Float64(x / z)) end
function tmp = code(x, y, z) tmp = y + (x / z); end
code[x_, y_, z_] := N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y + \frac{x}{z}
\end{array}
Initial program 89.6%
Taylor expanded in z around inf 71.1%
Taylor expanded in x around 0 79.1%
Final simplification79.1%
(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 89.6%
Taylor expanded in x around 0 43.1%
Final simplification43.1%
(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 2023336
(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))