Rust f32::asinh

Percentage Accurate: 37.2% → 99.4%
Time: 7.9s
Alternatives: 11
Speedup: 4.0×

Specification

?
\[\begin{array}{l} \\ \sinh^{-1} x \end{array} \]
(FPCore (x) :precision binary32 (asinh x))
float code(float x) {
	return asinhf(x);
}
function code(x)
	return asinh(x)
end
function tmp = code(x)
	tmp = asinh(x);
end
\begin{array}{l}

\\
\sinh^{-1} x
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 11 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 37.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \end{array} \]
(FPCore (x)
 :precision binary32
 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
	return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x)
	return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x)
end
function tmp = code(x)
	tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0))))));
end
\begin{array}{l}

\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}

Alternative 1: 99.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\ \mathbf{if}\;t_0 \leq -0.20000000298023224:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\ \mathbf{elif}\;t_0 \leq 0.004000000189989805:\\ \;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
   (if (<= t_0 -0.20000000298023224)
     (copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
     (if (<= t_0 0.004000000189989805)
       (copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
       (copysign (log (+ x (hypot 1.0 x))) x)))))
float code(float x) {
	float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
	float tmp;
	if (t_0 <= -0.20000000298023224f) {
		tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
	} else if (t_0 <= 0.004000000189989805f) {
		tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
	} else {
		tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
	}
	return tmp;
}
function code(x)
	t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x)
	tmp = Float32(0.0)
	if (t_0 <= Float32(-0.20000000298023224))
		tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x);
	elseif (t_0 <= Float32(0.004000000189989805))
		tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x);
	else
		tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0))))));
	tmp = single(0.0);
	if (t_0 <= single(-0.20000000298023224))
		tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x))));
	elseif (t_0 <= single(0.004000000189989805))
		tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666))));
	else
		tmp = sign(x) * abs(log((x + hypot(single(1.0), x))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t_0 \leq -0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\

\mathbf{elif}\;t_0 \leq 0.004000000189989805:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 2: 98.9% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{x \cdot -2 - \frac{0.5}{x}}\right), x\right)\\ \mathbf{elif}\;x \leq 0.004000000189989805:\\ \;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -1.0)
   (copysign (log (/ 1.0 (- (* x -2.0) (/ 0.5 x)))) x)
   (if (<= x 0.004000000189989805)
     (copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
     (copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
	float tmp;
	if (x <= -1.0f) {
		tmp = copysignf(logf((1.0f / ((x * -2.0f) - (0.5f / x)))), x);
	} else if (x <= 0.004000000189989805f) {
		tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
	} else {
		tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-1.0))
		tmp = copysign(log(Float32(Float32(1.0) / Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x);
	elseif (x <= Float32(0.004000000189989805))
		tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x);
	else
		tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-1.0))
		tmp = sign(x) * abs(log((single(1.0) / ((x * single(-2.0)) - (single(0.5) / x)))));
	elseif (x <= single(0.004000000189989805))
		tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666))));
	else
		tmp = sign(x) * abs(log((x + hypot(single(1.0), x))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{x \cdot -2 - \frac{0.5}{x}}\right), x\right)\\

\mathbf{elif}\;x \leq 0.004000000189989805:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 3: 99.4% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.20000000298023224:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\ \mathbf{elif}\;x \leq 0.004000000189989805:\\ \;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -0.20000000298023224)
   (copysign (- (log (- (hypot 1.0 x) x))) x)
   (if (<= x 0.004000000189989805)
     (copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
     (copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
	float tmp;
	if (x <= -0.20000000298023224f) {
		tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
	} else if (x <= 0.004000000189989805f) {
		tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
	} else {
		tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-0.20000000298023224))
		tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x);
	elseif (x <= Float32(0.004000000189989805))
		tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x);
	else
		tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-0.20000000298023224))
		tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x)));
	elseif (x <= single(0.004000000189989805))
		tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666))));
	else
		tmp = sign(x) * abs(log((x + hypot(single(1.0), x))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\

\mathbf{elif}\;x \leq 0.004000000189989805:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 4: 98.0% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{x \cdot -2 - \frac{0.5}{x}}\right), x\right)\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log x + \log 2, x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -1.0)
   (copysign (log (/ 1.0 (- (* x -2.0) (/ 0.5 x)))) x)
   (if (<= x 1.0)
     (copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
     (copysign (+ (log x) (log 2.0)) x))))
