Average Error: 30.7 → 21.1
Time: 19.0s
Precision: binary64
Cost: 13824
\[\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
\[2 \cdot \left(\left(b + a\right) \cdot \left(\left(0.5 \cdot \left(b - a\right)\right) \cdot \sin \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)\right)\right) \]
(FPCore (a b angle)
 :precision binary64
 (*
  (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* PI (/ angle 180.0))))
  (cos (* PI (/ angle 180.0)))))
(FPCore (a b angle)
 :precision binary64
 (*
  2.0
  (* (+ b a) (* (* 0.5 (- b a)) (sin (* PI (* angle 0.011111111111111112)))))))
double code(double a, double b, double angle) {
	return ((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin((((double) M_PI) * (angle / 180.0)))) * cos((((double) M_PI) * (angle / 180.0)));
}
double code(double a, double b, double angle) {
	return 2.0 * ((b + a) * ((0.5 * (b - a)) * sin((((double) M_PI) * (angle * 0.011111111111111112)))));
}
public static double code(double a, double b, double angle) {
	return ((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * Math.sin((Math.PI * (angle / 180.0)))) * Math.cos((Math.PI * (angle / 180.0)));
}
public static double code(double a, double b, double angle) {
	return 2.0 * ((b + a) * ((0.5 * (b - a)) * Math.sin((Math.PI * (angle * 0.011111111111111112)))));
}
def code(a, b, angle):
	return ((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * math.sin((math.pi * (angle / 180.0)))) * math.cos((math.pi * (angle / 180.0)))
def code(a, b, angle):
	return 2.0 * ((b + a) * ((0.5 * (b - a)) * math.sin((math.pi * (angle * 0.011111111111111112)))))
function code(a, b, angle)
	return Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * sin(Float64(pi * Float64(angle / 180.0)))) * cos(Float64(pi * Float64(angle / 180.0))))
end
function code(a, b, angle)
	return Float64(2.0 * Float64(Float64(b + a) * Float64(Float64(0.5 * Float64(b - a)) * sin(Float64(pi * Float64(angle * 0.011111111111111112))))))
end
function tmp = code(a, b, angle)
	tmp = ((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * sin((pi * (angle / 180.0)))) * cos((pi * (angle / 180.0)));
end
function tmp = code(a, b, angle)
	tmp = 2.0 * ((b + a) * ((0.5 * (b - a)) * sin((pi * (angle * 0.011111111111111112)))));
end
code[a_, b_, angle_] := N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[a_, b_, angle_] := N[(2.0 * N[(N[(b + a), $MachinePrecision] * N[(N[(0.5 * N[(b - a), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)
2 \cdot \left(\left(b + a\right) \cdot \left(\left(0.5 \cdot \left(b - a\right)\right) \cdot \sin \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)\right)\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 30.7

    \[\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right) \]
  2. Simplified30.7

    \[\leadsto \color{blue}{2 \cdot \left(\left(b \cdot b - a \cdot a\right) \cdot \left(\sin \left(\frac{\pi \cdot angle}{180}\right) \cdot \cos \left(\frac{\pi \cdot angle}{180}\right)\right)\right)} \]
    Proof
    (*.f64 2 (*.f64 (-.f64 (*.f64 b b) (*.f64 a a)) (*.f64 (sin.f64 (/.f64 (*.f64 (PI.f64) angle) 180)) (cos.f64 (/.f64 (*.f64 (PI.f64) angle) 180))))): 0 points increase in error, 0 points decrease in error
    (*.f64 2 (*.f64 (-.f64 (Rewrite<= unpow2_binary64 (pow.f64 b 2)) (*.f64 a a)) (*.f64 (sin.f64 (/.f64 (*.f64 (PI.f64) angle) 180)) (cos.f64 (/.f64 (*.f64 (PI.f64) angle) 180))))): 0 points increase in error, 0 points decrease in error
    (*.f64 2 (*.f64 (-.f64 (pow.f64 b 2) (Rewrite<= unpow2_binary64 (pow.f64 a 2))) (*.f64 (sin.f64 (/.f64 (*.f64 (PI.f64) angle) 180)) (cos.f64 (/.f64 (*.f64 (PI.f64) angle) 180))))): 0 points increase in error, 0 points decrease in error
    (*.f64 2 (*.f64 (-.f64 (pow.f64 b 2) (pow.f64 a 2)) (*.f64 (sin.f64 (Rewrite<= associate-*r/_binary64 (*.f64 (PI.f64) (/.f64 angle 180)))) (cos.f64 (/.f64 (*.f64 (PI.f64) angle) 180))))): 26 points increase in error, 27 points decrease in error
    (*.f64 2 (*.f64 (-.f64 (pow.f64 b 2) (pow.f64 a 2)) (*.f64 (sin.f64 (*.f64 (PI.f64) (/.f64 angle 180))) (cos.f64 (Rewrite<= associate-*r/_binary64 (*.f64 (PI.f64) (/.f64 angle 180))))))): 13 points increase in error, 17 points decrease in error
    (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 2 (-.f64 (pow.f64 b 2) (pow.f64 a 2))) (*.f64 (sin.f64 (*.f64 (PI.f64) (/.f64 angle 180))) (cos.f64 (*.f64 (PI.f64) (/.f64 angle 180)))))): 1 points increase in error, 1 points decrease in error
    (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 (*.f64 2 (-.f64 (pow.f64 b 2) (pow.f64 a 2))) (sin.f64 (*.f64 (PI.f64) (/.f64 angle 180)))) (cos.f64 (*.f64 (PI.f64) (/.f64 angle 180))))): 19 points increase in error, 13 points decrease in error
  3. Applied egg-rr26.4

    \[\leadsto 2 \cdot \color{blue}{\mathsf{fma}\left(b + a, \left(b - a\right) \cdot \left(\left(\sin \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right) + 0\right) \cdot 0.5\right), \mathsf{fma}\left(a, -a, a \cdot a\right) \cdot \left(\left(\sin \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right) + 0\right) \cdot 0.5\right)\right)} \]
  4. Taylor expanded in a around 0 21.1

    \[\leadsto 2 \cdot \mathsf{fma}\left(b + a, \left(b - a\right) \cdot \left(\left(\sin \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right) + 0\right) \cdot 0.5\right), \color{blue}{0} \cdot \left(\left(\sin \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right) + 0\right) \cdot 0.5\right)\right) \]
  5. Applied egg-rr21.1

    \[\leadsto 2 \cdot \color{blue}{\left(\left(b + a\right) \cdot \left(\sin \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right) \cdot \left(0.5 \cdot \left(b - a\right)\right)\right)\right)} \]
  6. Final simplification21.1

    \[\leadsto 2 \cdot \left(\left(b + a\right) \cdot \left(\left(0.5 \cdot \left(b - a\right)\right) \cdot \sin \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)\right)\right) \]

