
(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 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 92.6%
+-commutative92.6%
*-commutative92.6%
associate-*l*99.1%
fma-def99.1%
Simplified99.1%
Final simplification99.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}
Initial program 92.6%
associate-*l*98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* y (* z (tanh (/ t y)))))))
(if (<= t -1.02e-24)
t_1
(if (<= t -1.45e-236)
(+ x (* z (- t x)))
(if (<= t 1.06e-129)
(+ 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))));
double tmp;
if (t <= -1.02e-24) {
tmp = t_1;
} else if (t <= -1.45e-236) {
tmp = x + (z * (t - x));
} else if (t <= 1.06e-129) {
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))))
if (t <= (-1.02d-24)) then
tmp = t_1
else if (t <= (-1.45d-236)) then
tmp = x + (z * (t - x))
else if (t <= 1.06d-129) 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))));
double tmp;
if (t <= -1.02e-24) {
tmp = t_1;
} else if (t <= -1.45e-236) {
tmp = x + (z * (t - x));
} else if (t <= 1.06e-129) {
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)))) tmp = 0 if t <= -1.02e-24: tmp = t_1 elif t <= -1.45e-236: tmp = x + (z * (t - x)) elif t <= 1.06e-129: 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(y * Float64(z * tanh(Float64(t / y))))) tmp = 0.0 if (t <= -1.02e-24) tmp = t_1; elseif (t <= -1.45e-236) tmp = Float64(x + Float64(z * Float64(t - x))); elseif (t <= 1.06e-129) tmp = Float64(x + Float64(Float64(z * 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)))); tmp = 0.0; if (t <= -1.02e-24) tmp = t_1; elseif (t <= -1.45e-236) tmp = x + (z * (t - x)); elseif (t <= 1.06e-129) 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[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -1.02e-24], t$95$1, If[LessEqual[t, -1.45e-236], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.06e-129], N[(x + N[(N[(z * y), $MachinePrecision] * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{if}\;t \leq -1.02 \cdot 10^{-24}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t \leq -1.45 \cdot 10^{-236}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{elif}\;t \leq 1.06 \cdot 10^{-129}:\\
\;\;\;\;x + \left(z \cdot y\right) \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if t < -1.0200000000000001e-24 or 1.0600000000000001e-129 < t Initial program 94.0%
associate-*l*99.5%
Simplified99.5%
Taylor expanded in x around 0 12.6%
*-commutative12.6%
associate-/r*12.6%
div-sub12.6%
rec-exp12.6%
rec-exp12.6%
tanh-def-a87.8%
Simplified87.8%
if -1.0200000000000001e-24 < t < -1.45e-236Initial program 84.9%
+-commutative84.9%
*-commutative84.9%
associate-*l*97.3%
fma-def97.3%
Simplified97.3%
Taylor expanded in y around inf 93.6%
if -1.45e-236 < t < 1.0600000000000001e-129Initial program 94.7%
Taylor expanded in t around 0 91.3%
Final simplification89.6%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (* z (tanh (/ t y)))))) (if (<= y 1e+33) (+ x t_1) (+ x (- t_1 (* z x))))))
double code(double x, double y, double z, double t) {
double t_1 = y * (z * tanh((t / y)));
double tmp;
if (y <= 1e+33) {
tmp = x + t_1;
} else {
tmp = x + (t_1 - (z * 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 = y * (z * tanh((t / y)))
if (y <= 1d+33) then
tmp = x + t_1
else
tmp = x + (t_1 - (z * x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = y * (z * Math.tanh((t / y)));
double tmp;
if (y <= 1e+33) {
tmp = x + t_1;
} else {
tmp = x + (t_1 - (z * x));
}
return tmp;
}
def code(x, y, z, t): t_1 = y * (z * math.tanh((t / y))) tmp = 0 if y <= 1e+33: tmp = x + t_1 else: tmp = x + (t_1 - (z * x)) return tmp
function code(x, y, z, t) t_1 = Float64(y * Float64(z * tanh(Float64(t / y)))) tmp = 0.0 if (y <= 1e+33) tmp = Float64(x + t_1); else tmp = Float64(x + Float64(t_1 - Float64(z * x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * (z * tanh((t / y))); tmp = 0.0; if (y <= 1e+33) tmp = x + t_1; else tmp = x + (t_1 - (z * x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1e+33], N[(x + t$95$1), $MachinePrecision], N[(x + N[(t$95$1 - N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{if}\;y \leq 10^{+33}:\\
\;\;\;\;x + t_1\\
\mathbf{else}:\\
\;\;\;\;x + \left(t_1 - z \cdot x\right)\\
\end{array}
\end{array}
if y < 9.9999999999999995e32Initial program 96.9%
associate-*l*99.3%
Simplified99.3%
Taylor expanded in x around 0 22.5%
*-commutative22.5%
associate-/r*22.5%
div-sub22.5%
rec-exp22.5%
rec-exp22.5%
tanh-def-a80.6%
Simplified80.6%
if 9.9999999999999995e32 < y Initial program 79.4%
associate-*l*97.4%
Simplified97.4%
Taylor expanded in x around 0 52.8%
*-commutative52.8%
mul-1-neg52.8%
unsub-neg52.8%
Simplified96.1%
Final simplification84.5%
(FPCore (x y z t) :precision binary64 (if (<= y 3.5e+98) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.5e+98) {
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 <= 3.5d+98) 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 <= 3.5e+98) {
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 <= 3.5e+98: 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 <= 3.5e+98) 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 <= 3.5e+98) 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, 3.5e+98], 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 3.5 \cdot 10^{+98}:\\
\;\;\;\;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 < 3.5e98Initial program 96.7%
associate-*l*99.3%
Simplified99.3%
Taylor expanded in x around 0 22.3%
*-commutative22.3%
associate-/r*22.3%
div-sub22.3%
rec-exp22.3%
rec-exp22.3%
tanh-def-a80.9%
Simplified80.9%
if 3.5e98 < y Initial program 76.5%
+-commutative76.5%
*-commutative76.5%
associate-*l*98.1%
fma-def98.1%
Simplified98.1%
Taylor expanded in y around inf 92.8%
Final simplification83.3%
(FPCore (x y z t)
:precision binary64
(if (<= y 9.4e-20)
x
(if (or (<= y 5.6e+101) (not (<= y 2.4e+217)))
(+ x (* z t))
(- x (* z x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 9.4e-20) {
tmp = x;
} else if ((y <= 5.6e+101) || !(y <= 2.4e+217)) {
tmp = x + (z * t);
} else {
tmp = x - (z * 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.4d-20) then
tmp = x
else if ((y <= 5.6d+101) .or. (.not. (y <= 2.4d+217))) then
tmp = x + (z * t)
else
tmp = x - (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 9.4e-20) {
tmp = x;
} else if ((y <= 5.6e+101) || !(y <= 2.4e+217)) {
tmp = x + (z * t);
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 9.4e-20: tmp = x elif (y <= 5.6e+101) or not (y <= 2.4e+217): tmp = x + (z * t) else: tmp = x - (z * x) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 9.4e-20) tmp = x; elseif ((y <= 5.6e+101) || !(y <= 2.4e+217)) tmp = Float64(x + Float64(z * t)); else tmp = Float64(x - Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 9.4e-20) tmp = x; elseif ((y <= 5.6e+101) || ~((y <= 2.4e+217))) tmp = x + (z * t); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 9.4e-20], x, If[Or[LessEqual[y, 5.6e+101], N[Not[LessEqual[y, 2.4e+217]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9.4 \cdot 10^{-20}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{+101} \lor \neg \left(y \leq 2.4 \cdot 10^{+217}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if y < 9.4000000000000003e-20Initial program 96.7%
+-commutative96.7%
*-commutative96.7%
associate-*l*99.3%
fma-def99.3%
Simplified99.3%
Taylor expanded in z around 0 69.3%
if 9.4000000000000003e-20 < y < 5.59999999999999962e101 or 2.3999999999999998e217 < y Initial program 86.0%
associate-*l*98.7%
Simplified98.7%
Taylor expanded in x around 0 30.3%
*-commutative30.3%
associate-/r*30.3%
div-sub30.3%
rec-exp30.3%
rec-exp30.3%
tanh-def-a82.8%
Simplified82.8%
Taylor expanded in y around inf 66.7%
if 5.59999999999999962e101 < y < 2.3999999999999998e217Initial program 78.4%
+-commutative78.4%
*-commutative78.4%
associate-*l*96.8%
fma-def96.8%
Simplified96.8%
Taylor expanded in y around inf 87.5%
Taylor expanded in t around 0 71.1%
+-commutative71.1%
mul-1-neg71.1%
unsub-neg71.1%
Simplified71.1%
Final simplification69.0%
(FPCore (x y z t) :precision binary64 (if (<= z 1.05e+80) x (if (or (<= z 1.2e+165) (not (<= z 5e+215))) (* z (- x)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 1.05e+80) {
tmp = x;
} else if ((z <= 1.2e+165) || !(z <= 5e+215)) {
tmp = z * -x;
} 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 (z <= 1.05d+80) then
tmp = x
else if ((z <= 1.2d+165) .or. (.not. (z <= 5d+215))) then
tmp = z * -x
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= 1.05e+80) {
tmp = x;
} else if ((z <= 1.2e+165) || !(z <= 5e+215)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 1.05e+80: tmp = x elif (z <= 1.2e+165) or not (z <= 5e+215): tmp = z * -x else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 1.05e+80) tmp = x; elseif ((z <= 1.2e+165) || !(z <= 5e+215)) tmp = Float64(z * Float64(-x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= 1.05e+80) tmp = x; elseif ((z <= 1.2e+165) || ~((z <= 5e+215))) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 1.05e+80], x, If[Or[LessEqual[z, 1.2e+165], N[Not[LessEqual[z, 5e+215]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.05 \cdot 10^{+80}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{+165} \lor \neg \left(z \leq 5 \cdot 10^{+215}\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < 1.05000000000000001e80 or 1.2e165 < z < 5.0000000000000001e215Initial program 95.6%
+-commutative95.6%
*-commutative95.6%
associate-*l*99.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in z around 0 69.7%
if 1.05000000000000001e80 < z < 1.2e165 or 5.0000000000000001e215 < z Initial program 75.6%
+-commutative75.6%
*-commutative75.6%
associate-*l*96.9%
fma-def96.9%
Simplified96.9%
Taylor expanded in y around inf 72.7%
Taylor expanded in z around inf 72.7%
Taylor expanded in t around 0 45.9%
mul-1-neg45.9%
distribute-rgt-neg-out45.9%
Simplified45.9%
Final simplification66.1%
(FPCore (x y z t) :precision binary64 (if (<= y 6.4e-26) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.4e-26) {
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 <= 6.4d-26) 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 <= 6.4e-26) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 6.4e-26: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 6.4e-26) 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 <= 6.4e-26) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.4e-26], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.4 \cdot 10^{-26}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 6.4000000000000002e-26Initial program 96.7%
+-commutative96.7%
*-commutative96.7%
associate-*l*99.3%
fma-def99.3%
Simplified99.3%
Taylor expanded in z around 0 69.7%
if 6.4000000000000002e-26 < y Initial program 83.3%
+-commutative83.3%
*-commutative83.3%
associate-*l*98.7%
fma-def98.7%
Simplified98.7%
Taylor expanded in y around inf 79.9%
Final simplification72.8%
(FPCore (x y z t) :precision binary64 (if (<= y 1.8e+92) x (* z (- t x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.8e+92) {
tmp = x;
} 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) :: tmp
if (y <= 1.8d+92) then
tmp = x
else
tmp = 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.8e+92) {
tmp = x;
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.8e+92: tmp = x else: tmp = z * (t - x) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.8e+92) tmp = x; else tmp = Float64(z * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.8e+92) tmp = x; else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.8e+92], x, N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{+92}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.8e92Initial program 97.1%
+-commutative97.1%
*-commutative97.1%
associate-*l*99.4%
fma-def99.4%
Simplified99.4%
Taylor expanded in z around 0 68.2%
if 1.8e92 < y Initial program 75.6%
+-commutative75.6%
*-commutative75.6%
associate-*l*98.2%
fma-def98.2%
Simplified98.2%
Taylor expanded in y around inf 91.5%
Taylor expanded in z around inf 66.3%
Final simplification67.8%
(FPCore (x y z t) :precision binary64 (if (<= y 2.3e-20) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.3e-20) {
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 <= 2.3d-20) 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 <= 2.3e-20) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.3e-20: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.3e-20) 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 <= 2.3e-20) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.3e-20], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.3 \cdot 10^{-20}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 2.2999999999999999e-20Initial program 96.7%
+-commutative96.7%
*-commutative96.7%
associate-*l*99.3%
fma-def99.3%
Simplified99.3%
Taylor expanded in z around 0 69.3%
if 2.2999999999999999e-20 < y Initial program 83.1%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in x around 0 32.2%
*-commutative32.2%
associate-/r*32.2%
div-sub32.2%
rec-exp32.2%
rec-exp32.2%
tanh-def-a76.9%
Simplified76.9%
Taylor expanded in y around inf 63.5%
Final simplification67.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 92.6%
+-commutative92.6%
*-commutative92.6%
associate-*l*99.1%
fma-def99.1%
Simplified99.1%
Taylor expanded in z around 0 60.1%
Final simplification60.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 2023258
(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))))))