Average Error: 3.8 → 0.3
Time: 24.4s
Precision: binary64
Cost: 32384
\[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
\[\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \]
(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) (/ (sin th) (hypot (sin ky) (sin kx)))))
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) * (sin(th) / hypot(sin(ky), sin(kx)));
}
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.sin(th) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
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.sin(th) / math.hypot(math.sin(ky), math.sin(kx)))
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(sin(ky) * Float64(sin(th) / hypot(sin(ky), sin(kx))))
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) * (sin(th) / hypot(sin(ky), sin(kx)));
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[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 3.8

    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  2. Simplified2.4

    \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
  3. Applied egg-rr0.4

    \[\leadsto \color{blue}{\sin ky \cdot \left(\sin th \cdot \frac{1}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\right)} \]
  4. Applied egg-rr0.3

    \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
  5. Final simplification0.3

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

Alternatives

Alternative 1
Error37.6
Cost52180
\[\begin{array}{l} t_1 := \frac{\sin ky \cdot \sin th}{\sin ky}\\ t_2 := \frac{ky \cdot th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{if}\;\sin kx \leq -0.605:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\sin kx \leq -3 \cdot 10^{-169}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\sin kx \leq -1 \cdot 10^{-192}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\sin kx \leq -3 \cdot 10^{-281}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;\sin kx \leq 10^{-157}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\ \end{array} \]
Alternative 2
Error16.0
Cost45580
\[\begin{array}{l} t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\ t_2 := \frac{\sin ky \cdot th}{t_1}\\ \mathbf{if}\;\sin ky \leq -1 \cdot 10^{-8}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\sin ky \leq 0.05:\\ \;\;\;\;\frac{\sin th}{\frac{t_1}{ky}}\\ \mathbf{elif}\;\sin ky \leq 0.54:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 3
Error22.5
Cost32516
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 4
Error0.3
Cost32384
\[\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}} \]
Alternative 5
Error37.6
Cost26052
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq 10^{-76}:\\ \;\;\;\;\frac{\sin ky \cdot \sin th}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 6
Error37.1
Cost26052
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq 10^{-76}:\\ \;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 7
Error37.1
Cost26052
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq 10^{-76}:\\ \;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 8
Error38.5
Cost13384
\[\begin{array}{l} \mathbf{if}\;ky \leq -71684.1162285722:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 5.307659785243442 \cdot 10^{-77}:\\ \;\;\;\;\frac{ky \cdot \sin th}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 9
Error38.0
Cost13384
\[\begin{array}{l} \mathbf{if}\;ky \leq -71684.1162285722:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 5.307659785243442 \cdot 10^{-77}:\\ \;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 10
Error38.0
Cost13384
\[\begin{array}{l} \mathbf{if}\;ky \leq -71684.1162285722:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 5.307659785243442 \cdot 10^{-77}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 11
Error38.0
Cost13384
\[\begin{array}{l} \mathbf{if}\;ky \leq -71684.1162285722:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 5.307659785243442 \cdot 10^{-77}:\\ \;\;\;\;\frac{ky}{\frac{\sin kx}{\sin th}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 12
Error48.7
Cost6464
\[\sin th \]
Alternative 13
Error55.0
Cost64
\[th \]

Error

Reproduce

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