
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
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}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
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);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
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
(let* ((t_0 (* (exp re) (sin im))))
(if (<= t_0 (- INFINITY))
(* (exp re) -0.16666666666666666)
(if (<= t_0 -0.02)
(sin im)
(if (<= t_0 0.0)
(* 0.0 im)
(if (<= t_0 1.0) (* (+ 1.0 re) (sin im)) (* (exp re) 1.0)))))))
double code(double re, double im) {
double t_0 = exp(re) * sin(im);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = exp(re) * -0.16666666666666666;
} else if (t_0 <= -0.02) {
tmp = sin(im);
} else if (t_0 <= 0.0) {
tmp = 0.0 * im;
} else if (t_0 <= 1.0) {
tmp = (1.0 + re) * sin(im);
} else {
tmp = exp(re) * 1.0;
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(re) * Math.sin(im);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = Math.exp(re) * -0.16666666666666666;
} else if (t_0 <= -0.02) {
tmp = Math.sin(im);
} else if (t_0 <= 0.0) {
tmp = 0.0 * im;
} else if (t_0 <= 1.0) {
tmp = (1.0 + re) * Math.sin(im);
} else {
tmp = Math.exp(re) * 1.0;
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * math.sin(im) tmp = 0 if t_0 <= -math.inf: tmp = math.exp(re) * -0.16666666666666666 elif t_0 <= -0.02: tmp = math.sin(im) elif t_0 <= 0.0: tmp = 0.0 * im elif t_0 <= 1.0: tmp = (1.0 + re) * math.sin(im) else: tmp = math.exp(re) * 1.0 return tmp
function code(re, im) t_0 = Float64(exp(re) * sin(im)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(exp(re) * -0.16666666666666666); elseif (t_0 <= -0.02) tmp = sin(im); elseif (t_0 <= 0.0) tmp = Float64(0.0 * im); elseif (t_0 <= 1.0) tmp = Float64(Float64(1.0 + re) * sin(im)); else tmp = Float64(exp(re) * 1.0); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * sin(im); tmp = 0.0; if (t_0 <= -Inf) tmp = exp(re) * -0.16666666666666666; elseif (t_0 <= -0.02) tmp = sin(im); elseif (t_0 <= 0.0) tmp = 0.0 * im; elseif (t_0 <= 1.0) tmp = (1.0 + re) * sin(im); else tmp = exp(re) * 1.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[Exp[re], $MachinePrecision] * -0.16666666666666666), $MachinePrecision], If[LessEqual[t$95$0, -0.02], N[Sin[im], $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(0.0 * im), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(N[(1.0 + re), $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision], N[(N[Exp[re], $MachinePrecision] * 1.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \sin im\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;e^{re} \cdot -0.16666666666666666\\
\mathbf{elif}\;t\_0 \leq -0.02:\\
\;\;\;\;\sin im\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;0 \cdot im\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\left(1 + re\right) \cdot \sin im\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot 1\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < -inf.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites60.6%
Applied rewrites39.7%
Applied rewrites40.2%
if -inf.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0200000000000000004Initial program 100.0%
Taylor expanded in re around 0
Applied rewrites51.2%
if -0.0200000000000000004 < (*.f64 (exp.f64 re) (sin.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Taylor expanded in re around 0
Applied rewrites26.7%
Applied rewrites27.0%
if 0.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1Initial program 100.0%
Taylor expanded in re around 0
Applied rewrites51.8%
if 1 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Applied rewrites40.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (sin im))))
(if (<= t_0 (- INFINITY))
(* (exp re) -0.16666666666666666)
(if (<= t_0 -0.02)
(sin im)
(if (<= t_0 0.0)
(* 0.0 im)
(if (<= t_0 1.0) (sin im) (* (exp re) 1.0)))))))
double code(double re, double im) {
double t_0 = exp(re) * sin(im);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = exp(re) * -0.16666666666666666;
} else if (t_0 <= -0.02) {
tmp = sin(im);
} else if (t_0 <= 0.0) {
tmp = 0.0 * im;
} else if (t_0 <= 1.0) {
tmp = sin(im);
} else {
tmp = exp(re) * 1.0;
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(re) * Math.sin(im);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = Math.exp(re) * -0.16666666666666666;
} else if (t_0 <= -0.02) {
tmp = Math.sin(im);
} else if (t_0 <= 0.0) {
tmp = 0.0 * im;
} else if (t_0 <= 1.0) {
tmp = Math.sin(im);
} else {
tmp = Math.exp(re) * 1.0;
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * math.sin(im) tmp = 0 if t_0 <= -math.inf: tmp = math.exp(re) * -0.16666666666666666 elif t_0 <= -0.02: tmp = math.sin(im) elif t_0 <= 0.0: tmp = 0.0 * im elif t_0 <= 1.0: tmp = math.sin(im) else: tmp = math.exp(re) * 1.0 return tmp
function code(re, im) t_0 = Float64(exp(re) * sin(im)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(exp(re) * -0.16666666666666666); elseif (t_0 <= -0.02) tmp = sin(im); elseif (t_0 <= 0.0) tmp = Float64(0.0 * im); elseif (t_0 <= 1.0) tmp = sin(im); else tmp = Float64(exp(re) * 1.0); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * sin(im); tmp = 0.0; if (t_0 <= -Inf) tmp = exp(re) * -0.16666666666666666; elseif (t_0 <= -0.02) tmp = sin(im); elseif (t_0 <= 0.0) tmp = 0.0 * im; elseif (t_0 <= 1.0) tmp = sin(im); else tmp = exp(re) * 1.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[Exp[re], $MachinePrecision] * -0.16666666666666666), $MachinePrecision], If[LessEqual[t$95$0, -0.02], N[Sin[im], $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(0.0 * im), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[Sin[im], $MachinePrecision], N[(N[Exp[re], $MachinePrecision] * 1.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \sin im\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;e^{re} \cdot -0.16666666666666666\\
\mathbf{elif}\;t\_0 \leq -0.02:\\
\;\;\;\;\sin im\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;0 \cdot im\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\sin im\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot 1\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < -inf.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites60.6%
Applied rewrites39.7%
Applied rewrites40.2%
if -inf.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0200000000000000004 or 0.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1Initial program 100.0%
Taylor expanded in re around 0
Applied rewrites51.2%
if -0.0200000000000000004 < (*.f64 (exp.f64 re) (sin.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Taylor expanded in re around 0
Applied rewrites26.7%
Applied rewrites27.0%
if 1 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Applied rewrites40.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (sin im))))
(if (<= t_0 0.0)
(* (exp re) (- -0.16666666666666666 1.0))
(if (<= t_0 4e-8)
(* 1.0 (* im (+ 1.0 (* -0.16666666666666666 (pow im 2.0)))))
(* (exp re) 1.0)))))
double code(double re, double im) {
double t_0 = exp(re) * sin(im);
double tmp;
if (t_0 <= 0.0) {
tmp = exp(re) * (-0.16666666666666666 - 1.0);
} else if (t_0 <= 4e-8) {
tmp = 1.0 * (im * (1.0 + (-0.16666666666666666 * pow(im, 2.0))));
} else {
tmp = exp(re) * 1.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = exp(re) * sin(im)
if (t_0 <= 0.0d0) then
tmp = exp(re) * ((-0.16666666666666666d0) - 1.0d0)
else if (t_0 <= 4d-8) then
tmp = 1.0d0 * (im * (1.0d0 + ((-0.16666666666666666d0) * (im ** 2.0d0))))
else
tmp = exp(re) * 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(re) * Math.sin(im);
double tmp;
if (t_0 <= 0.0) {
tmp = Math.exp(re) * (-0.16666666666666666 - 1.0);
} else if (t_0 <= 4e-8) {
tmp = 1.0 * (im * (1.0 + (-0.16666666666666666 * Math.pow(im, 2.0))));
} else {
tmp = Math.exp(re) * 1.0;
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * math.sin(im) tmp = 0 if t_0 <= 0.0: tmp = math.exp(re) * (-0.16666666666666666 - 1.0) elif t_0 <= 4e-8: tmp = 1.0 * (im * (1.0 + (-0.16666666666666666 * math.pow(im, 2.0)))) else: tmp = math.exp(re) * 1.0 return tmp
function code(re, im) t_0 = Float64(exp(re) * sin(im)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(exp(re) * Float64(-0.16666666666666666 - 1.0)); elseif (t_0 <= 4e-8) tmp = Float64(1.0 * Float64(im * Float64(1.0 + Float64(-0.16666666666666666 * (im ^ 2.0))))); else tmp = Float64(exp(re) * 1.0); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * sin(im); tmp = 0.0; if (t_0 <= 0.0) tmp = exp(re) * (-0.16666666666666666 - 1.0); elseif (t_0 <= 4e-8) tmp = 1.0 * (im * (1.0 + (-0.16666666666666666 * (im ^ 2.0)))); else tmp = exp(re) * 1.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[Exp[re], $MachinePrecision] * N[(-0.16666666666666666 - 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e-8], N[(1.0 * N[(im * N[(1.0 + N[(-0.16666666666666666 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[re], $MachinePrecision] * 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \sin im\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;e^{re} \cdot \left(-0.16666666666666666 - 1\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{-8}:\\
\;\;\;\;1 \cdot \left(im \cdot \left(1 + -0.16666666666666666 \cdot {im}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot 1\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites60.6%
Applied rewrites40.5%
if 0.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < 4.0000000000000001e-8Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites60.6%
Taylor expanded in re around 0
Applied rewrites30.7%
if 4.0000000000000001e-8 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Applied rewrites40.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (sin im))))
(if (<= t_0 0.0)
(* (exp re) (- -0.16666666666666666 1.0))
(if (<= t_0 4e-8) (* 1.0 im) (* (exp re) 1.0)))))
double code(double re, double im) {
double t_0 = exp(re) * sin(im);
double tmp;
if (t_0 <= 0.0) {
tmp = exp(re) * (-0.16666666666666666 - 1.0);
} else if (t_0 <= 4e-8) {
tmp = 1.0 * im;
} else {
tmp = exp(re) * 1.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = exp(re) * sin(im)
if (t_0 <= 0.0d0) then
tmp = exp(re) * ((-0.16666666666666666d0) - 1.0d0)
else if (t_0 <= 4d-8) then
tmp = 1.0d0 * im
else
tmp = exp(re) * 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(re) * Math.sin(im);
double tmp;
if (t_0 <= 0.0) {
tmp = Math.exp(re) * (-0.16666666666666666 - 1.0);
} else if (t_0 <= 4e-8) {
tmp = 1.0 * im;
} else {
tmp = Math.exp(re) * 1.0;
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * math.sin(im) tmp = 0 if t_0 <= 0.0: tmp = math.exp(re) * (-0.16666666666666666 - 1.0) elif t_0 <= 4e-8: tmp = 1.0 * im else: tmp = math.exp(re) * 1.0 return tmp
function code(re, im) t_0 = Float64(exp(re) * sin(im)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(exp(re) * Float64(-0.16666666666666666 - 1.0)); elseif (t_0 <= 4e-8) tmp = Float64(1.0 * im); else tmp = Float64(exp(re) * 1.0); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * sin(im); tmp = 0.0; if (t_0 <= 0.0) tmp = exp(re) * (-0.16666666666666666 - 1.0); elseif (t_0 <= 4e-8) tmp = 1.0 * im; else tmp = exp(re) * 1.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[Exp[re], $MachinePrecision] * N[(-0.16666666666666666 - 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e-8], N[(1.0 * im), $MachinePrecision], N[(N[Exp[re], $MachinePrecision] * 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \sin im\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;e^{re} \cdot \left(-0.16666666666666666 - 1\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{-8}:\\
\;\;\;\;1 \cdot im\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot 1\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites60.6%
Applied rewrites40.5%
if 0.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < 4.0000000000000001e-8Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Taylor expanded in re around 0
Applied rewrites26.7%
if 4.0000000000000001e-8 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Applied rewrites40.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (sin im))))
(if (<= t_0 0.0)
(* (exp re) -0.16666666666666666)
(if (<= t_0 4e-8) (* 1.0 im) (* (exp re) 1.0)))))
double code(double re, double im) {
double t_0 = exp(re) * sin(im);
double tmp;
if (t_0 <= 0.0) {
tmp = exp(re) * -0.16666666666666666;
} else if (t_0 <= 4e-8) {
tmp = 1.0 * im;
} else {
tmp = exp(re) * 1.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = exp(re) * sin(im)
if (t_0 <= 0.0d0) then
tmp = exp(re) * (-0.16666666666666666d0)
else if (t_0 <= 4d-8) then
tmp = 1.0d0 * im
else
tmp = exp(re) * 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(re) * Math.sin(im);
double tmp;
if (t_0 <= 0.0) {
tmp = Math.exp(re) * -0.16666666666666666;
} else if (t_0 <= 4e-8) {
tmp = 1.0 * im;
} else {
tmp = Math.exp(re) * 1.0;
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * math.sin(im) tmp = 0 if t_0 <= 0.0: tmp = math.exp(re) * -0.16666666666666666 elif t_0 <= 4e-8: tmp = 1.0 * im else: tmp = math.exp(re) * 1.0 return tmp
function code(re, im) t_0 = Float64(exp(re) * sin(im)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(exp(re) * -0.16666666666666666); elseif (t_0 <= 4e-8) tmp = Float64(1.0 * im); else tmp = Float64(exp(re) * 1.0); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * sin(im); tmp = 0.0; if (t_0 <= 0.0) tmp = exp(re) * -0.16666666666666666; elseif (t_0 <= 4e-8) tmp = 1.0 * im; else tmp = exp(re) * 1.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[Exp[re], $MachinePrecision] * -0.16666666666666666), $MachinePrecision], If[LessEqual[t$95$0, 4e-8], N[(1.0 * im), $MachinePrecision], N[(N[Exp[re], $MachinePrecision] * 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \sin im\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;e^{re} \cdot -0.16666666666666666\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{-8}:\\
\;\;\;\;1 \cdot im\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot 1\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites60.6%
Applied rewrites39.7%
Applied rewrites40.2%
if 0.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < 4.0000000000000001e-8Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Taylor expanded in re around 0
Applied rewrites26.7%
if 4.0000000000000001e-8 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Applied rewrites40.4%
(FPCore (re im) :precision binary64 (if (<= (* (exp re) (sin im)) 0.0) (* (exp re) -0.16666666666666666) (* (+ 1.0 re) im)))
double code(double re, double im) {
double tmp;
if ((exp(re) * sin(im)) <= 0.0) {
tmp = exp(re) * -0.16666666666666666;
} else {
tmp = (1.0 + re) * im;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((exp(re) * sin(im)) <= 0.0d0) then
tmp = exp(re) * (-0.16666666666666666d0)
else
tmp = (1.0d0 + re) * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) * Math.sin(im)) <= 0.0) {
tmp = Math.exp(re) * -0.16666666666666666;
} else {
tmp = (1.0 + re) * im;
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) * math.sin(im)) <= 0.0: tmp = math.exp(re) * -0.16666666666666666 else: tmp = (1.0 + re) * im return tmp
function code(re, im) tmp = 0.0 if (Float64(exp(re) * sin(im)) <= 0.0) tmp = Float64(exp(re) * -0.16666666666666666); else tmp = Float64(Float64(1.0 + re) * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) * sin(im)) <= 0.0) tmp = exp(re) * -0.16666666666666666; else tmp = (1.0 + re) * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision], 0.0], N[(N[Exp[re], $MachinePrecision] * -0.16666666666666666), $MachinePrecision], N[(N[(1.0 + re), $MachinePrecision] * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \cdot \sin im \leq 0:\\
\;\;\;\;e^{re} \cdot -0.16666666666666666\\
\mathbf{else}:\\
\;\;\;\;\left(1 + re\right) \cdot im\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites60.6%
Applied rewrites39.7%
Applied rewrites40.2%
if 0.0 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Taylor expanded in re around 0
Applied rewrites30.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (sin im))))
(if (<= t_0 -0.02)
(* 1.0 (* im (* -0.16666666666666666 im)))
(if (<= t_0 0.0) (* 0.0 im) (* (+ 1.0 re) im)))))
double code(double re, double im) {
double t_0 = exp(re) * sin(im);
double tmp;
if (t_0 <= -0.02) {
tmp = 1.0 * (im * (-0.16666666666666666 * im));
} else if (t_0 <= 0.0) {
tmp = 0.0 * im;
} else {
tmp = (1.0 + re) * im;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = exp(re) * sin(im)
if (t_0 <= (-0.02d0)) then
tmp = 1.0d0 * (im * ((-0.16666666666666666d0) * im))
else if (t_0 <= 0.0d0) then
tmp = 0.0d0 * im
else
tmp = (1.0d0 + re) * im
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(re) * Math.sin(im);
double tmp;
if (t_0 <= -0.02) {
tmp = 1.0 * (im * (-0.16666666666666666 * im));
} else if (t_0 <= 0.0) {
tmp = 0.0 * im;
} else {
tmp = (1.0 + re) * im;
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * math.sin(im) tmp = 0 if t_0 <= -0.02: tmp = 1.0 * (im * (-0.16666666666666666 * im)) elif t_0 <= 0.0: tmp = 0.0 * im else: tmp = (1.0 + re) * im return tmp
function code(re, im) t_0 = Float64(exp(re) * sin(im)) tmp = 0.0 if (t_0 <= -0.02) tmp = Float64(1.0 * Float64(im * Float64(-0.16666666666666666 * im))); elseif (t_0 <= 0.0) tmp = Float64(0.0 * im); else tmp = Float64(Float64(1.0 + re) * im); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * sin(im); tmp = 0.0; if (t_0 <= -0.02) tmp = 1.0 * (im * (-0.16666666666666666 * im)); elseif (t_0 <= 0.0) tmp = 0.0 * im; else tmp = (1.0 + re) * im; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.02], N[(1.0 * N[(im * N[(-0.16666666666666666 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(0.0 * im), $MachinePrecision], N[(N[(1.0 + re), $MachinePrecision] * im), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \sin im\\
\mathbf{if}\;t\_0 \leq -0.02:\\
\;\;\;\;1 \cdot \left(im \cdot \left(-0.16666666666666666 \cdot im\right)\right)\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;0 \cdot im\\
\mathbf{else}:\\
\;\;\;\;\left(1 + re\right) \cdot im\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0200000000000000004Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites60.6%
Taylor expanded in re around 0
Applied rewrites30.7%
Applied rewrites11.9%
if -0.0200000000000000004 < (*.f64 (exp.f64 re) (sin.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Taylor expanded in re around 0
Applied rewrites26.7%
Applied rewrites27.0%
if 0.0 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Taylor expanded in re around 0
Applied rewrites30.0%
(FPCore (re im) :precision binary64 (if (<= (* (exp re) (sin im)) 0.0) (* 0.0 im) (* (+ 1.0 re) im)))
double code(double re, double im) {
double tmp;
if ((exp(re) * sin(im)) <= 0.0) {
tmp = 0.0 * im;
} else {
tmp = (1.0 + re) * im;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((exp(re) * sin(im)) <= 0.0d0) then
tmp = 0.0d0 * im
else
tmp = (1.0d0 + re) * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) * Math.sin(im)) <= 0.0) {
tmp = 0.0 * im;
} else {
tmp = (1.0 + re) * im;
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) * math.sin(im)) <= 0.0: tmp = 0.0 * im else: tmp = (1.0 + re) * im return tmp
function code(re, im) tmp = 0.0 if (Float64(exp(re) * sin(im)) <= 0.0) tmp = Float64(0.0 * im); else tmp = Float64(Float64(1.0 + re) * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) * sin(im)) <= 0.0) tmp = 0.0 * im; else tmp = (1.0 + re) * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision], 0.0], N[(0.0 * im), $MachinePrecision], N[(N[(1.0 + re), $MachinePrecision] * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \cdot \sin im \leq 0:\\
\;\;\;\;0 \cdot im\\
\mathbf{else}:\\
\;\;\;\;\left(1 + re\right) \cdot im\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Taylor expanded in re around 0
Applied rewrites26.7%
Applied rewrites27.0%
if 0.0 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Taylor expanded in re around 0
Applied rewrites30.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (sin im))))
(if (<= t_0 0.0)
(* 0.0 im)
(if (<= t_0 4e-8) (* 1.0 im) (* (+ 1.0 re) 1.0)))))
double code(double re, double im) {
double t_0 = exp(re) * sin(im);
double tmp;
if (t_0 <= 0.0) {
tmp = 0.0 * im;
} else if (t_0 <= 4e-8) {
tmp = 1.0 * im;
} else {
tmp = (1.0 + re) * 1.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = exp(re) * sin(im)
if (t_0 <= 0.0d0) then
tmp = 0.0d0 * im
else if (t_0 <= 4d-8) then
tmp = 1.0d0 * im
else
tmp = (1.0d0 + re) * 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(re) * Math.sin(im);
double tmp;
if (t_0 <= 0.0) {
tmp = 0.0 * im;
} else if (t_0 <= 4e-8) {
tmp = 1.0 * im;
} else {
tmp = (1.0 + re) * 1.0;
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * math.sin(im) tmp = 0 if t_0 <= 0.0: tmp = 0.0 * im elif t_0 <= 4e-8: tmp = 1.0 * im else: tmp = (1.0 + re) * 1.0 return tmp
function code(re, im) t_0 = Float64(exp(re) * sin(im)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(0.0 * im); elseif (t_0 <= 4e-8) tmp = Float64(1.0 * im); else tmp = Float64(Float64(1.0 + re) * 1.0); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * sin(im); tmp = 0.0; if (t_0 <= 0.0) tmp = 0.0 * im; elseif (t_0 <= 4e-8) tmp = 1.0 * im; else tmp = (1.0 + re) * 1.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(0.0 * im), $MachinePrecision], If[LessEqual[t$95$0, 4e-8], N[(1.0 * im), $MachinePrecision], N[(N[(1.0 + re), $MachinePrecision] * 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \sin im\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;0 \cdot im\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{-8}:\\
\;\;\;\;1 \cdot im\\
\mathbf{else}:\\
\;\;\;\;\left(1 + re\right) \cdot 1\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Taylor expanded in re around 0
Applied rewrites26.7%
Applied rewrites27.0%
if 0.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < 4.0000000000000001e-8Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Taylor expanded in re around 0
Applied rewrites26.7%
if 4.0000000000000001e-8 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Applied rewrites40.4%
Taylor expanded in re around 0
Applied rewrites5.2%
(FPCore (re im) :precision binary64 (if (<= (* (exp re) (sin im)) 0.0) (* 0.0 im) (* 1.0 im)))
double code(double re, double im) {
double tmp;
if ((exp(re) * sin(im)) <= 0.0) {
tmp = 0.0 * im;
} else {
tmp = 1.0 * im;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((exp(re) * sin(im)) <= 0.0d0) then
tmp = 0.0d0 * im
else
tmp = 1.0d0 * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) * Math.sin(im)) <= 0.0) {
tmp = 0.0 * im;
} else {
tmp = 1.0 * im;
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) * math.sin(im)) <= 0.0: tmp = 0.0 * im else: tmp = 1.0 * im return tmp
function code(re, im) tmp = 0.0 if (Float64(exp(re) * sin(im)) <= 0.0) tmp = Float64(0.0 * im); else tmp = Float64(1.0 * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) * sin(im)) <= 0.0) tmp = 0.0 * im; else tmp = 1.0 * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision], 0.0], N[(0.0 * im), $MachinePrecision], N[(1.0 * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \cdot \sin im \leq 0:\\
\;\;\;\;0 \cdot im\\
\mathbf{else}:\\
\;\;\;\;1 \cdot im\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (sin.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Taylor expanded in re around 0
Applied rewrites26.7%
Applied rewrites27.0%
if 0.0 < (*.f64 (exp.f64 re) (sin.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Taylor expanded in re around 0
Applied rewrites26.7%
(FPCore (re im) :precision binary64 (* 0.0 im))
double code(double re, double im) {
return 0.0 * im;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.0d0 * im
end function
public static double code(double re, double im) {
return 0.0 * im;
}
def code(re, im): return 0.0 * im
function code(re, im) return Float64(0.0 * im) end
function tmp = code(re, im) tmp = 0.0 * im; end
code[re_, im_] := N[(0.0 * im), $MachinePrecision]
\begin{array}{l}
\\
0 \cdot im
\end{array}
Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites68.4%
Taylor expanded in re around 0
Applied rewrites26.7%
Applied rewrites27.0%
herbie shell --seed 2025159
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))