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

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 4.0

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

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

    [Start]4.0

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

    +-commutative [=>]4.0

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

    unpow2 [=>]4.0

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

    unpow2 [=>]4.0

    \[ \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]

    hypot-def [=>]0.2

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

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\right)} - 1} \]
  4. Simplified0.2

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

    [Start]36.1

    \[ e^{\mathsf{log1p}\left(\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\right)} - 1 \]

    expm1-def [=>]0.3

    \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\right)\right)} \]

    expm1-log1p [=>]0.3

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

    *-commutative [=>]0.3

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

    associate-/r/ [<=]0.2

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

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

Alternatives

Alternative 1
Error34.9
Cost71776
\[\begin{array}{l} t_1 := \frac{\sin th \cdot ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ t_2 := \frac{\sin ky}{\frac{\mathsf{hypot}\left(kx, \sin ky\right)}{th}}\\ \mathbf{if}\;\sin kx \leq -0.0002:\\ \;\;\;\;\left|ky \cdot \frac{\sin th}{\sin kx}\right|\\ \mathbf{elif}\;\sin kx \leq -5 \cdot 10^{-72}:\\ \;\;\;\;\frac{\sin th \cdot \sin ky}{\sin ky}\\ \mathbf{elif}\;\sin kx \leq -1 \cdot 10^{-86}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\sin kx \leq -4 \cdot 10^{-151}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\sin kx \leq -1 \cdot 10^{-275}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-255}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-112}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-72}:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\ \end{array} \]
Alternative 2
Error34.1
Cost65244
\[\begin{array}{l} t_1 := \frac{\sin ky}{\frac{\mathsf{hypot}\left(kx, \sin ky\right)}{th}}\\ \mathbf{if}\;\sin kx \leq -5 \cdot 10^{-17}:\\ \;\;\;\;\left|\sin th \cdot \frac{\sin ky}{\sin kx}\right|\\ \mathbf{elif}\;\sin kx \leq -5 \cdot 10^{-63}:\\ \;\;\;\;\frac{\sin th \cdot \sin ky}{\sin ky}\\ \mathbf{elif}\;\sin kx \leq -2 \cdot 10^{-76}:\\ \;\;\;\;\frac{-\sin th}{\frac{kx}{\sin ky}}\\ \mathbf{elif}\;\sin kx \leq -4 \cdot 10^{-151}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\sin kx \leq -1 \cdot 10^{-275}:\\ \;\;\;\;\frac{\sin th \cdot ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;\sin kx \leq 10^{-272}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-72}:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\ \end{array} \]
Alternative 3
Error34.1
Cost65244
\[\begin{array}{l} t_1 := \frac{\sin ky}{\frac{\mathsf{hypot}\left(kx, \sin ky\right)}{th}}\\ \mathbf{if}\;\sin kx \leq -5 \cdot 10^{-17}:\\ \;\;\;\;\left|\frac{\sin th}{\frac{\sin kx}{\sin ky}}\right|\\ \mathbf{elif}\;\sin kx \leq -5 \cdot 10^{-63}:\\ \;\;\;\;\frac{\sin th \cdot \sin ky}{\sin ky}\\ \mathbf{elif}\;\sin kx \leq -2 \cdot 10^{-76}:\\ \;\;\;\;\frac{-\sin th}{\frac{kx}{\sin ky}}\\ \mathbf{elif}\;\sin kx \leq -4 \cdot 10^{-151}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\sin kx \leq -1 \cdot 10^{-275}:\\ \;\;\;\;\frac{\sin th \cdot ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;\sin kx \leq 10^{-272}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-72}:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\ \end{array} \]
Alternative 4
Error14.8
Cost58644
\[\begin{array}{l} t_1 := \frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\ \mathbf{if}\;\sin ky \leq -0.5:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\sin ky \leq -0.05:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-8}:\\ \;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{ky}}\\ \mathbf{elif}\;\sin ky \leq 0.825:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;\sin ky \leq 0.91:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 5
Error14.8
Cost58644
\[\begin{array}{l} t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\ t_2 := \frac{th \cdot \sin ky}{t_1}\\ \mathbf{if}\;\sin ky \leq -0.5:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\sin ky \leq -0.05:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-8}:\\ \;\;\;\;\frac{\sin th}{\frac{t_1}{ky}}\\ \mathbf{elif}\;\sin ky \leq 0.825:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;\sin ky \leq 0.91:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 6
Error34.8
Cost45648
\[\begin{array}{l} \mathbf{if}\;\sin kx \leq -0.0002:\\ \;\;\;\;\left|ky \cdot \frac{\sin th}{\sin kx}\right|\\ \mathbf{elif}\;\sin kx \leq -1 \cdot 10^{-115}:\\ \;\;\;\;\frac{-\sin th}{\frac{kx}{\sin ky}}\\ \mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-160}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-72}:\\ \;\;\;\;\frac{\sin th \cdot \sin ky}{\sin ky}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\ \end{array} \]
Alternative 7
Error35.0
Cost39116
\[\begin{array}{l} \mathbf{if}\;\sin kx \leq -0.0002:\\ \;\;\;\;\left|ky \cdot \frac{\sin th}{\sin kx}\right|\\ \mathbf{elif}\;\sin kx \leq -1 \cdot 10^{-115}:\\ \;\;\;\;\frac{-\sin th}{\frac{kx}{\sin ky}}\\ \mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-72}:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \end{array} \]
Alternative 8
Error35.0
Cost39116
\[\begin{array}{l} \mathbf{if}\;\sin kx \leq -0.0002:\\ \;\;\;\;\left|ky \cdot \frac{\sin th}{\sin kx}\right|\\ \mathbf{elif}\;\sin kx \leq -1 \cdot 10^{-115}:\\ \;\;\;\;\frac{-\sin th}{\frac{kx}{\sin ky}}\\ \mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-72}:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\ \end{array} \]
Alternative 9
Error16.8
Cost39048
\[\begin{array}{l} \mathbf{if}\;\sin kx \leq -0.0002:\\ \;\;\;\;\left|\sin th \cdot \frac{\sin ky}{\sin kx}\right|\\ \mathbf{elif}\;\sin kx \leq 10^{-6}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\ \end{array} \]
Alternative 10
Error14.6
Cost39048
\[\begin{array}{l} \mathbf{if}\;\sin kx \leq -0.004:\\ \;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\ \mathbf{elif}\;\sin kx \leq 10^{-6}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\ \end{array} \]
Alternative 11
Error36.5
Cost32716
\[\begin{array}{l} \mathbf{if}\;\sin kx \leq -0.0002:\\ \;\;\;\;\left|ky \cdot \frac{\sin th}{\sin kx}\right|\\ \mathbf{elif}\;\sin kx \leq -1 \cdot 10^{-115}:\\ \;\;\;\;\frac{-\sin th}{\frac{kx}{\sin ky}}\\ \mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-72}:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;\frac{ky}{\frac{\sin kx}{\sin th}}\\ \end{array} \]
Alternative 12
Error34.1
Cost32716
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq -1 \cdot 10^{-14}:\\ \;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(kx, \sin ky\right)}{th}}\\ \mathbf{elif}\;\sin ky \leq -1 \cdot 10^{-132}:\\ \;\;\;\;\left|ky \cdot \frac{\sin th}{\sin kx}\right|\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-140}:\\ \;\;\;\;\frac{ky}{\frac{\sin kx}{\sin th}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 13
Error33.6
Cost32716
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq -0.05:\\ \;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(kx, \sin ky\right)}{th}}\\ \mathbf{elif}\;\sin ky \leq -5 \cdot 10^{-134}:\\ \;\;\;\;\frac{th \cdot ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-140}:\\ \;\;\;\;\frac{ky}{\frac{\sin kx}{\sin th}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 14
Error0.2
Cost32384
\[\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \]
Alternative 15
Error38.6
Cost13384
\[\begin{array}{l} \mathbf{if}\;ky \leq -7000000000:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 2.9 \cdot 10^{-136}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 16
Error38.6
Cost13384
\[\begin{array}{l} \mathbf{if}\;ky \leq -50000000:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 9 \cdot 10^{-138}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 17
Error43.3
Cost6984
\[\begin{array}{l} \mathbf{if}\;ky \leq -7000000000:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 2.2 \cdot 10^{-204}:\\ \;\;\;\;th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 18
Error42.5
Cost6984
\[\begin{array}{l} \mathbf{if}\;ky \leq -7000000000:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 4.5 \cdot 10^{-160}:\\ \;\;\;\;ky \cdot \frac{\sin th}{kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 19
Error42.5
Cost6984
\[\begin{array}{l} \mathbf{if}\;ky \leq -7000000000:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 2.6 \cdot 10^{-160}:\\ \;\;\;\;\frac{\sin th}{\frac{kx}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 20
Error44.2
Cost6728
\[\begin{array}{l} \mathbf{if}\;ky \leq -7000000000:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 4.2 \cdot 10^{-202}:\\ \;\;\;\;\frac{th}{\frac{kx}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 21
Error55.3
Cost320
\[ky \cdot \frac{th}{kx} \]
Alternative 22
Error55.3
Cost320
\[th \cdot \frac{ky}{kx} \]
Alternative 23
Error55.3
Cost320
\[\frac{th}{\frac{kx}{ky}} \]

Error

Reproduce

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