
(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 11 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 (- (/ (+ (tan y) (tan z)) (- 1.0 (/ (* (sin y) (sin z)) (* (cos y) (cos z))))) (/ (sin a) (cos a)))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / (1.0 - ((sin(y) * sin(z)) / (cos(y) * cos(z))))) - (sin(a) / cos(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 - ((sin(y) * sin(z)) / (cos(y) * cos(z))))) - (sin(a) / cos(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.sin(y) * Math.sin(z)) / (Math.cos(y) * Math.cos(z))))) - (Math.sin(a) / Math.cos(a)));
}
def code(x, y, z, a): return x + (((math.tan(y) + math.tan(z)) / (1.0 - ((math.sin(y) * math.sin(z)) / (math.cos(y) * math.cos(z))))) - (math.sin(a) / math.cos(a)))
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(Float64(sin(y) * sin(z)) / Float64(cos(y) * cos(z))))) - Float64(sin(a) / cos(a)))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) / (1.0 - ((sin(y) * sin(z)) / (cos(y) * cos(z))))) - (sin(a) / cos(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[(N[Sin[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[y], $MachinePrecision] * N[Cos[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan y + \tan z}{1 - \frac{\sin y \cdot \sin z}{\cos y \cdot \cos z}} - \frac{\sin a}{\cos a}\right)
\end{array}
Initial program 79.5%
tan-sum99.7%
tan-quot99.7%
frac-sub99.7%
Applied egg-rr99.7%
div-sub99.7%
times-frac99.7%
*-inverses99.7%
cancel-sign-sub-inv99.7%
Simplified99.7%
Taylor expanded in y around inf 99.7%
Final simplification99.7%
(FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (/ (* (sin y) (sin z)) (* (cos y) (cos z))))) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / (1.0 - ((sin(y) * sin(z)) / (cos(y) * cos(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 - ((sin(y) * sin(z)) / (cos(y) * cos(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.sin(y) * Math.sin(z)) / (Math.cos(y) * Math.cos(z))))) - Math.tan(a));
}
def code(x, y, z, a): return x + (((math.tan(y) + math.tan(z)) / (1.0 - ((math.sin(y) * math.sin(z)) / (math.cos(y) * math.cos(z))))) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(Float64(sin(y) * sin(z)) / Float64(cos(y) * cos(z))))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) / (1.0 - ((sin(y) * sin(z)) / (cos(y) * cos(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[(N[Sin[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[y], $MachinePrecision] * N[Cos[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan y + \tan z}{1 - \frac{\sin y \cdot \sin z}{\cos y \cdot \cos z}} - \tan a\right)
\end{array}
Initial program 79.5%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in y around inf 99.7%
Final simplification99.7%
(FPCore (x y z a)
:precision binary64
(if (<= (tan a) -2e-7)
(fma (sin (+ y z)) (/ 1.0 (cos (+ y z))) (- x (tan a)))
(if (<= (tan a) 5e-82)
(+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) a))
(+ x (- (tan (+ y z)) (/ (sin a) (cos a)))))))
double code(double x, double y, double z, double a) {
double tmp;
if (tan(a) <= -2e-7) {
tmp = fma(sin((y + z)), (1.0 / cos((y + z))), (x - tan(a)));
} else if (tan(a) <= 5e-82) {
tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a);
} else {
tmp = x + (tan((y + z)) - (sin(a) / cos(a)));
}
return tmp;
}
function code(x, y, z, a) tmp = 0.0 if (tan(a) <= -2e-7) tmp = fma(sin(Float64(y + z)), Float64(1.0 / cos(Float64(y + z))), Float64(x - tan(a))); elseif (tan(a) <= 5e-82) tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - a)); else tmp = Float64(x + Float64(tan(Float64(y + z)) - Float64(sin(a) / cos(a)))); end return tmp end
code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -2e-7], N[(N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 5e-82], 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[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -2 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, x - \tan a\right)\\
\mathbf{elif}\;\tan a \leq 5 \cdot 10^{-82}:\\
\;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \frac{\sin a}{\cos a}\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -1.9999999999999999e-7Initial program 78.0%
+-commutative78.0%
associate-+l-78.0%
tan-quot77.9%
div-inv78.0%
fmm-def78.2%
Applied egg-rr78.2%
if -1.9999999999999999e-7 < (tan.f64 a) < 4.9999999999999998e-82Initial program 79.0%
tan-sum99.7%
tan-quot99.7%
frac-sub99.7%
Applied egg-rr99.7%
div-sub99.7%
times-frac99.7%
*-inverses99.7%
cancel-sign-sub-inv99.7%
Simplified99.7%
Taylor expanded in a around 0 99.7%
mul-1-neg99.7%
Simplified99.7%
if 4.9999999999999998e-82 < (tan.f64 a) Initial program 81.9%
tan-sum99.7%
tan-quot99.7%
frac-sub99.7%
Applied egg-rr99.7%
div-sub99.7%
times-frac99.7%
*-inverses99.7%
cancel-sign-sub-inv99.7%
Simplified99.7%
tan-sum82.0%
*-un-lft-identity82.0%
Applied egg-rr82.0%
*-lft-identity82.0%
Simplified82.0%
Final simplification89.0%
(FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) (/ (sin a) (cos a)))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - (sin(a) / cos(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)))) - (sin(a) / cos(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.sin(a) / Math.cos(a)));
}
def code(x, y, z, a): return x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - (math.sin(a) / math.cos(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)))) - Float64(sin(a) / cos(a)))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - (sin(a) / cos(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[(N[Sin[a], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - \frac{\sin a}{\cos a}\right)
\end{array}
Initial program 79.5%
tan-sum99.7%
tan-quot99.7%
frac-sub99.7%
Applied egg-rr99.7%
div-sub99.7%
times-frac99.7%
*-inverses99.7%
cancel-sign-sub-inv99.7%
Simplified99.7%
Final simplification99.7%
(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 79.5%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (/ (sin a) (cos a)))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - (sin(a) / cos(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)) - (sin(a) / cos(a)))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - (Math.sin(a) / Math.cos(a)));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - (math.sin(a) / math.cos(a)))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - Float64(sin(a) / cos(a)))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - (sin(a) / cos(a))); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \frac{\sin a}{\cos a}\right)
\end{array}
Initial program 79.5%
tan-sum99.7%
tan-quot99.7%
frac-sub99.7%
Applied egg-rr99.7%
div-sub99.7%
times-frac99.7%
*-inverses99.7%
cancel-sign-sub-inv99.7%
Simplified99.7%
tan-sum79.5%
*-un-lft-identity79.5%
Applied egg-rr79.5%
*-lft-identity79.5%
Simplified79.5%
Final simplification79.5%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) 2e-6) (+ x (- (tan y) (tan a))) (* x (+ (/ (tan (+ y z)) x) 1.0))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 2e-6) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = x * ((tan((y + z)) / x) + 1.0);
}
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) <= 2d-6) then
tmp = x + (tan(y) - tan(a))
else
tmp = x * ((tan((y + z)) / x) + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 2e-6) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = x * ((Math.tan((y + z)) / x) + 1.0);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= 2e-6: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x * ((math.tan((y + z)) / x) + 1.0) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= 2e-6) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x * Float64(Float64(tan(Float64(y + z)) / x) + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= 2e-6) tmp = x + (tan(y) - tan(a)); else tmp = x * ((tan((y + z)) / x) + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], 2e-6], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq 2 \cdot 10^{-6}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{\tan \left(y + z\right)}{x} + 1\right)\\
\end{array}
\end{array}
if (+.f64 y z) < 1.99999999999999991e-6Initial program 85.1%
Taylor expanded in z around 0 72.0%
+-commutative72.0%
associate--l+72.0%
Simplified72.0%
tan-quot72.0%
tan-quot72.0%
associate-+r-72.0%
Applied egg-rr72.0%
+-commutative72.0%
associate--l+72.0%
Simplified72.0%
if 1.99999999999999991e-6 < (+.f64 y z) Initial program 69.3%
Taylor expanded in x around inf 69.0%
associate--l+69.0%
+-commutative69.0%
*-commutative69.0%
+-commutative69.0%
associate-/r*69.1%
Simplified69.1%
Taylor expanded in a around 0 45.0%
associate-/r*45.0%
remove-double-neg45.0%
mul-1-neg45.0%
sub-neg45.0%
remove-double-neg45.0%
mul-1-neg45.0%
sub-neg45.0%
sub-neg45.0%
mul-1-neg45.0%
remove-double-neg45.0%
+-commutative45.0%
remove-double-neg45.0%
mul-1-neg45.0%
sub-neg45.0%
sub-neg45.0%
mul-1-neg45.0%
Simplified45.0%
*-un-lft-identity45.0%
associate-/r*45.0%
quot-tan45.1%
Applied egg-rr45.1%
*-lft-identity45.1%
+-commutative45.1%
Simplified45.1%
Final simplification62.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 79.5%
Final simplification79.5%
(FPCore (x y z a) :precision binary64 (* x (+ (/ (tan (+ y z)) x) 1.0)))
double code(double x, double y, double z, double a) {
return x * ((tan((y + z)) / x) + 1.0);
}
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)) / x) + 1.0d0)
end function
public static double code(double x, double y, double z, double a) {
return x * ((Math.tan((y + z)) / x) + 1.0);
}
def code(x, y, z, a): return x * ((math.tan((y + z)) / x) + 1.0)
function code(x, y, z, a) return Float64(x * Float64(Float64(tan(Float64(y + z)) / x) + 1.0)) end
function tmp = code(x, y, z, a) tmp = x * ((tan((y + z)) / x) + 1.0); end
code[x_, y_, z_, a_] := N[(x * N[(N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\frac{\tan \left(y + z\right)}{x} + 1\right)
\end{array}
Initial program 79.5%
Taylor expanded in x around inf 79.2%
associate--l+79.2%
+-commutative79.2%
*-commutative79.2%
+-commutative79.2%
associate-/r*79.3%
Simplified79.3%
Taylor expanded in a around 0 51.2%
associate-/r*51.2%
remove-double-neg51.2%
mul-1-neg51.2%
sub-neg51.2%
remove-double-neg51.2%
mul-1-neg51.2%
sub-neg51.2%
sub-neg51.2%
mul-1-neg51.2%
remove-double-neg51.2%
+-commutative51.2%
remove-double-neg51.2%
mul-1-neg51.2%
sub-neg51.2%
sub-neg51.2%
mul-1-neg51.2%
Simplified51.2%
*-un-lft-identity51.2%
associate-/r*51.2%
quot-tan51.3%
Applied egg-rr51.3%
*-lft-identity51.3%
+-commutative51.3%
Simplified51.3%
Final simplification51.3%
(FPCore (x y z a) :precision binary64 -1.0)
double code(double x, double y, double z, double a) {
return -1.0;
}
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 = -1.0d0
end function
public static double code(double x, double y, double z, double a) {
return -1.0;
}
def code(x, y, z, a): return -1.0
function code(x, y, z, a) return -1.0 end
function tmp = code(x, y, z, a) tmp = -1.0; end
code[x_, y_, z_, a_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 79.5%
expm1-log1p-u76.2%
expm1-undefine76.2%
+-commutative76.2%
associate-+l-76.2%
Applied egg-rr76.2%
expm1-define76.1%
associate--r-76.2%
+-commutative76.2%
Simplified76.2%
Taylor expanded in x around inf 22.1%
mul-1-neg22.1%
log-rec22.1%
remove-double-neg22.1%
Simplified22.1%
Taylor expanded in x around 0 2.7%
Final simplification2.7%
(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 79.5%
Taylor expanded in x around inf 33.2%
Final simplification33.2%
herbie shell --seed 2024112
(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))))