
(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 10 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 (let* ((t_1 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* z y))))) (if (<= t_1 2e+307) 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))) * (z * y));
double tmp;
if (t_1 <= 2e+307) {
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))) * (z * y))
if (t_1 <= 2d+307) 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))) * (z * y));
double tmp;
if (t_1 <= 2e+307) {
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))) * (z * y)) tmp = 0 if t_1 <= 2e+307: 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(z * y))) tmp = 0.0 if (t_1 <= 2e+307) 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))) * (z * y)); tmp = 0.0; if (t_1 <= 2e+307) 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[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e+307], 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(z \cdot y\right)\\
\mathbf{if}\;t_1 \leq 2 \cdot 10^{+307}:\\
\;\;\;\;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))))) < 1.99999999999999997e307Initial program 98.5%
if 1.99999999999999997e307 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 48.0%
Taylor expanded in y around inf 100.0%
Final simplification98.6%
(FPCore (x y z t) :precision binary64 (fma z (* y (- (tanh (/ t y)) (tanh (/ x y)))) x))
double code(double x, double y, double z, double t) {
return fma(z, (y * (tanh((t / y)) - tanh((x / y)))), x);
}
function code(x, y, z, t) return fma(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x) end
code[x_, y_, z_, t_] := N[(z * N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
\end{array}
Initial program 96.0%
+-commutative96.0%
*-commutative96.0%
associate-*l*98.6%
fma-def98.6%
Simplified98.6%
Final simplification98.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 7.8e+64)
(fma z (* y t_1) x)
(if (<= y 3.8e+194)
(fma x (- 1.0 z) (* y (* z t_1)))
(+ x (* z (- t x)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 7.8e+64) {
tmp = fma(z, (y * t_1), x);
} else if (y <= 3.8e+194) {
tmp = fma(x, (1.0 - z), (y * (z * t_1)));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 7.8e+64) tmp = fma(z, Float64(y * t_1), x); elseif (y <= 3.8e+194) tmp = fma(x, Float64(1.0 - z), Float64(y * Float64(z * t_1))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 7.8e+64], N[(z * N[(y * t$95$1), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 3.8e+194], N[(x * N[(1.0 - z), $MachinePrecision] + N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 7.8 \cdot 10^{+64}:\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot t_1, x\right)\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+194}:\\
\;\;\;\;\mathsf{fma}\left(x, 1 - z, y \cdot \left(z \cdot t_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 7.7999999999999996e64Initial program 98.1%
+-commutative98.1%
*-commutative98.1%
associate-*l*99.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in x around 0 20.2%
associate-/r*20.2%
div-sub20.2%
rec-exp20.2%
rec-exp20.2%
tanh-def-a85.9%
Simplified85.9%
if 7.7999999999999996e64 < y < 3.7999999999999999e194Initial program 90.5%
Taylor expanded in x around 0 46.5%
fma-def46.5%
mul-1-neg46.5%
associate-/r*46.5%
div-sub46.5%
rec-exp46.5%
Simplified88.1%
if 3.7999999999999999e194 < y Initial program 84.4%
Taylor expanded in y around inf 96.0%
Final simplification87.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 1.2e+65)
(fma z (* y t_1) x)
(if (<= y 2.1e+192)
(+ x (* y (* z (- t_1 (/ x y)))))
(+ x (* z (- t x)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 1.2e+65) {
tmp = fma(z, (y * t_1), x);
} else if (y <= 2.1e+192) {
tmp = x + (y * (z * (t_1 - (x / y))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 1.2e+65) tmp = fma(z, Float64(y * t_1), x); elseif (y <= 2.1e+192) tmp = Float64(x + Float64(y * Float64(z * Float64(t_1 - Float64(x / y))))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 1.2e+65], N[(z * N[(y * t$95$1), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 2.1e+192], N[(x + N[(y * N[(z * N[(t$95$1 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 1.2 \cdot 10^{+65}:\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot t_1, x\right)\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+192}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(t_1 - \frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.2000000000000001e65Initial program 98.1%
+-commutative98.1%
*-commutative98.1%
associate-*l*99.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in x around 0 20.2%
associate-/r*20.2%
div-sub20.2%
rec-exp20.2%
rec-exp20.2%
tanh-def-a85.9%
Simplified85.9%
if 1.2000000000000001e65 < y < 2.09999999999999995e192Initial program 90.5%
Taylor expanded in x around 0 78.6%
Taylor expanded in z around 0 36.6%
*-commutative36.6%
Simplified88.1%
if 2.09999999999999995e192 < y Initial program 84.4%
Taylor expanded in y around inf 96.0%
Final simplification87.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 1.85e+66)
(+ x (* y (* z t_1)))
(if (<= y 2.2e+192)
(+ x (* y (* z (- t_1 (/ x y)))))
(+ x (* z (- t x)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 1.85e+66) {
tmp = x + (y * (z * t_1));
} else if (y <= 2.2e+192) {
tmp = x + (y * (z * (t_1 - (x / y))));
} 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 = tanh((t / y))
if (y <= 1.85d+66) then
tmp = x + (y * (z * t_1))
else if (y <= 2.2d+192) then
tmp = x + (y * (z * (t_1 - (x / y))))
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 = Math.tanh((t / y));
double tmp;
if (y <= 1.85e+66) {
tmp = x + (y * (z * t_1));
} else if (y <= 2.2e+192) {
tmp = x + (y * (z * (t_1 - (x / y))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 1.85e+66: tmp = x + (y * (z * t_1)) elif y <= 2.2e+192: tmp = x + (y * (z * (t_1 - (x / y)))) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 1.85e+66) tmp = Float64(x + Float64(y * Float64(z * t_1))); elseif (y <= 2.2e+192) tmp = Float64(x + Float64(y * Float64(z * Float64(t_1 - Float64(x / y))))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 1.85e+66) tmp = x + (y * (z * t_1)); elseif (y <= 2.2e+192) tmp = x + (y * (z * (t_1 - (x / y)))); else tmp = x + (z * (t - 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.85e+66], N[(x + N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.2e+192], N[(x + N[(y * N[(z * N[(t$95$1 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 1.85 \cdot 10^{+66}:\\
\;\;\;\;x + y \cdot \left(z \cdot t_1\right)\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{+192}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(t_1 - \frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.85e66Initial program 98.1%
Taylor expanded in x around 0 20.2%
associate-/r*20.2%
div-sub20.2%
rec-exp20.2%
rec-exp20.2%
tanh-def-a85.3%
Simplified85.3%
if 1.85e66 < y < 2.2000000000000001e192Initial program 90.5%
Taylor expanded in x around 0 78.6%
Taylor expanded in z around 0 36.6%
*-commutative36.6%
Simplified88.1%
if 2.2000000000000001e192 < y Initial program 84.4%
Taylor expanded in y around inf 96.0%
Final simplification86.6%
(FPCore (x y z t) :precision binary64 (if (<= y 1.65e+186) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.65e+186) {
tmp = x + (y * (z * tanh((t / y))));
} 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 <= 1.65d+186) then
tmp = x + (y * (z * tanh((t / y))))
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 <= 1.65e+186) {
tmp = x + (y * (z * Math.tanh((t / y))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.65e+186: tmp = x + (y * (z * math.tanh((t / y)))) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.65e+186) tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); 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 <= 1.65e+186) tmp = x + (y * (z * tanh((t / y)))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.65e+186], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.65 \cdot 10^{+186}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.65000000000000012e186Initial program 97.1%
Taylor expanded in x around 0 22.9%
associate-/r*22.9%
div-sub22.9%
rec-exp22.9%
rec-exp22.9%
tanh-def-a85.1%
Simplified85.1%
if 1.65000000000000012e186 < y Initial program 85.7%
Taylor expanded in y around inf 92.6%
Final simplification85.8%
(FPCore (x y z t) :precision binary64 (if (<= y 7.8e+64) x (if (or (<= y 1.9e+205) (not (<= y 2.3e+217))) (* x (- 1.0 z)) (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.8e+64) {
tmp = x;
} else if ((y <= 1.9e+205) || !(y <= 2.3e+217)) {
tmp = x * (1.0 - z);
} else {
tmp = z * t;
}
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 <= 7.8d+64) then
tmp = x
else if ((y <= 1.9d+205) .or. (.not. (y <= 2.3d+217))) then
tmp = x * (1.0d0 - z)
else
tmp = z * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.8e+64) {
tmp = x;
} else if ((y <= 1.9e+205) || !(y <= 2.3e+217)) {
tmp = x * (1.0 - z);
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 7.8e+64: tmp = x elif (y <= 1.9e+205) or not (y <= 2.3e+217): tmp = x * (1.0 - z) else: tmp = z * t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 7.8e+64) tmp = x; elseif ((y <= 1.9e+205) || !(y <= 2.3e+217)) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 7.8e+64) tmp = x; elseif ((y <= 1.9e+205) || ~((y <= 2.3e+217))) tmp = x * (1.0 - z); else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 7.8e+64], x, If[Or[LessEqual[y, 1.9e+205], N[Not[LessEqual[y, 2.3e+217]], $MachinePrecision]], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.8 \cdot 10^{+64}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{+205} \lor \neg \left(y \leq 2.3 \cdot 10^{+217}\right):\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if y < 7.7999999999999996e64Initial program 98.1%
Taylor expanded in x around inf 69.2%
if 7.7999999999999996e64 < y < 1.9e205 or 2.2999999999999999e217 < y Initial program 89.0%
Taylor expanded in y around inf 79.0%
Taylor expanded in x around inf 60.1%
mul-1-neg60.1%
unsub-neg60.1%
Simplified60.1%
if 1.9e205 < y < 2.2999999999999999e217Initial program 74.2%
Taylor expanded in y around inf 99.2%
Taylor expanded in t around inf 99.2%
Taylor expanded in x around 0 74.7%
*-commutative74.7%
Simplified74.7%
Final simplification67.6%
(FPCore (x y z t) :precision binary64 (if (<= y 9.5e+57) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 9.5e+57) {
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 <= 9.5d+57) 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 <= 9.5e+57) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 9.5e+57: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 9.5e+57) 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 <= 9.5e+57) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 9.5e+57], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9.5 \cdot 10^{+57}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 9.4999999999999997e57Initial program 98.1%
Taylor expanded in x around inf 69.4%
if 9.4999999999999997e57 < y Initial program 88.3%
Taylor expanded in y around inf 79.6%
Final simplification71.6%
(FPCore (x y z t) :precision binary64 (if (<= y 1.25e+16) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.25e+16) {
tmp = x;
} else {
tmp = x + (z * t);
}
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.25d+16) then
tmp = x
else
tmp = x + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.25e+16) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.25e+16: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.25e+16) tmp = x; else tmp = Float64(x + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.25e+16) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.25e+16], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.25 \cdot 10^{+16}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 1.25e16Initial program 97.9%
Taylor expanded in x around inf 71.0%
if 1.25e16 < y Initial program 90.4%
Taylor expanded in y around inf 72.2%
Taylor expanded in t around inf 65.0%
Final simplification69.5%
(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 96.0%
Taylor expanded in x around inf 64.1%
Final simplification64.1%
(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 2024018
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:herbie-target
(+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))