
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
Initial program 100.0%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 0.0) (not (<= (exp re) 1.00000025))) (* (exp re) im) (* (sin im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.0) || !(exp(re) <= 1.00000025)) {
tmp = exp(re) * im;
} else {
tmp = sin(im) * (re + 1.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((exp(re) <= 0.0d0) .or. (.not. (exp(re) <= 1.00000025d0))) then
tmp = exp(re) * im
else
tmp = sin(im) * (re + 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) <= 0.0) || !(Math.exp(re) <= 1.00000025)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.0) or not (math.exp(re) <= 1.00000025): tmp = math.exp(re) * im else: tmp = math.sin(im) * (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.0) || !(exp(re) <= 1.00000025)) tmp = Float64(exp(re) * im); else tmp = Float64(sin(im) * Float64(re + 1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 0.0) || ~((exp(re) <= 1.00000025))) tmp = exp(re) * im; else tmp = sin(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.00000025]], $MachinePrecision]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0 \lor \neg \left(e^{re} \leq 1.00000025\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0 or 1.00000025000000003 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 84.9%
if 0.0 < (exp.f64 re) < 1.00000025000000003Initial program 100.0%
Taylor expanded in re around 0 99.4%
distribute-rgt1-in99.4%
Simplified99.4%
Final simplification92.3%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 0.0) (not (<= (exp re) 1.00000025))) (* (exp re) im) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.0) || !(exp(re) <= 1.00000025)) {
tmp = exp(re) * im;
} else {
tmp = sin(im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((exp(re) <= 0.0d0) .or. (.not. (exp(re) <= 1.00000025d0))) then
tmp = exp(re) * im
else
tmp = sin(im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) <= 0.0) || !(Math.exp(re) <= 1.00000025)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.0) or not (math.exp(re) <= 1.00000025): tmp = math.exp(re) * im else: tmp = math.sin(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.0) || !(exp(re) <= 1.00000025)) tmp = Float64(exp(re) * im); else tmp = sin(im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 0.0) || ~((exp(re) <= 1.00000025))) tmp = exp(re) * im; else tmp = sin(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.00000025]], $MachinePrecision]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[Sin[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0 \lor \neg \left(e^{re} \leq 1.00000025\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0 or 1.00000025000000003 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 84.9%
if 0.0 < (exp.f64 re) < 1.00000025000000003Initial program 100.0%
Taylor expanded in re around 0 98.4%
Final simplification91.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (- im (* re (* re im))))))
(if (<= re -8.5e+159)
(* re (/ im re))
(if (<= re 720.0)
(sin im)
(if (or (<= re 3.6e+166) (and (not (<= re 4.2e+268)) (<= re 5.8e+284)))
(/ t_0 im)
(/ t_0 (* im (- 1.0 re))))))))
double code(double re, double im) {
double t_0 = im * (im - (re * (re * im)));
double tmp;
if (re <= -8.5e+159) {
tmp = re * (im / re);
} else if (re <= 720.0) {
tmp = sin(im);
} else if ((re <= 3.6e+166) || (!(re <= 4.2e+268) && (re <= 5.8e+284))) {
tmp = t_0 / im;
} else {
tmp = t_0 / (im * (1.0 - re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = im * (im - (re * (re * im)))
if (re <= (-8.5d+159)) then
tmp = re * (im / re)
else if (re <= 720.0d0) then
tmp = sin(im)
else if ((re <= 3.6d+166) .or. (.not. (re <= 4.2d+268)) .and. (re <= 5.8d+284)) then
tmp = t_0 / im
else
tmp = t_0 / (im * (1.0d0 - re))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = im * (im - (re * (re * im)));
double tmp;
if (re <= -8.5e+159) {
tmp = re * (im / re);
} else if (re <= 720.0) {
tmp = Math.sin(im);
} else if ((re <= 3.6e+166) || (!(re <= 4.2e+268) && (re <= 5.8e+284))) {
tmp = t_0 / im;
} else {
tmp = t_0 / (im * (1.0 - re));
}
return tmp;
}
def code(re, im): t_0 = im * (im - (re * (re * im))) tmp = 0 if re <= -8.5e+159: tmp = re * (im / re) elif re <= 720.0: tmp = math.sin(im) elif (re <= 3.6e+166) or (not (re <= 4.2e+268) and (re <= 5.8e+284)): tmp = t_0 / im else: tmp = t_0 / (im * (1.0 - re)) return tmp
function code(re, im) t_0 = Float64(im * Float64(im - Float64(re * Float64(re * im)))) tmp = 0.0 if (re <= -8.5e+159) tmp = Float64(re * Float64(im / re)); elseif (re <= 720.0) tmp = sin(im); elseif ((re <= 3.6e+166) || (!(re <= 4.2e+268) && (re <= 5.8e+284))) tmp = Float64(t_0 / im); else tmp = Float64(t_0 / Float64(im * Float64(1.0 - re))); end return tmp end
function tmp_2 = code(re, im) t_0 = im * (im - (re * (re * im))); tmp = 0.0; if (re <= -8.5e+159) tmp = re * (im / re); elseif (re <= 720.0) tmp = sin(im); elseif ((re <= 3.6e+166) || (~((re <= 4.2e+268)) && (re <= 5.8e+284))) tmp = t_0 / im; else tmp = t_0 / (im * (1.0 - re)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(im - N[(re * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -8.5e+159], N[(re * N[(im / re), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 720.0], N[Sin[im], $MachinePrecision], If[Or[LessEqual[re, 3.6e+166], And[N[Not[LessEqual[re, 4.2e+268]], $MachinePrecision], LessEqual[re, 5.8e+284]]], N[(t$95$0 / im), $MachinePrecision], N[(t$95$0 / N[(im * N[(1.0 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(im - re \cdot \left(re \cdot im\right)\right)\\
\mathbf{if}\;re \leq -8.5 \cdot 10^{+159}:\\
\;\;\;\;re \cdot \frac{im}{re}\\
\mathbf{elif}\;re \leq 720:\\
\;\;\;\;\sin im\\
\mathbf{elif}\;re \leq 3.6 \cdot 10^{+166} \lor \neg \left(re \leq 4.2 \cdot 10^{+268}\right) \land re \leq 5.8 \cdot 10^{+284}:\\
\;\;\;\;\frac{t\_0}{im}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{im \cdot \left(1 - re\right)}\\
\end{array}
\end{array}
if re < -8.50000000000000076e159Initial program 100.0%
Taylor expanded in re around 0 2.3%
distribute-rgt1-in2.3%
Simplified2.3%
Taylor expanded in im around 0 2.2%
+-commutative2.2%
Simplified2.2%
Taylor expanded in re around inf 2.2%
Taylor expanded in re around 0 37.6%
if -8.50000000000000076e159 < re < 720Initial program 100.0%
Taylor expanded in re around 0 80.7%
if 720 < re < 3.5999999999999997e166 or 4.2000000000000003e268 < re < 5.7999999999999997e284Initial program 100.0%
Taylor expanded in re around 0 4.0%
distribute-rgt1-in4.0%
Simplified4.0%
Taylor expanded in im around 0 4.3%
+-commutative4.3%
Simplified4.3%
distribute-lft-in4.3%
*-rgt-identity4.3%
flip-+8.5%
unpow28.5%
Applied egg-rr8.5%
associate-*l*8.5%
unpow28.5%
distribute-lft-out--10.9%
sub-neg10.9%
mul-1-neg10.9%
*-commutative10.9%
distribute-lft-out10.9%
Simplified10.9%
Taylor expanded in re around 0 40.8%
neg-mul-140.8%
Simplified40.8%
if 3.5999999999999997e166 < re < 4.2000000000000003e268 or 5.7999999999999997e284 < re Initial program 100.0%
Taylor expanded in re around 0 5.5%
distribute-rgt1-in5.5%
Simplified5.5%
Taylor expanded in im around 0 28.2%
+-commutative28.2%
Simplified28.2%
distribute-lft-in28.2%
*-rgt-identity28.2%
flip-+29.9%
unpow229.9%
Applied egg-rr29.9%
associate-*l*36.8%
unpow236.8%
distribute-lft-out--36.8%
sub-neg36.8%
mul-1-neg36.8%
*-commutative36.8%
distribute-lft-out36.8%
Simplified36.8%
Final simplification65.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (- im (* re (* re im))))))
(if (<= im 2.6e-106)
(* re (/ im re))
(if (<= im 1.55e+49) (/ t_0 (* im (- 1.0 re))) (/ t_0 im)))))
double code(double re, double im) {
double t_0 = im * (im - (re * (re * im)));
double tmp;
if (im <= 2.6e-106) {
tmp = re * (im / re);
} else if (im <= 1.55e+49) {
tmp = t_0 / (im * (1.0 - re));
} else {
tmp = t_0 / im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = im * (im - (re * (re * im)))
if (im <= 2.6d-106) then
tmp = re * (im / re)
else if (im <= 1.55d+49) then
tmp = t_0 / (im * (1.0d0 - re))
else
tmp = t_0 / im
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = im * (im - (re * (re * im)));
double tmp;
if (im <= 2.6e-106) {
tmp = re * (im / re);
} else if (im <= 1.55e+49) {
tmp = t_0 / (im * (1.0 - re));
} else {
tmp = t_0 / im;
}
return tmp;
}
def code(re, im): t_0 = im * (im - (re * (re * im))) tmp = 0 if im <= 2.6e-106: tmp = re * (im / re) elif im <= 1.55e+49: tmp = t_0 / (im * (1.0 - re)) else: tmp = t_0 / im return tmp
function code(re, im) t_0 = Float64(im * Float64(im - Float64(re * Float64(re * im)))) tmp = 0.0 if (im <= 2.6e-106) tmp = Float64(re * Float64(im / re)); elseif (im <= 1.55e+49) tmp = Float64(t_0 / Float64(im * Float64(1.0 - re))); else tmp = Float64(t_0 / im); end return tmp end
function tmp_2 = code(re, im) t_0 = im * (im - (re * (re * im))); tmp = 0.0; if (im <= 2.6e-106) tmp = re * (im / re); elseif (im <= 1.55e+49) tmp = t_0 / (im * (1.0 - re)); else tmp = t_0 / im; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(im - N[(re * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 2.6e-106], N[(re * N[(im / re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.55e+49], N[(t$95$0 / N[(im * N[(1.0 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / im), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(im - re \cdot \left(re \cdot im\right)\right)\\
\mathbf{if}\;im \leq 2.6 \cdot 10^{-106}:\\
\;\;\;\;re \cdot \frac{im}{re}\\
\mathbf{elif}\;im \leq 1.55 \cdot 10^{+49}:\\
\;\;\;\;\frac{t\_0}{im \cdot \left(1 - re\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{im}\\
\end{array}
\end{array}
if im < 2.6000000000000001e-106Initial program 100.0%
Taylor expanded in re around 0 53.6%
distribute-rgt1-in53.6%
Simplified53.6%
Taylor expanded in im around 0 31.8%
+-commutative31.8%
Simplified31.8%
Taylor expanded in re around inf 31.6%
Taylor expanded in re around 0 32.5%
if 2.6000000000000001e-106 < im < 1.54999999999999996e49Initial program 100.0%
Taylor expanded in re around 0 43.2%
distribute-rgt1-in43.2%
Simplified43.2%
Taylor expanded in im around 0 34.4%
+-commutative34.4%
Simplified34.4%
distribute-lft-in34.4%
*-rgt-identity34.4%
flip-+57.9%
unpow257.9%
Applied egg-rr57.9%
associate-*l*60.8%
unpow260.8%
distribute-lft-out--60.8%
sub-neg60.8%
mul-1-neg60.8%
*-commutative60.8%
distribute-lft-out60.8%
Simplified60.8%
if 1.54999999999999996e49 < im Initial program 100.0%
Taylor expanded in re around 0 56.8%
distribute-rgt1-in56.8%
Simplified56.8%
Taylor expanded in im around 0 4.1%
+-commutative4.1%
Simplified4.1%
distribute-lft-in4.1%
*-rgt-identity4.1%
flip-+3.2%
unpow23.2%
Applied egg-rr3.2%
associate-*l*3.2%
unpow23.2%
distribute-lft-out--3.5%
sub-neg3.5%
mul-1-neg3.5%
*-commutative3.5%
distribute-lft-out3.5%
Simplified3.5%
Taylor expanded in re around 0 18.0%
neg-mul-118.0%
Simplified18.0%
Final simplification33.3%
(FPCore (re im) :precision binary64 (if (<= im 1.2e+34) (* re (/ im re)) (/ (* im (- im (* re (* re im)))) im)))
double code(double re, double im) {
double tmp;
if (im <= 1.2e+34) {
tmp = re * (im / re);
} else {
tmp = (im * (im - (re * (re * im)))) / im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.2d+34) then
tmp = re * (im / re)
else
tmp = (im * (im - (re * (re * im)))) / im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.2e+34) {
tmp = re * (im / re);
} else {
tmp = (im * (im - (re * (re * im)))) / im;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.2e+34: tmp = re * (im / re) else: tmp = (im * (im - (re * (re * im)))) / im return tmp
function code(re, im) tmp = 0.0 if (im <= 1.2e+34) tmp = Float64(re * Float64(im / re)); else tmp = Float64(Float64(im * Float64(im - Float64(re * Float64(re * im)))) / im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.2e+34) tmp = re * (im / re); else tmp = (im * (im - (re * (re * im)))) / im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.2e+34], N[(re * N[(im / re), $MachinePrecision]), $MachinePrecision], N[(N[(im * N[(im - N[(re * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.2 \cdot 10^{+34}:\\
\;\;\;\;re \cdot \frac{im}{re}\\
\mathbf{else}:\\
\;\;\;\;\frac{im \cdot \left(im - re \cdot \left(re \cdot im\right)\right)}{im}\\
\end{array}
\end{array}
if im < 1.19999999999999993e34Initial program 100.0%
Taylor expanded in re around 0 52.0%
distribute-rgt1-in52.0%
Simplified52.0%
Taylor expanded in im around 0 32.2%
+-commutative32.2%
Simplified32.2%
Taylor expanded in re around inf 32.1%
Taylor expanded in re around 0 32.6%
if 1.19999999999999993e34 < im Initial program 100.0%
Taylor expanded in re around 0 56.8%
distribute-rgt1-in56.8%
Simplified56.8%
Taylor expanded in im around 0 4.1%
+-commutative4.1%
Simplified4.1%
distribute-lft-in4.1%
*-rgt-identity4.1%
flip-+3.2%
unpow23.2%
Applied egg-rr3.2%
associate-*l*3.2%
unpow23.2%
distribute-lft-out--3.5%
sub-neg3.5%
mul-1-neg3.5%
*-commutative3.5%
distribute-lft-out3.5%
Simplified3.5%
Taylor expanded in re around 0 18.0%
neg-mul-118.0%
Simplified18.0%
Final simplification29.8%
(FPCore (re im) :precision binary64 (if (<= re -0.8) (* re (/ im re)) (* im (+ re 1.0))))
double code(double re, double im) {
double tmp;
if (re <= -0.8) {
tmp = re * (im / re);
} else {
tmp = im * (re + 1.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-0.8d0)) then
tmp = re * (im / re)
else
tmp = im * (re + 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -0.8) {
tmp = re * (im / re);
} else {
tmp = im * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.8: tmp = re * (im / re) else: tmp = im * (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.8) tmp = Float64(re * Float64(im / re)); else tmp = Float64(im * Float64(re + 1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -0.8) tmp = re * (im / re); else tmp = im * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.8], N[(re * N[(im / re), $MachinePrecision]), $MachinePrecision], N[(im * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.8:\\
\;\;\;\;re \cdot \frac{im}{re}\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if re < -0.80000000000000004Initial program 100.0%
Taylor expanded in re around 0 2.8%
distribute-rgt1-in2.8%
Simplified2.8%
Taylor expanded in im around 0 2.6%
+-commutative2.6%
Simplified2.6%
Taylor expanded in re around inf 2.6%
Taylor expanded in re around 0 19.3%
if -0.80000000000000004 < re Initial program 100.0%
Taylor expanded in re around 0 66.3%
distribute-rgt1-in66.3%
Simplified66.3%
Taylor expanded in im around 0 33.3%
+-commutative33.3%
Simplified33.3%
(FPCore (re im) :precision binary64 (if (<= im 7.8e-6) im (* re im)))
double code(double re, double im) {
double tmp;
if (im <= 7.8e-6) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 7.8d-6) then
tmp = im
else
tmp = re * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 7.8e-6) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 7.8e-6: tmp = im else: tmp = re * im return tmp
function code(re, im) tmp = 0.0 if (im <= 7.8e-6) tmp = im; else tmp = Float64(re * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 7.8e-6) tmp = im; else tmp = re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 7.8e-6], im, N[(re * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 7.8 \cdot 10^{-6}:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re \cdot im\\
\end{array}
\end{array}
if im < 7.7999999999999999e-6Initial program 100.0%
Taylor expanded in re around 0 52.9%
distribute-rgt1-in52.9%
Simplified52.9%
Taylor expanded in im around 0 33.6%
+-commutative33.6%
Simplified33.6%
Taylor expanded in re around 0 30.0%
if 7.7999999999999999e-6 < im Initial program 100.0%
Taylor expanded in re around 0 52.8%
distribute-rgt1-in52.8%
Simplified52.8%
Taylor expanded in im around 0 4.3%
+-commutative4.3%
Simplified4.3%
Taylor expanded in re around inf 4.9%
Final simplification24.2%
(FPCore (re im) :precision binary64 (* im (+ re 1.0)))
double code(double re, double im) {
return im * (re + 1.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * (re + 1.0d0)
end function
public static double code(double re, double im) {
return im * (re + 1.0);
}
def code(re, im): return im * (re + 1.0)
function code(re, im) return Float64(im * Float64(re + 1.0)) end
function tmp = code(re, im) tmp = im * (re + 1.0); end
code[re_, im_] := N[(im * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(re + 1\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 52.9%
distribute-rgt1-in52.9%
Simplified52.9%
Taylor expanded in im around 0 26.8%
+-commutative26.8%
Simplified26.8%
(FPCore (re im) :precision binary64 im)
double code(double re, double im) {
return im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im
end function
public static double code(double re, double im) {
return im;
}
def code(re, im): return im
function code(re, im) return im end
function tmp = code(re, im) tmp = im; end
code[re_, im_] := im
\begin{array}{l}
\\
im
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 52.9%
distribute-rgt1-in52.9%
Simplified52.9%
Taylor expanded in im around 0 26.8%
+-commutative26.8%
Simplified26.8%
Taylor expanded in re around 0 23.6%
herbie shell --seed 2024087
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))