
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (+ d2 (- (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
return d1 * (d2 + ((d4 - d3) - d1));
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * (d2 + ((d4 - d3) - d1))
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (d2 + ((d4 - d3) - d1));
}
def code(d1, d2, d3, d4): return d1 * (d2 + ((d4 - d3) - d1))
function code(d1, d2, d3, d4) return Float64(d1 * Float64(d2 + Float64(Float64(d4 - d3) - d1))) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (d2 + ((d4 - d3) - d1)); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(d2 + N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(d2 + \left(\left(d4 - d3\right) - d1\right)\right)
\end{array}
Initial program 88.6%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d1 -6.2e+69)
(* d1 (- d2 d1))
(if (<= d1 9.2e-58)
(* d1 (+ d2 d4))
(if (<= d1 5.8e+108) (* d1 (- d4 d3)) (* d1 (- d4 d1))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -6.2e+69) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 9.2e-58) {
tmp = d1 * (d2 + d4);
} else if (d1 <= 5.8e+108) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d1 <= (-6.2d+69)) then
tmp = d1 * (d2 - d1)
else if (d1 <= 9.2d-58) then
tmp = d1 * (d2 + d4)
else if (d1 <= 5.8d+108) then
tmp = d1 * (d4 - d3)
else
tmp = d1 * (d4 - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -6.2e+69) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 9.2e-58) {
tmp = d1 * (d2 + d4);
} else if (d1 <= 5.8e+108) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -6.2e+69: tmp = d1 * (d2 - d1) elif d1 <= 9.2e-58: tmp = d1 * (d2 + d4) elif d1 <= 5.8e+108: tmp = d1 * (d4 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -6.2e+69) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d1 <= 9.2e-58) tmp = Float64(d1 * Float64(d2 + d4)); elseif (d1 <= 5.8e+108) tmp = Float64(d1 * Float64(d4 - d3)); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d1 <= -6.2e+69) tmp = d1 * (d2 - d1); elseif (d1 <= 9.2e-58) tmp = d1 * (d2 + d4); elseif (d1 <= 5.8e+108) tmp = d1 * (d4 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -6.2e+69], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 9.2e-58], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 5.8e+108], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -6.2 \cdot 10^{+69}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d1 \leq 9.2 \cdot 10^{-58}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{elif}\;d1 \leq 5.8 \cdot 10^{+108}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d1 < -6.1999999999999997e69Initial program 76.5%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d1 around inf
Simplified82.5%
if -6.1999999999999997e69 < d1 < 9.1999999999999995e-58Initial program 100.0%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d1 around 0
--lowering--.f6499.2%
Simplified99.2%
Taylor expanded in d3 around 0
*-lowering-*.f64N/A
+-lowering-+.f6477.8%
Simplified77.8%
if 9.1999999999999995e-58 < d1 < 5.80000000000000015e108Initial program 99.9%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f6499.9%
Simplified99.9%
Taylor expanded in d1 around 0
--lowering--.f6486.9%
Simplified86.9%
Taylor expanded in d2 around 0
*-lowering-*.f64N/A
--lowering--.f6476.5%
Simplified76.5%
if 5.80000000000000015e108 < d1 Initial program 65.3%
Taylor expanded in d4 around inf
*-lowering-*.f6475.9%
Simplified75.9%
distribute-lft-out--N/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f6486.2%
Applied egg-rr86.2%
Final simplification80.2%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d1))))
(if (<= d1 -7e+68)
t_0
(if (<= d1 2.5e-60)
(* d1 (+ d2 d4))
(if (<= d1 2.45e+135) (* d1 (- d4 d3)) t_0)))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double tmp;
if (d1 <= -7e+68) {
tmp = t_0;
} else if (d1 <= 2.5e-60) {
tmp = d1 * (d2 + d4);
} else if (d1 <= 2.45e+135) {
tmp = d1 * (d4 - d3);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d1)
if (d1 <= (-7d+68)) then
tmp = t_0
else if (d1 <= 2.5d-60) then
tmp = d1 * (d2 + d4)
else if (d1 <= 2.45d+135) then
tmp = d1 * (d4 - d3)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double tmp;
if (d1 <= -7e+68) {
tmp = t_0;
} else if (d1 <= 2.5e-60) {
tmp = d1 * (d2 + d4);
} else if (d1 <= 2.45e+135) {
tmp = d1 * (d4 - d3);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) tmp = 0 if d1 <= -7e+68: tmp = t_0 elif d1 <= 2.5e-60: tmp = d1 * (d2 + d4) elif d1 <= 2.45e+135: tmp = d1 * (d4 - d3) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) tmp = 0.0 if (d1 <= -7e+68) tmp = t_0; elseif (d1 <= 2.5e-60) tmp = Float64(d1 * Float64(d2 + d4)); elseif (d1 <= 2.45e+135) tmp = Float64(d1 * Float64(d4 - d3)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d1); tmp = 0.0; if (d1 <= -7e+68) tmp = t_0; elseif (d1 <= 2.5e-60) tmp = d1 * (d2 + d4); elseif (d1 <= 2.45e+135) tmp = d1 * (d4 - d3); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d1, -7e+68], t$95$0, If[LessEqual[d1, 2.5e-60], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 2.45e+135], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d1 \leq -7 \cdot 10^{+68}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d1 \leq 2.5 \cdot 10^{-60}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{elif}\;d1 \leq 2.45 \cdot 10^{+135}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d1 < -6.99999999999999955e68 or 2.4500000000000001e135 < d1 Initial program 68.8%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d1 around inf
Simplified85.4%
if -6.99999999999999955e68 < d1 < 2.5000000000000001e-60Initial program 100.0%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d1 around 0
--lowering--.f6499.2%
Simplified99.2%
Taylor expanded in d3 around 0
*-lowering-*.f64N/A
+-lowering-+.f6477.8%
Simplified77.8%
if 2.5000000000000001e-60 < d1 < 2.4500000000000001e135Initial program 99.9%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f6499.9%
Simplified99.9%
Taylor expanded in d1 around 0
--lowering--.f6483.9%
Simplified83.9%
Taylor expanded in d2 around 0
*-lowering-*.f64N/A
--lowering--.f6470.4%
Simplified70.4%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d1))))
(if (<= d1 -1.6e+70)
t_0
(if (<= d1 4.4e+14)
(* d1 (+ d2 d4))
(if (<= d1 2.9e+134) (* d1 (- d2 d3)) t_0)))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double tmp;
if (d1 <= -1.6e+70) {
tmp = t_0;
} else if (d1 <= 4.4e+14) {
tmp = d1 * (d2 + d4);
} else if (d1 <= 2.9e+134) {
tmp = d1 * (d2 - d3);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d1)
if (d1 <= (-1.6d+70)) then
tmp = t_0
else if (d1 <= 4.4d+14) then
tmp = d1 * (d2 + d4)
else if (d1 <= 2.9d+134) then
tmp = d1 * (d2 - d3)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double tmp;
if (d1 <= -1.6e+70) {
tmp = t_0;
} else if (d1 <= 4.4e+14) {
tmp = d1 * (d2 + d4);
} else if (d1 <= 2.9e+134) {
tmp = d1 * (d2 - d3);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) tmp = 0 if d1 <= -1.6e+70: tmp = t_0 elif d1 <= 4.4e+14: tmp = d1 * (d2 + d4) elif d1 <= 2.9e+134: tmp = d1 * (d2 - d3) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) tmp = 0.0 if (d1 <= -1.6e+70) tmp = t_0; elseif (d1 <= 4.4e+14) tmp = Float64(d1 * Float64(d2 + d4)); elseif (d1 <= 2.9e+134) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d1); tmp = 0.0; if (d1 <= -1.6e+70) tmp = t_0; elseif (d1 <= 4.4e+14) tmp = d1 * (d2 + d4); elseif (d1 <= 2.9e+134) tmp = d1 * (d2 - d3); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d1, -1.6e+70], t$95$0, If[LessEqual[d1, 4.4e+14], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 2.9e+134], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d1 \leq -1.6 \cdot 10^{+70}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d1 \leq 4.4 \cdot 10^{+14}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{elif}\;d1 \leq 2.9 \cdot 10^{+134}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d1 < -1.6000000000000001e70 or 2.90000000000000012e134 < d1 Initial program 68.8%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d1 around inf
Simplified85.4%
if -1.6000000000000001e70 < d1 < 4.4e14Initial program 100.0%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d1 around 0
--lowering--.f6498.6%
Simplified98.6%
Taylor expanded in d3 around 0
*-lowering-*.f64N/A
+-lowering-+.f6476.4%
Simplified76.4%
if 4.4e14 < d1 < 2.90000000000000012e134Initial program 99.9%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f6499.9%
Simplified99.9%
Taylor expanded in d3 around inf
Simplified70.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -1.9e+88) (* d1 (- d2 d1)) (if (<= d1 3900.0) (* d1 (+ d2 (- d4 d3))) (* d1 (- d4 (+ d1 d3))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -1.9e+88) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 3900.0) {
tmp = d1 * (d2 + (d4 - d3));
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d1 <= (-1.9d+88)) then
tmp = d1 * (d2 - d1)
else if (d1 <= 3900.0d0) then
tmp = d1 * (d2 + (d4 - d3))
else
tmp = d1 * (d4 - (d1 + d3))
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -1.9e+88) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 3900.0) {
tmp = d1 * (d2 + (d4 - d3));
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -1.9e+88: tmp = d1 * (d2 - d1) elif d1 <= 3900.0: tmp = d1 * (d2 + (d4 - d3)) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -1.9e+88) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d1 <= 3900.0) tmp = Float64(d1 * Float64(d2 + Float64(d4 - d3))); else tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3))); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d1 <= -1.9e+88) tmp = d1 * (d2 - d1); elseif (d1 <= 3900.0) tmp = d1 * (d2 + (d4 - d3)); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -1.9e+88], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 3900.0], N[(d1 * N[(d2 + N[(d4 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -1.9 \cdot 10^{+88}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d1 \leq 3900:\\
\;\;\;\;d1 \cdot \left(d2 + \left(d4 - d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d1 < -1.8999999999999998e88Initial program 72.7%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d1 around inf
Simplified86.5%
if -1.8999999999999998e88 < d1 < 3900Initial program 100.0%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d1 around 0
--lowering--.f6498.6%
Simplified98.6%
if 3900 < d1 Initial program 75.0%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d2 around 0
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6492.4%
Simplified92.4%
Final simplification94.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -4.6e+88) (* d1 (- d2 d1)) (if (<= d1 3.6e+109) (* d1 (+ d2 (- d4 d3))) (* d1 (- d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -4.6e+88) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 3.6e+109) {
tmp = d1 * (d2 + (d4 - d3));
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d1 <= (-4.6d+88)) then
tmp = d1 * (d2 - d1)
else if (d1 <= 3.6d+109) then
tmp = d1 * (d2 + (d4 - d3))
else
tmp = d1 * (d4 - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -4.6e+88) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 3.6e+109) {
tmp = d1 * (d2 + (d4 - d3));
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -4.6e+88: tmp = d1 * (d2 - d1) elif d1 <= 3.6e+109: tmp = d1 * (d2 + (d4 - d3)) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -4.6e+88) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d1 <= 3.6e+109) tmp = Float64(d1 * Float64(d2 + Float64(d4 - d3))); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d1 <= -4.6e+88) tmp = d1 * (d2 - d1); elseif (d1 <= 3.6e+109) tmp = d1 * (d2 + (d4 - d3)); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -4.6e+88], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 3.6e+109], N[(d1 * N[(d2 + N[(d4 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -4.6 \cdot 10^{+88}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d1 \leq 3.6 \cdot 10^{+109}:\\
\;\;\;\;d1 \cdot \left(d2 + \left(d4 - d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d1 < -4.6000000000000003e88Initial program 72.7%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d1 around inf
Simplified86.5%
if -4.6000000000000003e88 < d1 < 3.6e109Initial program 100.0%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d1 around 0
--lowering--.f6496.4%
Simplified96.4%
if 3.6e109 < d1 Initial program 65.3%
Taylor expanded in d4 around inf
*-lowering-*.f6475.9%
Simplified75.9%
distribute-lft-out--N/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f6486.2%
Applied egg-rr86.2%
Final simplification92.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (let* ((t_0 (* d1 (- d2 d1)))) (if (<= d1 -2e+68) t_0 (if (<= d1 2.1e+134) (* d1 (+ d2 d4)) t_0))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double tmp;
if (d1 <= -2e+68) {
tmp = t_0;
} else if (d1 <= 2.1e+134) {
tmp = d1 * (d2 + d4);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d1)
if (d1 <= (-2d+68)) then
tmp = t_0
else if (d1 <= 2.1d+134) then
tmp = d1 * (d2 + d4)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double tmp;
if (d1 <= -2e+68) {
tmp = t_0;
} else if (d1 <= 2.1e+134) {
tmp = d1 * (d2 + d4);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) tmp = 0 if d1 <= -2e+68: tmp = t_0 elif d1 <= 2.1e+134: tmp = d1 * (d2 + d4) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) tmp = 0.0 if (d1 <= -2e+68) tmp = t_0; elseif (d1 <= 2.1e+134) tmp = Float64(d1 * Float64(d2 + d4)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d1); tmp = 0.0; if (d1 <= -2e+68) tmp = t_0; elseif (d1 <= 2.1e+134) tmp = d1 * (d2 + d4); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d1, -2e+68], t$95$0, If[LessEqual[d1, 2.1e+134], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d1 \leq -2 \cdot 10^{+68}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d1 \leq 2.1 \cdot 10^{+134}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d1 < -1.99999999999999991e68 or 2.1000000000000001e134 < d1 Initial program 69.1%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d1 around inf
Simplified84.6%
if -1.99999999999999991e68 < d1 < 2.1000000000000001e134Initial program 100.0%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d1 around 0
--lowering--.f6495.8%
Simplified95.8%
Taylor expanded in d3 around 0
*-lowering-*.f64N/A
+-lowering-+.f6470.6%
Simplified70.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3e+14) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3e+14) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 3d+14) then
tmp = d1 * d2
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3e+14) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3e+14: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3e+14) tmp = Float64(d1 * d2); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 3e+14) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3e+14], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3 \cdot 10^{+14}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 3e14Initial program 88.7%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d2 around inf
*-lowering-*.f6433.0%
Simplified33.0%
if 3e14 < d4 Initial program 88.5%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d4 around inf
*-lowering-*.f6462.0%
Simplified62.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (+ d2 d4)))
double code(double d1, double d2, double d3, double d4) {
return d1 * (d2 + d4);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * (d2 + d4)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (d2 + d4);
}
def code(d1, d2, d3, d4): return d1 * (d2 + d4)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(d2 + d4)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (d2 + d4); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(d2 + d4\right)
\end{array}
Initial program 88.6%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d1 around 0
--lowering--.f6481.2%
Simplified81.2%
Taylor expanded in d3 around 0
*-lowering-*.f64N/A
+-lowering-+.f6459.6%
Simplified59.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * d2
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
def code(d1, d2, d3, d4): return d1 * d2
function code(d1, d2, d3, d4) return Float64(d1 * d2) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d2; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d2
\end{array}
Initial program 88.6%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+l-N/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in d2 around inf
*-lowering-*.f6429.8%
Simplified29.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- (+ (- d2 d3) d4) d1)))
double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * (((d2 - d3) + d4) - d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
def code(d1, d2, d3, d4): return d1 * (((d2 - d3) + d4) - d1)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(Float64(d2 - d3) + d4) - d1)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (((d2 - d3) + d4) - d1); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(N[(d2 - d3), $MachinePrecision] + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(\left(d2 - d3\right) + d4\right) - d1\right)
\end{array}
herbie shell --seed 2024164
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(! :herbie-platform default (* d1 (- (+ (- d2 d3) d4) d1)))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))