Average Error: 3.9 → 0.2
Time: 31.5s
Precision: binary64
Cost: 32384
\[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
\[\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th \]
(FPCore (kx ky th)
 :precision binary64
 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
(FPCore (kx ky th)
 :precision binary64
 (* (/ (sin ky) (hypot (sin ky) (sin kx))) (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);
}
double code(double kx, double ky, double th) {
	return (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th);
}
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);
}
public static double code(double kx, double ky, double th) {
	return (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * 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)
def code(kx, ky, th):
	return (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * 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 code(kx, ky, th)
	return Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * sin(th))
end
function tmp = code(kx, ky, th)
	tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th);
end
function tmp = code(kx, ky, th)
	tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * 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]
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 3.9

    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  2. Taylor expanded in kx around inf 3.9

    \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
  3. Simplified0.2

    \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
    Proof
    (hypot.f64 (sin.f64 ky) (sin.f64 kx)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= hypot-def_binary64 (sqrt.f64 (+.f64 (*.f64 (sin.f64 ky) (sin.f64 ky)) (*.f64 (sin.f64 kx) (sin.f64 kx))))): 5 points increase in error, 17 points decrease in error
    (sqrt.f64 (+.f64 (Rewrite<= unpow2_binary64 (pow.f64 (sin.f64 ky) 2)) (*.f64 (sin.f64 kx) (sin.f64 kx)))): 0 points increase in error, 0 points decrease in error
    (sqrt.f64 (+.f64 (pow.f64 (sin.f64 ky) 2) (Rewrite<= unpow2_binary64 (pow.f64 (sin.f64 kx) 2)))): 0 points increase in error, 0 points decrease in error
  4. Final simplification0.2

    \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th \]

Alternatives

Alternative 1
Error36.0
Cost45648
\[\begin{array}{l} t_1 := \frac{\sin th}{\frac{\sin kx}{\sin ky}}\\ \mathbf{if}\;\sin ky \leq -0.0005:\\ \;\;\;\;\sqrt{{\sin th}^{2}}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-156}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-64}:\\ \;\;\;\;\frac{ky \cdot \sin th}{\sin ky}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 2
Error28.7
Cost39624
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq -0.0005:\\ \;\;\;\;\sqrt{{\sin th}^{2}}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-11}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\left(0.5 + \cos \left(kx + kx\right) \cdot -0.5\right) + ky \cdot ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 3
Error33.8
Cost39436
\[\begin{array}{l} \mathbf{if}\;\sin kx \leq -2 \cdot 10^{-8}:\\ \;\;\;\;\sin th \cdot \left(ky \cdot \sqrt{\frac{1}{0.5 + \cos \left(kx \cdot 2\right) \cdot -0.5}}\right)\\ \mathbf{elif}\;\sin kx \leq -2 \cdot 10^{-263}:\\ \;\;\;\;\sqrt{{\sin th}^{2}}\\ \mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-6}:\\ \;\;\;\;\frac{\sin th}{0.5 \cdot {\left(\frac{kx}{\sin ky}\right)}^{2} + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\ \end{array} \]
Alternative 4
Error32.4
Cost39436
\[\begin{array}{l} \mathbf{if}\;\sin kx \leq -2 \cdot 10^{-8}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{0.5 + \cos \left(kx \cdot 2\right) \cdot -0.5}}\\ \mathbf{elif}\;\sin kx \leq -2 \cdot 10^{-263}:\\ \;\;\;\;\sqrt{{\sin th}^{2}}\\ \mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-6}:\\ \;\;\;\;\frac{\sin th}{0.5 \cdot {\left(\frac{kx}{\sin ky}\right)}^{2} + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\ \end{array} \]
Alternative 5
Error36.0
Cost39248
\[\begin{array}{l} t_1 := \frac{\sin th}{\frac{\sin kx}{ky}}\\ \mathbf{if}\;\sin ky \leq -0.0005:\\ \;\;\;\;\sqrt{{\sin th}^{2}}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-156}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-64}:\\ \;\;\;\;\frac{ky \cdot \sin th}{\sin ky}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 6
Error0.2
Cost32384
\[\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}} \]
Alternative 7
Error39.6
Cost13648
\[\begin{array}{l} t_1 := \sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{if}\;ky \leq -448056818614.6629:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 3.505809371626864 \cdot 10^{-156}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ky \leq 1.6522915464139594 \cdot 10^{-64}:\\ \;\;\;\;\frac{\sin th}{1 + \left(kx \cdot kx\right) \cdot \left(\frac{0.5}{ky \cdot ky} + 0.16666666666666666\right)}\\ \mathbf{elif}\;ky \leq 3.127663083485781 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 8
Error39.6
Cost13648
\[\begin{array}{l} t_1 := \frac{\sin th}{\frac{\sin kx}{ky}}\\ \mathbf{if}\;ky \leq -448056818614.6629:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 3.505809371626864 \cdot 10^{-156}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ky \leq 1.6522915464139594 \cdot 10^{-64}:\\ \;\;\;\;\frac{\sin th}{1 + \left(kx \cdot kx\right) \cdot \left(\frac{0.5}{ky \cdot ky} + 0.16666666666666666\right)}\\ \mathbf{elif}\;ky \leq 3.127663083485781 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 9
Error39.8
Cost13648
\[\begin{array}{l} t_1 := \frac{\sin th}{\frac{\sin kx}{ky}}\\ \mathbf{if}\;ky \leq -448056818614.6629:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 3.505809371626864 \cdot 10^{-156}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ky \leq 1.6522915464139594 \cdot 10^{-64}:\\ \;\;\;\;\frac{ky \cdot \sin th}{\sin ky}\\ \mathbf{elif}\;ky \leq 3.127663083485781 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 10
Error46.1
Cost7492
\[\begin{array}{l} \mathbf{if}\;th \leq 1.8618355634580832 \cdot 10^{-126}:\\ \;\;\;\;\frac{\sin th}{1 + \left(kx \cdot kx\right) \cdot \left(\frac{0.5}{ky \cdot ky} + 0.16666666666666666\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 11
Error45.7
Cost7112
\[\begin{array}{l} \mathbf{if}\;ky \leq -0.0007719611587784836:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 9.964511369354392 \cdot 10^{-129}:\\ \;\;\;\;\sin ky \cdot \left(0.16666666666666666 \cdot \left(ky \cdot th\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 12
Error46.5
Cost6920
\[\begin{array}{l} \mathbf{if}\;ky \leq -6.473984689813482 \cdot 10^{-5}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 4.6024765211504276 \cdot 10^{-141}:\\ \;\;\;\;-0.16666666666666666 \cdot {th}^{3}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 13
Error49.0
Cost6464
\[\sin th \]
Alternative 14
Error55.0
Cost576
\[\frac{1}{\frac{1}{th} + th \cdot 0.16666666666666666} \]
Alternative 15
Error55.4
Cost64
\[th \]

Error

Reproduce

herbie shell --seed 2022310 
(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)))