Alternatives

Alternative 1
Error21.4
Cost14088
\[\begin{array}{l} t_0 := 0.011111111111111112 \cdot \left(\pi \cdot angle\right)\\ \mathbf{if}\;angle \leq -1.28 \cdot 10^{-6}:\\ \;\;\;\;\left(b \cdot b - a \cdot a\right) \cdot \sin t_0\\ \mathbf{elif}\;angle \leq 0.0033:\\ \;\;\;\;2 \cdot \left(\left(b + a\right) \cdot \left(\left(0.5 \cdot \left(b - a\right)\right) \cdot t_0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\sin \left(angle \cdot \left(\pi \cdot 0.011111111111111112\right)\right) \cdot \left(\left(b + a\right) \cdot \left(\left(b + a\right) \cdot 0.5\right)\right)\right)\\ \end{array} \]
Alternative 2
Error21.4
Cost14088
\[\begin{array}{l} t_0 := 0.011111111111111112 \cdot \left(\pi \cdot angle\right)\\ \mathbf{if}\;angle \leq -1.6 \cdot 10^{-7}:\\ \;\;\;\;\left(b \cdot b - a \cdot a\right) \cdot \sin t_0\\ \mathbf{elif}\;angle \leq 0.00035:\\ \;\;\;\;2 \cdot \left(\left(b + a\right) \cdot \left(\left(0.5 \cdot \left(b - a\right)\right) \cdot t_0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\left(b + a\right) \cdot \left(\sin \left(angle \cdot \left(\pi \cdot 0.011111111111111112\right)\right) \cdot \left(\left(b + a\right) \cdot 0.5\right)\right)\right)\\ \end{array} \]
Alternative 3
Error22.3
Cost13832
\[\begin{array}{l} t_0 := 0.011111111111111112 \cdot \left(\pi \cdot angle\right)\\ \mathbf{if}\;angle \leq -0.0036:\\ \;\;\;\;2 \cdot \left(-0.5 \cdot \left(a \cdot \left(a \cdot \sin t_0\right)\right)\right)\\ \mathbf{elif}\;angle \leq 0.0024:\\ \;\;\;\;2 \cdot \left(\left(b + a\right) \cdot \left(\left(0.5 \cdot \left(b - a\right)\right) \cdot t_0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(0.5 \cdot \left(\left(b \cdot b\right) \cdot \sin \left(angle \cdot \left(\pi \cdot 0.011111111111111112\right)\right)\right)\right)\\ \end{array} \]
Alternative 4
Error22.3
Cost13832
\[\begin{array}{l} t_0 := 0.011111111111111112 \cdot \left(\pi \cdot angle\right)\\ \mathbf{if}\;angle \leq -0.00085:\\ \;\;\;\;2 \cdot \left(-0.5 \cdot \left(a \cdot \left(a \cdot \sin t_0\right)\right)\right)\\ \mathbf{elif}\;angle \leq 0.0013:\\ \;\;\;\;2 \cdot \left(\left(b + a\right) \cdot \left(\left(0.5 \cdot \left(b - a\right)\right) \cdot t_0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(0.5 \cdot \left(\left(b \cdot b\right) \cdot \sin \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)\right)\right)\\ \end{array} \]
Alternative 5
Error22.3
Cost13832
\[\begin{array}{l} t_0 := \sin \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)\\ \mathbf{if}\;angle \leq -0.0056:\\ \;\;\;\;2 \cdot \left(t_0 \cdot \left(a \cdot \left(a \cdot -0.5\right)\right)\right)\\ \mathbf{elif}\;angle \leq 0.0032:\\ \;\;\;\;2 \cdot \left(\left(b + a\right) \cdot \left(\left(0.5 \cdot \left(b - a\right)\right) \cdot \left(0.011111111111111112 \cdot \left(\pi \cdot angle\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(0.5 \cdot \left(\left(b \cdot b\right) \cdot t_0\right)\right)\\ \end{array} \]
Alternative 6
Error21.2
Cost13832
\[\begin{array}{l} t_0 := 0.011111111111111112 \cdot \left(\pi \cdot angle\right)\\ t_1 := \left(b \cdot b - a \cdot a\right) \cdot \sin t_0\\ \mathbf{if}\;angle \leq -8 \cdot 10^{-7}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;angle \leq 3.9 \cdot 10^{-32}:\\ \;\;\;\;2 \cdot \left(\left(b + a\right) \cdot \left(\left(0.5 \cdot \left(b - a\right)\right) \cdot t_0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error22.9
Cost13704
\[\begin{array}{l} t_0 := \sin \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right) \cdot \left(\left(a \cdot a\right) \cdot -2\right)\\ \mathbf{if}\;angle \leq -210000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;angle \leq 1.95 \cdot 10^{+34}:\\ \;\;\;\;2 \cdot \left(\left(b + a\right) \cdot \left(\left(0.5 \cdot \left(b - a\right)\right) \cdot \left(0.011111111111111112 \cdot \left(\pi \cdot angle\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error22.7
Cost13704
\[\begin{array}{l} t_0 := 0.011111111111111112 \cdot \left(\pi \cdot angle\right)\\ \mathbf{if}\;angle \leq -9.8 \cdot 10^{-5}:\\ \;\;\;\;2 \cdot \left(-0.5 \cdot \left(a \cdot \left(a \cdot \sin t_0\right)\right)\right)\\ \mathbf{elif}\;angle \leq 2.8 \cdot 10^{+34}:\\ \;\;\;\;2 \cdot \left(\left(b + a\right) \cdot \left(\left(0.5 \cdot \left(b - a\right)\right) \cdot t_0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right) \cdot \left(\left(a \cdot a\right) \cdot -2\right)\\ \end{array} \]
Alternative 9
Error29.2
Cost7696
\[\begin{array}{l} t_0 := 0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(b \cdot b - a \cdot a\right)\right)\right)\\ t_1 := \left(angle \cdot \left(b \cdot \pi\right)\right) \cdot \left(b \cdot 0.011111111111111112\right)\\ \mathbf{if}\;b \leq -7.2 \cdot 10^{+80}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -8.5 \cdot 10^{-48}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq -9.5 \cdot 10^{-237}:\\ \;\;\;\;\left(\pi \cdot \left(a \cdot \left(a \cdot angle\right)\right)\right) \cdot -0.011111111111111112\\ \mathbf{elif}\;b \leq 2 \cdot 10^{+152}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error29.0
Cost7696
\[\begin{array}{l} t_0 := b \cdot b - a \cdot a\\ t_1 := \left(angle \cdot \left(b \cdot \pi\right)\right) \cdot \left(b \cdot 0.011111111111111112\right)\\ \mathbf{if}\;b \leq -2.65 \cdot 10^{+153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -4.5 \cdot 10^{-48}:\\ \;\;\;\;0.011111111111111112 \cdot \left(\pi \cdot \left(angle \cdot t_0\right)\right)\\ \mathbf{elif}\;b \leq -6.6 \cdot 10^{-239}:\\ \;\;\;\;\left(\pi \cdot \left(a \cdot \left(a \cdot angle\right)\right)\right) \cdot -0.011111111111111112\\ \mathbf{elif}\;b \leq 3 \cdot 10^{+153}:\\ \;\;\;\;0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot t_0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error24.9
Cost7556
\[\begin{array}{l} \mathbf{if}\;angle \leq -1.7 \cdot 10^{+19}:\\ \;\;\;\;0.011111111111111112 \cdot \left(angle \cdot \left(b \cdot \left(b \cdot \pi\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\left(b + a\right) \cdot \left(\left(0.5 \cdot \left(b - a\right)\right) \cdot \left(0.011111111111111112 \cdot \left(\pi \cdot angle\right)\right)\right)\right)\\ \end{array} \]
Alternative 12
Error25.0
Cost7428
\[\begin{array}{l} \mathbf{if}\;angle \leq -5 \cdot 10^{+19}:\\ \;\;\;\;0.011111111111111112 \cdot \left(angle \cdot \left(b \cdot \left(b \cdot \pi\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\left(b + a\right) \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \left(\pi \cdot \left(b - a\right)\right)\right)\right)\right)\\ \end{array} \]
Alternative 13
Error25.0
Cost7300
\[\begin{array}{l} \mathbf{if}\;angle \leq -5.2 \cdot 10^{+19}:\\ \;\;\;\;0.011111111111111112 \cdot \left(angle \cdot \left(b \cdot \left(b \cdot \pi\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.011111111111111112 \cdot \left(\left(b + a\right) \cdot \left(\left(b - a\right) \cdot \left(\pi \cdot angle\right)\right)\right)\\ \end{array} \]
Alternative 14
Error38.5
Cost7176
\[\begin{array}{l} t_0 := \left(angle \cdot \left(b \cdot \pi\right)\right) \cdot \left(b \cdot 0.011111111111111112\right)\\ \mathbf{if}\;b \leq -4.2 \cdot 10^{+41}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 5 \cdot 10^{+140}:\\ \;\;\;\;\left(\pi \cdot 0.011111111111111112\right) \cdot \left(angle \cdot \left(b \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 15
Error32.6
Cost7176
\[\begin{array}{l} t_0 := \left(angle \cdot \left(b \cdot \pi\right)\right) \cdot \left(b \cdot 0.011111111111111112\right)\\ \mathbf{if}\;b \leq -1.5 \cdot 10^{-64}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 4.4 \cdot 10^{-72}:\\ \;\;\;\;-0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(a \cdot a\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 16
Error32.0
Cost7176
\[\begin{array}{l} t_0 := \left(angle \cdot \left(b \cdot \pi\right)\right) \cdot \left(b \cdot 0.011111111111111112\right)\\ \mathbf{if}\;b \leq -2.25 \cdot 10^{+79}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 4.6 \cdot 10^{-67}:\\ \;\;\;\;\left(\pi \cdot \left(a \cdot \left(a \cdot angle\right)\right)\right) \cdot -0.011111111111111112\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 17
Error43.4
Cost6912
\[0.011111111111111112 \cdot \left(angle \cdot \left(b \cdot \left(b \cdot \pi\right)\right)\right) \]

Error

Reproduce

herbie shell --seed 2022330 
(FPCore (a b angle)
  :name "ab-angle->ABCF B"
  :precision binary64
  (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* PI (/ angle 180.0)))) (cos (* PI (/ angle 180.0)))))