float code(float x) {
	float tmp;
	if (x <= -1.0f) {
		tmp = copysignf(logf((1.0f / ((x * -2.0f) - (0.5f / x)))), x);
	} else if (x <= 1.0f) {
		tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
	} else {
		tmp = copysignf((logf(x) + logf(2.0f)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-1.0))
		tmp = copysign(log(Float32(Float32(1.0) / Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x);
	elseif (x <= Float32(1.0))
		tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x);
	else
		tmp = copysign(Float32(log(x) + log(Float32(2.0))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-1.0))
		tmp = sign(x) * abs(log((single(1.0) / ((x * single(-2.0)) - (single(0.5) / x)))));
	elseif (x <= single(1.0))
		tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666))));
	else
		tmp = sign(x) * abs((log(x) + log(single(2.0))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{x \cdot -2 - \frac{0.5}{x}}\right), x\right)\\

\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x + \log 2, x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 5: 98.3% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -1.0)
   (copysign (log (/ -0.5 x)) x)
   (if (<= x 1.0)
     (copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
     (copysign (log (+ (* x 2.0) (* 0.5 (/ 1.0 x)))) x))))
float code(float x) {
	float tmp;
	if (x <= -1.0f) {
		tmp = copysignf(logf((-0.5f / x)), x);
	} else if (x <= 1.0f) {
		tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
	} else {
		tmp = copysignf(logf(((x * 2.0f) + (0.5f * (1.0f / x)))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-1.0))
		tmp = copysign(log(Float32(Float32(-0.5) / x)), x);
	elseif (x <= Float32(1.0))
		tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x);
	else
		tmp = copysign(log(Float32(Float32(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(Float32(1.0) / x)))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-1.0))
		tmp = sign(x) * abs(log((single(-0.5) / x)));
	elseif (x <= single(1.0))
		tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666))));
	else
		tmp = sign(x) * abs(log(((x * single(2.0)) + (single(0.5) * (single(1.0) / x)))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\

\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 6: 98.4% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{x \cdot -2 - \frac{0.5}{x}}\right), x\right)\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -1.0)
   (copysign (log (/ 1.0 (- (* x -2.0) (/ 0.5 x)))) x)
   (if (<= x 1.0)
     (copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
     (copysign (log (+ (* x 2.0) (* 0.5 (/ 1.0 x)))) x))))
float code(float x) {
	float tmp;
	if (x <= -1.0f) {
		tmp = copysignf(logf((1.0f / ((x * -2.0f) - (0.5f / x)))), x);
	} else if (x <= 1.0f) {
		tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
	} else {
		tmp = copysignf(logf(((x * 2.0f) + (0.5f * (1.0f / x)))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-1.0))
		tmp = copysign(log(Float32(Float32(1.0) / Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x);
	elseif (x <= Float32(1.0))
		tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x);
	else
		tmp = copysign(log(Float32(Float32(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(Float32(1.0) / x)))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-1.0))
		tmp = sign(x) * abs(log((single(1.0) / ((x * single(-2.0)) - (single(0.5) / x)))));
	elseif (x <= single(1.0))
		tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666))));
	else
		tmp = sign(x) * abs(log(((x * single(2.0)) + (single(0.5) * (single(1.0) / x)))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{x \cdot -2 - \frac{0.5}{x}}\right), x\right)\\

\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 7: 97.9% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -1.0)
   (copysign (log (/ -0.5 x)) x)
   (if (<= x 1.0)
     (copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
     (copysign (log (* x 2.0)) x))))
