
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
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(kx, ky, th)
use fmin_fmax_functions
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
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(kx, ky, th)
use fmin_fmax_functions
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (hypot (sin kx) (sin ky))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / hypot(sin(kx), sin(ky))) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / hypot(sin(kx), sin(ky))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / hypot(sin(kx), sin(ky))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin th
\end{array}
Initial program 95.2%
Taylor expanded in kx around inf
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
(FPCore (kx ky th) :precision binary64 (* (* (pow (hypot (sin kx) (sin ky)) -1.0) (sin ky)) (sin th)))
double code(double kx, double ky, double th) {
return (pow(hypot(sin(kx), sin(ky)), -1.0) * sin(ky)) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (Math.pow(Math.hypot(Math.sin(kx), Math.sin(ky)), -1.0) * Math.sin(ky)) * Math.sin(th);
}
def code(kx, ky, th): return (math.pow(math.hypot(math.sin(kx), math.sin(ky)), -1.0) * math.sin(ky)) * math.sin(th)
function code(kx, ky, th) return Float64(Float64((hypot(sin(kx), sin(ky)) ^ -1.0) * sin(ky)) * sin(th)) end
function tmp = code(kx, ky, th) tmp = ((hypot(sin(kx), sin(ky)) ^ -1.0) * sin(ky)) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Power[N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision], -1.0], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \sin ky\right) \cdot \sin th
\end{array}
Initial program 95.2%
Taylor expanded in kx around inf
*-commutativeN/A
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
inv-powN/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
(FPCore (kx ky th) :precision binary64 (let* ((t_1 (* (log (hypot (pow (sin ky) 1.0) (pow (sin kx) 1.0))) -1.0))) (* (* (+ (cosh t_1) (sinh t_1)) (sin ky)) (sin th))))
double code(double kx, double ky, double th) {
double t_1 = log(hypot(pow(sin(ky), 1.0), pow(sin(kx), 1.0))) * -1.0;
return ((cosh(t_1) + sinh(t_1)) * sin(ky)) * sin(th);
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.log(Math.hypot(Math.pow(Math.sin(ky), 1.0), Math.pow(Math.sin(kx), 1.0))) * -1.0;
return ((Math.cosh(t_1) + Math.sinh(t_1)) * Math.sin(ky)) * Math.sin(th);
}
def code(kx, ky, th): t_1 = math.log(math.hypot(math.pow(math.sin(ky), 1.0), math.pow(math.sin(kx), 1.0))) * -1.0 return ((math.cosh(t_1) + math.sinh(t_1)) * math.sin(ky)) * math.sin(th)
function code(kx, ky, th) t_1 = Float64(log(hypot((sin(ky) ^ 1.0), (sin(kx) ^ 1.0))) * -1.0) return Float64(Float64(Float64(cosh(t_1) + sinh(t_1)) * sin(ky)) * sin(th)) end
function tmp = code(kx, ky, th) t_1 = log(hypot((sin(ky) ^ 1.0), (sin(kx) ^ 1.0))) * -1.0; tmp = ((cosh(t_1) + sinh(t_1)) * sin(ky)) * sin(th); end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Log[N[Sqrt[N[Power[N[Sin[ky], $MachinePrecision], 1.0], $MachinePrecision] ^ 2 + N[Power[N[Sin[kx], $MachinePrecision], 1.0], $MachinePrecision] ^ 2], $MachinePrecision]], $MachinePrecision] * -1.0), $MachinePrecision]}, N[(N[(N[(N[Cosh[t$95$1], $MachinePrecision] + N[Sinh[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right) \cdot -1\\
\left(\left(\cosh t\_1 + \sinh t\_1\right) \cdot \sin ky\right) \cdot \sin th
\end{array}
\end{array}
Initial program 95.2%
Taylor expanded in kx around inf
*-commutativeN/A
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
inv-powN/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-hypot.f64N/A
pow-to-expN/A
sinh-+-cosh-revN/A
lower-+.f64N/A
Applied rewrites97.9%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (pow (sin ky) 1.0)) (t_2 (pow (sin kx) 2.0)))
(if (<= (/ (sin ky) (sqrt (+ t_2 (pow (sin ky) 2.0)))) 1.0)
(* (* (pow (fma t_1 t_1 t_2) -0.5) (sin th)) (sin ky))
(* (pow (hypot (sin kx) (sin ky)) -1.0) (* (sin th) (sin ky))))))
double code(double kx, double ky, double th) {
double t_1 = pow(sin(ky), 1.0);
double t_2 = pow(sin(kx), 2.0);
double tmp;
if ((sin(ky) / sqrt((t_2 + pow(sin(ky), 2.0)))) <= 1.0) {
tmp = (pow(fma(t_1, t_1, t_2), -0.5) * sin(th)) * sin(ky);
} else {
tmp = pow(hypot(sin(kx), sin(ky)), -1.0) * (sin(th) * sin(ky));
}
return tmp;
}
function code(kx, ky, th) t_1 = sin(ky) ^ 1.0 t_2 = sin(kx) ^ 2.0 tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64(t_2 + (sin(ky) ^ 2.0)))) <= 1.0) tmp = Float64(Float64((fma(t_1, t_1, t_2) ^ -0.5) * sin(th)) * sin(ky)); else tmp = Float64((hypot(sin(kx), sin(ky)) ^ -1.0) * Float64(sin(th) * sin(ky))); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sin[ky], $MachinePrecision], 1.0], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(t$95$2 + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1.0], N[(N[(N[Power[N[(t$95$1 * t$95$1 + t$95$2), $MachinePrecision], -0.5], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision], -1.0], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\sin ky}^{1}\\
t_2 := {\sin kx}^{2}\\
\mathbf{if}\;\frac{\sin ky}{\sqrt{t\_2 + {\sin ky}^{2}}} \leq 1:\\
\;\;\;\;\left({\left(\mathsf{fma}\left(t\_1, t\_1, t\_2\right)\right)}^{-0.5} \cdot \sin th\right) \cdot \sin ky\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin ky\right)\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 1Initial program 97.1%
Taylor expanded in kx around inf
*-commutativeN/A
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
inv-powN/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6495.6
Applied rewrites95.6%
Applied rewrites96.8%
if 1 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 3.0%
Taylor expanded in kx around inf
*-commutativeN/A
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
inv-powN/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.1
Applied rewrites99.1%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (pow (sin kx) 0.5))
(t_2 (pow (sin ky) 1.0))
(t_3 (pow (sin kx) 2.0)))
(if (<= (/ (sin ky) (sqrt (+ t_3 (pow (sin ky) 2.0)))) 1.0)
(* (* (pow (fma t_2 t_2 t_3) -0.5) (sin th)) (sin ky))
(*
(*
(pow (hypot t_2 (pow (sin kx) 1.0)) -0.5)
(pow (hypot t_2 (* t_1 t_1)) -0.5))
(* (sin th) (sin ky))))))
double code(double kx, double ky, double th) {
double t_1 = pow(sin(kx), 0.5);
double t_2 = pow(sin(ky), 1.0);
double t_3 = pow(sin(kx), 2.0);
double tmp;
if ((sin(ky) / sqrt((t_3 + pow(sin(ky), 2.0)))) <= 1.0) {
tmp = (pow(fma(t_2, t_2, t_3), -0.5) * sin(th)) * sin(ky);
} else {
tmp = (pow(hypot(t_2, pow(sin(kx), 1.0)), -0.5) * pow(hypot(t_2, (t_1 * t_1)), -0.5)) * (sin(th) * sin(ky));
}
return tmp;
}
function code(kx, ky, th) t_1 = sin(kx) ^ 0.5 t_2 = sin(ky) ^ 1.0 t_3 = sin(kx) ^ 2.0 tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64(t_3 + (sin(ky) ^ 2.0)))) <= 1.0) tmp = Float64(Float64((fma(t_2, t_2, t_3) ^ -0.5) * sin(th)) * sin(ky)); else tmp = Float64(Float64((hypot(t_2, (sin(kx) ^ 1.0)) ^ -0.5) * (hypot(t_2, Float64(t_1 * t_1)) ^ -0.5)) * Float64(sin(th) * sin(ky))); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sin[kx], $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[ky], $MachinePrecision], 1.0], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(t$95$3 + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1.0], N[(N[(N[Power[N[(t$95$2 * t$95$2 + t$95$3), $MachinePrecision], -0.5], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[Sqrt[t$95$2 ^ 2 + N[Power[N[Sin[kx], $MachinePrecision], 1.0], $MachinePrecision] ^ 2], $MachinePrecision], -0.5], $MachinePrecision] * N[Power[N[Sqrt[t$95$2 ^ 2 + N[(t$95$1 * t$95$1), $MachinePrecision] ^ 2], $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\sin kx}^{0.5}\\
t_2 := {\sin ky}^{1}\\
t_3 := {\sin kx}^{2}\\
\mathbf{if}\;\frac{\sin ky}{\sqrt{t\_3 + {\sin ky}^{2}}} \leq 1:\\
\;\;\;\;\left({\left(\mathsf{fma}\left(t\_2, t\_2, t\_3\right)\right)}^{-0.5} \cdot \sin th\right) \cdot \sin ky\\
\mathbf{else}:\\
\;\;\;\;\left({\left(\mathsf{hypot}\left(t\_2, {\sin kx}^{1}\right)\right)}^{-0.5} \cdot {\left(\mathsf{hypot}\left(t\_2, t\_1 \cdot t\_1\right)\right)}^{-0.5}\right) \cdot \left(\sin th \cdot \sin ky\right)\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 1Initial program 97.1%
Taylor expanded in kx around inf
*-commutativeN/A
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
inv-powN/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6495.6
Applied rewrites95.6%
Applied rewrites96.8%
if 1 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 3.0%
Taylor expanded in kx around inf
*-commutativeN/A
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
inv-powN/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.1
Applied rewrites99.1%
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-hypot.f64N/A
sqr-powN/A
lower-*.f64N/A
Applied rewrites98.4%
lift-pow.f64N/A
lift-sin.f64N/A
sqr-powN/A
lower-*.f64N/A
metadata-evalN/A
lower-pow.f64N/A
lift-sin.f64N/A
metadata-evalN/A
lower-pow.f64N/A
lift-sin.f6478.8
Applied rewrites78.8%
(FPCore (kx ky th) :precision binary64 (let* ((t_1 (pow (hypot (pow (sin ky) 1.0) (pow (sin kx) 1.0)) -0.5))) (* (* t_1 t_1) (* (sin th) (sin ky)))))
double code(double kx, double ky, double th) {
double t_1 = pow(hypot(pow(sin(ky), 1.0), pow(sin(kx), 1.0)), -0.5);
return (t_1 * t_1) * (sin(th) * sin(ky));
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.pow(Math.hypot(Math.pow(Math.sin(ky), 1.0), Math.pow(Math.sin(kx), 1.0)), -0.5);
return (t_1 * t_1) * (Math.sin(th) * Math.sin(ky));
}
def code(kx, ky, th): t_1 = math.pow(math.hypot(math.pow(math.sin(ky), 1.0), math.pow(math.sin(kx), 1.0)), -0.5) return (t_1 * t_1) * (math.sin(th) * math.sin(ky))
function code(kx, ky, th) t_1 = hypot((sin(ky) ^ 1.0), (sin(kx) ^ 1.0)) ^ -0.5 return Float64(Float64(t_1 * t_1) * Float64(sin(th) * sin(ky))) end
function tmp = code(kx, ky, th) t_1 = hypot((sin(ky) ^ 1.0), (sin(kx) ^ 1.0)) ^ -0.5; tmp = (t_1 * t_1) * (sin(th) * sin(ky)); end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sqrt[N[Power[N[Sin[ky], $MachinePrecision], 1.0], $MachinePrecision] ^ 2 + N[Power[N[Sin[kx], $MachinePrecision], 1.0], $MachinePrecision] ^ 2], $MachinePrecision], -0.5], $MachinePrecision]}, N[(N[(t$95$1 * t$95$1), $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{-0.5}\\
\left(t\_1 \cdot t\_1\right) \cdot \left(\sin th \cdot \sin ky\right)
\end{array}
\end{array}
Initial program 95.2%
Taylor expanded in kx around inf
*-commutativeN/A
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
inv-powN/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6495.6
Applied rewrites95.6%
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-hypot.f64N/A
sqr-powN/A
lower-*.f64N/A
Applied rewrites95.2%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (pow (sin kx) 0.5)) (t_2 (pow (sin ky) 1.0)))
(*
(*
(pow (hypot t_2 (pow (sin kx) 1.0)) -0.5)
(pow (hypot t_2 (* t_1 t_1)) -0.5))
(* (sin th) (sin ky)))))
double code(double kx, double ky, double th) {
double t_1 = pow(sin(kx), 0.5);
double t_2 = pow(sin(ky), 1.0);
return (pow(hypot(t_2, pow(sin(kx), 1.0)), -0.5) * pow(hypot(t_2, (t_1 * t_1)), -0.5)) * (sin(th) * sin(ky));
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.pow(Math.sin(kx), 0.5);
double t_2 = Math.pow(Math.sin(ky), 1.0);
return (Math.pow(Math.hypot(t_2, Math.pow(Math.sin(kx), 1.0)), -0.5) * Math.pow(Math.hypot(t_2, (t_1 * t_1)), -0.5)) * (Math.sin(th) * Math.sin(ky));
}
def code(kx, ky, th): t_1 = math.pow(math.sin(kx), 0.5) t_2 = math.pow(math.sin(ky), 1.0) return (math.pow(math.hypot(t_2, math.pow(math.sin(kx), 1.0)), -0.5) * math.pow(math.hypot(t_2, (t_1 * t_1)), -0.5)) * (math.sin(th) * math.sin(ky))
function code(kx, ky, th) t_1 = sin(kx) ^ 0.5 t_2 = sin(ky) ^ 1.0 return Float64(Float64((hypot(t_2, (sin(kx) ^ 1.0)) ^ -0.5) * (hypot(t_2, Float64(t_1 * t_1)) ^ -0.5)) * Float64(sin(th) * sin(ky))) end
function tmp = code(kx, ky, th) t_1 = sin(kx) ^ 0.5; t_2 = sin(ky) ^ 1.0; tmp = ((hypot(t_2, (sin(kx) ^ 1.0)) ^ -0.5) * (hypot(t_2, (t_1 * t_1)) ^ -0.5)) * (sin(th) * sin(ky)); end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sin[kx], $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[ky], $MachinePrecision], 1.0], $MachinePrecision]}, N[(N[(N[Power[N[Sqrt[t$95$2 ^ 2 + N[Power[N[Sin[kx], $MachinePrecision], 1.0], $MachinePrecision] ^ 2], $MachinePrecision], -0.5], $MachinePrecision] * N[Power[N[Sqrt[t$95$2 ^ 2 + N[(t$95$1 * t$95$1), $MachinePrecision] ^ 2], $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\sin kx}^{0.5}\\
t_2 := {\sin ky}^{1}\\
\left({\left(\mathsf{hypot}\left(t\_2, {\sin kx}^{1}\right)\right)}^{-0.5} \cdot {\left(\mathsf{hypot}\left(t\_2, t\_1 \cdot t\_1\right)\right)}^{-0.5}\right) \cdot \left(\sin th \cdot \sin ky\right)
\end{array}
\end{array}
Initial program 95.2%
Taylor expanded in kx around inf
*-commutativeN/A
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
inv-powN/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6495.6
Applied rewrites95.6%
lift-pow.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-hypot.f64N/A
sqr-powN/A
lower-*.f64N/A
Applied rewrites95.2%
lift-pow.f64N/A
lift-sin.f64N/A
sqr-powN/A
lower-*.f64N/A
metadata-evalN/A
lower-pow.f64N/A
lift-sin.f64N/A
metadata-evalN/A
lower-pow.f64N/A
lift-sin.f6450.1
Applied rewrites50.1%
herbie shell --seed 2025065
(FPCore (kx ky th)
:name "Toniolo and Linder, Equation (3b), real"
:precision binary64
(* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))