
(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 (+ y (* (/ x z) (- 1.0 y))))
double code(double x, double y, double z) {
return y + ((x / z) * (1.0 - 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 + ((x / z) * (1.0d0 - y))
end function
public static double code(double x, double y, double z) {
return y + ((x / z) * (1.0 - y));
}
def code(x, y, z): return y + ((x / z) * (1.0 - y))
function code(x, y, z) return Float64(y + Float64(Float64(x / z) * Float64(1.0 - y))) end
function tmp = code(x, y, z) tmp = y + ((x / z) * (1.0 - y)); end
code[x_, y_, z_] := N[(y + N[(N[(x / z), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y + \frac{x}{z} \cdot \left(1 - y\right)
\end{array}
Initial program 90.4%
Taylor expanded in y around 0 96.0%
Taylor expanded in x around 0 95.4%
neg-mul-195.4%
+-commutative95.4%
sub-neg95.4%
div-sub95.4%
associate-/l*97.0%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (or (<= x -3.65e+56)
(not
(or (<= x -1.5e-108) (and (not (<= x -6.5e-124)) (<= x 1.8e-11)))))
(/ x z)
y))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.65e+56) || !((x <= -1.5e-108) || (!(x <= -6.5e-124) && (x <= 1.8e-11)))) {
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 ((x <= (-3.65d+56)) .or. (.not. (x <= (-1.5d-108)) .or. (.not. (x <= (-6.5d-124))) .and. (x <= 1.8d-11))) 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 ((x <= -3.65e+56) || !((x <= -1.5e-108) || (!(x <= -6.5e-124) && (x <= 1.8e-11)))) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.65e+56) or not ((x <= -1.5e-108) or (not (x <= -6.5e-124) and (x <= 1.8e-11))): tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.65e+56) || !((x <= -1.5e-108) || (!(x <= -6.5e-124) && (x <= 1.8e-11)))) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.65e+56) || ~(((x <= -1.5e-108) || (~((x <= -6.5e-124)) && (x <= 1.8e-11))))) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.65e+56], N[Not[Or[LessEqual[x, -1.5e-108], And[N[Not[LessEqual[x, -6.5e-124]], $MachinePrecision], LessEqual[x, 1.8e-11]]]], $MachinePrecision]], N[(x / z), $MachinePrecision], y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.65 \cdot 10^{+56} \lor \neg \left(x \leq -1.5 \cdot 10^{-108} \lor \neg \left(x \leq -6.5 \cdot 10^{-124}\right) \land x \leq 1.8 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if x < -3.65e56 or -1.49999999999999996e-108 < x < -6.49999999999999988e-124 or 1.79999999999999992e-11 < x Initial program 91.8%
Taylor expanded in y around 0 55.6%
if -3.65e56 < x < -1.49999999999999996e-108 or -6.49999999999999988e-124 < x < 1.79999999999999992e-11Initial program 88.7%
Taylor expanded in x around 0 75.1%
Final simplification64.6%
(FPCore (x y z)
:precision binary64
(if (<= y 1.3e+42)
(+ y (/ x z))
(if (or (<= y 3.55e+103) (not (<= y 8.5e+256)))
(- (* x (/ y z)))
(/ (* y x) x))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.3e+42) {
tmp = y + (x / z);
} else if ((y <= 3.55e+103) || !(y <= 8.5e+256)) {
tmp = -(x * (y / z));
} else {
tmp = (y * x) / 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 (y <= 1.3d+42) then
tmp = y + (x / z)
else if ((y <= 3.55d+103) .or. (.not. (y <= 8.5d+256))) then
tmp = -(x * (y / z))
else
tmp = (y * x) / x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.3e+42) {
tmp = y + (x / z);
} else if ((y <= 3.55e+103) || !(y <= 8.5e+256)) {
tmp = -(x * (y / z));
} else {
tmp = (y * x) / x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.3e+42: tmp = y + (x / z) elif (y <= 3.55e+103) or not (y <= 8.5e+256): tmp = -(x * (y / z)) else: tmp = (y * x) / x return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.3e+42) tmp = Float64(y + Float64(x / z)); elseif ((y <= 3.55e+103) || !(y <= 8.5e+256)) tmp = Float64(-Float64(x * Float64(y / z))); else tmp = Float64(Float64(y * x) / x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.3e+42) tmp = y + (x / z); elseif ((y <= 3.55e+103) || ~((y <= 8.5e+256))) tmp = -(x * (y / z)); else tmp = (y * x) / x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.3e+42], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 3.55e+103], N[Not[LessEqual[y, 8.5e+256]], $MachinePrecision]], (-N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]), N[(N[(y * x), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.3 \cdot 10^{+42}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 3.55 \cdot 10^{+103} \lor \neg \left(y \leq 8.5 \cdot 10^{+256}\right):\\
\;\;\;\;-x \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{x}\\
\end{array}
\end{array}
if y < 1.29999999999999995e42Initial program 93.3%
Taylor expanded in y around 0 98.0%
Taylor expanded in x around 0 89.0%
if 1.29999999999999995e42 < y < 3.5500000000000001e103 or 8.5000000000000006e256 < y Initial program 85.5%
Taylor expanded in x around inf 74.4%
associate-/l*74.4%
mul-1-neg74.4%
unsub-neg74.4%
Simplified74.4%
Taylor expanded in y around inf 74.4%
neg-mul-174.4%
distribute-neg-frac74.4%
Simplified74.4%
if 3.5500000000000001e103 < y < 8.5000000000000006e256Initial program 77.0%
Taylor expanded in x around inf 64.0%
associate-+r+64.0%
+-commutative64.0%
mul-1-neg64.0%
unsub-neg64.0%
div-sub64.0%
Simplified64.0%
Taylor expanded in z around inf 22.8%
associate-*r/63.7%
Applied egg-rr63.7%
Final simplification84.2%
(FPCore (x y z)
:precision binary64
(if (<= y 2e+44)
(+ y (/ x z))
(if (or (<= y 4.2e+102) (not (<= y 9.4e+256)))
(* y (/ x (- z)))
(/ (* y x) x))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2e+44) {
tmp = y + (x / z);
} else if ((y <= 4.2e+102) || !(y <= 9.4e+256)) {
tmp = y * (x / -z);
} else {
tmp = (y * x) / 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 (y <= 2d+44) then
tmp = y + (x / z)
else if ((y <= 4.2d+102) .or. (.not. (y <= 9.4d+256))) then
tmp = y * (x / -z)
else
tmp = (y * x) / x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2e+44) {
tmp = y + (x / z);
} else if ((y <= 4.2e+102) || !(y <= 9.4e+256)) {
tmp = y * (x / -z);
} else {
tmp = (y * x) / x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2e+44: tmp = y + (x / z) elif (y <= 4.2e+102) or not (y <= 9.4e+256): tmp = y * (x / -z) else: tmp = (y * x) / x return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2e+44) tmp = Float64(y + Float64(x / z)); elseif ((y <= 4.2e+102) || !(y <= 9.4e+256)) tmp = Float64(y * Float64(x / Float64(-z))); else tmp = Float64(Float64(y * x) / x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2e+44) tmp = y + (x / z); elseif ((y <= 4.2e+102) || ~((y <= 9.4e+256))) tmp = y * (x / -z); else tmp = (y * x) / x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2e+44], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 4.2e+102], N[Not[LessEqual[y, 9.4e+256]], $MachinePrecision]], N[(y * N[(x / (-z)), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{+44}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+102} \lor \neg \left(y \leq 9.4 \cdot 10^{+256}\right):\\
\;\;\;\;y \cdot \frac{x}{-z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{x}\\
\end{array}
\end{array}
if y < 2.0000000000000002e44Initial program 93.3%
Taylor expanded in y around 0 98.0%
Taylor expanded in x around 0 89.0%
if 2.0000000000000002e44 < y < 4.20000000000000003e102 or 9.39999999999999935e256 < y Initial program 85.5%
Taylor expanded in y around inf 85.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around 0 79.3%
mul-1-neg79.3%
distribute-frac-neg279.3%
Simplified79.3%
if 4.20000000000000003e102 < y < 9.39999999999999935e256Initial program 77.0%
Taylor expanded in x around inf 64.0%
associate-+r+64.0%
+-commutative64.0%
mul-1-neg64.0%
unsub-neg64.0%
div-sub64.0%
Simplified64.0%
Taylor expanded in z around inf 22.8%
associate-*r/63.7%
Applied egg-rr63.7%
Final simplification84.6%
(FPCore (x y z)
:precision binary64
(if (<= y 8.6e+43)
(+ y (/ x z))
(if (or (<= y 1.55e+104) (not (<= y 8.8e+256)))
(/ y (/ (- z) x))
(/ (* y x) x))))
double code(double x, double y, double z) {
double tmp;
if (y <= 8.6e+43) {
tmp = y + (x / z);
} else if ((y <= 1.55e+104) || !(y <= 8.8e+256)) {
tmp = y / (-z / x);
} else {
tmp = (y * x) / 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 (y <= 8.6d+43) then
tmp = y + (x / z)
else if ((y <= 1.55d+104) .or. (.not. (y <= 8.8d+256))) then
tmp = y / (-z / x)
else
tmp = (y * x) / x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 8.6e+43) {
tmp = y + (x / z);
} else if ((y <= 1.55e+104) || !(y <= 8.8e+256)) {
tmp = y / (-z / x);
} else {
tmp = (y * x) / x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 8.6e+43: tmp = y + (x / z) elif (y <= 1.55e+104) or not (y <= 8.8e+256): tmp = y / (-z / x) else: tmp = (y * x) / x return tmp
function code(x, y, z) tmp = 0.0 if (y <= 8.6e+43) tmp = Float64(y + Float64(x / z)); elseif ((y <= 1.55e+104) || !(y <= 8.8e+256)) tmp = Float64(y / Float64(Float64(-z) / x)); else tmp = Float64(Float64(y * x) / x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 8.6e+43) tmp = y + (x / z); elseif ((y <= 1.55e+104) || ~((y <= 8.8e+256))) tmp = y / (-z / x); else tmp = (y * x) / x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 8.6e+43], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.55e+104], N[Not[LessEqual[y, 8.8e+256]], $MachinePrecision]], N[(y / N[((-z) / x), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.6 \cdot 10^{+43}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+104} \lor \neg \left(y \leq 8.8 \cdot 10^{+256}\right):\\
\;\;\;\;\frac{y}{\frac{-z}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{x}\\
\end{array}
\end{array}
if y < 8.6e43Initial program 93.3%
Taylor expanded in y around 0 98.0%
Taylor expanded in x around 0 89.0%
if 8.6e43 < y < 1.55000000000000008e104 or 8.7999999999999997e256 < y Initial program 85.5%
Taylor expanded in y around inf 85.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around 0 79.3%
mul-1-neg79.3%
distribute-frac-neg279.3%
Simplified79.3%
add-sqr-sqrt15.7%
sqrt-unprod16.1%
sqr-neg16.1%
sqrt-unprod0.3%
add-sqr-sqrt1.3%
clear-num1.3%
div-inv1.3%
frac-2neg1.3%
distribute-frac-neg1.3%
add-sqr-sqrt1.1%
sqrt-unprod64.4%
sqr-neg64.4%
sqrt-unprod63.2%
add-sqr-sqrt79.3%
Applied egg-rr79.3%
if 1.55000000000000008e104 < y < 8.7999999999999997e256Initial program 77.0%
Taylor expanded in x around inf 64.0%
associate-+r+64.0%
+-commutative64.0%
mul-1-neg64.0%
unsub-neg64.0%
div-sub64.0%
Simplified64.0%
Taylor expanded in z around inf 22.8%
associate-*r/63.7%
Applied egg-rr63.7%
Final simplification84.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.4e+89) (not (<= x 9.6e-16))) (* x (/ (- 1.0 y) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.4e+89) || !(x <= 9.6e-16)) {
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.4d+89)) .or. (.not. (x <= 9.6d-16))) 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.4e+89) || !(x <= 9.6e-16)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.4e+89) or not (x <= 9.6e-16): tmp = x * ((1.0 - y) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.4e+89) || !(x <= 9.6e-16)) 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.4e+89) || ~((x <= 9.6e-16))) 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.4e+89], N[Not[LessEqual[x, 9.6e-16]], $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.4 \cdot 10^{+89} \lor \neg \left(x \leq 9.6 \cdot 10^{-16}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -1.3999999999999999e89 or 9.60000000000000019e-16 < x Initial program 91.6%
Taylor expanded in x around inf 85.2%
associate-/l*88.0%
mul-1-neg88.0%
unsub-neg88.0%
Simplified88.0%
if -1.3999999999999999e89 < x < 9.60000000000000019e-16Initial program 89.1%
Taylor expanded in y around 0 99.2%
Taylor expanded in x around 0 91.4%
Final simplification89.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -380000.0) (not (<= y 1.0))) (* y (/ (- z x) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -380000.0) || !(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 <= (-380000.0d0)) .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 <= -380000.0) || !(y <= 1.0)) {
tmp = y * ((z - x) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -380000.0) 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 <= -380000.0) || !(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 <= -380000.0) || ~((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, -380000.0], 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 -380000 \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 < -3.8e5 or 1 < y Initial program 80.8%
Taylor expanded in y around inf 80.6%
associate-/l*99.8%
Simplified99.8%
if -3.8e5 < y < 1Initial program 99.9%
Taylor expanded in y around 0 96.9%
Taylor expanded in x around 0 99.2%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= y -380000.0) (* y (/ (- z x) z)) (if (<= y 1.0) (+ y (/ x z)) (- y (* y (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -380000.0) {
tmp = y * ((z - x) / z);
} else if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = y - (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 <= (-380000.0d0)) then
tmp = y * ((z - x) / z)
else if (y <= 1.0d0) then
tmp = y + (x / z)
else
tmp = y - (y * (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -380000.0) {
tmp = y * ((z - x) / z);
} else if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = y - (y * (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -380000.0: tmp = y * ((z - x) / z) elif y <= 1.0: tmp = y + (x / z) else: tmp = y - (y * (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -380000.0) tmp = Float64(y * Float64(Float64(z - x) / z)); elseif (y <= 1.0) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y - Float64(y * Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -380000.0) tmp = y * ((z - x) / z); elseif (y <= 1.0) tmp = y + (x / z); else tmp = y - (y * (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -380000.0], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -380000:\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -3.8e5Initial program 79.4%
Taylor expanded in y around inf 79.1%
associate-/l*99.6%
Simplified99.6%
if -3.8e5 < y < 1Initial program 99.9%
Taylor expanded in y around 0 96.9%
Taylor expanded in x around 0 99.2%
if 1 < y Initial program 82.0%
Taylor expanded in y around 0 91.1%
Taylor expanded in x around 0 91.6%
neg-mul-191.6%
+-commutative91.6%
sub-neg91.6%
div-sub91.6%
associate-/l*93.0%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around inf 93.0%
mul-1-neg93.0%
associate-*l/99.9%
distribute-rgt-neg-out99.9%
Simplified99.9%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= y 2.1e+122) (+ y (/ x z)) (/ (* y x) x)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.1e+122) {
tmp = y + (x / z);
} else {
tmp = (y * x) / 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 (y <= 2.1d+122) then
tmp = y + (x / z)
else
tmp = (y * x) / x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.1e+122) {
tmp = y + (x / z);
} else {
tmp = (y * x) / x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.1e+122: tmp = y + (x / z) else: tmp = (y * x) / x return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.1e+122) tmp = Float64(y + Float64(x / z)); else tmp = Float64(Float64(y * x) / x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.1e+122) tmp = y + (x / z); else tmp = (y * x) / x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.1e+122], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{+122}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{x}\\
\end{array}
\end{array}
if y < 2.10000000000000016e122Initial program 91.6%
Taylor expanded in y around 0 97.6%
Taylor expanded in x around 0 85.0%
if 2.10000000000000016e122 < y Initial program 83.2%
Taylor expanded in x around inf 63.5%
associate-+r+63.5%
+-commutative63.5%
mul-1-neg63.5%
unsub-neg63.5%
div-sub63.5%
Simplified63.5%
Taylor expanded in z around inf 16.6%
associate-*r/55.5%
Applied egg-rr55.5%
Final simplification80.5%
(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 90.4%
Taylor expanded in y around 0 96.0%
Taylor expanded in x around 0 78.6%
Final simplification78.6%
(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 90.4%
Taylor expanded in x around 0 42.6%
Final simplification42.6%
(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 2024081
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:alt
(- (+ y (/ x z)) (/ y (/ z x)))
(/ (+ x (* y (- z x))) z))