
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (+ (/ (- x z) (* y 0.25)) 2.0))
double code(double x, double y, double z) {
return ((x - z) / (y * 0.25)) + 2.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x - z) / (y * 0.25d0)) + 2.0d0
end function
public static double code(double x, double y, double z) {
return ((x - z) / (y * 0.25)) + 2.0;
}
def code(x, y, z): return ((x - z) / (y * 0.25)) + 2.0
function code(x, y, z) return Float64(Float64(Float64(x - z) / Float64(y * 0.25)) + 2.0) end
function tmp = code(x, y, z) tmp = ((x - z) / (y * 0.25)) + 2.0; end
code[x_, y_, z_] := N[(N[(N[(x - z), $MachinePrecision] / N[(y * 0.25), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - z}{y \cdot 0.25} + 2
\end{array}
Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ z y) -4.0)) (t_1 (+ 1.0 (* x (/ 4.0 y)))))
(if (<= x -0.00042)
t_1
(if (<= x -5.8e-33)
t_0
(if (<= x -1.02e-109)
2.0
(if (<= x 1.06e-69) t_0 (if (<= x 4e+41) 2.0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = (z / y) * -4.0;
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -0.00042) {
tmp = t_1;
} else if (x <= -5.8e-33) {
tmp = t_0;
} else if (x <= -1.02e-109) {
tmp = 2.0;
} else if (x <= 1.06e-69) {
tmp = t_0;
} else if (x <= 4e+41) {
tmp = 2.0;
} else {
tmp = t_1;
}
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 = (z / y) * (-4.0d0)
t_1 = 1.0d0 + (x * (4.0d0 / y))
if (x <= (-0.00042d0)) then
tmp = t_1
else if (x <= (-5.8d-33)) then
tmp = t_0
else if (x <= (-1.02d-109)) then
tmp = 2.0d0
else if (x <= 1.06d-69) then
tmp = t_0
else if (x <= 4d+41) then
tmp = 2.0d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z / y) * -4.0;
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -0.00042) {
tmp = t_1;
} else if (x <= -5.8e-33) {
tmp = t_0;
} else if (x <= -1.02e-109) {
tmp = 2.0;
} else if (x <= 1.06e-69) {
tmp = t_0;
} else if (x <= 4e+41) {
tmp = 2.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (z / y) * -4.0 t_1 = 1.0 + (x * (4.0 / y)) tmp = 0 if x <= -0.00042: tmp = t_1 elif x <= -5.8e-33: tmp = t_0 elif x <= -1.02e-109: tmp = 2.0 elif x <= 1.06e-69: tmp = t_0 elif x <= 4e+41: tmp = 2.0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(z / y) * -4.0) t_1 = Float64(1.0 + Float64(x * Float64(4.0 / y))) tmp = 0.0 if (x <= -0.00042) tmp = t_1; elseif (x <= -5.8e-33) tmp = t_0; elseif (x <= -1.02e-109) tmp = 2.0; elseif (x <= 1.06e-69) tmp = t_0; elseif (x <= 4e+41) tmp = 2.0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z / y) * -4.0; t_1 = 1.0 + (x * (4.0 / y)); tmp = 0.0; if (x <= -0.00042) tmp = t_1; elseif (x <= -5.8e-33) tmp = t_0; elseif (x <= -1.02e-109) tmp = 2.0; elseif (x <= 1.06e-69) tmp = t_0; elseif (x <= 4e+41) tmp = 2.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.00042], t$95$1, If[LessEqual[x, -5.8e-33], t$95$0, If[LessEqual[x, -1.02e-109], 2.0, If[LessEqual[x, 1.06e-69], t$95$0, If[LessEqual[x, 4e+41], 2.0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z}{y} \cdot -4\\
t_1 := 1 + x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -0.00042:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -5.8 \cdot 10^{-33}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.02 \cdot 10^{-109}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 1.06 \cdot 10^{-69}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+41}:\\
\;\;\;\;2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -4.2000000000000002e-4 or 4.00000000000000002e41 < x Initial program 100.0%
Taylor expanded in x around inf 67.7%
associate-*r/67.7%
associate-*l/67.5%
*-commutative67.5%
Simplified67.5%
if -4.2000000000000002e-4 < x < -5.80000000000000005e-33 or -1.02e-109 < x < 1.05999999999999997e-69Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 96.9%
+-commutative96.9%
associate-*r/96.9%
*-commutative96.9%
associate-/l*96.7%
fma-define96.7%
Simplified96.7%
Taylor expanded in z around inf 64.1%
if -5.80000000000000005e-33 < x < -1.02e-109 or 1.05999999999999997e-69 < x < 4.00000000000000002e41Initial program 99.9%
Taylor expanded in y around inf 54.8%
Final simplification63.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* z (/ -4.0 y)))) (t_1 (+ 1.0 (* x (/ 4.0 y)))))
(if (<= x -0.00045)
t_1
(if (<= x -5.3e-67)
t_0
(if (<= x -1.08e-104)
2.0
(if (<= x 5.5e-65) t_0 (if (<= x 3.6e+41) 2.0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (z * (-4.0 / y));
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -0.00045) {
tmp = t_1;
} else if (x <= -5.3e-67) {
tmp = t_0;
} else if (x <= -1.08e-104) {
tmp = 2.0;
} else if (x <= 5.5e-65) {
tmp = t_0;
} else if (x <= 3.6e+41) {
tmp = 2.0;
} else {
tmp = t_1;
}
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 = 1.0d0 + (z * ((-4.0d0) / y))
t_1 = 1.0d0 + (x * (4.0d0 / y))
if (x <= (-0.00045d0)) then
tmp = t_1
else if (x <= (-5.3d-67)) then
tmp = t_0
else if (x <= (-1.08d-104)) then
tmp = 2.0d0
else if (x <= 5.5d-65) then
tmp = t_0
else if (x <= 3.6d+41) then
tmp = 2.0d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 + (z * (-4.0 / y));
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -0.00045) {
tmp = t_1;
} else if (x <= -5.3e-67) {
tmp = t_0;
} else if (x <= -1.08e-104) {
tmp = 2.0;
} else if (x <= 5.5e-65) {
tmp = t_0;
} else if (x <= 3.6e+41) {
tmp = 2.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z * (-4.0 / y)) t_1 = 1.0 + (x * (4.0 / y)) tmp = 0 if x <= -0.00045: tmp = t_1 elif x <= -5.3e-67: tmp = t_0 elif x <= -1.08e-104: tmp = 2.0 elif x <= 5.5e-65: tmp = t_0 elif x <= 3.6e+41: tmp = 2.0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(z * Float64(-4.0 / y))) t_1 = Float64(1.0 + Float64(x * Float64(4.0 / y))) tmp = 0.0 if (x <= -0.00045) tmp = t_1; elseif (x <= -5.3e-67) tmp = t_0; elseif (x <= -1.08e-104) tmp = 2.0; elseif (x <= 5.5e-65) tmp = t_0; elseif (x <= 3.6e+41) tmp = 2.0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (z * (-4.0 / y)); t_1 = 1.0 + (x * (4.0 / y)); tmp = 0.0; if (x <= -0.00045) tmp = t_1; elseif (x <= -5.3e-67) tmp = t_0; elseif (x <= -1.08e-104) tmp = 2.0; elseif (x <= 5.5e-65) tmp = t_0; elseif (x <= 3.6e+41) tmp = 2.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.00045], t$95$1, If[LessEqual[x, -5.3e-67], t$95$0, If[LessEqual[x, -1.08e-104], 2.0, If[LessEqual[x, 5.5e-65], t$95$0, If[LessEqual[x, 3.6e+41], 2.0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + z \cdot \frac{-4}{y}\\
t_1 := 1 + x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -0.00045:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -5.3 \cdot 10^{-67}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.08 \cdot 10^{-104}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-65}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{+41}:\\
\;\;\;\;2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -4.4999999999999999e-4 or 3.60000000000000025e41 < x Initial program 100.0%
Taylor expanded in x around inf 67.7%
associate-*r/67.7%
associate-*l/67.5%
*-commutative67.5%
Simplified67.5%
if -4.4999999999999999e-4 < x < -5.29999999999999971e-67 or -1.07999999999999997e-104 < x < 5.4999999999999999e-65Initial program 99.9%
Taylor expanded in z around inf 65.8%
associate-*r/65.8%
metadata-eval65.8%
associate-*r*65.8%
neg-mul-165.8%
associate-*l/65.7%
distribute-rgt-neg-out65.7%
*-commutative65.7%
distribute-rgt-neg-in65.7%
distribute-neg-frac65.7%
metadata-eval65.7%
Simplified65.7%
if -5.29999999999999971e-67 < x < -1.07999999999999997e-104 or 5.4999999999999999e-65 < x < 3.60000000000000025e41Initial program 99.9%
Taylor expanded in y around inf 64.3%
Final simplification66.2%
(FPCore (x y z)
:precision binary64
(if (or (<= z -4.9e+83)
(and (not (<= z -2.3e+57)) (or (<= z -3.4e-33) (not (<= z 3e+17)))))
(* (/ z y) -4.0)
2.0))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.9e+83) || (!(z <= -2.3e+57) && ((z <= -3.4e-33) || !(z <= 3e+17)))) {
tmp = (z / y) * -4.0;
} else {
tmp = 2.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-4.9d+83)) .or. (.not. (z <= (-2.3d+57))) .and. (z <= (-3.4d-33)) .or. (.not. (z <= 3d+17))) then
tmp = (z / y) * (-4.0d0)
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.9e+83) || (!(z <= -2.3e+57) && ((z <= -3.4e-33) || !(z <= 3e+17)))) {
tmp = (z / y) * -4.0;
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.9e+83) or (not (z <= -2.3e+57) and ((z <= -3.4e-33) or not (z <= 3e+17))): tmp = (z / y) * -4.0 else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.9e+83) || (!(z <= -2.3e+57) && ((z <= -3.4e-33) || !(z <= 3e+17)))) tmp = Float64(Float64(z / y) * -4.0); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.9e+83) || (~((z <= -2.3e+57)) && ((z <= -3.4e-33) || ~((z <= 3e+17))))) tmp = (z / y) * -4.0; else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.9e+83], And[N[Not[LessEqual[z, -2.3e+57]], $MachinePrecision], Or[LessEqual[z, -3.4e-33], N[Not[LessEqual[z, 3e+17]], $MachinePrecision]]]], N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision], 2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.9 \cdot 10^{+83} \lor \neg \left(z \leq -2.3 \cdot 10^{+57}\right) \land \left(z \leq -3.4 \cdot 10^{-33} \lor \neg \left(z \leq 3 \cdot 10^{+17}\right)\right):\\
\;\;\;\;\frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if z < -4.89999999999999979e83 or -2.2999999999999999e57 < z < -3.4000000000000001e-33 or 3e17 < z Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 85.8%
+-commutative85.8%
associate-*r/85.8%
*-commutative85.8%
associate-/l*85.7%
fma-define85.7%
Simplified85.7%
Taylor expanded in z around inf 73.4%
if -4.89999999999999979e83 < z < -2.2999999999999999e57 or -3.4000000000000001e-33 < z < 3e17Initial program 100.0%
Taylor expanded in y around inf 49.0%
Final simplification60.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -1e+186) (not (<= x 2.9e+106))) (+ 1.0 (* x (/ 4.0 y))) (+ 2.0 (* (/ z y) -4.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1e+186) || !(x <= 2.9e+106)) {
tmp = 1.0 + (x * (4.0 / y));
} else {
tmp = 2.0 + ((z / y) * -4.0);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-1d+186)) .or. (.not. (x <= 2.9d+106))) then
tmp = 1.0d0 + (x * (4.0d0 / y))
else
tmp = 2.0d0 + ((z / y) * (-4.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1e+186) || !(x <= 2.9e+106)) {
tmp = 1.0 + (x * (4.0 / y));
} else {
tmp = 2.0 + ((z / y) * -4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1e+186) or not (x <= 2.9e+106): tmp = 1.0 + (x * (4.0 / y)) else: tmp = 2.0 + ((z / y) * -4.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1e+186) || !(x <= 2.9e+106)) tmp = Float64(1.0 + Float64(x * Float64(4.0 / y))); else tmp = Float64(2.0 + Float64(Float64(z / y) * -4.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1e+186) || ~((x <= 2.9e+106))) tmp = 1.0 + (x * (4.0 / y)); else tmp = 2.0 + ((z / y) * -4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1e+186], N[Not[LessEqual[x, 2.9e+106]], $MachinePrecision]], N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+186} \lor \neg \left(x \leq 2.9 \cdot 10^{+106}\right):\\
\;\;\;\;1 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\end{array}
\end{array}
if x < -9.9999999999999998e185 or 2.9000000000000002e106 < x Initial program 100.0%
Taylor expanded in x around inf 87.7%
associate-*r/87.7%
associate-*l/87.6%
*-commutative87.6%
Simplified87.6%
if -9.9999999999999998e185 < x < 2.9000000000000002e106Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 85.0%
+-commutative85.0%
*-commutative85.0%
Simplified85.0%
Final simplification85.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.00013) (not (<= z 1.12e-111))) (+ 2.0 (* (/ z y) -4.0)) (+ 2.0 (/ (* x 4.0) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.00013) || !(z <= 1.12e-111)) {
tmp = 2.0 + ((z / y) * -4.0);
} else {
tmp = 2.0 + ((x * 4.0) / 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 <= (-0.00013d0)) .or. (.not. (z <= 1.12d-111))) then
tmp = 2.0d0 + ((z / y) * (-4.0d0))
else
tmp = 2.0d0 + ((x * 4.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.00013) || !(z <= 1.12e-111)) {
tmp = 2.0 + ((z / y) * -4.0);
} else {
tmp = 2.0 + ((x * 4.0) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.00013) or not (z <= 1.12e-111): tmp = 2.0 + ((z / y) * -4.0) else: tmp = 2.0 + ((x * 4.0) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.00013) || !(z <= 1.12e-111)) tmp = Float64(2.0 + Float64(Float64(z / y) * -4.0)); else tmp = Float64(2.0 + Float64(Float64(x * 4.0) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.00013) || ~((z <= 1.12e-111))) tmp = 2.0 + ((z / y) * -4.0); else tmp = 2.0 + ((x * 4.0) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.00013], N[Not[LessEqual[z, 1.12e-111]], $MachinePrecision]], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.00013 \lor \neg \left(z \leq 1.12 \cdot 10^{-111}\right):\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{x \cdot 4}{y}\\
\end{array}
\end{array}
if z < -1.29999999999999989e-4 or 1.12000000000000009e-111 < z Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 85.8%
+-commutative85.8%
*-commutative85.8%
Simplified85.8%
if -1.29999999999999989e-4 < z < 1.12000000000000009e-111Initial program 99.9%
+-commutative99.9%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.7%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 90.9%
+-commutative90.9%
associate-*r/90.9%
Simplified90.9%
Final simplification87.9%
(FPCore (x y z) :precision binary64 (+ 2.0 (* (- x z) (/ 4.0 y))))
double code(double x, double y, double z) {
return 2.0 + ((x - z) * (4.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 = 2.0d0 + ((x - z) * (4.0d0 / y))
end function
public static double code(double x, double y, double z) {
return 2.0 + ((x - z) * (4.0 / y));
}
def code(x, y, z): return 2.0 + ((x - z) * (4.0 / y))
function code(x, y, z) return Float64(2.0 + Float64(Float64(x - z) * Float64(4.0 / y))) end
function tmp = code(x, y, z) tmp = 2.0 + ((x - z) * (4.0 / y)); end
code[x_, y_, z_] := N[(2.0 + N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 + \left(x - z\right) \cdot \frac{4}{y}
\end{array}
Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
Taylor expanded in x around inf 36.8%
associate-*r/36.8%
associate-*l/36.7%
*-commutative36.7%
Simplified36.7%
Taylor expanded in x around 0 7.8%
Final simplification7.8%
(FPCore (x y z) :precision binary64 2.0)
double code(double x, double y, double z) {
return 2.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0
end function
public static double code(double x, double y, double z) {
return 2.0;
}
def code(x, y, z): return 2.0
function code(x, y, z) return 2.0 end
function tmp = code(x, y, z) tmp = 2.0; end
code[x_, y_, z_] := 2.0
\begin{array}{l}
\\
2
\end{array}
Initial program 100.0%
Taylor expanded in y around inf 31.8%
Final simplification31.8%
herbie shell --seed 2024043
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, C"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))