
(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 11 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 (or (<= y -5e+66) (not (<= y 30000.0))) (* y (/ (- z x) z)) (+ y (/ (* x (- 1.0 y)) z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5e+66) || !(y <= 30000.0)) {
tmp = y * ((z - x) / z);
} else {
tmp = y + ((x * (1.0 - 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 <= (-5d+66)) .or. (.not. (y <= 30000.0d0))) then
tmp = y * ((z - x) / z)
else
tmp = y + ((x * (1.0d0 - y)) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5e+66) || !(y <= 30000.0)) {
tmp = y * ((z - x) / z);
} else {
tmp = y + ((x * (1.0 - y)) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5e+66) or not (y <= 30000.0): tmp = y * ((z - x) / z) else: tmp = y + ((x * (1.0 - y)) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5e+66) || !(y <= 30000.0)) tmp = Float64(y * Float64(Float64(z - x) / z)); else tmp = Float64(y + Float64(Float64(x * Float64(1.0 - y)) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5e+66) || ~((y <= 30000.0))) tmp = y * ((z - x) / z); else tmp = y + ((x * (1.0 - y)) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5e+66], N[Not[LessEqual[y, 30000.0]], $MachinePrecision]], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y + N[(N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{+66} \lor \neg \left(y \leq 30000\right):\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x \cdot \left(1 - y\right)}{z}\\
\end{array}
\end{array}
if y < -4.99999999999999991e66 or 3e4 < y Initial program 75.3%
Taylor expanded in y around inf 75.3%
associate-/l*99.9%
Simplified99.9%
if -4.99999999999999991e66 < y < 3e4Initial program 99.3%
Taylor expanded in x around inf 99.7%
associate-+r+99.7%
+-commutative99.7%
mul-1-neg99.7%
unsub-neg99.7%
div-sub99.7%
Simplified99.7%
Taylor expanded in z around inf 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.2e+36) (not (<= y 1.0))) (* y (/ (- z x) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.2e+36) || !(y <= 1.0)) {
tmp = y * ((z - 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.2d+36)) .or. (.not. (y <= 1.0d0))) then
tmp = y * ((z - 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.2e+36) || !(y <= 1.0)) {
tmp = y * ((z - x) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.2e+36) or not (y <= 1.0): tmp = y * ((z - x) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.2e+36) || !(y <= 1.0)) tmp = Float64(y * Float64(Float64(z - 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.2e+36) || ~((y <= 1.0))) tmp = y * ((z - x) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.2e+36], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+36} \lor \neg \left(y \leq 1\right):\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -4.20000000000000009e36 or 1 < y Initial program 76.4%
Taylor expanded in y around inf 75.4%
associate-/l*98.9%
Simplified98.9%
if -4.20000000000000009e36 < y < 1Initial program 99.3%
Taylor expanded in x around inf 99.7%
associate-+r+99.7%
+-commutative99.7%
mul-1-neg99.7%
unsub-neg99.7%
div-sub99.7%
Simplified99.7%
Taylor expanded in z around inf 100.0%
Taylor expanded in y around 0 98.9%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.05e-17) (not (<= x 9.6e+120))) (* x (/ (- 1.0 y) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.05e-17) || !(x <= 9.6e+120)) {
tmp = x * ((1.0 - 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 ((x <= (-1.05d-17)) .or. (.not. (x <= 9.6d+120))) then
tmp = x * ((1.0d0 - 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 ((x <= -1.05e-17) || !(x <= 9.6e+120)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.05e-17) or not (x <= 9.6e+120): tmp = x * ((1.0 - y) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.05e-17) || !(x <= 9.6e+120)) tmp = Float64(x * Float64(Float64(1.0 - y) / z)); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.05e-17) || ~((x <= 9.6e+120))) tmp = x * ((1.0 - y) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.05e-17], N[Not[LessEqual[x, 9.6e+120]], $MachinePrecision]], N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{-17} \lor \neg \left(x \leq 9.6 \cdot 10^{+120}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -1.04999999999999996e-17 or 9.60000000000000004e120 < x Initial program 89.2%
Taylor expanded in x around inf 81.2%
associate-/l*85.8%
mul-1-neg85.8%
unsub-neg85.8%
Simplified85.8%
if -1.04999999999999996e-17 < x < 9.60000000000000004e120Initial program 89.5%
Taylor expanded in x around inf 81.5%
associate-+r+81.5%
+-commutative81.5%
mul-1-neg81.5%
unsub-neg81.5%
div-sub81.5%
Simplified81.5%
Taylor expanded in z around inf 97.8%
Taylor expanded in y around 0 88.4%
Final simplification87.3%
(FPCore (x y z) :precision binary64 (if (<= y -4.2e+36) (/ y (/ z (- z x))) (if (<= y 1.0) (+ y (/ x z)) (* y (/ (- z x) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.2e+36) {
tmp = y / (z / (z - x));
} else if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = y * ((z - 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.2d+36)) then
tmp = y / (z / (z - x))
else if (y <= 1.0d0) then
tmp = y + (x / z)
else
tmp = y * ((z - x) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.2e+36) {
tmp = y / (z / (z - x));
} else if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = y * ((z - x) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.2e+36: tmp = y / (z / (z - x)) elif y <= 1.0: tmp = y + (x / z) else: tmp = y * ((z - x) / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.2e+36) tmp = Float64(y / Float64(z / Float64(z - x))); elseif (y <= 1.0) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y * Float64(Float64(z - x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.2e+36) tmp = y / (z / (z - x)); elseif (y <= 1.0) tmp = y + (x / z); else tmp = y * ((z - x) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.2e+36], N[(y / N[(z / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+36}:\\
\;\;\;\;\frac{y}{\frac{z}{z - x}}\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\end{array}
\end{array}
if y < -4.20000000000000009e36Initial program 75.7%
Taylor expanded in y around inf 75.7%
associate-/l*99.8%
Simplified99.8%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
if -4.20000000000000009e36 < y < 1Initial program 99.3%
Taylor expanded in x around inf 99.7%
associate-+r+99.7%
+-commutative99.7%
mul-1-neg99.7%
unsub-neg99.7%
div-sub99.7%
Simplified99.7%
Taylor expanded in z around inf 100.0%
Taylor expanded in y around 0 98.9%
if 1 < y Initial program 76.9%
Taylor expanded in y around inf 75.3%
associate-/l*98.3%
Simplified98.3%
(FPCore (x y z) :precision binary64 (if (<= y -1.8e+82) y (if (<= y 2.15e-39) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.8e+82) {
tmp = y;
} else if (y <= 2.15e-39) {
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 <= (-1.8d+82)) then
tmp = y
else if (y <= 2.15d-39) 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 <= -1.8e+82) {
tmp = y;
} else if (y <= 2.15e-39) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.8e+82: tmp = y elif y <= 2.15e-39: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.8e+82) tmp = y; elseif (y <= 2.15e-39) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.8e+82) tmp = y; elseif (y <= 2.15e-39) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.8e+82], y, If[LessEqual[y, 2.15e-39], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.8 \cdot 10^{+82}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 2.15 \cdot 10^{-39}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -1.80000000000000007e82 or 2.15e-39 < y Initial program 77.4%
Taylor expanded in x around 0 54.1%
if -1.80000000000000007e82 < y < 2.15e-39Initial program 98.6%
Taylor expanded in y around 0 70.3%
(FPCore (x y z) :precision binary64 (if (<= x 3.7e+239) (+ y (/ x z)) (/ y (/ z (- x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 3.7e+239) {
tmp = y + (x / z);
} else {
tmp = y / (z / -x);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 3.7d+239) then
tmp = y + (x / z)
else
tmp = y / (z / -x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 3.7e+239) {
tmp = y + (x / z);
} else {
tmp = y / (z / -x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 3.7e+239: tmp = y + (x / z) else: tmp = y / (z / -x) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 3.7e+239) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y / Float64(z / Float64(-x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 3.7e+239) tmp = y + (x / z); else tmp = y / (z / -x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 3.7e+239], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y / N[(z / (-x)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.7 \cdot 10^{+239}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{-x}}\\
\end{array}
\end{array}
if x < 3.69999999999999998e239Initial program 90.2%
Taylor expanded in x around inf 88.8%
associate-+r+88.8%
+-commutative88.8%
mul-1-neg88.8%
unsub-neg88.8%
div-sub88.8%
Simplified88.8%
Taylor expanded in z around inf 95.9%
Taylor expanded in y around 0 82.7%
if 3.69999999999999998e239 < x Initial program 77.9%
Taylor expanded in y around inf 60.6%
associate-/l*88.1%
Simplified88.1%
clear-num88.1%
un-div-inv88.1%
Applied egg-rr88.1%
Taylor expanded in z around 0 86.3%
associate-*r/86.3%
neg-mul-186.3%
Simplified86.3%
Final simplification82.9%
(FPCore (x y z) :precision binary64 (if (<= x 8.6e+239) (+ y (/ x z)) (* y (/ x (- z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 8.6e+239) {
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 (x <= 8.6d+239) 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 (x <= 8.6e+239) {
tmp = y + (x / z);
} else {
tmp = y * (x / -z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 8.6e+239: tmp = y + (x / z) else: tmp = y * (x / -z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 8.6e+239) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y * Float64(x / Float64(-z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 8.6e+239) tmp = y + (x / z); else tmp = y * (x / -z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 8.6e+239], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / (-z)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.6 \cdot 10^{+239}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{-z}\\
\end{array}
\end{array}
if x < 8.6000000000000008e239Initial program 90.2%
Taylor expanded in x around inf 88.8%
associate-+r+88.8%
+-commutative88.8%
mul-1-neg88.8%
unsub-neg88.8%
div-sub88.8%
Simplified88.8%
Taylor expanded in z around inf 95.9%
Taylor expanded in y around 0 82.7%
if 8.6000000000000008e239 < x Initial program 77.9%
Taylor expanded in y around inf 60.6%
associate-/l*88.1%
Simplified88.1%
Taylor expanded in z around 0 86.2%
neg-mul-186.2%
Simplified86.2%
Final simplification82.9%
(FPCore (x y z) :precision binary64 (if (<= x 3.1e+239) (+ y (/ x z)) (* x (/ y (- z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 3.1e+239) {
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 (x <= 3.1d+239) 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 (x <= 3.1e+239) {
tmp = y + (x / z);
} else {
tmp = x * (y / -z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 3.1e+239: tmp = y + (x / z) else: tmp = x * (y / -z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 3.1e+239) tmp = Float64(y + Float64(x / z)); else tmp = Float64(x * Float64(y / Float64(-z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 3.1e+239) tmp = y + (x / z); else tmp = x * (y / -z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 3.1e+239], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / (-z)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.1 \cdot 10^{+239}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{-z}\\
\end{array}
\end{array}
if x < 3.10000000000000001e239Initial program 90.2%
Taylor expanded in x around inf 88.8%
associate-+r+88.8%
+-commutative88.8%
mul-1-neg88.8%
unsub-neg88.8%
div-sub88.8%
Simplified88.8%
Taylor expanded in z around inf 95.9%
Taylor expanded in y around 0 82.7%
if 3.10000000000000001e239 < x Initial program 77.9%
Taylor expanded in x around inf 77.9%
associate-/l*98.0%
mul-1-neg98.0%
unsub-neg98.0%
Simplified98.0%
Taylor expanded in y around inf 80.8%
neg-mul-180.8%
distribute-neg-frac80.8%
Simplified80.8%
Final simplification82.5%
(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.6%
Taylor expanded in x around inf 91.4%
associate-+r+91.4%
+-commutative91.4%
mul-1-neg91.4%
unsub-neg91.4%
div-sub91.4%
Simplified91.4%
Taylor expanded in z around inf 96.5%
Taylor expanded in y around 0 88.2%
if 1 < y Initial program 76.9%
Taylor expanded in x around inf 84.0%
associate-+r+84.1%
+-commutative84.1%
mul-1-neg84.1%
unsub-neg84.1%
div-sub84.1%
Simplified84.1%
Taylor expanded in z around inf 89.4%
Taylor expanded in y around 0 54.6%
frac-2neg54.6%
div-inv54.6%
add-sqr-sqrt25.5%
sqrt-unprod60.2%
sqr-neg60.2%
sqrt-unprod36.2%
add-sqr-sqrt65.3%
cancel-sign-sub-inv65.3%
div-inv65.3%
Applied egg-rr65.3%
(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.4%
Taylor expanded in x around inf 89.6%
associate-+r+89.6%
+-commutative89.6%
mul-1-neg89.6%
unsub-neg89.6%
div-sub89.6%
Simplified89.6%
Taylor expanded in z around inf 94.7%
Taylor expanded in y around 0 79.7%
(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.4%
Taylor expanded in x around 0 39.5%
(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 2024182
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:alt
(! :herbie-platform default (- (+ y (/ x z)) (/ y (/ z x))))
(/ (+ x (* y (- z x))) z))