
(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 (fma 4.0 (+ 0.75 (/ (- x z) y)) 1.0))
double code(double x, double y, double z) {
return fma(4.0, (0.75 + ((x - z) / y)), 1.0);
}
function code(x, y, z) return fma(4.0, Float64(0.75 + Float64(Float64(x - z) / y)), 1.0) end
code[x_, y_, z_] := N[(4.0 * N[(0.75 + N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(4, 0.75 + \frac{x - z}{y}, 1\right)
\end{array}
Initial program 99.6%
+-commutative99.6%
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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ z y))))
(if (<= z -1.12e-67)
t_0
(if (<= z 6.9e-90) (/ (* 4.0 x) y) (if (<= z 1.34e+67) 4.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (z / y);
double tmp;
if (z <= -1.12e-67) {
tmp = t_0;
} else if (z <= 6.9e-90) {
tmp = (4.0 * x) / y;
} else if (z <= 1.34e+67) {
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) * (z / y)
if (z <= (-1.12d-67)) then
tmp = t_0
else if (z <= 6.9d-90) then
tmp = (4.0d0 * x) / y
else if (z <= 1.34d+67) 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 * (z / y);
double tmp;
if (z <= -1.12e-67) {
tmp = t_0;
} else if (z <= 6.9e-90) {
tmp = (4.0 * x) / y;
} else if (z <= 1.34e+67) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (z / y) tmp = 0 if z <= -1.12e-67: tmp = t_0 elif z <= 6.9e-90: tmp = (4.0 * x) / y elif z <= 1.34e+67: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(z / y)) tmp = 0.0 if (z <= -1.12e-67) tmp = t_0; elseif (z <= 6.9e-90) tmp = Float64(Float64(4.0 * x) / y); elseif (z <= 1.34e+67) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (z / y); tmp = 0.0; if (z <= -1.12e-67) tmp = t_0; elseif (z <= 6.9e-90) tmp = (4.0 * x) / y; elseif (z <= 1.34e+67) tmp = 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.12e-67], t$95$0, If[LessEqual[z, 6.9e-90], N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[z, 1.34e+67], 4.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{z}{y}\\
\mathbf{if}\;z \leq -1.12 \cdot 10^{-67}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 6.9 \cdot 10^{-90}:\\
\;\;\;\;\frac{4 \cdot x}{y}\\
\mathbf{elif}\;z \leq 1.34 \cdot 10^{+67}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.12e-67 or 1.33999999999999994e67 < z Initial program 99.2%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in z around inf 64.6%
if -1.12e-67 < z < 6.90000000000000025e-90Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around inf 57.8%
*-commutative57.8%
associate-*l/57.8%
Simplified57.8%
if 6.90000000000000025e-90 < z < 1.33999999999999994e67Initial program 100.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around inf 55.6%
Final simplification61.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ z y))))
(if (<= z -1.25e-67)
t_0
(if (<= z 2.6e-89) (/ 4.0 (/ y x)) (if (<= z 7.5e+65) 4.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (z / y);
double tmp;
if (z <= -1.25e-67) {
tmp = t_0;
} else if (z <= 2.6e-89) {
tmp = 4.0 / (y / x);
} else if (z <= 7.5e+65) {
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) * (z / y)
if (z <= (-1.25d-67)) then
tmp = t_0
else if (z <= 2.6d-89) then
tmp = 4.0d0 / (y / x)
else if (z <= 7.5d+65) 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 * (z / y);
double tmp;
if (z <= -1.25e-67) {
tmp = t_0;
} else if (z <= 2.6e-89) {
tmp = 4.0 / (y / x);
} else if (z <= 7.5e+65) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (z / y) tmp = 0 if z <= -1.25e-67: tmp = t_0 elif z <= 2.6e-89: tmp = 4.0 / (y / x) elif z <= 7.5e+65: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(z / y)) tmp = 0.0 if (z <= -1.25e-67) tmp = t_0; elseif (z <= 2.6e-89) tmp = Float64(4.0 / Float64(y / x)); elseif (z <= 7.5e+65) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (z / y); tmp = 0.0; if (z <= -1.25e-67) tmp = t_0; elseif (z <= 2.6e-89) tmp = 4.0 / (y / x); elseif (z <= 7.5e+65) tmp = 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.25e-67], t$95$0, If[LessEqual[z, 2.6e-89], N[(4.0 / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7.5e+65], 4.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{z}{y}\\
\mathbf{if}\;z \leq -1.25 \cdot 10^{-67}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{-89}:\\
\;\;\;\;\frac{4}{\frac{y}{x}}\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{+65}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.25e-67 or 7.50000000000000006e65 < z Initial program 99.2%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in z around inf 64.6%
if -1.25e-67 < z < 2.5999999999999999e-89Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
Simplified100.0%
clear-num99.8%
inv-pow99.8%
*-un-lft-identity99.8%
times-frac99.8%
metadata-eval99.8%
Applied egg-rr99.8%
unpow-199.8%
associate-/r*99.8%
metadata-eval99.8%
associate-+r-99.8%
+-commutative99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in x around inf 57.6%
if 2.5999999999999999e-89 < z < 7.50000000000000006e65Initial program 100.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around inf 55.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.5e+36) (not (<= y 2.2e+62))) (+ 4.0 (* z (/ -4.0 y))) (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.5e+36) || !(y <= 2.2e+62)) {
tmp = 4.0 + (z * (-4.0 / y));
} else {
tmp = 4.0 * ((x - 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 <= (-5.5d+36)) .or. (.not. (y <= 2.2d+62))) then
tmp = 4.0d0 + (z * ((-4.0d0) / y))
else
tmp = 4.0d0 * ((x - z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5.5e+36) || !(y <= 2.2e+62)) {
tmp = 4.0 + (z * (-4.0 / y));
} else {
tmp = 4.0 * ((x - z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.5e+36) or not (y <= 2.2e+62): tmp = 4.0 + (z * (-4.0 / y)) else: tmp = 4.0 * ((x - z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.5e+36) || !(y <= 2.2e+62)) tmp = Float64(4.0 + Float64(z * Float64(-4.0 / y))); else tmp = Float64(4.0 * Float64(Float64(x - z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.5e+36) || ~((y <= 2.2e+62))) tmp = 4.0 + (z * (-4.0 / y)); else tmp = 4.0 * ((x - z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.5e+36], N[Not[LessEqual[y, 2.2e+62]], $MachinePrecision]], N[(4.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+36} \lor \neg \left(y \leq 2.2 \cdot 10^{+62}\right):\\
\;\;\;\;4 + z \cdot \frac{-4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\end{array}
\end{array}
if y < -5.5000000000000002e36 or 2.20000000000000015e62 < y Initial program 99.1%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 99.1%
distribute-lft-out99.1%
Simplified99.1%
Taylor expanded in x around 0 83.0%
div-sub83.0%
sub-neg83.0%
*-inverses83.0%
distribute-frac-neg283.0%
distribute-rgt-in83.0%
metadata-eval83.0%
distribute-frac-neg283.0%
distribute-lft-neg-in83.0%
*-rgt-identity83.0%
associate-*r/82.9%
associate-*r*82.9%
*-commutative82.9%
distribute-rgt-neg-in82.9%
associate-*r/82.9%
metadata-eval82.9%
distribute-neg-frac82.9%
metadata-eval82.9%
Simplified82.9%
if -5.5000000000000002e36 < y < 2.20000000000000015e62Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 92.4%
*-commutative92.4%
Simplified92.4%
Final simplification88.4%
(FPCore (x y z) :precision binary64 (if (<= y -1.2e+22) (+ 4.0 (/ (* 4.0 x) y)) (if (<= y 1.8e+60) (* 4.0 (/ (- x z) y)) (+ 4.0 (/ (* z -4.0) y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.2e+22) {
tmp = 4.0 + ((4.0 * x) / y);
} else if (y <= 1.8e+60) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + ((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.2d+22)) then
tmp = 4.0d0 + ((4.0d0 * x) / y)
else if (y <= 1.8d+60) then
tmp = 4.0d0 * ((x - z) / y)
else
tmp = 4.0d0 + ((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.2e+22) {
tmp = 4.0 + ((4.0 * x) / y);
} else if (y <= 1.8e+60) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + ((z * -4.0) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.2e+22: tmp = 4.0 + ((4.0 * x) / y) elif y <= 1.8e+60: tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 + ((z * -4.0) / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.2e+22) tmp = Float64(4.0 + Float64(Float64(4.0 * x) / y)); elseif (y <= 1.8e+60) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = Float64(4.0 + Float64(Float64(z * -4.0) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.2e+22) tmp = 4.0 + ((4.0 * x) / y); elseif (y <= 1.8e+60) tmp = 4.0 * ((x - z) / y); else tmp = 4.0 + ((z * -4.0) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.2e+22], N[(4.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e+60], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{+22}:\\
\;\;\;\;4 + \frac{4 \cdot x}{y}\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+60}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + \frac{z \cdot -4}{y}\\
\end{array}
\end{array}
if y < -1.2e22Initial program 98.5%
+-commutative98.5%
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 82.4%
distribute-lft-in82.4%
metadata-eval82.4%
associate-+r+82.4%
metadata-eval82.4%
*-commutative82.4%
associate-*l/82.4%
Simplified82.4%
if -1.2e22 < y < 1.79999999999999984e60Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 92.9%
*-commutative92.9%
Simplified92.9%
if 1.79999999999999984e60 < y Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around 0 85.2%
div-sub85.2%
*-commutative85.2%
*-lft-identity85.2%
associate-*l/85.1%
associate-*r*85.2%
lft-mult-inverse85.2%
metadata-eval85.2%
sub-neg85.2%
distribute-lft-in85.2%
metadata-eval85.2%
associate-+r+85.2%
metadata-eval85.2%
neg-mul-185.2%
associate-*r*85.2%
metadata-eval85.2%
*-commutative85.2%
associate-*l/85.2%
Simplified85.2%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (if (<= y -1.4e+23) (+ 4.0 (/ (* 4.0 x) y)) (if (<= y 1.35e+60) (* 4.0 (/ (- x z) y)) (+ 4.0 (* z (/ -4.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.4e+23) {
tmp = 4.0 + ((4.0 * x) / y);
} else if (y <= 1.35e+60) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + (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+23)) then
tmp = 4.0d0 + ((4.0d0 * x) / y)
else if (y <= 1.35d+60) then
tmp = 4.0d0 * ((x - z) / y)
else
tmp = 4.0d0 + (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+23) {
tmp = 4.0 + ((4.0 * x) / y);
} else if (y <= 1.35e+60) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + (z * (-4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.4e+23: tmp = 4.0 + ((4.0 * x) / y) elif y <= 1.35e+60: tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 + (z * (-4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.4e+23) tmp = Float64(4.0 + Float64(Float64(4.0 * x) / y)); elseif (y <= 1.35e+60) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = Float64(4.0 + Float64(z * Float64(-4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.4e+23) tmp = 4.0 + ((4.0 * x) / y); elseif (y <= 1.35e+60) tmp = 4.0 * ((x - z) / y); else tmp = 4.0 + (z * (-4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.4e+23], N[(4.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e+60], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{+23}:\\
\;\;\;\;4 + \frac{4 \cdot x}{y}\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+60}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + z \cdot \frac{-4}{y}\\
\end{array}
\end{array}
if y < -1.4e23Initial program 98.5%
+-commutative98.5%
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 82.4%
distribute-lft-in82.4%
metadata-eval82.4%
associate-+r+82.4%
metadata-eval82.4%
*-commutative82.4%
associate-*l/82.4%
Simplified82.4%
if -1.4e23 < y < 1.35e60Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 92.9%
*-commutative92.9%
Simplified92.9%
if 1.35e60 < y Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 99.9%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in x around 0 85.2%
div-sub85.2%
sub-neg85.2%
*-inverses85.2%
distribute-frac-neg285.2%
distribute-rgt-in85.2%
metadata-eval85.2%
distribute-frac-neg285.2%
distribute-lft-neg-in85.2%
*-rgt-identity85.2%
associate-*r/85.0%
associate-*r*85.0%
*-commutative85.0%
distribute-rgt-neg-in85.0%
associate-*r/85.0%
metadata-eval85.0%
distribute-neg-frac85.0%
metadata-eval85.0%
Simplified85.0%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (if (<= y -1e+134) 4.0 (if (<= y 1.35e+198) (* 4.0 (/ (- x z) y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1e+134) {
tmp = 4.0;
} else if (y <= 1.35e+198) {
tmp = 4.0 * ((x - z) / 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 <= (-1d+134)) then
tmp = 4.0d0
else if (y <= 1.35d+198) then
tmp = 4.0d0 * ((x - z) / 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 <= -1e+134) {
tmp = 4.0;
} else if (y <= 1.35e+198) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1e+134: tmp = 4.0 elif y <= 1.35e+198: tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1e+134) tmp = 4.0; elseif (y <= 1.35e+198) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1e+134) tmp = 4.0; elseif (y <= 1.35e+198) tmp = 4.0 * ((x - z) / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1e+134], 4.0, If[LessEqual[y, 1.35e+198], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+134}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+198}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -9.99999999999999921e133 or 1.35e198 < y Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 77.7%
if -9.99999999999999921e133 < y < 1.35e198Initial program 99.5%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 84.6%
*-commutative84.6%
Simplified84.6%
Final simplification83.0%
(FPCore (x y z) :precision binary64 (if (<= y -3.4e+34) 4.0 (if (<= y 3.15e+112) (* -4.0 (/ z y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.4e+34) {
tmp = 4.0;
} else if (y <= 3.15e+112) {
tmp = -4.0 * (z / 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 <= (-3.4d+34)) then
tmp = 4.0d0
else if (y <= 3.15d+112) then
tmp = (-4.0d0) * (z / 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 <= -3.4e+34) {
tmp = 4.0;
} else if (y <= 3.15e+112) {
tmp = -4.0 * (z / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.4e+34: tmp = 4.0 elif y <= 3.15e+112: tmp = -4.0 * (z / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.4e+34) tmp = 4.0; elseif (y <= 3.15e+112) tmp = Float64(-4.0 * Float64(z / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.4e+34) tmp = 4.0; elseif (y <= 3.15e+112) tmp = -4.0 * (z / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.4e+34], 4.0, If[LessEqual[y, 3.15e+112], N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{+34}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 3.15 \cdot 10^{+112}:\\
\;\;\;\;-4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -3.3999999999999999e34 or 3.1499999999999998e112 < y Initial program 98.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 63.9%
if -3.3999999999999999e34 < y < 3.1499999999999998e112Initial program 100.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in z around inf 51.9%
(FPCore (x y z) :precision binary64 (+ 1.0 (* 4.0 (/ (+ x (- (* 0.75 y) z)) y))))
double code(double x, double y, double z) {
return 1.0 + (4.0 * ((x + ((0.75 * y) - 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 + ((0.75d0 * y) - z)) / y))
end function
public static double code(double x, double y, double z) {
return 1.0 + (4.0 * ((x + ((0.75 * y) - z)) / y));
}
def code(x, y, z): return 1.0 + (4.0 * ((x + ((0.75 * y) - z)) / y))
function code(x, y, z) return Float64(1.0 + Float64(4.0 * Float64(Float64(x + Float64(Float64(0.75 * y) - z)) / y))) end
function tmp = code(x, y, z) tmp = 1.0 + (4.0 * ((x + ((0.75 * y) - z)) / y)); end
code[x_, y_, z_] := N[(1.0 + N[(4.0 * N[(N[(x + N[(N[(0.75 * y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + 4 \cdot \frac{x + \left(0.75 \cdot y - z\right)}{y}
\end{array}
Initial program 99.6%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (/ 4.0 (/ y (+ x (- y z)))))
double code(double x, double y, double z) {
return 4.0 / (y / (x + (y - z)));
}
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 / (y / (x + (y - z)))
end function
public static double code(double x, double y, double z) {
return 4.0 / (y / (x + (y - z)));
}
def code(x, y, z): return 4.0 / (y / (x + (y - z)))
function code(x, y, z) return Float64(4.0 / Float64(y / Float64(x + Float64(y - z)))) end
function tmp = code(x, y, z) tmp = 4.0 / (y / (x + (y - z))); end
code[x_, y_, z_] := N[(4.0 / N[(y / N[(x + N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{4}{\frac{y}{x + \left(y - z\right)}}
\end{array}
Initial program 99.6%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 99.6%
distribute-lft-out99.6%
Simplified99.6%
clear-num99.4%
inv-pow99.4%
*-un-lft-identity99.4%
times-frac99.8%
metadata-eval99.8%
Applied egg-rr99.8%
unpow-199.8%
associate-/r*99.8%
metadata-eval99.8%
associate-+r-99.8%
+-commutative99.8%
associate--l+99.8%
Simplified99.8%
(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.6%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 31.5%
herbie shell --seed 2024108
(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)))