float code(float x) {
	float tmp;
	if (x <= -1.0f) {
		tmp = copysignf(logf((-0.5f / x)), x);
	} else if (x <= 1.0f) {
		tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
	} else {
		tmp = copysignf(logf((x * 2.0f)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-1.0))
		tmp = copysign(log(Float32(Float32(-0.5) / x)), x);
	elseif (x <= Float32(1.0))
		tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x);
	else
		tmp = copysign(log(Float32(x * Float32(2.0))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-1.0))
		tmp = sign(x) * abs(log((single(-0.5) / x)));
	elseif (x <= single(1.0))
		tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666))));
	else
		tmp = sign(x) * abs(log((x * single(2.0))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\

\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 8: 97.2% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\mathsf{copysign}\left(x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -1.0)
   (copysign (log (/ -0.5 x)) x)
   (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
	float tmp;
	if (x <= -1.0f) {
		tmp = copysignf(logf((-0.5f / x)), x);
	} else if (x <= 1.0f) {
		tmp = copysignf(x, x);
	} else {
		tmp = copysignf(logf((x * 2.0f)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-1.0))
		tmp = copysign(log(Float32(Float32(-0.5) / x)), x);
	elseif (x <= Float32(1.0))
		tmp = copysign(x, x);
	else
		tmp = copysign(log(Float32(x * Float32(2.0))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-1.0))
		tmp = sign(x) * abs(log((single(-0.5) / x)));
	elseif (x <= single(1.0))
		tmp = sign(x) * abs(x);
	else
		tmp = sign(x) * abs(log((x * single(2.0))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\

\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 9: 75.4% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\mathsf{copysign}\left(x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
	float tmp;
	if (x <= 1.0f) {
		tmp = copysignf(x, x);
	} else {
		tmp = copysignf(logf((x * 2.0f)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(1.0))
		tmp = copysign(x, x);
	else
		tmp = copysign(log(Float32(x * Float32(2.0))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(1.0))
		tmp = sign(x) * abs(x);
	else
		tmp = sign(x) * abs(log((x * single(2.0))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 10: 62.4% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\mathsf{copysign}\left(x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x 1.0) (copysign x x) (copysign (log x) x)))
float code(float x) {
	float tmp;
	if (x <= 1.0f) {
		tmp = copysignf(x, x);
	} else {
		tmp = copysignf(logf(x), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(1.0))
		tmp = copysign(x, x);
	else
		tmp = copysign(log(x), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(1.0))
		tmp = sign(x) * abs(x);
	else
		tmp = sign(x) * abs(log(x));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 11: 54.3% accurate, 4.0× speedup?

\[\begin{array}{l} \\ \mathsf{copysign}\left(x, x\right) \end{array} \]
(FPCore (x) :precision binary32 (copysign x x))
float code(float x) {
	return copysignf(x, x);
}
function code(x)
	return copysign(x, x)
end
function tmp = code(x)
	tmp = sign(x) * abs(x);
end
\begin{array}{l}

\\
\mathsf{copysign}\left(x, x\right)
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Developer target: 99.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\left|x\right|}\\ \mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right| + \frac{\left|x\right|}{\mathsf{hypot}\left(1, t_0\right) + t_0}\right), x\right) \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (let* ((t_0 (/ 1.0 (fabs x))))
   (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 t_0) t_0)))) x)))
float code(float x) {
	float t_0 = 1.0f / fabsf(x);
	return copysignf(log1pf((fabsf(x) + (fabsf(x) / (hypotf(1.0f, t_0) + t_0)))), x);
}
function code(x)
	t_0 = Float32(Float32(1.0) / abs(x))
	return copysign(log1p(Float32(abs(x) + Float32(abs(x) / Float32(hypot(Float32(1.0), t_0) + t_0)))), x)
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right| + \frac{\left|x\right|}{\mathsf{hypot}\left(1, t_0\right) + t_0}\right), x\right)
\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023340 
(FPCore (x)
  :name "Rust f32::asinh"
  :precision binary32

  :herbie-target
  (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 (/ 1.0 (fabs x))) (/ 1.0 (fabs x)))))) x)

  (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))