
(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 11 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 (fma (* y (- (tanh (/ t y)) (tanh (/ x y)))) z x))
double code(double x, double y, double z, double t) {
return fma((y * (tanh((t / y)) - tanh((x / y)))), z, x);
}
function code(x, y, z, t) return fma(Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), z, x) end
code[x_, y_, z_, t_] := N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), z, x\right)
\end{array}
Initial program 94.4%
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
fma-defineN/A
fma-lowering-fma.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f6498.0%
Applied egg-rr98.0%
Final simplification98.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* y z))))) (if (<= t_1 5e+303) t_1 (* 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 <= 5e+303) {
tmp = t_1;
} else {
tmp = 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 <= 5d+303) then
tmp = t_1
else
tmp = 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 <= 5e+303) {
tmp = t_1;
} else {
tmp = 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 <= 5e+303: tmp = t_1 else: tmp = 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 <= 5e+303) tmp = t_1; else tmp = 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 <= 5e+303) tmp = t_1; else tmp = 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, 5e+303], t$95$1, N[(z * N[(t - x), $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 5 \cdot 10^{+303}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;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))))) < 4.9999999999999997e303Initial program 97.7%
if 4.9999999999999997e303 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 41.9%
Taylor expanded in y around inf
/-lowering-/.f64N/A
--lowering--.f6442.4%
Simplified42.4%
Taylor expanded in z around inf
*-lowering-*.f64N/A
--lowering--.f6493.9%
Simplified93.9%
Final simplification97.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* (* y z) (- (tanh (/ t y)) (/ x y))))))
(if (<= t -8.5e+78)
t_1
(if (<= t 2.65e+67) (fma (* y (- (/ t y) (tanh (/ x y)))) z x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = x + ((y * z) * (tanh((t / y)) - (x / y)));
double tmp;
if (t <= -8.5e+78) {
tmp = t_1;
} else if (t <= 2.65e+67) {
tmp = fma((y * ((t / y) - tanh((x / y)))), z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - Float64(x / y)))) tmp = 0.0 if (t <= -8.5e+78) tmp = t_1; elseif (t <= 2.65e+67) tmp = fma(Float64(y * Float64(Float64(t / y) - tanh(Float64(x / y)))), z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -8.5e+78], t$95$1, If[LessEqual[t, 2.65e+67], N[(N[(y * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)\\
\mathbf{if}\;t \leq -8.5 \cdot 10^{+78}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2.65 \cdot 10^{+67}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -8.50000000000000079e78 or 2.65e67 < t Initial program 99.0%
Taylor expanded in x around 0
/-lowering-/.f6474.3%
Simplified74.3%
if -8.50000000000000079e78 < t < 2.65e67Initial program 91.2%
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
fma-defineN/A
fma-lowering-fma.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f6496.5%
Applied egg-rr96.5%
Taylor expanded in t around 0
/-lowering-/.f6488.8%
Simplified88.8%
Final simplification82.8%
(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 94.4%
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f6497.9%
Applied egg-rr97.9%
Final simplification97.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* (* y z) (- (tanh (/ t y)) (/ x y))))))
(if (<= t -2.25e+70)
t_1
(if (<= t 3.7e+63)
(+ x (* z (- (* y (/ t y)) (* y (tanh (/ x y))))))
t_1))))
double code(double x, double y, double z, double t) {
double t_1 = x + ((y * z) * (tanh((t / y)) - (x / y)));
double tmp;
if (t <= -2.25e+70) {
tmp = t_1;
} else if (t <= 3.7e+63) {
tmp = x + (z * ((y * (t / y)) - (y * tanh((x / y)))));
} else {
tmp = t_1;
}
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 + ((y * z) * (tanh((t / y)) - (x / y)))
if (t <= (-2.25d+70)) then
tmp = t_1
else if (t <= 3.7d+63) then
tmp = x + (z * ((y * (t / y)) - (y * tanh((x / y)))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x + ((y * z) * (Math.tanh((t / y)) - (x / y)));
double tmp;
if (t <= -2.25e+70) {
tmp = t_1;
} else if (t <= 3.7e+63) {
tmp = x + (z * ((y * (t / y)) - (y * Math.tanh((x / y)))));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + ((y * z) * (math.tanh((t / y)) - (x / y))) tmp = 0 if t <= -2.25e+70: tmp = t_1 elif t <= 3.7e+63: tmp = x + (z * ((y * (t / y)) - (y * math.tanh((x / y))))) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - Float64(x / y)))) tmp = 0.0 if (t <= -2.25e+70) tmp = t_1; elseif (t <= 3.7e+63) tmp = Float64(x + Float64(z * Float64(Float64(y * Float64(t / y)) - Float64(y * tanh(Float64(x / y)))))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + ((y * z) * (tanh((t / y)) - (x / y))); tmp = 0.0; if (t <= -2.25e+70) tmp = t_1; elseif (t <= 3.7e+63) tmp = x + (z * ((y * (t / y)) - (y * tanh((x / y))))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -2.25e+70], t$95$1, If[LessEqual[t, 3.7e+63], N[(x + N[(z * N[(N[(y * N[(t / y), $MachinePrecision]), $MachinePrecision] - N[(y * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)\\
\mathbf{if}\;t \leq -2.25 \cdot 10^{+70}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 3.7 \cdot 10^{+63}:\\
\;\;\;\;x + z \cdot \left(y \cdot \frac{t}{y} - y \cdot \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.25e70 or 3.69999999999999968e63 < t Initial program 99.0%
Taylor expanded in x around 0
/-lowering-/.f6474.3%
Simplified74.3%
if -2.25e70 < t < 3.69999999999999968e63Initial program 91.2%
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f6496.5%
Applied egg-rr96.5%
Taylor expanded in t around 0
/-lowering-/.f6488.8%
Simplified88.8%
*-commutativeN/A
sub-negN/A
distribute-rgt-inN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
neg-sub0N/A
--lowering--.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f6488.8%
Applied egg-rr88.8%
Final simplification82.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* (* y z) (- (tanh (/ t y)) (/ x y))))))
(if (<= t -4.2e+70)
t_1
(if (<= t 5.2e+64) (+ x (* z (* y (- (/ t y) (tanh (/ x y)))))) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = x + ((y * z) * (tanh((t / y)) - (x / y)));
double tmp;
if (t <= -4.2e+70) {
tmp = t_1;
} else if (t <= 5.2e+64) {
tmp = x + (z * (y * ((t / y) - tanh((x / y)))));
} else {
tmp = t_1;
}
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 + ((y * z) * (tanh((t / y)) - (x / y)))
if (t <= (-4.2d+70)) then
tmp = t_1
else if (t <= 5.2d+64) then
tmp = x + (z * (y * ((t / y) - tanh((x / y)))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x + ((y * z) * (Math.tanh((t / y)) - (x / y)));
double tmp;
if (t <= -4.2e+70) {
tmp = t_1;
} else if (t <= 5.2e+64) {
tmp = x + (z * (y * ((t / y) - Math.tanh((x / y)))));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + ((y * z) * (math.tanh((t / y)) - (x / y))) tmp = 0 if t <= -4.2e+70: tmp = t_1 elif t <= 5.2e+64: tmp = x + (z * (y * ((t / y) - math.tanh((x / y))))) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - Float64(x / y)))) tmp = 0.0 if (t <= -4.2e+70) tmp = t_1; elseif (t <= 5.2e+64) tmp = Float64(x + Float64(z * Float64(y * Float64(Float64(t / y) - tanh(Float64(x / y)))))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + ((y * z) * (tanh((t / y)) - (x / y))); tmp = 0.0; if (t <= -4.2e+70) tmp = t_1; elseif (t <= 5.2e+64) tmp = x + (z * (y * ((t / y) - tanh((x / y))))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -4.2e+70], t$95$1, If[LessEqual[t, 5.2e+64], N[(x + N[(z * N[(y * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)\\
\mathbf{if}\;t \leq -4.2 \cdot 10^{+70}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 5.2 \cdot 10^{+64}:\\
\;\;\;\;x + z \cdot \left(y \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -4.20000000000000015e70 or 5.19999999999999994e64 < t Initial program 99.0%
Taylor expanded in x around 0
/-lowering-/.f6474.3%
Simplified74.3%
if -4.20000000000000015e70 < t < 5.19999999999999994e64Initial program 91.2%
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f6496.5%
Applied egg-rr96.5%
Taylor expanded in t around 0
/-lowering-/.f6488.8%
Simplified88.8%
Final simplification82.8%
(FPCore (x y z t)
:precision binary64
(if (<= y 9.5e-37)
x
(if (<= y 6.8e+167)
(+ x (* (* y z) (- (tanh (/ t y)) (/ x y))))
(+ x (* z (- t x))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 9.5e-37) {
tmp = x;
} else if (y <= 6.8e+167) {
tmp = x + ((y * z) * (tanh((t / y)) - (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) :: tmp
if (y <= 9.5d-37) then
tmp = x
else if (y <= 6.8d+167) then
tmp = x + ((y * z) * (tanh((t / y)) - (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 tmp;
if (y <= 9.5e-37) {
tmp = x;
} else if (y <= 6.8e+167) {
tmp = x + ((y * z) * (Math.tanh((t / y)) - (x / y)));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 9.5e-37: tmp = x elif y <= 6.8e+167: tmp = x + ((y * z) * (math.tanh((t / y)) - (x / y))) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 9.5e-37) tmp = x; elseif (y <= 6.8e+167) tmp = Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - Float64(x / 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 <= 9.5e-37) tmp = x; elseif (y <= 6.8e+167) tmp = x + ((y * z) * (tanh((t / y)) - (x / y))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 9.5e-37], x, If[LessEqual[y, 6.8e+167], N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9.5 \cdot 10^{-37}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{+167}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 9.49999999999999927e-37Initial program 96.3%
Taylor expanded in x around inf
Simplified66.7%
if 9.49999999999999927e-37 < y < 6.8000000000000001e167Initial program 94.7%
Taylor expanded in x around 0
/-lowering-/.f6487.0%
Simplified87.0%
if 6.8000000000000001e167 < y Initial program 82.9%
Taylor expanded in y around inf
+-lowering-+.f64N/A
*-lowering-*.f64N/A
--lowering--.f6492.1%
Simplified92.1%
(FPCore (x y z t) :precision binary64 (if (<= y 6.5e+42) x (if (<= y 1.25e+246) (+ x (* t z)) (* x (- 1.0 z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.5e+42) {
tmp = x;
} else if (y <= 1.25e+246) {
tmp = x + (t * z);
} else {
tmp = x * (1.0 - 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 <= 6.5d+42) then
tmp = x
else if (y <= 1.25d+246) then
tmp = x + (t * z)
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.5e+42) {
tmp = x;
} else if (y <= 1.25e+246) {
tmp = x + (t * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 6.5e+42: tmp = x elif y <= 1.25e+246: tmp = x + (t * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 6.5e+42) tmp = x; elseif (y <= 1.25e+246) tmp = Float64(x + Float64(t * z)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 6.5e+42) tmp = x; elseif (y <= 1.25e+246) tmp = x + (t * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.5e+42], x, If[LessEqual[y, 1.25e+246], N[(x + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{+42}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{+246}:\\
\;\;\;\;x + t \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 6.50000000000000052e42Initial program 96.6%
Taylor expanded in x around inf
Simplified64.4%
if 6.50000000000000052e42 < y < 1.24999999999999994e246Initial program 88.2%
Taylor expanded in y around inf
/-lowering-/.f64N/A
--lowering--.f6476.7%
Simplified76.7%
Taylor expanded in t around inf
*-commutativeN/A
*-lowering-*.f6475.8%
Simplified75.8%
if 1.24999999999999994e246 < y Initial program 72.3%
Taylor expanded in y around inf
/-lowering-/.f64N/A
--lowering--.f6472.3%
Simplified72.3%
Taylor expanded in x around inf
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f6486.7%
Simplified86.7%
Final simplification67.0%
(FPCore (x y z t) :precision binary64 (if (<= y 1.2e-36) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.2e-36) {
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 <= 1.2d-36) 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 <= 1.2e-36) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.2e-36: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.2e-36) 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 <= 1.2e-36) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.2e-36], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.2 \cdot 10^{-36}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.2e-36Initial program 96.3%
Taylor expanded in x around inf
Simplified66.7%
if 1.2e-36 < y Initial program 89.2%
Taylor expanded in y around inf
+-lowering-+.f64N/A
*-lowering-*.f64N/A
--lowering--.f6481.1%
Simplified81.1%
(FPCore (x y z t) :precision binary64 (if (<= y 1.1e+94) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.1e+94) {
tmp = x;
} else {
tmp = x * (1.0 - 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 <= 1.1d+94) then
tmp = x
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.1e+94) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.1e+94: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.1e+94) tmp = x; else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.1e+94) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.1e+94], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.1 \cdot 10^{+94}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 1.10000000000000006e94Initial program 96.4%
Taylor expanded in x around inf
Simplified63.5%
if 1.10000000000000006e94 < y Initial program 82.7%
Taylor expanded in y around inf
/-lowering-/.f64N/A
--lowering--.f6473.4%
Simplified73.4%
Taylor expanded in x around inf
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f6464.1%
Simplified64.1%
(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 94.4%
Taylor expanded in x around inf
Simplified60.5%
(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 2024150
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:alt
(! :herbie-platform default (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))