
(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 (- (+ d4 (- d2 d3)) d1)))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 + (d2 - 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 * ((d4 + (d2 - d3)) - d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 + (d2 - d3)) - d1);
}
def code(d1, d2, d3, d4): return d1 * ((d4 + (d2 - d3)) - d1)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d4 + Float64(d2 - d3)) - d1)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d4 + (d2 - d3)) - d1); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d4 + N[(d2 - d3), $MachinePrecision]), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d4 + \left(d2 - d3\right)\right) - d1\right)
\end{array}
Initial program 86.3%
+-commutative86.3%
*-commutative86.3%
distribute-lft-out--87.9%
distribute-lft-out89.0%
distribute-lft-out--100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 -3.2e-163)
(* d1 d2)
(if (<= d4 4.9e-247)
(- (* d1 d1))
(if (<= d4 3.2e+107) (* d1 (- d3)) (* d1 d4)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -3.2e-163) {
tmp = d1 * d2;
} else if (d4 <= 4.9e-247) {
tmp = -(d1 * d1);
} else if (d4 <= 3.2e+107) {
tmp = d1 * -d3;
} 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 <= (-3.2d-163)) then
tmp = d1 * d2
else if (d4 <= 4.9d-247) then
tmp = -(d1 * d1)
else if (d4 <= 3.2d+107) then
tmp = d1 * -d3
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 <= -3.2e-163) {
tmp = d1 * d2;
} else if (d4 <= 4.9e-247) {
tmp = -(d1 * d1);
} else if (d4 <= 3.2e+107) {
tmp = d1 * -d3;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -3.2e-163: tmp = d1 * d2 elif d4 <= 4.9e-247: tmp = -(d1 * d1) elif d4 <= 3.2e+107: tmp = d1 * -d3 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -3.2e-163) tmp = Float64(d1 * d2); elseif (d4 <= 4.9e-247) tmp = Float64(-Float64(d1 * d1)); elseif (d4 <= 3.2e+107) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= -3.2e-163) tmp = d1 * d2; elseif (d4 <= 4.9e-247) tmp = -(d1 * d1); elseif (d4 <= 3.2e+107) tmp = d1 * -d3; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -3.2e-163], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 4.9e-247], (-N[(d1 * d1), $MachinePrecision]), If[LessEqual[d4, 3.2e+107], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -3.2 \cdot 10^{-163}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 4.9 \cdot 10^{-247}:\\
\;\;\;\;-d1 \cdot d1\\
\mathbf{elif}\;d4 \leq 3.2 \cdot 10^{+107}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -3.19999999999999988e-163Initial program 83.7%
+-commutative83.7%
*-commutative83.7%
distribute-lft-out--83.7%
distribute-lft-out86.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 26.1%
if -3.19999999999999988e-163 < d4 < 4.9e-247Initial program 90.7%
+-commutative90.7%
*-commutative90.7%
distribute-lft-out--92.6%
distribute-lft-out92.6%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 40.8%
neg-mul-140.8%
Simplified40.8%
if 4.9e-247 < d4 < 3.20000000000000029e107Initial program 88.3%
+-commutative88.3%
*-commutative88.3%
distribute-lft-out--91.7%
distribute-lft-out91.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 44.5%
mul-1-neg44.5%
distribute-rgt-neg-out44.5%
Simplified44.5%
if 3.20000000000000029e107 < d4 Initial program 84.2%
+-commutative84.2%
*-commutative84.2%
distribute-lft-out--86.8%
distribute-lft-out86.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 76.8%
Final simplification41.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -1e+110) (* d1 (- d2 d1)) (if (<= d1 5e+128) (* d1 (- (+ d4 d2) d3)) (* d1 (- d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -1e+110) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 5e+128) {
tmp = d1 * ((d4 + d2) - 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 <= (-1d+110)) then
tmp = d1 * (d2 - d1)
else if (d1 <= 5d+128) then
tmp = d1 * ((d4 + d2) - 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 <= -1e+110) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 5e+128) {
tmp = d1 * ((d4 + d2) - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -1e+110: tmp = d1 * (d2 - d1) elif d1 <= 5e+128: tmp = d1 * ((d4 + d2) - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -1e+110) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d1 <= 5e+128) tmp = Float64(d1 * Float64(Float64(d4 + d2) - 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 <= -1e+110) tmp = d1 * (d2 - d1); elseif (d1 <= 5e+128) tmp = d1 * ((d4 + d2) - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -1e+110], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 5e+128], N[(d1 * N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -1 \cdot 10^{+110}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d1 \leq 5 \cdot 10^{+128}:\\
\;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d1 < -1e110Initial program 51.4%
+-commutative51.4%
*-commutative51.4%
distribute-lft-out--54.3%
distribute-lft-out57.1%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 88.6%
if -1e110 < d1 < 5e128Initial program 99.4%
+-commutative99.4%
*-commutative99.4%
distribute-lft-out--99.4%
distribute-lft-out100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 91.7%
if 5e128 < d1 Initial program 55.3%
+-commutative55.3%
*-commutative55.3%
distribute-lft-out--63.2%
distribute-lft-out65.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 89.2%
Final simplification90.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.05e+85) (not (<= d3 6.4e+65))) (* d1 (- d2 d3)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.05e+85) || !(d3 <= 6.4e+65)) {
tmp = d1 * (d2 - 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 ((d3 <= (-1.05d+85)) .or. (.not. (d3 <= 6.4d+65))) then
tmp = d1 * (d2 - 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 ((d3 <= -1.05e+85) || !(d3 <= 6.4e+65)) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.05e+85) or not (d3 <= 6.4e+65): tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.05e+85) || !(d3 <= 6.4e+65)) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -1.05e+85) || ~((d3 <= 6.4e+65))) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1.05e+85], N[Not[LessEqual[d3, 6.4e+65]], $MachinePrecision]], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.05 \cdot 10^{+85} \lor \neg \left(d3 \leq 6.4 \cdot 10^{+65}\right):\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d3 < -1.05000000000000005e85 or 6.40000000000000014e65 < d3 Initial program 84.0%
+-commutative84.0%
*-commutative84.0%
distribute-lft-out--87.2%
distribute-lft-out89.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 94.9%
Taylor expanded in d4 around 0 81.7%
if -1.05000000000000005e85 < d3 < 6.40000000000000014e65Initial program 87.6%
+-commutative87.6%
*-commutative87.6%
distribute-lft-out--88.3%
distribute-lft-out88.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 65.9%
Final simplification71.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -4.6e+149) (not (<= d3 2700000000.0))) (* d1 (- d2 d3)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -4.6e+149) || !(d3 <= 2700000000.0)) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 + d2);
}
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 ((d3 <= (-4.6d+149)) .or. (.not. (d3 <= 2700000000.0d0))) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (d4 + d2)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -4.6e+149) || !(d3 <= 2700000000.0)) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -4.6e+149) or not (d3 <= 2700000000.0): tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -4.6e+149) || !(d3 <= 2700000000.0)) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -4.6e+149) || ~((d3 <= 2700000000.0))) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -4.6e+149], N[Not[LessEqual[d3, 2700000000.0]], $MachinePrecision]], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -4.6 \cdot 10^{+149} \lor \neg \left(d3 \leq 2700000000\right):\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d3 < -4.5999999999999997e149 or 2.7e9 < d3 Initial program 87.9%
+-commutative87.9%
*-commutative87.9%
distribute-lft-out--89.9%
distribute-lft-out91.9%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 93.3%
Taylor expanded in d4 around 0 79.4%
if -4.5999999999999997e149 < d3 < 2.7e9Initial program 85.3%
+-commutative85.3%
*-commutative85.3%
distribute-lft-out--86.6%
distribute-lft-out87.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 70.8%
Taylor expanded in d3 around 0 68.3%
+-commutative68.3%
Simplified68.3%
Final simplification72.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -3.3e+155) (not (<= d3 4.6e+66))) (* d1 (- d3)) (* d1 (+ d4 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -3.3e+155) || !(d3 <= 4.6e+66)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d4 + d2);
}
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 ((d3 <= (-3.3d+155)) .or. (.not. (d3 <= 4.6d+66))) then
tmp = d1 * -d3
else
tmp = d1 * (d4 + d2)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -3.3e+155) || !(d3 <= 4.6e+66)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d4 + d2);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -3.3e+155) or not (d3 <= 4.6e+66): tmp = d1 * -d3 else: tmp = d1 * (d4 + d2) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -3.3e+155) || !(d3 <= 4.6e+66)) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d4 + d2)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -3.3e+155) || ~((d3 <= 4.6e+66))) tmp = d1 * -d3; else tmp = d1 * (d4 + d2); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -3.3e+155], N[Not[LessEqual[d3, 4.6e+66]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -3.3 \cdot 10^{+155} \lor \neg \left(d3 \leq 4.6 \cdot 10^{+66}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right)\\
\end{array}
\end{array}
if d3 < -3.2999999999999999e155 or 4.6e66 < d3 Initial program 87.0%
+-commutative87.0%
*-commutative87.0%
distribute-lft-out--89.6%
distribute-lft-out92.2%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d3 around inf 84.4%
mul-1-neg84.4%
distribute-rgt-neg-out84.4%
Simplified84.4%
if -3.2999999999999999e155 < d3 < 4.6e66Initial program 86.0%
+-commutative86.0%
*-commutative86.0%
distribute-lft-out--87.1%
distribute-lft-out87.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around 0 71.7%
Taylor expanded in d3 around 0 66.3%
+-commutative66.3%
Simplified66.3%
Final simplification71.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 -9.6e-161) (* d1 d2) (if (<= d4 185000000.0) (- (* d1 d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -9.6e-161) {
tmp = d1 * d2;
} else if (d4 <= 185000000.0) {
tmp = -(d1 * d1);
} 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 <= (-9.6d-161)) then
tmp = d1 * d2
else if (d4 <= 185000000.0d0) then
tmp = -(d1 * d1)
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 <= -9.6e-161) {
tmp = d1 * d2;
} else if (d4 <= 185000000.0) {
tmp = -(d1 * d1);
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -9.6e-161: tmp = d1 * d2 elif d4 <= 185000000.0: tmp = -(d1 * d1) else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -9.6e-161) tmp = Float64(d1 * d2); elseif (d4 <= 185000000.0) tmp = Float64(-Float64(d1 * d1)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= -9.6e-161) tmp = d1 * d2; elseif (d4 <= 185000000.0) tmp = -(d1 * d1); else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -9.6e-161], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 185000000.0], (-N[(d1 * d1), $MachinePrecision]), N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -9.6 \cdot 10^{-161}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 185000000:\\
\;\;\;\;-d1 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -9.59999999999999995e-161Initial program 83.7%
+-commutative83.7%
*-commutative83.7%
distribute-lft-out--83.7%
distribute-lft-out86.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 26.1%
if -9.59999999999999995e-161 < d4 < 1.85e8Initial program 90.6%
+-commutative90.6%
*-commutative90.6%
distribute-lft-out--93.8%
distribute-lft-out93.8%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 34.6%
neg-mul-134.6%
Simplified34.6%
if 1.85e8 < d4 Initial program 83.9%
+-commutative83.9%
*-commutative83.9%
distribute-lft-out--85.7%
distribute-lft-out85.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 58.7%
Final simplification36.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3e-8) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3e-8) {
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-8) 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-8) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3e-8: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3e-8) 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-8) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3e-8], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3 \cdot 10^{-8}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 2.99999999999999973e-8Initial program 87.0%
+-commutative87.0%
*-commutative87.0%
distribute-lft-out--88.5%
distribute-lft-out90.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 32.1%
if 2.99999999999999973e-8 < d4 Initial program 83.9%
+-commutative83.9%
*-commutative83.9%
distribute-lft-out--85.7%
distribute-lft-out85.7%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d4 around inf 58.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3.4e+221) (* d1 d2) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.4e+221) {
tmp = d1 * d2;
} else {
tmp = d1 * 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 (d4 <= 3.4d+221) then
tmp = d1 * d2
else
tmp = d1 * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.4e+221) {
tmp = d1 * d2;
} else {
tmp = d1 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.4e+221: tmp = d1 * d2 else: tmp = d1 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.4e+221) tmp = Float64(d1 * d2); else tmp = Float64(d1 * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 3.4e+221) tmp = d1 * d2; else tmp = d1 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.4e+221], N[(d1 * d2), $MachinePrecision], N[(d1 * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3.4 \cdot 10^{+221}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d1\\
\end{array}
\end{array}
if d4 < 3.3999999999999998e221Initial program 86.5%
+-commutative86.5%
*-commutative86.5%
distribute-lft-out--88.2%
distribute-lft-out89.5%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d2 around inf 30.9%
if 3.3999999999999998e221 < d4 Initial program 83.3%
+-commutative83.3%
*-commutative83.3%
distribute-lft-out--83.3%
distribute-lft-out83.3%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 12.7%
neg-mul-112.7%
Simplified12.7%
neg-sub012.7%
sub-neg12.7%
add-sqr-sqrt12.1%
sqrt-unprod19.1%
sqr-neg19.1%
sqrt-unprod7.0%
add-sqr-sqrt18.8%
Applied egg-rr18.8%
+-lft-identity18.8%
Simplified18.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d1))
double code(double d1, double d2, double d3, double d4) {
return 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 * d1
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d1;
}
def code(d1, d2, d3, d4): return d1 * d1
function code(d1, d2, d3, d4) return Float64(d1 * d1) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d1; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d1), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d1
\end{array}
Initial program 86.3%
+-commutative86.3%
*-commutative86.3%
distribute-lft-out--87.9%
distribute-lft-out89.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in d1 around inf 31.9%
neg-mul-131.9%
Simplified31.9%
neg-sub031.9%
sub-neg31.9%
add-sqr-sqrt13.7%
sqrt-unprod17.8%
sqr-neg17.8%
sqrt-unprod4.1%
add-sqr-sqrt8.4%
Applied egg-rr8.4%
+-lft-identity8.4%
Simplified8.4%
(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 2024139
(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)))