
(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 14 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%
Final simplification100.0%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 0.0) (not (<= (exp re) 20.0))) (* (exp re) im) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.0) || !(exp(re) <= 20.0)) {
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) <= 20.0d0))) 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) <= 20.0)) {
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) <= 20.0): 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) <= 20.0)) 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) <= 20.0))) 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], 20.0]], $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 20\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0 or 20 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 91.2%
if 0.0 < (exp.f64 re) < 20Initial program 100.0%
Taylor expanded in re around 0 96.9%
Final simplification93.9%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.075) (and (not (<= re 2.9)) (<= re 1.05e+103)))
(* (exp re) im)
(*
(sin im)
(+ (+ re 1.0) (* (* re re) (+ (* re 0.16666666666666666) 0.5))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.075) || (!(re <= 2.9) && (re <= 1.05e+103))) {
tmp = exp(re) * im;
} else {
tmp = sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 0.5)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((re <= (-0.075d0)) .or. (.not. (re <= 2.9d0)) .and. (re <= 1.05d+103)) then
tmp = exp(re) * im
else
tmp = sin(im) * ((re + 1.0d0) + ((re * re) * ((re * 0.16666666666666666d0) + 0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.075) || (!(re <= 2.9) && (re <= 1.05e+103))) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.075) or (not (re <= 2.9) and (re <= 1.05e+103)): tmp = math.exp(re) * im else: tmp = math.sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 0.5))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.075) || (!(re <= 2.9) && (re <= 1.05e+103))) tmp = Float64(exp(re) * im); else tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + Float64(Float64(re * re) * Float64(Float64(re * 0.16666666666666666) + 0.5)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.075) || (~((re <= 2.9)) && (re <= 1.05e+103))) tmp = exp(re) * im; else tmp = sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.075], And[N[Not[LessEqual[re, 2.9]], $MachinePrecision], LessEqual[re, 1.05e+103]]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(N[(re * re), $MachinePrecision] * N[(N[(re * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.075 \lor \neg \left(re \leq 2.9\right) \land re \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + \left(re \cdot re\right) \cdot \left(re \cdot 0.16666666666666666 + 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.0749999999999999972 or 2.89999999999999991 < re < 1.0500000000000001e103Initial program 100.0%
Taylor expanded in im around 0 95.7%
if -0.0749999999999999972 < re < 2.89999999999999991 or 1.0500000000000001e103 < re Initial program 100.0%
Taylor expanded in re around 0 98.8%
associate-+r+98.8%
*-commutative98.8%
distribute-rgt1-in98.8%
*-commutative98.8%
+-commutative98.8%
*-commutative98.8%
associate-*r*98.8%
*-commutative98.8%
associate-*r*98.8%
distribute-rgt-out98.8%
distribute-lft-out98.8%
+-commutative98.8%
Simplified98.8%
Final simplification97.7%
(FPCore (re im) :precision binary64 (if (or (<= re -0.075) (and (not (<= re 2.9)) (<= re 1.25e+151))) (* (exp re) im) (* (sin im) (+ (+ re 1.0) (* re (* re 0.5))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.075) || (!(re <= 2.9) && (re <= 1.25e+151))) {
tmp = exp(re) * im;
} else {
tmp = sin(im) * ((re + 1.0) + (re * (re * 0.5)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((re <= (-0.075d0)) .or. (.not. (re <= 2.9d0)) .and. (re <= 1.25d+151)) then
tmp = exp(re) * im
else
tmp = sin(im) * ((re + 1.0d0) + (re * (re * 0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.075) || (!(re <= 2.9) && (re <= 1.25e+151))) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * ((re + 1.0) + (re * (re * 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.075) or (not (re <= 2.9) and (re <= 1.25e+151)): tmp = math.exp(re) * im else: tmp = math.sin(im) * ((re + 1.0) + (re * (re * 0.5))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.075) || (!(re <= 2.9) && (re <= 1.25e+151))) tmp = Float64(exp(re) * im); else tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + Float64(re * Float64(re * 0.5)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.075) || (~((re <= 2.9)) && (re <= 1.25e+151))) tmp = exp(re) * im; else tmp = sin(im) * ((re + 1.0) + (re * (re * 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.075], And[N[Not[LessEqual[re, 2.9]], $MachinePrecision], LessEqual[re, 1.25e+151]]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.075 \lor \neg \left(re \leq 2.9\right) \land re \leq 1.25 \cdot 10^{+151}:\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.0749999999999999972 or 2.89999999999999991 < re < 1.2500000000000001e151Initial program 100.0%
Taylor expanded in im around 0 94.3%
if -0.0749999999999999972 < re < 2.89999999999999991 or 1.2500000000000001e151 < re Initial program 100.0%
Taylor expanded in re around 0 97.9%
associate-+r+97.9%
+-commutative97.9%
*-commutative97.9%
distribute-lft1-in97.9%
*-commutative97.9%
associate-*r*97.9%
distribute-rgt-out97.9%
*-commutative97.9%
unpow297.9%
associate-*l*97.9%
Simplified97.9%
Final simplification96.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) im)))
(if (<= re -0.075)
t_0
(if (<= re 2.9)
(* (sin im) (+ re 1.0))
(if (<= re 1.25e+151) t_0 (* (sin im) (* (* re re) 0.5)))))))
double code(double re, double im) {
double t_0 = exp(re) * im;
double tmp;
if (re <= -0.075) {
tmp = t_0;
} else if (re <= 2.9) {
tmp = sin(im) * (re + 1.0);
} else if (re <= 1.25e+151) {
tmp = t_0;
} else {
tmp = sin(im) * ((re * re) * 0.5);
}
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 = exp(re) * im
if (re <= (-0.075d0)) then
tmp = t_0
else if (re <= 2.9d0) then
tmp = sin(im) * (re + 1.0d0)
else if (re <= 1.25d+151) then
tmp = t_0
else
tmp = sin(im) * ((re * re) * 0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(re) * im;
double tmp;
if (re <= -0.075) {
tmp = t_0;
} else if (re <= 2.9) {
tmp = Math.sin(im) * (re + 1.0);
} else if (re <= 1.25e+151) {
tmp = t_0;
} else {
tmp = Math.sin(im) * ((re * re) * 0.5);
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * im tmp = 0 if re <= -0.075: tmp = t_0 elif re <= 2.9: tmp = math.sin(im) * (re + 1.0) elif re <= 1.25e+151: tmp = t_0 else: tmp = math.sin(im) * ((re * re) * 0.5) return tmp
function code(re, im) t_0 = Float64(exp(re) * im) tmp = 0.0 if (re <= -0.075) tmp = t_0; elseif (re <= 2.9) tmp = Float64(sin(im) * Float64(re + 1.0)); elseif (re <= 1.25e+151) tmp = t_0; else tmp = Float64(sin(im) * Float64(Float64(re * re) * 0.5)); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * im; tmp = 0.0; if (re <= -0.075) tmp = t_0; elseif (re <= 2.9) tmp = sin(im) * (re + 1.0); elseif (re <= 1.25e+151) tmp = t_0; else tmp = sin(im) * ((re * re) * 0.5); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[re, -0.075], t$95$0, If[LessEqual[re, 2.9], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.25e+151], t$95$0, N[(N[Sin[im], $MachinePrecision] * N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot im\\
\mathbf{if}\;re \leq -0.075:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 2.9:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\mathbf{elif}\;re \leq 1.25 \cdot 10^{+151}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -0.0749999999999999972 or 2.89999999999999991 < re < 1.2500000000000001e151Initial program 100.0%
Taylor expanded in im around 0 94.3%
if -0.0749999999999999972 < re < 2.89999999999999991Initial program 100.0%
Taylor expanded in re around 0 97.7%
*-commutative97.7%
distribute-rgt1-in97.7%
Simplified97.7%
if 1.2500000000000001e151 < re Initial program 100.0%
Taylor expanded in re around 0 97.2%
associate-+r+97.2%
+-commutative97.2%
*-commutative97.2%
distribute-lft1-in97.2%
*-commutative97.2%
associate-*r*97.2%
distribute-rgt-out97.2%
*-commutative97.2%
unpow297.2%
associate-*l*97.2%
Simplified97.2%
Taylor expanded in re around inf 97.2%
unpow297.2%
associate-*r*97.2%
*-commutative97.2%
associate-*r*97.2%
Simplified97.2%
Final simplification96.3%
(FPCore (re im) :precision binary64 (if (or (<= re -0.075) (not (<= re 2.9))) (* (exp re) im) (* (sin im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((re <= -0.075) || !(re <= 2.9)) {
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 ((re <= (-0.075d0)) .or. (.not. (re <= 2.9d0))) 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 ((re <= -0.075) || !(re <= 2.9)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.075) or not (re <= 2.9): tmp = math.exp(re) * im else: tmp = math.sin(im) * (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.075) || !(re <= 2.9)) 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 ((re <= -0.075) || ~((re <= 2.9))) tmp = exp(re) * im; else tmp = sin(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.075], N[Not[LessEqual[re, 2.9]], $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}\;re \leq -0.075 \lor \neg \left(re \leq 2.9\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if re < -0.0749999999999999972 or 2.89999999999999991 < re Initial program 100.0%
Taylor expanded in im around 0 91.2%
if -0.0749999999999999972 < re < 2.89999999999999991Initial program 100.0%
Taylor expanded in re around 0 97.7%
*-commutative97.7%
distribute-rgt1-in97.7%
Simplified97.7%
Final simplification94.3%
(FPCore (re im) :precision binary64 (if (<= re 1.02e+61) (sin im) (* (* re re) (* im 0.5))))
double code(double re, double im) {
double tmp;
if (re <= 1.02e+61) {
tmp = sin(im);
} else {
tmp = (re * re) * (im * 0.5);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 1.02d+61) then
tmp = sin(im)
else
tmp = (re * re) * (im * 0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 1.02e+61) {
tmp = Math.sin(im);
} else {
tmp = (re * re) * (im * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.02e+61: tmp = math.sin(im) else: tmp = (re * re) * (im * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= 1.02e+61) tmp = sin(im); else tmp = Float64(Float64(re * re) * Float64(im * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.02e+61) tmp = sin(im); else tmp = (re * re) * (im * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.02e+61], N[Sin[im], $MachinePrecision], N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.02 \cdot 10^{+61}:\\
\;\;\;\;\sin im\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 1.01999999999999999e61Initial program 100.0%
Taylor expanded in re around 0 58.0%
if 1.01999999999999999e61 < re Initial program 100.0%
Taylor expanded in re around 0 61.0%
associate-+r+61.0%
+-commutative61.0%
*-commutative61.0%
distribute-lft1-in61.0%
*-commutative61.0%
associate-*r*61.0%
distribute-rgt-out61.0%
*-commutative61.0%
unpow261.0%
associate-*l*61.0%
Simplified61.0%
Taylor expanded in re around inf 61.0%
unpow261.0%
associate-*r*61.0%
*-commutative61.0%
associate-*r*61.0%
Simplified61.0%
Taylor expanded in im around 0 58.2%
unpow258.2%
associate-*r*58.2%
*-commutative58.2%
associate-*l*58.2%
Simplified58.2%
Final simplification58.0%
(FPCore (re im) :precision binary64 (if (<= re 0.00082) (/ (- 1.0 (* re re)) (/ (- 1.0 re) im)) (* (* re re) (* im 0.5))))
double code(double re, double im) {
double tmp;
if (re <= 0.00082) {
tmp = (1.0 - (re * re)) / ((1.0 - re) / im);
} else {
tmp = (re * re) * (im * 0.5);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 0.00082d0) then
tmp = (1.0d0 - (re * re)) / ((1.0d0 - re) / im)
else
tmp = (re * re) * (im * 0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 0.00082) {
tmp = (1.0 - (re * re)) / ((1.0 - re) / im);
} else {
tmp = (re * re) * (im * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.00082: tmp = (1.0 - (re * re)) / ((1.0 - re) / im) else: tmp = (re * re) * (im * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= 0.00082) tmp = Float64(Float64(1.0 - Float64(re * re)) / Float64(Float64(1.0 - re) / im)); else tmp = Float64(Float64(re * re) * Float64(im * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.00082) tmp = (1.0 - (re * re)) / ((1.0 - re) / im); else tmp = (re * re) * (im * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.00082], N[(N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - re), $MachinePrecision] / im), $MachinePrecision]), $MachinePrecision], N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.00082:\\
\;\;\;\;\frac{1 - re \cdot re}{\frac{1 - re}{im}}\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 8.1999999999999998e-4Initial program 100.0%
Taylor expanded in re around 0 62.7%
*-commutative62.7%
distribute-rgt1-in62.7%
Simplified62.7%
Taylor expanded in im around 0 33.7%
+-commutative33.7%
*-commutative33.7%
+-commutative33.7%
flip-+33.6%
associate-*r/33.6%
metadata-eval33.6%
Applied egg-rr33.6%
*-commutative33.6%
associate-/l*34.9%
Simplified34.9%
if 8.1999999999999998e-4 < re Initial program 100.0%
Taylor expanded in re around 0 47.8%
associate-+r+47.8%
+-commutative47.8%
*-commutative47.8%
distribute-lft1-in47.8%
*-commutative47.8%
associate-*r*47.8%
distribute-rgt-out47.8%
*-commutative47.8%
unpow247.8%
associate-*l*47.8%
Simplified47.8%
Taylor expanded in re around inf 46.6%
unpow246.6%
associate-*r*46.6%
*-commutative46.6%
associate-*r*46.6%
Simplified46.6%
Taylor expanded in im around 0 43.8%
unpow243.8%
associate-*r*43.8%
*-commutative43.8%
associate-*l*43.8%
Simplified43.8%
Final simplification37.3%
(FPCore (re im) :precision binary64 (if (<= re 0.00082) im (* 0.5 (* re (* re im)))))
double code(double re, double im) {
double tmp;
if (re <= 0.00082) {
tmp = im;
} else {
tmp = 0.5 * (re * (re * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 0.00082d0) then
tmp = im
else
tmp = 0.5d0 * (re * (re * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 0.00082) {
tmp = im;
} else {
tmp = 0.5 * (re * (re * im));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.00082: tmp = im else: tmp = 0.5 * (re * (re * im)) return tmp
function code(re, im) tmp = 0.0 if (re <= 0.00082) tmp = im; else tmp = Float64(0.5 * Float64(re * Float64(re * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.00082) tmp = im; else tmp = 0.5 * (re * (re * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.00082], im, N[(0.5 * N[(re * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.00082:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(re \cdot im\right)\right)\\
\end{array}
\end{array}
if re < 8.1999999999999998e-4Initial program 100.0%
Taylor expanded in im around 0 70.7%
Taylor expanded in re around 0 34.1%
if 8.1999999999999998e-4 < re Initial program 100.0%
Taylor expanded in re around 0 47.8%
associate-+r+47.8%
+-commutative47.8%
*-commutative47.8%
distribute-lft1-in47.8%
*-commutative47.8%
associate-*r*47.8%
distribute-rgt-out47.8%
*-commutative47.8%
unpow247.8%
associate-*l*47.8%
Simplified47.8%
Taylor expanded in re around inf 46.6%
unpow246.6%
associate-*r*46.6%
*-commutative46.6%
associate-*r*46.6%
Simplified46.6%
Taylor expanded in im around 0 43.8%
unpow243.8%
associate-*r*43.8%
*-commutative43.8%
associate-*l*43.8%
Simplified43.8%
Taylor expanded in re around 0 43.8%
unpow243.8%
associate-*l*31.7%
Simplified31.7%
Final simplification33.4%
(FPCore (re im) :precision binary64 (if (<= re 0.00082) im (* (* re re) (* im 0.5))))
double code(double re, double im) {
double tmp;
if (re <= 0.00082) {
tmp = im;
} else {
tmp = (re * re) * (im * 0.5);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 0.00082d0) then
tmp = im
else
tmp = (re * re) * (im * 0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 0.00082) {
tmp = im;
} else {
tmp = (re * re) * (im * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.00082: tmp = im else: tmp = (re * re) * (im * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= 0.00082) tmp = im; else tmp = Float64(Float64(re * re) * Float64(im * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.00082) tmp = im; else tmp = (re * re) * (im * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.00082], im, N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.00082:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 8.1999999999999998e-4Initial program 100.0%
Taylor expanded in im around 0 70.7%
Taylor expanded in re around 0 34.1%
if 8.1999999999999998e-4 < re Initial program 100.0%
Taylor expanded in re around 0 47.8%
associate-+r+47.8%
+-commutative47.8%
*-commutative47.8%
distribute-lft1-in47.8%
*-commutative47.8%
associate-*r*47.8%
distribute-rgt-out47.8%
*-commutative47.8%
unpow247.8%
associate-*l*47.8%
Simplified47.8%
Taylor expanded in re around inf 46.6%
unpow246.6%
associate-*r*46.6%
*-commutative46.6%
associate-*r*46.6%
Simplified46.6%
Taylor expanded in im around 0 43.8%
unpow243.8%
associate-*r*43.8%
*-commutative43.8%
associate-*l*43.8%
Simplified43.8%
Final simplification36.7%
(FPCore (re im) :precision binary64 (if (<= re 0.00082) im (* re im)))
double code(double re, double im) {
double tmp;
if (re <= 0.00082) {
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 (re <= 0.00082d0) then
tmp = im
else
tmp = re * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 0.00082) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.00082: tmp = im else: tmp = re * im return tmp
function code(re, im) tmp = 0.0 if (re <= 0.00082) tmp = im; else tmp = Float64(re * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.00082) tmp = im; else tmp = re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.00082], im, N[(re * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.00082:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re \cdot im\\
\end{array}
\end{array}
if re < 8.1999999999999998e-4Initial program 100.0%
Taylor expanded in im around 0 70.7%
Taylor expanded in re around 0 34.1%
if 8.1999999999999998e-4 < re Initial program 100.0%
Taylor expanded in re around 0 5.6%
*-commutative5.6%
distribute-rgt1-in5.6%
Simplified5.6%
Taylor expanded in im around 0 11.7%
Taylor expanded in re around inf 11.7%
Final simplification28.0%
(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 47.3%
*-commutative47.3%
distribute-rgt1-in47.3%
Simplified47.3%
Taylor expanded in im around 0 27.8%
Final simplification27.8%
(FPCore (re im) :precision binary64 (+ im (* re im)))
double code(double re, double im) {
return im + (re * im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im + (re * im)
end function
public static double code(double re, double im) {
return im + (re * im);
}
def code(re, im): return im + (re * im)
function code(re, im) return Float64(im + Float64(re * im)) end
function tmp = code(re, im) tmp = im + (re * im); end
code[re_, im_] := N[(im + N[(re * im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im + re \cdot im
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 72.7%
Taylor expanded in re around 0 27.8%
Final simplification27.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 im around 0 72.7%
Taylor expanded in re around 0 25.6%
Final simplification25.6%
herbie shell --seed 2023187
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))