
(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 9 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(4.0 * Float64(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[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 + 4 \cdot \frac{x - z}{y}
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))))
(if (<= x -3.5e+64)
t_0
(if (<= x 1.12e-102) (* -4.0 (/ z y)) (if (<= x 3.8e+105) 4.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double tmp;
if (x <= -3.5e+64) {
tmp = t_0;
} else if (x <= 1.12e-102) {
tmp = -4.0 * (z / y);
} else if (x <= 3.8e+105) {
tmp = 4.0;
} 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) :: tmp
t_0 = 4.0d0 * (x / y)
if (x <= (-3.5d+64)) then
tmp = t_0
else if (x <= 1.12d-102) then
tmp = (-4.0d0) * (z / y)
else if (x <= 3.8d+105) then
tmp = 4.0d0
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 tmp;
if (x <= -3.5e+64) {
tmp = t_0;
} else if (x <= 1.12e-102) {
tmp = -4.0 * (z / y);
} else if (x <= 3.8e+105) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) tmp = 0 if x <= -3.5e+64: tmp = t_0 elif x <= 1.12e-102: tmp = -4.0 * (z / y) elif x <= 3.8e+105: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / y)) tmp = 0.0 if (x <= -3.5e+64) tmp = t_0; elseif (x <= 1.12e-102) tmp = Float64(-4.0 * Float64(z / y)); elseif (x <= 3.8e+105) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / y); tmp = 0.0; if (x <= -3.5e+64) tmp = t_0; elseif (x <= 1.12e-102) tmp = -4.0 * (z / y); elseif (x <= 3.8e+105) tmp = 4.0; 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]}, If[LessEqual[x, -3.5e+64], t$95$0, If[LessEqual[x, 1.12e-102], N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.8e+105], 4.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -3.5 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{-102}:\\
\;\;\;\;-4 \cdot \frac{z}{y}\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+105}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.4999999999999999e64 or 3.8e105 < x Initial program 99.9%
Taylor expanded in x around inf 72.9%
if -3.4999999999999999e64 < x < 1.12000000000000009e-102Initial program 99.9%
Taylor expanded in z around inf 51.0%
*-commutative51.0%
Simplified51.0%
if 1.12000000000000009e-102 < x < 3.8e105Initial program 99.9%
Taylor expanded in y around inf 66.5%
Final simplification61.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))))
(if (<= x -3.2e+65)
t_0
(if (<= x 1.1e-101) (* z (/ -4.0 y)) (if (<= x 1.12e+105) 4.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double tmp;
if (x <= -3.2e+65) {
tmp = t_0;
} else if (x <= 1.1e-101) {
tmp = z * (-4.0 / y);
} else if (x <= 1.12e+105) {
tmp = 4.0;
} 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) :: tmp
t_0 = 4.0d0 * (x / y)
if (x <= (-3.2d+65)) then
tmp = t_0
else if (x <= 1.1d-101) then
tmp = z * ((-4.0d0) / y)
else if (x <= 1.12d+105) then
tmp = 4.0d0
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 tmp;
if (x <= -3.2e+65) {
tmp = t_0;
} else if (x <= 1.1e-101) {
tmp = z * (-4.0 / y);
} else if (x <= 1.12e+105) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) tmp = 0 if x <= -3.2e+65: tmp = t_0 elif x <= 1.1e-101: tmp = z * (-4.0 / y) elif x <= 1.12e+105: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / y)) tmp = 0.0 if (x <= -3.2e+65) tmp = t_0; elseif (x <= 1.1e-101) tmp = Float64(z * Float64(-4.0 / y)); elseif (x <= 1.12e+105) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / y); tmp = 0.0; if (x <= -3.2e+65) tmp = t_0; elseif (x <= 1.1e-101) tmp = z * (-4.0 / y); elseif (x <= 1.12e+105) tmp = 4.0; 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]}, If[LessEqual[x, -3.2e+65], t$95$0, If[LessEqual[x, 1.1e-101], N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.12e+105], 4.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -3.2 \cdot 10^{+65}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-101}:\\
\;\;\;\;z \cdot \frac{-4}{y}\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{+105}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.20000000000000007e65 or 1.12e105 < x Initial program 99.9%
Taylor expanded in x around inf 72.9%
if -3.20000000000000007e65 < x < 1.0999999999999999e-101Initial program 99.9%
Taylor expanded in z around inf 51.0%
associate-*r/51.0%
*-commutative51.0%
associate-/l*50.8%
Simplified50.8%
if 1.0999999999999999e-101 < x < 1.12e105Initial program 99.9%
Taylor expanded in y around inf 66.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.4e+84) (not (<= y 2.9e+88))) (+ 4.0 (* x (/ 4.0 y))) (* (- x z) (/ 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.4e+84) || !(y <= 2.9e+88)) {
tmp = 4.0 + (x * (4.0 / y));
} else {
tmp = (x - z) * (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 ((y <= (-1.4d+84)) .or. (.not. (y <= 2.9d+88))) then
tmp = 4.0d0 + (x * (4.0d0 / y))
else
tmp = (x - z) * (4.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.4e+84) || !(y <= 2.9e+88)) {
tmp = 4.0 + (x * (4.0 / y));
} else {
tmp = (x - z) * (4.0 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.4e+84) or not (y <= 2.9e+88): tmp = 4.0 + (x * (4.0 / y)) else: tmp = (x - z) * (4.0 / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.4e+84) || !(y <= 2.9e+88)) tmp = Float64(4.0 + Float64(x * Float64(4.0 / y))); else tmp = Float64(Float64(x - z) * Float64(4.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.4e+84) || ~((y <= 2.9e+88))) tmp = 4.0 + (x * (4.0 / y)); else tmp = (x - z) * (4.0 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.4e+84], N[Not[LessEqual[y, 2.9e+88]], $MachinePrecision]], N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{+84} \lor \neg \left(y \leq 2.9 \cdot 10^{+88}\right):\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\end{array}
\end{array}
if y < -1.39999999999999991e84 or 2.9e88 < y Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 87.1%
distribute-lft-in87.1%
metadata-eval87.1%
associate-+r+87.1%
metadata-eval87.1%
associate-*r/87.1%
*-commutative87.1%
associate-*r/87.0%
Simplified87.0%
if -1.39999999999999991e84 < y < 2.9e88Initial program 100.0%
Taylor expanded in y around 0 87.9%
*-lft-identity87.9%
associate-*l/87.6%
associate-*r*87.6%
associate-*r/87.6%
metadata-eval87.6%
Simplified87.6%
Final simplification87.4%
(FPCore (x y z) :precision binary64 (if (<= x -9e+20) (* (- x z) (/ 4.0 y)) (if (<= x 6.2e+37) (+ 4.0 (/ (* z -4.0) y)) (+ 4.0 (* x (/ 4.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -9e+20) {
tmp = (x - z) * (4.0 / y);
} else if (x <= 6.2e+37) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = 4.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 (x <= (-9d+20)) then
tmp = (x - z) * (4.0d0 / y)
else if (x <= 6.2d+37) then
tmp = 4.0d0 + ((z * (-4.0d0)) / y)
else
tmp = 4.0d0 + (x * (4.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -9e+20) {
tmp = (x - z) * (4.0 / y);
} else if (x <= 6.2e+37) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = 4.0 + (x * (4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -9e+20: tmp = (x - z) * (4.0 / y) elif x <= 6.2e+37: tmp = 4.0 + ((z * -4.0) / y) else: tmp = 4.0 + (x * (4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -9e+20) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); elseif (x <= 6.2e+37) tmp = Float64(4.0 + Float64(Float64(z * -4.0) / y)); else tmp = Float64(4.0 + Float64(x * Float64(4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -9e+20) tmp = (x - z) * (4.0 / y); elseif (x <= 6.2e+37) tmp = 4.0 + ((z * -4.0) / y); else tmp = 4.0 + (x * (4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -9e+20], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6.2e+37], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+20}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{+37}:\\
\;\;\;\;4 + \frac{z \cdot -4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\end{array}
\end{array}
if x < -9e20Initial program 100.0%
Taylor expanded in y around 0 83.3%
*-lft-identity83.3%
associate-*l/83.0%
associate-*r*83.0%
associate-*r/83.0%
metadata-eval83.0%
Simplified83.0%
if -9e20 < x < 6.2000000000000004e37Initial program 99.9%
Taylor expanded in y around inf 100.0%
Taylor expanded in x around 0 92.4%
+-commutative92.4%
associate-*r/92.4%
Simplified92.4%
if 6.2000000000000004e37 < x Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 93.4%
distribute-lft-in93.4%
metadata-eval93.4%
associate-+r+93.4%
metadata-eval93.4%
associate-*r/93.4%
*-commutative93.4%
associate-*r/93.2%
Simplified93.2%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (if (<= x -6.2e+21) (* (- x z) (/ 4.0 y)) (if (<= x 3.7e+36) (+ 4.0 (* z (/ -4.0 y))) (+ 4.0 (* x (/ 4.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -6.2e+21) {
tmp = (x - z) * (4.0 / y);
} else if (x <= 3.7e+36) {
tmp = 4.0 + (z * (-4.0 / y));
} else {
tmp = 4.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 (x <= (-6.2d+21)) then
tmp = (x - z) * (4.0d0 / y)
else if (x <= 3.7d+36) then
tmp = 4.0d0 + (z * ((-4.0d0) / y))
else
tmp = 4.0d0 + (x * (4.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -6.2e+21) {
tmp = (x - z) * (4.0 / y);
} else if (x <= 3.7e+36) {
tmp = 4.0 + (z * (-4.0 / y));
} else {
tmp = 4.0 + (x * (4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -6.2e+21: tmp = (x - z) * (4.0 / y) elif x <= 3.7e+36: tmp = 4.0 + (z * (-4.0 / y)) else: tmp = 4.0 + (x * (4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -6.2e+21) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); elseif (x <= 3.7e+36) tmp = Float64(4.0 + Float64(z * Float64(-4.0 / y))); else tmp = Float64(4.0 + Float64(x * Float64(4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -6.2e+21) tmp = (x - z) * (4.0 / y); elseif (x <= 3.7e+36) tmp = 4.0 + (z * (-4.0 / y)); else tmp = 4.0 + (x * (4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -6.2e+21], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.7e+36], N[(4.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.2 \cdot 10^{+21}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{+36}:\\
\;\;\;\;4 + z \cdot \frac{-4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\end{array}
\end{array}
if x < -6.2e21Initial program 100.0%
Taylor expanded in y around 0 83.3%
*-lft-identity83.3%
associate-*l/83.0%
associate-*r*83.0%
associate-*r/83.0%
metadata-eval83.0%
Simplified83.0%
if -6.2e21 < x < 3.70000000000000029e36Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub100.0%
sub-neg100.0%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 92.4%
sub-neg92.4%
distribute-lft-in92.4%
metadata-eval92.4%
associate-+r+92.4%
metadata-eval92.4%
neg-mul-192.4%
associate-*r*92.4%
metadata-eval92.4%
associate-*r/92.4%
*-commutative92.4%
associate-/l*92.2%
Simplified92.2%
if 3.70000000000000029e36 < x Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 93.4%
distribute-lft-in93.4%
metadata-eval93.4%
associate-+r+93.4%
metadata-eval93.4%
associate-*r/93.4%
*-commutative93.4%
associate-*r/93.2%
Simplified93.2%
Final simplification89.8%
(FPCore (x y z) :precision binary64 (if (<= y -2.5e+145) 4.0 (if (<= y 1.35e+99) (* (- x z) (/ 4.0 y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.5e+145) {
tmp = 4.0;
} else if (y <= 1.35e+99) {
tmp = (x - z) * (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 (y <= (-2.5d+145)) then
tmp = 4.0d0
else if (y <= 1.35d+99) then
tmp = (x - z) * (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 (y <= -2.5e+145) {
tmp = 4.0;
} else if (y <= 1.35e+99) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.5e+145: tmp = 4.0 elif y <= 1.35e+99: tmp = (x - z) * (4.0 / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.5e+145) tmp = 4.0; elseif (y <= 1.35e+99) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.5e+145) tmp = 4.0; elseif (y <= 1.35e+99) tmp = (x - z) * (4.0 / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.5e+145], 4.0, If[LessEqual[y, 1.35e+99], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{+145}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+99}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -2.49999999999999983e145 or 1.34999999999999994e99 < y Initial program 99.9%
Taylor expanded in y around inf 75.9%
if -2.49999999999999983e145 < y < 1.34999999999999994e99Initial program 100.0%
Taylor expanded in y around 0 85.3%
*-lft-identity85.3%
associate-*l/85.0%
associate-*r*85.0%
associate-*r/85.0%
metadata-eval85.0%
Simplified85.0%
Final simplification82.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.65e+27) (not (<= x 1.11e+105))) (* 4.0 (/ x y)) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.65e+27) || !(x <= 1.11e+105)) {
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 <= (-1.65d+27)) .or. (.not. (x <= 1.11d+105))) 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 <= -1.65e+27) || !(x <= 1.11e+105)) {
tmp = 4.0 * (x / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.65e+27) or not (x <= 1.11e+105): tmp = 4.0 * (x / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.65e+27) || !(x <= 1.11e+105)) 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 <= -1.65e+27) || ~((x <= 1.11e+105))) tmp = 4.0 * (x / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.65e+27], N[Not[LessEqual[x, 1.11e+105]], $MachinePrecision]], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.65 \cdot 10^{+27} \lor \neg \left(x \leq 1.11 \cdot 10^{+105}\right):\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if x < -1.6499999999999999e27 or 1.11e105 < x Initial program 99.9%
Taylor expanded in x around inf 69.5%
if -1.6499999999999999e27 < x < 1.11e105Initial program 99.9%
Taylor expanded in y around inf 48.5%
Final simplification57.6%
(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%
Taylor expanded in y around inf 34.8%
herbie shell --seed 2024165
(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)))