
(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 11 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) 1.0018))) (* (exp re) im) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.0) || !(exp(re) <= 1.0018)) {
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.0018d0))) 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.0018)) {
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.0018): 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.0018)) 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.0018))) 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.0018]], $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.0018\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0 or 1.00180000000000002 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 86.5%
if 0.0 < (exp.f64 re) < 1.00180000000000002Initial program 100.0%
Taylor expanded in re around 0 98.7%
Final simplification93.1%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.27) (and (not (<= re 0.00182)) (<= re 2.5e+99)))
(* (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.27) || (!(re <= 0.00182) && (re <= 2.5e+99))) {
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.27d0)) .or. (.not. (re <= 0.00182d0)) .and. (re <= 2.5d+99)) 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.27) || (!(re <= 0.00182) && (re <= 2.5e+99))) {
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.27) or (not (re <= 0.00182) and (re <= 2.5e+99)): 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.27) || (!(re <= 0.00182) && (re <= 2.5e+99))) 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.27) || (~((re <= 0.00182)) && (re <= 2.5e+99))) 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.27], And[N[Not[LessEqual[re, 0.00182]], $MachinePrecision], LessEqual[re, 2.5e+99]]], 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.27 \lor \neg \left(re \leq 0.00182\right) \land re \leq 2.5 \cdot 10^{+99}:\\
\;\;\;\;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.27000000000000002 or 0.00182 < re < 2.50000000000000004e99Initial program 100.0%
Taylor expanded in im around 0 97.2%
if -0.27000000000000002 < re < 0.00182 or 2.50000000000000004e99 < re Initial program 100.0%
Taylor expanded in re around 0 99.1%
associate-+r+99.1%
*-commutative99.1%
distribute-rgt1-in99.1%
*-commutative99.1%
+-commutative99.1%
*-commutative99.1%
associate-*r*99.1%
*-commutative99.1%
associate-*r*99.1%
distribute-rgt-out99.1%
distribute-lft-out99.1%
+-commutative99.1%
Simplified99.1%
Final simplification98.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) im)))
(if (<= re -0.27)
t_0
(if (<= re 0.00182)
(* (sin im) (+ (+ re 1.0) (* re (* re 0.5))))
(if (<= re 1.35e+154) t_0 (* 0.5 (* (sin im) (* re re))))))))
double code(double re, double im) {
double t_0 = exp(re) * im;
double tmp;
if (re <= -0.27) {
tmp = t_0;
} else if (re <= 0.00182) {
tmp = sin(im) * ((re + 1.0) + (re * (re * 0.5)));
} else if (re <= 1.35e+154) {
tmp = t_0;
} else {
tmp = 0.5 * (sin(im) * (re * 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 = exp(re) * im
if (re <= (-0.27d0)) then
tmp = t_0
else if (re <= 0.00182d0) then
tmp = sin(im) * ((re + 1.0d0) + (re * (re * 0.5d0)))
else if (re <= 1.35d+154) then
tmp = t_0
else
tmp = 0.5d0 * (sin(im) * (re * re))
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.27) {
tmp = t_0;
} else if (re <= 0.00182) {
tmp = Math.sin(im) * ((re + 1.0) + (re * (re * 0.5)));
} else if (re <= 1.35e+154) {
tmp = t_0;
} else {
tmp = 0.5 * (Math.sin(im) * (re * re));
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * im tmp = 0 if re <= -0.27: tmp = t_0 elif re <= 0.00182: tmp = math.sin(im) * ((re + 1.0) + (re * (re * 0.5))) elif re <= 1.35e+154: tmp = t_0 else: tmp = 0.5 * (math.sin(im) * (re * re)) return tmp
function code(re, im) t_0 = Float64(exp(re) * im) tmp = 0.0 if (re <= -0.27) tmp = t_0; elseif (re <= 0.00182) tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + Float64(re * Float64(re * 0.5)))); elseif (re <= 1.35e+154) tmp = t_0; else tmp = Float64(0.5 * Float64(sin(im) * Float64(re * re))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * im; tmp = 0.0; if (re <= -0.27) tmp = t_0; elseif (re <= 0.00182) tmp = sin(im) * ((re + 1.0) + (re * (re * 0.5))); elseif (re <= 1.35e+154) tmp = t_0; else tmp = 0.5 * (sin(im) * (re * re)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[re, -0.27], t$95$0, If[LessEqual[re, 0.00182], N[(N[Sin[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.35e+154], t$95$0, N[(0.5 * N[(N[Sin[im], $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot im\\
\mathbf{if}\;re \leq -0.27:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 0.00182:\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin im \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if re < -0.27000000000000002 or 0.00182 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0 93.8%
if -0.27000000000000002 < re < 0.00182Initial program 100.0%
Taylor expanded in re around 0 99.2%
associate-+r+99.2%
+-commutative99.2%
*-commutative99.2%
distribute-lft1-in99.2%
*-commutative99.2%
associate-*r*99.2%
distribute-rgt-out99.2%
*-commutative99.2%
unpow299.2%
associate-*l*99.2%
Simplified99.2%
if 1.35000000000000003e154 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
associate-+r+100.0%
+-commutative100.0%
*-commutative100.0%
distribute-lft1-in100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
unpow2100.0%
Simplified100.0%
Final simplification97.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) im)))
(if (<= re -0.27)
t_0
(if (<= re 0.0017)
(* (sin im) (+ re 1.0))
(if (<= re 1.35e+154) t_0 (* 0.5 (* (sin im) (* re re))))))))
double code(double re, double im) {
double t_0 = exp(re) * im;
double tmp;
if (re <= -0.27) {
tmp = t_0;
} else if (re <= 0.0017) {
tmp = sin(im) * (re + 1.0);
} else if (re <= 1.35e+154) {
tmp = t_0;
} else {
tmp = 0.5 * (sin(im) * (re * 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 = exp(re) * im
if (re <= (-0.27d0)) then
tmp = t_0
else if (re <= 0.0017d0) then
tmp = sin(im) * (re + 1.0d0)
else if (re <= 1.35d+154) then
tmp = t_0
else
tmp = 0.5d0 * (sin(im) * (re * re))
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.27) {
tmp = t_0;
} else if (re <= 0.0017) {
tmp = Math.sin(im) * (re + 1.0);
} else if (re <= 1.35e+154) {
tmp = t_0;
} else {
tmp = 0.5 * (Math.sin(im) * (re * re));
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * im tmp = 0 if re <= -0.27: tmp = t_0 elif re <= 0.0017: tmp = math.sin(im) * (re + 1.0) elif re <= 1.35e+154: tmp = t_0 else: tmp = 0.5 * (math.sin(im) * (re * re)) return tmp
function code(re, im) t_0 = Float64(exp(re) * im) tmp = 0.0 if (re <= -0.27) tmp = t_0; elseif (re <= 0.0017) tmp = Float64(sin(im) * Float64(re + 1.0)); elseif (re <= 1.35e+154) tmp = t_0; else tmp = Float64(0.5 * Float64(sin(im) * Float64(re * re))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * im; tmp = 0.0; if (re <= -0.27) tmp = t_0; elseif (re <= 0.0017) tmp = sin(im) * (re + 1.0); elseif (re <= 1.35e+154) tmp = t_0; else tmp = 0.5 * (sin(im) * (re * re)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[re, -0.27], t$95$0, If[LessEqual[re, 0.0017], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.35e+154], t$95$0, N[(0.5 * N[(N[Sin[im], $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot im\\
\mathbf{if}\;re \leq -0.27:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 0.0017:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin im \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if re < -0.27000000000000002 or 0.00169999999999999991 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0 93.8%
if -0.27000000000000002 < re < 0.00169999999999999991Initial program 100.0%
Taylor expanded in re around 0 99.1%
*-commutative99.1%
distribute-rgt1-in99.1%
Simplified99.1%
if 1.35000000000000003e154 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
associate-+r+100.0%
+-commutative100.0%
*-commutative100.0%
distribute-lft1-in100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
unpow2100.0%
Simplified100.0%
Final simplification97.5%
(FPCore (re im) :precision binary64 (if (or (<= re -0.27) (not (<= re 0.0017))) (* (exp re) im) (* (sin im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((re <= -0.27) || !(re <= 0.0017)) {
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.27d0)) .or. (.not. (re <= 0.0017d0))) 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.27) || !(re <= 0.0017)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.27) or not (re <= 0.0017): 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.27) || !(re <= 0.0017)) 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.27) || ~((re <= 0.0017))) tmp = exp(re) * im; else tmp = sin(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.27], N[Not[LessEqual[re, 0.0017]], $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.27 \lor \neg \left(re \leq 0.0017\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if re < -0.27000000000000002 or 0.00169999999999999991 < re Initial program 100.0%
Taylor expanded in im around 0 86.5%
if -0.27000000000000002 < re < 0.00169999999999999991Initial program 100.0%
Taylor expanded in re around 0 99.1%
*-commutative99.1%
distribute-rgt1-in99.1%
Simplified99.1%
Final simplification93.2%
(FPCore (re im) :precision binary64 (if (<= re 390.0) (sin im) (* 0.5 (* im (* re re)))))
double code(double re, double im) {
double tmp;
if (re <= 390.0) {
tmp = sin(im);
} else {
tmp = 0.5 * (im * (re * re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 390.0d0) then
tmp = sin(im)
else
tmp = 0.5d0 * (im * (re * re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 390.0) {
tmp = Math.sin(im);
} else {
tmp = 0.5 * (im * (re * re));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 390.0: tmp = math.sin(im) else: tmp = 0.5 * (im * (re * re)) return tmp
function code(re, im) tmp = 0.0 if (re <= 390.0) tmp = sin(im); else tmp = Float64(0.5 * Float64(im * Float64(re * re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 390.0) tmp = sin(im); else tmp = 0.5 * (im * (re * re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 390.0], N[Sin[im], $MachinePrecision], N[(0.5 * N[(im * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 390:\\
\;\;\;\;\sin im\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if re < 390Initial program 100.0%
Taylor expanded in re around 0 71.3%
if 390 < re Initial program 100.0%
Taylor expanded in re around 0 63.8%
associate-+r+63.8%
+-commutative63.8%
*-commutative63.8%
distribute-lft1-in63.8%
*-commutative63.8%
associate-*r*63.8%
distribute-rgt-out63.8%
*-commutative63.8%
unpow263.8%
associate-*l*63.8%
Simplified63.8%
Taylor expanded in re around inf 63.8%
*-commutative63.8%
unpow263.8%
associate-*r*45.5%
associate-*r*45.5%
*-commutative45.5%
Simplified45.5%
Taylor expanded in im around 0 48.6%
*-commutative48.6%
*-commutative48.6%
unpow248.6%
Simplified48.6%
Final simplification65.9%
(FPCore (re im) :precision binary64 (if (<= re 16.5) (* im (+ re 1.0)) (* 0.5 (* re (* re im)))))
double code(double re, double im) {
double tmp;
if (re <= 16.5) {
tmp = im * (re + 1.0);
} 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 <= 16.5d0) then
tmp = im * (re + 1.0d0)
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 <= 16.5) {
tmp = im * (re + 1.0);
} else {
tmp = 0.5 * (re * (re * im));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 16.5: tmp = im * (re + 1.0) else: tmp = 0.5 * (re * (re * im)) return tmp
function code(re, im) tmp = 0.0 if (re <= 16.5) tmp = Float64(im * Float64(re + 1.0)); 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 <= 16.5) tmp = im * (re + 1.0); else tmp = 0.5 * (re * (re * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 16.5], N[(im * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(re * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 16.5:\\
\;\;\;\;im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(re \cdot im\right)\right)\\
\end{array}
\end{array}
if re < 16.5Initial program 100.0%
Taylor expanded in re around 0 71.2%
*-commutative71.2%
distribute-rgt1-in71.2%
Simplified71.2%
Taylor expanded in im around 0 38.3%
if 16.5 < re Initial program 100.0%
Taylor expanded in re around 0 63.8%
associate-+r+63.8%
+-commutative63.8%
*-commutative63.8%
distribute-lft1-in63.8%
*-commutative63.8%
associate-*r*63.8%
distribute-rgt-out63.8%
*-commutative63.8%
unpow263.8%
associate-*l*63.8%
Simplified63.8%
Taylor expanded in re around inf 63.8%
unpow263.8%
Simplified63.8%
Taylor expanded in im around 0 48.6%
unpow248.6%
associate-*l*30.3%
Simplified30.3%
Final simplification36.4%
(FPCore (re im) :precision binary64 (if (<= re 210.0) (* im (+ re 1.0)) (* 0.5 (* im (* re re)))))
double code(double re, double im) {
double tmp;
if (re <= 210.0) {
tmp = im * (re + 1.0);
} else {
tmp = 0.5 * (im * (re * re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 210.0d0) then
tmp = im * (re + 1.0d0)
else
tmp = 0.5d0 * (im * (re * re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 210.0) {
tmp = im * (re + 1.0);
} else {
tmp = 0.5 * (im * (re * re));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 210.0: tmp = im * (re + 1.0) else: tmp = 0.5 * (im * (re * re)) return tmp
function code(re, im) tmp = 0.0 if (re <= 210.0) tmp = Float64(im * Float64(re + 1.0)); else tmp = Float64(0.5 * Float64(im * Float64(re * re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 210.0) tmp = im * (re + 1.0); else tmp = 0.5 * (im * (re * re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 210.0], N[(im * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 210:\\
\;\;\;\;im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if re < 210Initial program 100.0%
Taylor expanded in re around 0 71.2%
*-commutative71.2%
distribute-rgt1-in71.2%
Simplified71.2%
Taylor expanded in im around 0 38.3%
if 210 < re Initial program 100.0%
Taylor expanded in re around 0 63.8%
associate-+r+63.8%
+-commutative63.8%
*-commutative63.8%
distribute-lft1-in63.8%
*-commutative63.8%
associate-*r*63.8%
distribute-rgt-out63.8%
*-commutative63.8%
unpow263.8%
associate-*l*63.8%
Simplified63.8%
Taylor expanded in re around inf 63.8%
*-commutative63.8%
unpow263.8%
associate-*r*45.5%
associate-*r*45.5%
*-commutative45.5%
Simplified45.5%
Taylor expanded in im around 0 48.6%
*-commutative48.6%
*-commutative48.6%
unpow248.6%
Simplified48.6%
Final simplification40.8%
(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 55.3%
*-commutative55.3%
distribute-rgt1-in55.3%
Simplified55.3%
Taylor expanded in im around 0 32.1%
Final simplification32.1%
(FPCore (re im) :precision binary64 (* re im))
double code(double re, double im) {
return re * im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re * im
end function
public static double code(double re, double im) {
return re * im;
}
def code(re, im): return re * im
function code(re, im) return Float64(re * im) end
function tmp = code(re, im) tmp = re * im; end
code[re_, im_] := N[(re * im), $MachinePrecision]
\begin{array}{l}
\\
re \cdot im
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 55.3%
*-commutative55.3%
distribute-rgt1-in55.3%
Simplified55.3%
Taylor expanded in re around inf 4.3%
Taylor expanded in im around 0 6.2%
Final simplification6.2%
herbie shell --seed 2023182
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))