
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - 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.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - 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.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (+ 4.0 (/ (* 4.0 (- x z)) y)))
double code(double x, double y, double z) {
return 4.0 + ((4.0 * (x - 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 = 4.0d0 + ((4.0d0 * (x - z)) / y)
end function
public static double code(double x, double y, double z) {
return 4.0 + ((4.0 * (x - z)) / y);
}
def code(x, y, z): return 4.0 + ((4.0 * (x - z)) / y)
function code(x, y, z) return Float64(4.0 + Float64(Float64(4.0 * Float64(x - z)) / y)) end
function tmp = code(x, y, z) tmp = 4.0 + ((4.0 * (x - z)) / y); end
code[x_, y_, z_] := N[(4.0 + N[(N[(4.0 * N[(x - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 + \frac{4 \cdot \left(x - z\right)}{y}
\end{array}
Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ z y))) (t_1 (+ 1.0 (* 4.0 (/ x y)))))
(if (<= x -13600000.0)
t_1
(if (<= x -8e-57)
t_0
(if (<= x 4.4e-120)
4.0
(if (<= x 2.6e-57)
t_0
(if (<= x 1.16e+17) 4.0 (if (<= x 9e+107) t_0 t_1))))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (z / y);
double t_1 = 1.0 + (4.0 * (x / y));
double tmp;
if (x <= -13600000.0) {
tmp = t_1;
} else if (x <= -8e-57) {
tmp = t_0;
} else if (x <= 4.4e-120) {
tmp = 4.0;
} else if (x <= 2.6e-57) {
tmp = t_0;
} else if (x <= 1.16e+17) {
tmp = 4.0;
} else if (x <= 9e+107) {
tmp = t_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 = (-4.0d0) * (z / y)
t_1 = 1.0d0 + (4.0d0 * (x / y))
if (x <= (-13600000.0d0)) then
tmp = t_1
else if (x <= (-8d-57)) then
tmp = t_0
else if (x <= 4.4d-120) then
tmp = 4.0d0
else if (x <= 2.6d-57) then
tmp = t_0
else if (x <= 1.16d+17) then
tmp = 4.0d0
else if (x <= 9d+107) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -4.0 * (z / y);
double t_1 = 1.0 + (4.0 * (x / y));
double tmp;
if (x <= -13600000.0) {
tmp = t_1;
} else if (x <= -8e-57) {
tmp = t_0;
} else if (x <= 4.4e-120) {
tmp = 4.0;
} else if (x <= 2.6e-57) {
tmp = t_0;
} else if (x <= 1.16e+17) {
tmp = 4.0;
} else if (x <= 9e+107) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (z / y) t_1 = 1.0 + (4.0 * (x / y)) tmp = 0 if x <= -13600000.0: tmp = t_1 elif x <= -8e-57: tmp = t_0 elif x <= 4.4e-120: tmp = 4.0 elif x <= 2.6e-57: tmp = t_0 elif x <= 1.16e+17: tmp = 4.0 elif x <= 9e+107: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(z / y)) t_1 = Float64(1.0 + Float64(4.0 * Float64(x / y))) tmp = 0.0 if (x <= -13600000.0) tmp = t_1; elseif (x <= -8e-57) tmp = t_0; elseif (x <= 4.4e-120) tmp = 4.0; elseif (x <= 2.6e-57) tmp = t_0; elseif (x <= 1.16e+17) tmp = 4.0; elseif (x <= 9e+107) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (z / y); t_1 = 1.0 + (4.0 * (x / y)); tmp = 0.0; if (x <= -13600000.0) tmp = t_1; elseif (x <= -8e-57) tmp = t_0; elseif (x <= 4.4e-120) tmp = 4.0; elseif (x <= 2.6e-57) tmp = t_0; elseif (x <= 1.16e+17) tmp = 4.0; elseif (x <= 9e+107) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -13600000.0], t$95$1, If[LessEqual[x, -8e-57], t$95$0, If[LessEqual[x, 4.4e-120], 4.0, If[LessEqual[x, 2.6e-57], t$95$0, If[LessEqual[x, 1.16e+17], 4.0, If[LessEqual[x, 9e+107], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{z}{y}\\
t_1 := 1 + 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -13600000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -8 \cdot 10^{-57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{-120}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.16 \cdot 10^{+17}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+107}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -1.36e7 or 9e107 < x Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around inf 77.9%
if -1.36e7 < x < -7.99999999999999964e-57 or 4.40000000000000025e-120 < x < 2.59999999999999985e-57 or 1.16e17 < x < 9e107Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around inf 98.0%
+-commutative98.0%
distribute-lft-out98.0%
Simplified98.0%
Taylor expanded in z around inf 60.5%
*-commutative60.5%
Simplified60.5%
if -7.99999999999999964e-57 < x < 4.40000000000000025e-120 or 2.59999999999999985e-57 < x < 1.16e17Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around inf 55.6%
Final simplification65.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* -4.0 (/ z y)))) (t_1 (+ 1.0 (* 4.0 (/ x y)))))
(if (<= x -235000000.0)
t_1
(if (<= x -6.8e-138)
t_0
(if (<= x -1.45e-303)
4.0
(if (<= x 6.2e-57)
t_0
(if (<= x 4.2e+17) 4.0 (if (<= x 1.4e+109) t_0 t_1))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (-4.0 * (z / y));
double t_1 = 1.0 + (4.0 * (x / y));
double tmp;
if (x <= -235000000.0) {
tmp = t_1;
} else if (x <= -6.8e-138) {
tmp = t_0;
} else if (x <= -1.45e-303) {
tmp = 4.0;
} else if (x <= 6.2e-57) {
tmp = t_0;
} else if (x <= 4.2e+17) {
tmp = 4.0;
} else if (x <= 1.4e+109) {
tmp = t_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 + ((-4.0d0) * (z / y))
t_1 = 1.0d0 + (4.0d0 * (x / y))
if (x <= (-235000000.0d0)) then
tmp = t_1
else if (x <= (-6.8d-138)) then
tmp = t_0
else if (x <= (-1.45d-303)) then
tmp = 4.0d0
else if (x <= 6.2d-57) then
tmp = t_0
else if (x <= 4.2d+17) then
tmp = 4.0d0
else if (x <= 1.4d+109) then
tmp = t_0
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 + (-4.0 * (z / y));
double t_1 = 1.0 + (4.0 * (x / y));
double tmp;
if (x <= -235000000.0) {
tmp = t_1;
} else if (x <= -6.8e-138) {
tmp = t_0;
} else if (x <= -1.45e-303) {
tmp = 4.0;
} else if (x <= 6.2e-57) {
tmp = t_0;
} else if (x <= 4.2e+17) {
tmp = 4.0;
} else if (x <= 1.4e+109) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (-4.0 * (z / y)) t_1 = 1.0 + (4.0 * (x / y)) tmp = 0 if x <= -235000000.0: tmp = t_1 elif x <= -6.8e-138: tmp = t_0 elif x <= -1.45e-303: tmp = 4.0 elif x <= 6.2e-57: tmp = t_0 elif x <= 4.2e+17: tmp = 4.0 elif x <= 1.4e+109: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(-4.0 * Float64(z / y))) t_1 = Float64(1.0 + Float64(4.0 * Float64(x / y))) tmp = 0.0 if (x <= -235000000.0) tmp = t_1; elseif (x <= -6.8e-138) tmp = t_0; elseif (x <= -1.45e-303) tmp = 4.0; elseif (x <= 6.2e-57) tmp = t_0; elseif (x <= 4.2e+17) tmp = 4.0; elseif (x <= 1.4e+109) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (-4.0 * (z / y)); t_1 = 1.0 + (4.0 * (x / y)); tmp = 0.0; if (x <= -235000000.0) tmp = t_1; elseif (x <= -6.8e-138) tmp = t_0; elseif (x <= -1.45e-303) tmp = 4.0; elseif (x <= 6.2e-57) tmp = t_0; elseif (x <= 4.2e+17) tmp = 4.0; elseif (x <= 1.4e+109) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -235000000.0], t$95$1, If[LessEqual[x, -6.8e-138], t$95$0, If[LessEqual[x, -1.45e-303], 4.0, If[LessEqual[x, 6.2e-57], t$95$0, If[LessEqual[x, 4.2e+17], 4.0, If[LessEqual[x, 1.4e+109], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + -4 \cdot \frac{z}{y}\\
t_1 := 1 + 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -235000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -6.8 \cdot 10^{-138}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.45 \cdot 10^{-303}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{+17}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+109}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -2.35e8 or 1.4000000000000001e109 < x Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around inf 77.9%
if -2.35e8 < x < -6.8000000000000003e-138 or -1.45000000000000007e-303 < x < 6.19999999999999952e-57 or 4.2e17 < x < 1.4000000000000001e109Initial program 99.9%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in z around inf 58.1%
*-commutative58.1%
Simplified58.1%
if -6.8000000000000003e-138 < x < -1.45000000000000007e-303 or 6.19999999999999952e-57 < x < 4.2e17Initial program 99.8%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around inf 62.3%
Final simplification66.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))) (t_1 (* -4.0 (/ z y))))
(if (<= x -15500000.0)
t_0
(if (<= x -2.6e-58)
t_1
(if (<= x 1.9e-127)
4.0
(if (<= x 1.2e-55)
t_1
(if (<= x 2.05e+20) 4.0 (if (<= x 7.2e+110) t_1 t_0))))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double t_1 = -4.0 * (z / y);
double tmp;
if (x <= -15500000.0) {
tmp = t_0;
} else if (x <= -2.6e-58) {
tmp = t_1;
} else if (x <= 1.9e-127) {
tmp = 4.0;
} else if (x <= 1.2e-55) {
tmp = t_1;
} else if (x <= 2.05e+20) {
tmp = 4.0;
} else if (x <= 7.2e+110) {
tmp = t_1;
} else {
tmp = t_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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 4.0d0 * (x / y)
t_1 = (-4.0d0) * (z / y)
if (x <= (-15500000.0d0)) then
tmp = t_0
else if (x <= (-2.6d-58)) then
tmp = t_1
else if (x <= 1.9d-127) then
tmp = 4.0d0
else if (x <= 1.2d-55) then
tmp = t_1
else if (x <= 2.05d+20) then
tmp = 4.0d0
else if (x <= 7.2d+110) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double t_1 = -4.0 * (z / y);
double tmp;
if (x <= -15500000.0) {
tmp = t_0;
} else if (x <= -2.6e-58) {
tmp = t_1;
} else if (x <= 1.9e-127) {
tmp = 4.0;
} else if (x <= 1.2e-55) {
tmp = t_1;
} else if (x <= 2.05e+20) {
tmp = 4.0;
} else if (x <= 7.2e+110) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) t_1 = -4.0 * (z / y) tmp = 0 if x <= -15500000.0: tmp = t_0 elif x <= -2.6e-58: tmp = t_1 elif x <= 1.9e-127: tmp = 4.0 elif x <= 1.2e-55: tmp = t_1 elif x <= 2.05e+20: tmp = 4.0 elif x <= 7.2e+110: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / y)) t_1 = Float64(-4.0 * Float64(z / y)) tmp = 0.0 if (x <= -15500000.0) tmp = t_0; elseif (x <= -2.6e-58) tmp = t_1; elseif (x <= 1.9e-127) tmp = 4.0; elseif (x <= 1.2e-55) tmp = t_1; elseif (x <= 2.05e+20) tmp = 4.0; elseif (x <= 7.2e+110) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / y); t_1 = -4.0 * (z / y); tmp = 0.0; if (x <= -15500000.0) tmp = t_0; elseif (x <= -2.6e-58) tmp = t_1; elseif (x <= 1.9e-127) tmp = 4.0; elseif (x <= 1.2e-55) tmp = t_1; elseif (x <= 2.05e+20) tmp = 4.0; elseif (x <= 7.2e+110) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -15500000.0], t$95$0, If[LessEqual[x, -2.6e-58], t$95$1, If[LessEqual[x, 1.9e-127], 4.0, If[LessEqual[x, 1.2e-55], t$95$1, If[LessEqual[x, 2.05e+20], 4.0, If[LessEqual[x, 7.2e+110], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
t_1 := -4 \cdot \frac{z}{y}\\
\mathbf{if}\;x \leq -15500000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.6 \cdot 10^{-58}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-127}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-55}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{+20}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{+110}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.55e7 or 7.1999999999999994e110 < x Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around inf 95.9%
+-commutative95.9%
distribute-lft-out95.9%
Simplified95.9%
Taylor expanded in x around inf 76.2%
*-commutative76.2%
Simplified76.2%
if -1.55e7 < x < -2.60000000000000007e-58 or 1.90000000000000001e-127 < x < 1.19999999999999996e-55 or 2.05e20 < x < 7.1999999999999994e110Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around inf 98.0%
+-commutative98.0%
distribute-lft-out98.0%
Simplified98.0%
Taylor expanded in z around inf 60.5%
*-commutative60.5%
Simplified60.5%
if -2.60000000000000007e-58 < x < 1.90000000000000001e-127 or 1.19999999999999996e-55 < x < 2.05e20Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around inf 55.6%
Final simplification64.6%
(FPCore (x y z) :precision binary64 (if (<= y -1.75e-40) (+ 4.0 (/ x (* y 0.25))) (if (<= y 2.1e+40) (+ 1.0 (/ 4.0 (/ y (- x z)))) (+ 4.0 (* -4.0 (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.75e-40) {
tmp = 4.0 + (x / (y * 0.25));
} else if (y <= 2.1e+40) {
tmp = 1.0 + (4.0 / (y / (x - z)));
} else {
tmp = 4.0 + (-4.0 * (z / 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.75d-40)) then
tmp = 4.0d0 + (x / (y * 0.25d0))
else if (y <= 2.1d+40) then
tmp = 1.0d0 + (4.0d0 / (y / (x - z)))
else
tmp = 4.0d0 + ((-4.0d0) * (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.75e-40) {
tmp = 4.0 + (x / (y * 0.25));
} else if (y <= 2.1e+40) {
tmp = 1.0 + (4.0 / (y / (x - z)));
} else {
tmp = 4.0 + (-4.0 * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.75e-40: tmp = 4.0 + (x / (y * 0.25)) elif y <= 2.1e+40: tmp = 1.0 + (4.0 / (y / (x - z))) else: tmp = 4.0 + (-4.0 * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.75e-40) tmp = Float64(4.0 + Float64(x / Float64(y * 0.25))); elseif (y <= 2.1e+40) tmp = Float64(1.0 + Float64(4.0 / Float64(y / Float64(x - z)))); else tmp = Float64(4.0 + Float64(-4.0 * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.75e-40) tmp = 4.0 + (x / (y * 0.25)); elseif (y <= 2.1e+40) tmp = 1.0 + (4.0 / (y / (x - z))); else tmp = 4.0 + (-4.0 * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.75e-40], N[(4.0 + N[(x / N[(y * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.1e+40], N[(1.0 + N[(4.0 / N[(y / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{-40}:\\
\;\;\;\;4 + \frac{x}{y \cdot 0.25}\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+40}:\\
\;\;\;\;1 + \frac{4}{\frac{y}{x - z}}\\
\mathbf{else}:\\
\;\;\;\;4 + -4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if y < -1.7500000000000001e-40Initial program 99.9%
associate-*l/99.9%
+-commutative99.9%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around inf 86.7%
associate-*r/86.7%
/-rgt-identity86.7%
*-commutative86.7%
associate-/l*86.7%
metadata-eval86.7%
associate-/r*86.7%
*-commutative86.7%
Simplified86.7%
if -1.7500000000000001e-40 < y < 2.1000000000000001e40Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 94.4%
associate-*r/94.4%
associate-/l*94.2%
Simplified94.2%
if 2.1000000000000001e40 < y Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around 0 86.9%
Final simplification90.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.7e+128) (not (<= x 9.5e+108))) (+ 1.0 (* 4.0 (/ x y))) (+ 4.0 (* -4.0 (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.7e+128) || !(x <= 9.5e+108)) {
tmp = 1.0 + (4.0 * (x / y));
} else {
tmp = 4.0 + (-4.0 * (z / 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 <= (-5.7d+128)) .or. (.not. (x <= 9.5d+108))) then
tmp = 1.0d0 + (4.0d0 * (x / y))
else
tmp = 4.0d0 + ((-4.0d0) * (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5.7e+128) || !(x <= 9.5e+108)) {
tmp = 1.0 + (4.0 * (x / y));
} else {
tmp = 4.0 + (-4.0 * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.7e+128) or not (x <= 9.5e+108): tmp = 1.0 + (4.0 * (x / y)) else: tmp = 4.0 + (-4.0 * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.7e+128) || !(x <= 9.5e+108)) tmp = Float64(1.0 + Float64(4.0 * Float64(x / y))); else tmp = Float64(4.0 + Float64(-4.0 * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5.7e+128) || ~((x <= 9.5e+108))) tmp = 1.0 + (4.0 * (x / y)); else tmp = 4.0 + (-4.0 * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.7e+128], N[Not[LessEqual[x, 9.5e+108]], $MachinePrecision]], N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.7 \cdot 10^{+128} \lor \neg \left(x \leq 9.5 \cdot 10^{+108}\right):\\
\;\;\;\;1 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + -4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < -5.70000000000000024e128 or 9.50000000000000097e108 < x Initial program 100.0%
associate-*l/99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in x around inf 88.0%
if -5.70000000000000024e128 < x < 9.50000000000000097e108Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around 0 82.7%
Final simplification84.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.1e+24) (not (<= z 1.25e+121))) (+ 4.0 (* -4.0 (/ z y))) (+ 4.0 (/ x (* y 0.25)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.1e+24) || !(z <= 1.25e+121)) {
tmp = 4.0 + (-4.0 * (z / y));
} else {
tmp = 4.0 + (x / (y * 0.25));
}
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.1d+24)) .or. (.not. (z <= 1.25d+121))) then
tmp = 4.0d0 + ((-4.0d0) * (z / y))
else
tmp = 4.0d0 + (x / (y * 0.25d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.1e+24) || !(z <= 1.25e+121)) {
tmp = 4.0 + (-4.0 * (z / y));
} else {
tmp = 4.0 + (x / (y * 0.25));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.1e+24) or not (z <= 1.25e+121): tmp = 4.0 + (-4.0 * (z / y)) else: tmp = 4.0 + (x / (y * 0.25)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.1e+24) || !(z <= 1.25e+121)) tmp = Float64(4.0 + Float64(-4.0 * Float64(z / y))); else tmp = Float64(4.0 + Float64(x / Float64(y * 0.25))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.1e+24) || ~((z <= 1.25e+121))) tmp = 4.0 + (-4.0 * (z / y)); else tmp = 4.0 + (x / (y * 0.25)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.1e+24], N[Not[LessEqual[z, 1.25e+121]], $MachinePrecision]], N[(4.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(x / N[(y * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.1 \cdot 10^{+24} \lor \neg \left(z \leq 1.25 \cdot 10^{+121}\right):\\
\;\;\;\;4 + -4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + \frac{x}{y \cdot 0.25}\\
\end{array}
\end{array}
if z < -4.1000000000000001e24 or 1.25000000000000002e121 < z Initial program 100.0%
associate-*l/99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around 0 88.0%
if -4.1000000000000001e24 < z < 1.25000000000000002e121Initial program 99.9%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around inf 90.2%
associate-*r/90.2%
/-rgt-identity90.2%
*-commutative90.2%
associate-/l*90.2%
metadata-eval90.2%
associate-/r*90.2%
*-commutative90.2%
Simplified90.2%
Final simplification89.3%
(FPCore (x y z) :precision binary64 (if (<= y -1.75e-40) (+ 4.0 (/ x (* y 0.25))) (if (<= y 1.15e+40) (/ (* 4.0 (- x z)) y) (+ 4.0 (* -4.0 (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.75e-40) {
tmp = 4.0 + (x / (y * 0.25));
} else if (y <= 1.15e+40) {
tmp = (4.0 * (x - z)) / y;
} else {
tmp = 4.0 + (-4.0 * (z / 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.75d-40)) then
tmp = 4.0d0 + (x / (y * 0.25d0))
else if (y <= 1.15d+40) then
tmp = (4.0d0 * (x - z)) / y
else
tmp = 4.0d0 + ((-4.0d0) * (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.75e-40) {
tmp = 4.0 + (x / (y * 0.25));
} else if (y <= 1.15e+40) {
tmp = (4.0 * (x - z)) / y;
} else {
tmp = 4.0 + (-4.0 * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.75e-40: tmp = 4.0 + (x / (y * 0.25)) elif y <= 1.15e+40: tmp = (4.0 * (x - z)) / y else: tmp = 4.0 + (-4.0 * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.75e-40) tmp = Float64(4.0 + Float64(x / Float64(y * 0.25))); elseif (y <= 1.15e+40) tmp = Float64(Float64(4.0 * Float64(x - z)) / y); else tmp = Float64(4.0 + Float64(-4.0 * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.75e-40) tmp = 4.0 + (x / (y * 0.25)); elseif (y <= 1.15e+40) tmp = (4.0 * (x - z)) / y; else tmp = 4.0 + (-4.0 * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.75e-40], N[(4.0 + N[(x / N[(y * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.15e+40], N[(N[(4.0 * N[(x - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(4.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{-40}:\\
\;\;\;\;4 + \frac{x}{y \cdot 0.25}\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{+40}:\\
\;\;\;\;\frac{4 \cdot \left(x - z\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + -4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if y < -1.7500000000000001e-40Initial program 99.9%
associate-*l/99.9%
+-commutative99.9%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around inf 86.7%
associate-*r/86.7%
/-rgt-identity86.7%
*-commutative86.7%
associate-/l*86.7%
metadata-eval86.7%
associate-/r*86.7%
*-commutative86.7%
Simplified86.7%
if -1.7500000000000001e-40 < y < 1.14999999999999997e40Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around inf 96.2%
+-commutative96.2%
distribute-lft-out96.2%
Simplified96.2%
Taylor expanded in y around 0 93.7%
associate-*r/93.7%
Simplified93.7%
if 1.14999999999999997e40 < y Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around 0 86.9%
Final simplification90.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.7e-22) (not (<= x 4.1e+57))) (* x (/ 4.0 y)) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.7e-22) || !(x <= 4.1e+57)) {
tmp = x * (4.0 / y);
} else {
tmp = 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 <= (-1.7d-22)) .or. (.not. (x <= 4.1d+57))) then
tmp = x * (4.0d0 / y)
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.7e-22) || !(x <= 4.1e+57)) {
tmp = x * (4.0 / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.7e-22) or not (x <= 4.1e+57): tmp = x * (4.0 / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.7e-22) || !(x <= 4.1e+57)) tmp = Float64(x * Float64(4.0 / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.7e-22) || ~((x <= 4.1e+57))) tmp = x * (4.0 / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.7e-22], N[Not[LessEqual[x, 4.1e+57]], $MachinePrecision]], N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{-22} \lor \neg \left(x \leq 4.1 \cdot 10^{+57}\right):\\
\;\;\;\;x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if x < -1.6999999999999999e-22 or 4.1e57 < x Initial program 100.0%
associate-*l/99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in x around inf 95.7%
+-commutative95.7%
distribute-lft-out95.7%
Simplified95.7%
Taylor expanded in x around inf 69.1%
*-commutative69.1%
Simplified69.1%
Taylor expanded in x around 0 69.1%
associate-*r/69.1%
associate-*l/69.0%
*-commutative69.0%
Simplified69.0%
if -1.6999999999999999e-22 < x < 4.1e57Initial program 99.9%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around inf 49.1%
Final simplification58.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -2e-22) (not (<= x 8e+58))) (* 4.0 (/ x y)) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2e-22) || !(x <= 8e+58)) {
tmp = 4.0 * (x / y);
} else {
tmp = 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 <= (-2d-22)) .or. (.not. (x <= 8d+58))) then
tmp = 4.0d0 * (x / y)
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2e-22) || !(x <= 8e+58)) {
tmp = 4.0 * (x / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2e-22) or not (x <= 8e+58): tmp = 4.0 * (x / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2e-22) || !(x <= 8e+58)) tmp = Float64(4.0 * Float64(x / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2e-22) || ~((x <= 8e+58))) tmp = 4.0 * (x / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2e-22], N[Not[LessEqual[x, 8e+58]], $MachinePrecision]], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-22} \lor \neg \left(x \leq 8 \cdot 10^{+58}\right):\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if x < -2.0000000000000001e-22 or 7.99999999999999955e58 < x Initial program 100.0%
associate-*l/99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in x around inf 95.7%
+-commutative95.7%
distribute-lft-out95.7%
Simplified95.7%
Taylor expanded in x around inf 69.1%
*-commutative69.1%
Simplified69.1%
if -2.0000000000000001e-22 < x < 7.99999999999999955e58Initial program 99.9%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around inf 49.1%
Final simplification58.2%
(FPCore (x y z) :precision binary64 4.0)
double code(double x, double y, double z) {
return 4.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 4.0d0
end function
public static double code(double x, double y, double z) {
return 4.0;
}
def code(x, y, z): return 4.0
function code(x, y, z) return 4.0 end
function tmp = code(x, y, z) tmp = 4.0; end
code[x_, y_, z_] := 4.0
\begin{array}{l}
\\
4
\end{array}
Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around inf 33.1%
Final simplification33.1%
herbie shell --seed 2023318
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, A"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))