
(FPCore (re im) :precision binary64 (/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))
double code(double re, double im) {
return log(sqrt(((re * re) + (im * im)))) / log(10.0);
}
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 = log(sqrt(((re * re) + (im * im)))) / log(10.0d0)
end function
public static double code(double re, double im) {
return Math.log(Math.sqrt(((re * re) + (im * im)))) / Math.log(10.0);
}
def code(re, im): return math.log(math.sqrt(((re * re) + (im * im)))) / math.log(10.0)
function code(re, im) return Float64(log(sqrt(Float64(Float64(re * re) + Float64(im * im)))) / log(10.0)) end
function tmp = code(re, im) tmp = log(sqrt(((re * re) + (im * im)))) / log(10.0); end
code[re_, im_] := N[(N[Log[N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / N[Log[10.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))
double code(double re, double im) {
return log(sqrt(((re * re) + (im * im)))) / log(10.0);
}
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 = log(sqrt(((re * re) + (im * im)))) / log(10.0d0)
end function
public static double code(double re, double im) {
return Math.log(Math.sqrt(((re * re) + (im * im)))) / Math.log(10.0);
}
def code(re, im): return math.log(math.sqrt(((re * re) + (im * im)))) / math.log(10.0)
function code(re, im) return Float64(log(sqrt(Float64(Float64(re * re) + Float64(im * im)))) / log(10.0)) end
function tmp = code(re, im) tmp = log(sqrt(((re * re) + (im * im)))) / log(10.0); end
code[re_, im_] := N[(N[Log[N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / N[Log[10.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\end{array}
(FPCore (re im) :precision binary64 (let* ((t_0 (log (hypot im re))) (t_1 (* (log 0.1) t_0))) (/ (fma 0.0 (log 10.0) (* t_1 t_0)) (* t_1 (- (log 0.1))))))
double code(double re, double im) {
double t_0 = log(hypot(im, re));
double t_1 = log(0.1) * t_0;
return fma(0.0, log(10.0), (t_1 * t_0)) / (t_1 * -log(0.1));
}
function code(re, im) t_0 = log(hypot(im, re)) t_1 = Float64(log(0.1) * t_0) return Float64(fma(0.0, log(10.0), Float64(t_1 * t_0)) / Float64(t_1 * Float64(-log(0.1)))) end
code[re_, im_] := Block[{t$95$0 = N[Log[N[Sqrt[im ^ 2 + re ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[0.1], $MachinePrecision] * t$95$0), $MachinePrecision]}, N[(N[(0.0 * N[Log[10.0], $MachinePrecision] + N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 * (-N[Log[0.1], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(im, re\right)\right)\\
t_1 := \log 0.1 \cdot t\_0\\
\frac{\mathsf{fma}\left(0, \log 10, t\_1 \cdot t\_0\right)}{t\_1 \cdot \left(-\log 0.1\right)}
\end{array}
\end{array}
Initial program 51.7%
Applied rewrites99.1%
lift-neg.f64N/A
lift-log.f64N/A
neg-logN/A
lift-hypot.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
pow1/2N/A
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow1/2N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-hypot.f64N/A
log-divN/A
metadata-evalN/A
lift-log.f64N/A
flip--N/A
lower-/.f64N/A
Applied rewrites99.1%
Applied rewrites99.0%
lift-log.f64N/A
metadata-evalN/A
neg-logN/A
lift-log.f64N/A
lower-neg.f6499.1
Applied rewrites99.1%
(FPCore (re im) :precision binary64 (/ (log (hypot im re)) (- (log 0.1))))
double code(double re, double im) {
return log(hypot(im, re)) / -log(0.1);
}
public static double code(double re, double im) {
return Math.log(Math.hypot(im, re)) / -Math.log(0.1);
}
def code(re, im): return math.log(math.hypot(im, re)) / -math.log(0.1)
function code(re, im) return Float64(log(hypot(im, re)) / Float64(-log(0.1))) end
function tmp = code(re, im) tmp = log(hypot(im, re)) / -log(0.1); end
code[re_, im_] := N[(N[Log[N[Sqrt[im ^ 2 + re ^ 2], $MachinePrecision]], $MachinePrecision] / (-N[Log[0.1], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
\frac{\log \left(\mathsf{hypot}\left(im, re\right)\right)}{-\log 0.1}
\end{array}
Initial program 51.7%
Applied rewrites99.1%
Final simplification99.1%
(FPCore (re im) :precision binary64 (/ (log (hypot re im)) (log 10.0)))
double code(double re, double im) {
return log(hypot(re, im)) / log(10.0);
}
public static double code(double re, double im) {
return Math.log(Math.hypot(re, im)) / Math.log(10.0);
}
def code(re, im): return math.log(math.hypot(re, im)) / math.log(10.0)
function code(re, im) return Float64(log(hypot(re, im)) / log(10.0)) end
function tmp = code(re, im) tmp = log(hypot(re, im)) / log(10.0); end
code[re_, im_] := N[(N[Log[N[Sqrt[re ^ 2 + im ^ 2], $MachinePrecision]], $MachinePrecision] / N[Log[10.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}
\end{array}
Initial program 51.7%
Applied rewrites99.0%
(FPCore (re im) :precision binary64 (/ (fma (/ (* 0.5 re) im) (/ re im) (log im)) (- (log 0.1))))
double code(double re, double im) {
return fma(((0.5 * re) / im), (re / im), log(im)) / -log(0.1);
}
function code(re, im) return Float64(fma(Float64(Float64(0.5 * re) / im), Float64(re / im), log(im)) / Float64(-log(0.1))) end
code[re_, im_] := N[(N[(N[(N[(0.5 * re), $MachinePrecision] / im), $MachinePrecision] * N[(re / im), $MachinePrecision] + N[Log[im], $MachinePrecision]), $MachinePrecision] / (-N[Log[0.1], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\frac{0.5 \cdot re}{im}, \frac{re}{im}, \log im\right)}{-\log 0.1}
\end{array}
Initial program 51.7%
Applied rewrites99.1%
Taylor expanded in re around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
associate-*r/N/A
unpow2N/A
associate-*r*N/A
unpow2N/A
times-fracN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
Applied rewrites22.0%
Final simplification22.0%
(FPCore (re im) :precision binary64 (/ (fma (/ (* 0.5 re) im) (/ re im) (log im)) (log 10.0)))
double code(double re, double im) {
return fma(((0.5 * re) / im), (re / im), log(im)) / log(10.0);
}
function code(re, im) return Float64(fma(Float64(Float64(0.5 * re) / im), Float64(re / im), log(im)) / log(10.0)) end
code[re_, im_] := N[(N[(N[(N[(0.5 * re), $MachinePrecision] / im), $MachinePrecision] * N[(re / im), $MachinePrecision] + N[Log[im], $MachinePrecision]), $MachinePrecision] / N[Log[10.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\frac{0.5 \cdot re}{im}, \frac{re}{im}, \log im\right)}{\log 10}
\end{array}
Initial program 51.7%
Taylor expanded in re around 0
lower-log.f6423.5
Applied rewrites23.5%
Taylor expanded in re around 0
+-commutativeN/A
associate-/r*N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
Applied rewrites21.9%
(FPCore (re im) :precision binary64 (/ (log im) (- (log 0.1))))
double code(double re, double im) {
return log(im) / -log(0.1);
}
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 = log(im) / -log(0.1d0)
end function
public static double code(double re, double im) {
return Math.log(im) / -Math.log(0.1);
}
def code(re, im): return math.log(im) / -math.log(0.1)
function code(re, im) return Float64(log(im) / Float64(-log(0.1))) end
function tmp = code(re, im) tmp = log(im) / -log(0.1); end
code[re_, im_] := N[(N[Log[im], $MachinePrecision] / (-N[Log[0.1], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
\frac{\log im}{-\log 0.1}
\end{array}
Initial program 51.7%
Taylor expanded in re around 0
lower-log.f6423.5
Applied rewrites23.5%
lift-/.f64N/A
frac-2neg-revN/A
lift-log.f64N/A
neg-logN/A
metadata-evalN/A
lift-log.f64N/A
lower-/.f64N/A
lower-neg.f6423.5
Applied rewrites23.5%
Final simplification23.5%
(FPCore (re im) :precision binary64 (/ (log im) (log 10.0)))
double code(double re, double im) {
return log(im) / log(10.0);
}
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 = log(im) / log(10.0d0)
end function
public static double code(double re, double im) {
return Math.log(im) / Math.log(10.0);
}
def code(re, im): return math.log(im) / math.log(10.0)
function code(re, im) return Float64(log(im) / log(10.0)) end
function tmp = code(re, im) tmp = log(im) / log(10.0); end
code[re_, im_] := N[(N[Log[im], $MachinePrecision] / N[Log[10.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\log im}{\log 10}
\end{array}
Initial program 51.7%
Taylor expanded in re around 0
lower-log.f6423.5
Applied rewrites23.5%
(FPCore (re im) :precision binary64 (/ (* (/ 0.5 im) (* (/ re im) re)) (- (log 0.1))))
double code(double re, double im) {
return ((0.5 / im) * ((re / im) * re)) / -log(0.1);
}
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.5d0 / im) * ((re / im) * re)) / -log(0.1d0)
end function
public static double code(double re, double im) {
return ((0.5 / im) * ((re / im) * re)) / -Math.log(0.1);
}
def code(re, im): return ((0.5 / im) * ((re / im) * re)) / -math.log(0.1)
function code(re, im) return Float64(Float64(Float64(0.5 / im) * Float64(Float64(re / im) * re)) / Float64(-log(0.1))) end
function tmp = code(re, im) tmp = ((0.5 / im) * ((re / im) * re)) / -log(0.1); end
code[re_, im_] := N[(N[(N[(0.5 / im), $MachinePrecision] * N[(N[(re / im), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision] / (-N[Log[0.1], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{0.5}{im} \cdot \left(\frac{re}{im} \cdot re\right)}{-\log 0.1}
\end{array}
Initial program 51.7%
Applied rewrites99.1%
Taylor expanded in re around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
associate-*r/N/A
unpow2N/A
associate-*r*N/A
unpow2N/A
times-fracN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
Applied rewrites22.0%
Taylor expanded in re around inf
Applied rewrites3.3%
Applied rewrites3.5%
Final simplification3.5%
(FPCore (re im) :precision binary64 (/ (* re (* (/ re im) (/ 0.5 im))) (- (log 0.1))))
double code(double re, double im) {
return (re * ((re / im) * (0.5 / im))) / -log(0.1);
}
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 = (re * ((re / im) * (0.5d0 / im))) / -log(0.1d0)
end function
public static double code(double re, double im) {
return (re * ((re / im) * (0.5 / im))) / -Math.log(0.1);
}
def code(re, im): return (re * ((re / im) * (0.5 / im))) / -math.log(0.1)
function code(re, im) return Float64(Float64(re * Float64(Float64(re / im) * Float64(0.5 / im))) / Float64(-log(0.1))) end
function tmp = code(re, im) tmp = (re * ((re / im) * (0.5 / im))) / -log(0.1); end
code[re_, im_] := N[(N[(re * N[(N[(re / im), $MachinePrecision] * N[(0.5 / im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-N[Log[0.1], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
\frac{re \cdot \left(\frac{re}{im} \cdot \frac{0.5}{im}\right)}{-\log 0.1}
\end{array}
Initial program 51.7%
Applied rewrites99.1%
Taylor expanded in re around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
associate-*r/N/A
unpow2N/A
associate-*r*N/A
unpow2N/A
times-fracN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
Applied rewrites22.0%
Taylor expanded in re around inf
Applied rewrites3.3%
Applied rewrites3.5%
Final simplification3.5%
(FPCore (re im) :precision binary64 (/ (* (* 0.5 re) (/ re (* im im))) (- (log 0.1))))
double code(double re, double im) {
return ((0.5 * re) * (re / (im * im))) / -log(0.1);
}
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.5d0 * re) * (re / (im * im))) / -log(0.1d0)
end function
public static double code(double re, double im) {
return ((0.5 * re) * (re / (im * im))) / -Math.log(0.1);
}
def code(re, im): return ((0.5 * re) * (re / (im * im))) / -math.log(0.1)
function code(re, im) return Float64(Float64(Float64(0.5 * re) * Float64(re / Float64(im * im))) / Float64(-log(0.1))) end
function tmp = code(re, im) tmp = ((0.5 * re) * (re / (im * im))) / -log(0.1); end
code[re_, im_] := N[(N[(N[(0.5 * re), $MachinePrecision] * N[(re / N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-N[Log[0.1], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(0.5 \cdot re\right) \cdot \frac{re}{im \cdot im}}{-\log 0.1}
\end{array}
Initial program 51.7%
Applied rewrites99.1%
Taylor expanded in re around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
associate-*r/N/A
unpow2N/A
associate-*r*N/A
unpow2N/A
times-fracN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
Applied rewrites22.0%
Taylor expanded in re around inf
Applied rewrites3.3%
Applied rewrites3.1%
Final simplification3.1%
(FPCore (re im) :precision binary64 (/ (* 0.5 (/ (* re re) (* im im))) (- (log 0.1))))
double code(double re, double im) {
return (0.5 * ((re * re) / (im * im))) / -log(0.1);
}
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.5d0 * ((re * re) / (im * im))) / -log(0.1d0)
end function
public static double code(double re, double im) {
return (0.5 * ((re * re) / (im * im))) / -Math.log(0.1);
}
def code(re, im): return (0.5 * ((re * re) / (im * im))) / -math.log(0.1)
function code(re, im) return Float64(Float64(0.5 * Float64(Float64(re * re) / Float64(im * im))) / Float64(-log(0.1))) end
function tmp = code(re, im) tmp = (0.5 * ((re * re) / (im * im))) / -log(0.1); end
code[re_, im_] := N[(N[(0.5 * N[(N[(re * re), $MachinePrecision] / N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-N[Log[0.1], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5 \cdot \frac{re \cdot re}{im \cdot im}}{-\log 0.1}
\end{array}
Initial program 51.7%
Applied rewrites99.1%
Taylor expanded in re around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
associate-*r/N/A
unpow2N/A
associate-*r*N/A
unpow2N/A
times-fracN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
Applied rewrites22.0%
Taylor expanded in re around inf
Applied rewrites3.3%
Applied rewrites2.8%
Final simplification2.8%
herbie shell --seed 2024346
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))