
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
(FPCore (x y z t) :precision binary64 (+ x (* (* y (- (tanh (/ t y)) (tanh (/ x y)))) z)))
double code(double x, double y, double z, double t) {
return x + ((y * (tanh((t / y)) - tanh((x / y)))) * z);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * (tanh((t / y)) - tanh((x / y)))) * z)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (Math.tanh((t / y)) - Math.tanh((x / y)))) * z);
}
def code(x, y, z, t): return x + ((y * (math.tanh((t / y)) - math.tanh((x / y)))) * z)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))) * z)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (tanh((t / y)) - tanh((x / y)))) * z); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) \cdot z
\end{array}
Initial program 95.1%
*-commutative95.1%
associate-*r*98.4%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* y z))))) (if (<= t_1 4e+303) t_1 (+ x (* z (- t x))))))
double code(double x, double y, double z, double t) {
double t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z));
double tmp;
if (t_1 <= 4e+303) {
tmp = t_1;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z))
if (t_1 <= 4d+303) then
tmp = t_1
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x + ((Math.tanh((t / y)) - Math.tanh((x / y))) * (y * z));
double tmp;
if (t_1 <= 4e+303) {
tmp = t_1;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = x + ((math.tanh((t / y)) - math.tanh((x / y))) * (y * z)) tmp = 0 if t_1 <= 4e+303: tmp = t_1 else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * Float64(y * z))) tmp = 0.0 if (t_1 <= 4e+303) tmp = t_1; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z)); tmp = 0.0; if (t_1 <= 4e+303) tmp = t_1; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 4e+303], t$95$1, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)\\
\mathbf{if}\;t\_1 \leq 4 \cdot 10^{+303}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4e303Initial program 98.4%
if 4e303 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 38.5%
Taylor expanded in y around inf 93.4%
Final simplification98.1%
(FPCore (x y z t)
:precision binary64
(if (<= y 3.4e-96)
x
(if (<= y 9.2e-75)
(* y (* (tanh (/ t y)) z))
(if (<= y 2.5e+59) x (+ x (* z (- t x)))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.4e-96) {
tmp = x;
} else if (y <= 9.2e-75) {
tmp = y * (tanh((t / y)) * z);
} else if (y <= 2.5e+59) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 3.4d-96) then
tmp = x
else if (y <= 9.2d-75) then
tmp = y * (tanh((t / y)) * z)
else if (y <= 2.5d+59) then
tmp = x
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.4e-96) {
tmp = x;
} else if (y <= 9.2e-75) {
tmp = y * (Math.tanh((t / y)) * z);
} else if (y <= 2.5e+59) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.4e-96: tmp = x elif y <= 9.2e-75: tmp = y * (math.tanh((t / y)) * z) elif y <= 2.5e+59: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.4e-96) tmp = x; elseif (y <= 9.2e-75) tmp = Float64(y * Float64(tanh(Float64(t / y)) * z)); elseif (y <= 2.5e+59) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 3.4e-96) tmp = x; elseif (y <= 9.2e-75) tmp = y * (tanh((t / y)) * z); elseif (y <= 2.5e+59) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.4e-96], x, If[LessEqual[y, 9.2e-75], N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.5e+59], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.4 \cdot 10^{-96}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{-75}:\\
\;\;\;\;y \cdot \left(\tanh \left(\frac{t}{y}\right) \cdot z\right)\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+59}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3.4000000000000001e-96 or 9.2e-75 < y < 2.4999999999999999e59Initial program 98.5%
Taylor expanded in x around 0 27.3%
associate-*r*27.2%
associate-/r*27.2%
div-sub27.2%
rec-exp27.2%
rec-exp27.2%
tanh-def-a89.8%
Simplified89.8%
Taylor expanded in x around inf 70.2%
if 3.4000000000000001e-96 < y < 9.2e-75Initial program 100.0%
Taylor expanded in x around 0 22.5%
associate-*r*22.5%
associate-/r*22.5%
div-sub22.5%
rec-exp22.5%
rec-exp22.5%
tanh-def-a100.0%
Simplified100.0%
+-commutative100.0%
associate-*l*100.0%
fma-define100.0%
Applied egg-rr100.0%
Taylor expanded in z around inf 1.1%
associate-/l*1.1%
associate-/l*1.1%
rec-exp1.1%
rec-exp1.1%
tanh-def-a72.4%
Simplified72.4%
if 2.4999999999999999e59 < y Initial program 78.3%
Taylor expanded in y around inf 82.0%
Final simplification72.3%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (tanh (/ t y)))) (if (<= y 1.65e+102) (+ x (* t_1 (* y z))) (+ x (* z (- (* y t_1) x))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 1.65e+102) {
tmp = x + (t_1 * (y * z));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (y <= 1.65d+102) then
tmp = x + (t_1 * (y * z))
else
tmp = x + (z * ((y * t_1) - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (y <= 1.65e+102) {
tmp = x + (t_1 * (y * z));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 1.65e+102: tmp = x + (t_1 * (y * z)) else: tmp = x + (z * ((y * t_1) - x)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 1.65e+102) tmp = Float64(x + Float64(t_1 * Float64(y * z))); else tmp = Float64(x + Float64(z * Float64(Float64(y * t_1) - x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 1.65e+102) tmp = x + (t_1 * (y * z)); else tmp = x + (z * ((y * t_1) - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 1.65e+102], N[(x + N[(t$95$1 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 1.65 \cdot 10^{+102}:\\
\;\;\;\;x + t\_1 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t\_1 - x\right)\\
\end{array}
\end{array}
if y < 1.64999999999999999e102Initial program 98.2%
Taylor expanded in x around 0 27.4%
associate-*r*27.3%
associate-/r*27.3%
div-sub27.3%
rec-exp27.3%
rec-exp27.3%
tanh-def-a89.4%
Simplified89.4%
if 1.64999999999999999e102 < y Initial program 75.5%
Taylor expanded in x around 0 46.6%
+-commutative46.6%
Simplified91.5%
Final simplification89.7%
(FPCore (x y z t) :precision binary64 (if (<= y 4.4e+98) (+ x (* (tanh (/ t y)) (* y z))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.4e+98) {
tmp = x + (tanh((t / y)) * (y * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 4.4d+98) then
tmp = x + (tanh((t / y)) * (y * z))
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.4e+98) {
tmp = x + (Math.tanh((t / y)) * (y * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 4.4e+98: tmp = x + (math.tanh((t / y)) * (y * z)) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 4.4e+98) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 4.4e+98) tmp = x + (tanh((t / y)) * (y * z)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.4e+98], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.4 \cdot 10^{+98}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 4.40000000000000017e98Initial program 98.6%
Taylor expanded in x around 0 27.3%
associate-*r*27.2%
associate-/r*27.2%
div-sub27.2%
rec-exp27.2%
rec-exp27.2%
tanh-def-a89.7%
Simplified89.7%
if 4.40000000000000017e98 < y Initial program 74.9%
Taylor expanded in y around inf 86.3%
Final simplification89.2%
(FPCore (x y z t) :precision binary64 (if (<= y 1.15e+198) x (if (<= y 1.02e+236) (* t z) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.15e+198) {
tmp = x;
} else if (y <= 1.02e+236) {
tmp = t * z;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 1.15d+198) then
tmp = x
else if (y <= 1.02d+236) then
tmp = t * z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.15e+198) {
tmp = x;
} else if (y <= 1.02e+236) {
tmp = t * z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.15e+198: tmp = x elif y <= 1.02e+236: tmp = t * z else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.15e+198) tmp = x; elseif (y <= 1.02e+236) tmp = Float64(t * z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.15e+198) tmp = x; elseif (y <= 1.02e+236) tmp = t * z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.15e+198], x, If[LessEqual[y, 1.02e+236], N[(t * z), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.15 \cdot 10^{+198}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+236}:\\
\;\;\;\;t \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < 1.15e198 or 1.01999999999999993e236 < y Initial program 95.4%
Taylor expanded in x around 0 28.3%
associate-*r*28.1%
associate-/r*28.1%
div-sub28.1%
rec-exp28.1%
rec-exp28.1%
tanh-def-a86.6%
Simplified86.6%
Taylor expanded in x around inf 66.2%
if 1.15e198 < y < 1.01999999999999993e236Initial program 75.0%
Taylor expanded in x around 0 26.5%
associate-*r*25.4%
associate-/r*25.4%
div-sub25.4%
rec-exp25.4%
rec-exp25.4%
tanh-def-a75.0%
Simplified75.0%
Taylor expanded in z around inf 26.3%
+-commutative26.3%
associate-/l*26.3%
rec-exp26.3%
rec-exp26.3%
tanh-def-a75.9%
Simplified75.9%
Taylor expanded in y around inf 100.0%
Taylor expanded in z around inf 78.0%
*-commutative78.0%
Simplified78.0%
Final simplification66.4%
(FPCore (x y z t) :precision binary64 (if (<= y 2.1e+60) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.1e+60) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 2.1d+60) then
tmp = x
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.1e+60) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.1e+60: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.1e+60) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.1e+60) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.1e+60], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{+60}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.1000000000000001e60Initial program 98.6%
Taylor expanded in x around 0 27.1%
associate-*r*27.0%
associate-/r*27.0%
div-sub27.0%
rec-exp27.0%
rec-exp27.0%
tanh-def-a90.3%
Simplified90.3%
Taylor expanded in x around inf 68.3%
if 2.1000000000000001e60 < y Initial program 78.3%
Taylor expanded in y around inf 82.0%
(FPCore (x y z t) :precision binary64 (if (<= y 2.8e-16) x (+ x (* t z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.8e-16) {
tmp = x;
} else {
tmp = x + (t * z);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 2.8d-16) then
tmp = x
else
tmp = x + (t * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.8e-16) {
tmp = x;
} else {
tmp = x + (t * z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.8e-16: tmp = x else: tmp = x + (t * z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.8e-16) tmp = x; else tmp = Float64(x + Float64(t * z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.8e-16) tmp = x; else tmp = x + (t * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.8e-16], x, N[(x + N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.8 \cdot 10^{-16}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + t \cdot z\\
\end{array}
\end{array}
if y < 2.8000000000000001e-16Initial program 98.5%
Taylor expanded in x around 0 25.9%
associate-*r*25.8%
associate-/r*25.8%
div-sub25.8%
rec-exp25.8%
rec-exp25.8%
tanh-def-a90.2%
Simplified90.2%
Taylor expanded in x around inf 69.4%
if 2.8000000000000001e-16 < y Initial program 83.2%
Taylor expanded in y around inf 80.0%
Taylor expanded in t around inf 68.9%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 95.1%
Taylor expanded in x around 0 28.2%
associate-*r*28.0%
associate-/r*28.0%
div-sub28.0%
rec-exp28.0%
rec-exp28.0%
tanh-def-a86.4%
Simplified86.4%
Taylor expanded in x around inf 65.6%
(FPCore (x y z t) :precision binary64 (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
return x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + (y * (z * (tanh((t / y)) - tanh((x / y)))))
end function
public static double code(double x, double y, double z, double t) {
return x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
}
def code(x, y, z, t): return x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y)))))
function code(x, y, z, t) return Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))) end
function tmp = code(x, y, z, t) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y))))); end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)
\end{array}
herbie shell --seed 2024097
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:alt
(+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))