
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
(FPCore (x y z a) :precision binary64 (+ x (fma (+ (tan y) (tan z)) (/ 1.0 (- 1.0 (* (tan y) (tan z)))) (- (tan a)))))
double code(double x, double y, double z, double a) {
return x + fma((tan(y) + tan(z)), (1.0 / (1.0 - (tan(y) * tan(z)))), -tan(a));
}
function code(x, y, z, a) return Float64(x + fma(Float64(tan(y) + tan(z)), Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z)))), Float64(-tan(a)))) end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \tan y \cdot \tan z}, -\tan a\right)
\end{array}
Initial program 83.1%
tan-sum99.7%
div-inv99.7%
fma-neg99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))))
(if (<= (tan a) -0.002)
(+ x (- t_0 (tan a)))
(if (<= (tan a) 0.0002)
(+ x (- (* (+ (tan y) (tan z)) (/ 1.0 (- 1.0 (* (tan y) (tan z))))) a))
(log (exp (+ t_0 (- x (tan a)))))))))
double code(double x, double y, double z, double a) {
double t_0 = tan((y + z));
double tmp;
if (tan(a) <= -0.002) {
tmp = x + (t_0 - tan(a));
} else if (tan(a) <= 0.0002) {
tmp = x + (((tan(y) + tan(z)) * (1.0 / (1.0 - (tan(y) * tan(z))))) - a);
} else {
tmp = log(exp((t_0 + (x - tan(a)))));
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: t_0
real(8) :: tmp
t_0 = tan((y + z))
if (tan(a) <= (-0.002d0)) then
tmp = x + (t_0 - tan(a))
else if (tan(a) <= 0.0002d0) then
tmp = x + (((tan(y) + tan(z)) * (1.0d0 / (1.0d0 - (tan(y) * tan(z))))) - a)
else
tmp = log(exp((t_0 + (x - tan(a)))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan((y + z));
double tmp;
if (Math.tan(a) <= -0.002) {
tmp = x + (t_0 - Math.tan(a));
} else if (Math.tan(a) <= 0.0002) {
tmp = x + (((Math.tan(y) + Math.tan(z)) * (1.0 / (1.0 - (Math.tan(y) * Math.tan(z))))) - a);
} else {
tmp = Math.log(Math.exp((t_0 + (x - Math.tan(a)))));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan((y + z)) tmp = 0 if math.tan(a) <= -0.002: tmp = x + (t_0 - math.tan(a)) elif math.tan(a) <= 0.0002: tmp = x + (((math.tan(y) + math.tan(z)) * (1.0 / (1.0 - (math.tan(y) * math.tan(z))))) - a) else: tmp = math.log(math.exp((t_0 + (x - math.tan(a))))) return tmp
function code(x, y, z, a) t_0 = tan(Float64(y + z)) tmp = 0.0 if (tan(a) <= -0.002) tmp = Float64(x + Float64(t_0 - tan(a))); elseif (tan(a) <= 0.0002) tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) * Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z))))) - a)); else tmp = log(exp(Float64(t_0 + Float64(x - tan(a))))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan((y + z)); tmp = 0.0; if (tan(a) <= -0.002) tmp = x + (t_0 - tan(a)); elseif (tan(a) <= 0.0002) tmp = x + (((tan(y) + tan(z)) * (1.0 / (1.0 - (tan(y) * tan(z))))) - a); else tmp = log(exp((t_0 + (x - tan(a))))); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.002], N[(x + N[(t$95$0 - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 0.0002], N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[Log[N[Exp[N[(t$95$0 + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
\mathbf{if}\;\tan a \leq -0.002:\\
\;\;\;\;x + \left(t_0 - \tan a\right)\\
\mathbf{elif}\;\tan a \leq 0.0002:\\
\;\;\;\;x + \left(\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z} - a\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{t_0 + \left(x - \tan a\right)}\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -2e-3Initial program 79.1%
if -2e-3 < (tan.f64 a) < 2.0000000000000001e-4Initial program 82.1%
Taylor expanded in a around 0 82.1%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
if 2.0000000000000001e-4 < (tan.f64 a) Initial program 89.6%
add-log-exp89.7%
associate-+r-89.5%
+-commutative89.5%
associate--l+89.7%
Applied egg-rr89.7%
Final simplification91.4%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))))
(if (<= (tan a) -0.002)
(+ x (- t_0 (tan a)))
(if (<= (tan a) 0.0002)
(+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) a))
(log (exp (+ t_0 (- x (tan a)))))))))
double code(double x, double y, double z, double a) {
double t_0 = tan((y + z));
double tmp;
if (tan(a) <= -0.002) {
tmp = x + (t_0 - tan(a));
} else if (tan(a) <= 0.0002) {
tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a);
} else {
tmp = log(exp((t_0 + (x - tan(a)))));
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: t_0
real(8) :: tmp
t_0 = tan((y + z))
if (tan(a) <= (-0.002d0)) then
tmp = x + (t_0 - tan(a))
else if (tan(a) <= 0.0002d0) then
tmp = x + (((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) - a)
else
tmp = log(exp((t_0 + (x - tan(a)))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan((y + z));
double tmp;
if (Math.tan(a) <= -0.002) {
tmp = x + (t_0 - Math.tan(a));
} else if (Math.tan(a) <= 0.0002) {
tmp = x + (((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) - a);
} else {
tmp = Math.log(Math.exp((t_0 + (x - Math.tan(a)))));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan((y + z)) tmp = 0 if math.tan(a) <= -0.002: tmp = x + (t_0 - math.tan(a)) elif math.tan(a) <= 0.0002: tmp = x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - a) else: tmp = math.log(math.exp((t_0 + (x - math.tan(a))))) return tmp
function code(x, y, z, a) t_0 = tan(Float64(y + z)) tmp = 0.0 if (tan(a) <= -0.002) tmp = Float64(x + Float64(t_0 - tan(a))); elseif (tan(a) <= 0.0002) tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - a)); else tmp = log(exp(Float64(t_0 + Float64(x - tan(a))))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan((y + z)); tmp = 0.0; if (tan(a) <= -0.002) tmp = x + (t_0 - tan(a)); elseif (tan(a) <= 0.0002) tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a); else tmp = log(exp((t_0 + (x - tan(a))))); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.002], N[(x + N[(t$95$0 - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 0.0002], N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[Log[N[Exp[N[(t$95$0 + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
\mathbf{if}\;\tan a \leq -0.002:\\
\;\;\;\;x + \left(t_0 - \tan a\right)\\
\mathbf{elif}\;\tan a \leq 0.0002:\\
\;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - a\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{t_0 + \left(x - \tan a\right)}\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -2e-3Initial program 79.1%
if -2e-3 < (tan.f64 a) < 2.0000000000000001e-4Initial program 82.1%
Taylor expanded in a around 0 82.1%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
if 2.0000000000000001e-4 < (tan.f64 a) Initial program 89.6%
add-log-exp89.7%
associate-+r-89.5%
+-commutative89.5%
associate--l+89.7%
Applied egg-rr89.7%
Final simplification91.4%
(FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) - Math.tan(a));
}
def code(x, y, z, a): return x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right)
\end{array}
Initial program 83.1%
tan-sum49.0%
div-inv49.0%
Applied egg-rr99.7%
associate-*r/49.0%
*-rgt-identity49.0%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z a) :precision binary64 (if (or (<= (tan a) -0.002) (not (<= (tan a) 2e-8))) (- x (tan a)) (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -0.002) || !(tan(a) <= 2e-8)) {
tmp = x - tan(a);
} else {
tmp = x + (tan((y + z)) - a);
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((tan(a) <= (-0.002d0)) .or. (.not. (tan(a) <= 2d-8))) then
tmp = x - tan(a)
else
tmp = x + (tan((y + z)) - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((Math.tan(a) <= -0.002) || !(Math.tan(a) <= 2e-8)) {
tmp = x - Math.tan(a);
} else {
tmp = x + (Math.tan((y + z)) - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (math.tan(a) <= -0.002) or not (math.tan(a) <= 2e-8): tmp = x - math.tan(a) else: tmp = x + (math.tan((y + z)) - a) return tmp
function code(x, y, z, a) tmp = 0.0 if ((tan(a) <= -0.002) || !(tan(a) <= 2e-8)) tmp = Float64(x - tan(a)); else tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((tan(a) <= -0.002) || ~((tan(a) <= 2e-8))) tmp = x - tan(a); else tmp = x + (tan((y + z)) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.002], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 2e-8]], $MachinePrecision]], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.002 \lor \neg \left(\tan a \leq 2 \cdot 10^{-8}\right):\\
\;\;\;\;x - \tan a\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -2e-3 or 2e-8 < (tan.f64 a) Initial program 83.4%
Taylor expanded in y around 0 63.4%
tan-quot63.5%
add-log-exp63.5%
Applied egg-rr63.5%
Taylor expanded in z around 0 44.9%
if -2e-3 < (tan.f64 a) < 2e-8Initial program 82.8%
Taylor expanded in a around 0 82.8%
Final simplification62.5%
(FPCore (x y z a) :precision binary64 (if (<= (tan a) -0.002) (+ x (- (sin z) (tan a))) (if (<= (tan a) 2e-8) (+ x (- (tan (+ y z)) a)) (- x (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if (tan(a) <= -0.002) {
tmp = x + (sin(z) - tan(a));
} else if (tan(a) <= 2e-8) {
tmp = x + (tan((y + z)) - a);
} else {
tmp = x - tan(a);
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (tan(a) <= (-0.002d0)) then
tmp = x + (sin(z) - tan(a))
else if (tan(a) <= 2d-8) then
tmp = x + (tan((y + z)) - a)
else
tmp = x - tan(a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (Math.tan(a) <= -0.002) {
tmp = x + (Math.sin(z) - Math.tan(a));
} else if (Math.tan(a) <= 2e-8) {
tmp = x + (Math.tan((y + z)) - a);
} else {
tmp = x - Math.tan(a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if math.tan(a) <= -0.002: tmp = x + (math.sin(z) - math.tan(a)) elif math.tan(a) <= 2e-8: tmp = x + (math.tan((y + z)) - a) else: tmp = x - math.tan(a) return tmp
function code(x, y, z, a) tmp = 0.0 if (tan(a) <= -0.002) tmp = Float64(x + Float64(sin(z) - tan(a))); elseif (tan(a) <= 2e-8) tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); else tmp = Float64(x - tan(a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (tan(a) <= -0.002) tmp = x + (sin(z) - tan(a)); elseif (tan(a) <= 2e-8) tmp = x + (tan((y + z)) - a); else tmp = x - tan(a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -0.002], N[(x + N[(N[Sin[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 2e-8], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.002:\\
\;\;\;\;x + \left(\sin z - \tan a\right)\\
\mathbf{elif}\;\tan a \leq 2 \cdot 10^{-8}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;x - \tan a\\
\end{array}
\end{array}
if (tan.f64 a) < -2e-3Initial program 79.1%
tan-quot79.0%
clear-num79.1%
Applied egg-rr79.1%
Taylor expanded in z around 0 60.0%
+-commutative60.0%
mul-1-neg60.0%
unsub-neg60.0%
Simplified60.0%
Taylor expanded in y around 0 42.0%
if -2e-3 < (tan.f64 a) < 2e-8Initial program 82.8%
Taylor expanded in a around 0 82.8%
if 2e-8 < (tan.f64 a) Initial program 88.3%
Taylor expanded in y around 0 66.3%
tan-quot66.4%
add-log-exp66.4%
Applied egg-rr66.4%
Taylor expanded in z around 0 48.4%
Final simplification62.6%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -0.0005) (+ x (+ (tan a) (tan (+ y z)))) (+ x (- (tan z) (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -0.0005) {
tmp = x + (tan(a) + tan((y + z)));
} else {
tmp = x + (tan(z) - tan(a));
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((y + z) <= (-0.0005d0)) then
tmp = x + (tan(a) + tan((y + z)))
else
tmp = x + (tan(z) - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -0.0005) {
tmp = x + (Math.tan(a) + Math.tan((y + z)));
} else {
tmp = x + (Math.tan(z) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -0.0005: tmp = x + (math.tan(a) + math.tan((y + z))) else: tmp = x + (math.tan(z) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -0.0005) tmp = Float64(x + Float64(tan(a) + tan(Float64(y + z)))); else tmp = Float64(x + Float64(tan(z) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -0.0005) tmp = x + (tan(a) + tan((y + z))); else tmp = x + (tan(z) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -0.0005], N[(x + N[(N[Tan[a], $MachinePrecision] + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -0.0005:\\
\;\;\;\;x + \left(\tan a + \tan \left(y + z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\end{array}
\end{array}
if (+.f64 y z) < -5.0000000000000001e-4Initial program 73.8%
sub-neg73.8%
Applied egg-rr73.8%
+-commutative73.8%
rem-square-sqrt36.7%
fabs-sqr36.7%
rem-square-sqrt58.6%
fabs-neg58.6%
rem-square-sqrt21.8%
fabs-sqr21.8%
rem-square-sqrt45.8%
Simplified45.8%
if -5.0000000000000001e-4 < (+.f64 y z) Initial program 88.5%
Taylor expanded in y around 0 71.0%
tan-quot71.0%
expm1-log1p-u65.4%
expm1-udef65.4%
Applied egg-rr65.4%
expm1-def65.4%
expm1-log1p71.0%
Simplified71.0%
Final simplification61.8%
(FPCore (x y z a) :precision binary64 (if (or (<= a -0.0008) (not (<= a 7.2))) (+ x (- (tan z) (tan a))) (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -0.0008) || !(a <= 7.2)) {
tmp = x + (tan(z) - tan(a));
} else {
tmp = x + (tan((y + z)) - a);
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((a <= (-0.0008d0)) .or. (.not. (a <= 7.2d0))) then
tmp = x + (tan(z) - tan(a))
else
tmp = x + (tan((y + z)) - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -0.0008) || !(a <= 7.2)) {
tmp = x + (Math.tan(z) - Math.tan(a));
} else {
tmp = x + (Math.tan((y + z)) - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (a <= -0.0008) or not (a <= 7.2): tmp = x + (math.tan(z) - math.tan(a)) else: tmp = x + (math.tan((y + z)) - a) return tmp
function code(x, y, z, a) tmp = 0.0 if ((a <= -0.0008) || !(a <= 7.2)) tmp = Float64(x + Float64(tan(z) - tan(a))); else tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((a <= -0.0008) || ~((a <= 7.2))) tmp = x + (tan(z) - tan(a)); else tmp = x + (tan((y + z)) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -0.0008], N[Not[LessEqual[a, 7.2]], $MachinePrecision]], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0008 \lor \neg \left(a \leq 7.2\right):\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\end{array}
\end{array}
if a < -8.00000000000000038e-4 or 7.20000000000000018 < a Initial program 83.8%
Taylor expanded in y around 0 64.3%
tan-quot64.4%
expm1-log1p-u57.6%
expm1-udef57.6%
Applied egg-rr57.6%
expm1-def57.6%
expm1-log1p64.4%
Simplified64.4%
if -8.00000000000000038e-4 < a < 7.20000000000000018Initial program 82.4%
Taylor expanded in a around 0 81.4%
Final simplification72.5%
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Initial program 83.1%
Final simplification83.1%
(FPCore (x y z a) :precision binary64 (if (or (<= a -0.047) (not (<= a 82000000.0))) (+ x (- z (tan a))) (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -0.047) || !(a <= 82000000.0)) {
tmp = x + (z - tan(a));
} else {
tmp = x + (tan((y + z)) - a);
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((a <= (-0.047d0)) .or. (.not. (a <= 82000000.0d0))) then
tmp = x + (z - tan(a))
else
tmp = x + (tan((y + z)) - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -0.047) || !(a <= 82000000.0)) {
tmp = x + (z - Math.tan(a));
} else {
tmp = x + (Math.tan((y + z)) - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (a <= -0.047) or not (a <= 82000000.0): tmp = x + (z - math.tan(a)) else: tmp = x + (math.tan((y + z)) - a) return tmp
function code(x, y, z, a) tmp = 0.0 if ((a <= -0.047) || !(a <= 82000000.0)) tmp = Float64(x + Float64(z - tan(a))); else tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((a <= -0.047) || ~((a <= 82000000.0))) tmp = x + (z - tan(a)); else tmp = x + (tan((y + z)) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -0.047], N[Not[LessEqual[a, 82000000.0]], $MachinePrecision]], N[(x + N[(z - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.047 \lor \neg \left(a \leq 82000000\right):\\
\;\;\;\;x + \left(z - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\end{array}
\end{array}
if a < -0.047 or 8.2e7 < a Initial program 84.2%
Taylor expanded in y around 0 64.8%
Taylor expanded in z around 0 36.5%
if -0.047 < a < 8.2e7Initial program 81.9%
Taylor expanded in a around 0 80.7%
Final simplification57.7%
(FPCore (x y z a) :precision binary64 (if (<= z 1.46) (+ x (- z (tan a))) x))
double code(double x, double y, double z, double a) {
double tmp;
if (z <= 1.46) {
tmp = x + (z - tan(a));
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (z <= 1.46d0) then
tmp = x + (z - tan(a))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (z <= 1.46) {
tmp = x + (z - Math.tan(a));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if z <= 1.46: tmp = x + (z - math.tan(a)) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (z <= 1.46) tmp = Float64(x + Float64(z - tan(a))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (z <= 1.46) tmp = x + (z - tan(a)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[z, 1.46], N[(x + N[(z - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.46:\\
\;\;\;\;x + \left(z - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < 1.46Initial program 88.2%
Taylor expanded in y around 0 60.6%
Taylor expanded in z around 0 43.1%
if 1.46 < z Initial program 67.5%
Taylor expanded in x around inf 22.6%
Final simplification38.0%
(FPCore (x y z a) :precision binary64 x)
double code(double x, double y, double z, double a) {
return x;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x
end function
public static double code(double x, double y, double z, double a) {
return x;
}
def code(x, y, z, a): return x
function code(x, y, z, a) return x end
function tmp = code(x, y, z, a) tmp = x; end
code[x_, y_, z_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 83.1%
Taylor expanded in x around inf 30.3%
Final simplification30.3%
herbie shell --seed 2023172
(FPCore (x y z a)
:name "tan-example (used to crash)"
:precision binary64
:pre (and (and (and (or (== x 0.0) (and (<= 0.5884142 x) (<= x 505.5909))) (or (and (<= -1.796658e+308 y) (<= y -9.425585e-310)) (and (<= 1.284938e-309 y) (<= y 1.751224e+308)))) (or (and (<= -1.776707e+308 z) (<= z -8.599796e-310)) (and (<= 3.293145e-311 z) (<= z 1.725154e+308)))) (or (and (<= -1.796658e+308 a) (<= a -9.425585e-310)) (and (<= 1.284938e-309 a) (<= a 1.751224e+308))))
(+ x (- (tan (+ y z)) (tan a))))