asinh — Element-wise inverse hyperbolic sine in MATLAB and RunMat.

Y = asinh(X) evaluates the inverse hyperbolic sine of each element in X. Real and complex inputs are handled element-wise, with branch behavior matching MATLAB semantics.

Syntax

Y = asinh(X)

Inputs

NameTypeRequiredDefaultDescription
XAnyYesInput scalar, array, char array, complex value, or gpuArray.

Returns

NameTypeDescription
YAnyElement-wise inverse hyperbolic sine result.

Errors

IdentifierWhenMessage
RunMat:asinh:InvalidInputInput cannot be interpreted as supported numeric/char/complex data.asinh: invalid input
RunMat:asinh:InternalInternal gather/conversion/allocation/provider flow failed.asinh: internal error

How asinh works

  • Accepts scalars, vectors, matrices, and N-D tensors and applies the operation element-wise using MATLAB's broadcasting rules.
  • Logical inputs are promoted to doubles (true → 1.0, false → 0.0) before the inverse hyperbolic sine is applied.
  • Character arrays are interpreted as numeric code points and return dense double arrays with the same shape.
  • Real inputs produce real outputs for all finite values. Complex inputs follow MATLAB's principal branch definition asinh(z) = log(z + sqrt(z^2 + 1)).
  • NaNs and infinities propagate according to IEEE arithmetic and match MATLAB's special-case tables.

Does RunMat run asinh on the GPU?

RunMat Accelerate keeps tensors on the GPU when:

1. A provider is registered and implements the unary_asinh hook. 2. The inputs do not require complex promotion that the provider cannot represent.

If either condition is not met, RunMat gathers the data to the host, evaluates asinh with the CPU reference implementation, and returns the correct MATLAB result. This guarantees correctness without forcing users to manually call gpuArray or gather.

GPU memory and residency

You usually do not need to call gpuArray explicitly. The fusion planner keeps tensors on the GPU whenever the active provider exposes the necessary hooks (unary_asinh) and the runtime can keep the data in real form. When the GPU path is incomplete, RunMat gathers to the host automatically and still returns MATLAB-compatible results. Manual gpuArray / gather remains available for workflows that require explicit residency control.

Examples

Inverse hyperbolic sine of a scalar

y = asinh(0.5)

Expected output:

y = 0.4812

Applying asinh to every element of a vector

x = linspace(-2, 2, 5);
y = asinh(x)

Expected output:

y = [-1.4436 -0.8814 0 0.8814 1.4436]

Evaluating asinh on a matrix

A = [0 -0.5 1.0; 1.5 -2.0 3.0];
B = asinh(A)

Expected output:

B =
         0   -0.4812    0.8814
    1.1948   -1.4436    1.8184

Computing asinh on GPU data

G = gpuArray([0.25 0.5; 0.75 1.0]);
result_gpu = asinh(G);
result = gather(result_gpu)

Expected output:

result = [0.2475 0.4812; 0.6931 0.8814]

Handling complex arguments with asinh

z = [1 + 2i, -0.5 + 0.75i];
w = asinh(z)

Expected output:

w =
   1.4694 + 1.0634i
  -0.6063 + 0.6822i

Using asinh inside fused GPU expressions

G = gpuArray(rand(1024, 1));
Y = sinh(G) + asinh(G)

Using asinh with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how asinh changes the result.

Run a small asinh example, explain the result, then change one input and compare the output.

FAQ

Does asinh ever return complex numbers for real inputs?

No. Real arguments always produce real results. Complex outputs arise only when the inputs themselves are complex.

How are logical or integer inputs handled?

They are promoted to double precision before evaluation, mirroring MATLAB's behavior. The result is returned as a dense double tensor (or complex tensor for complex inputs).

What happens if the GPU provider lacks unary_asinh?

RunMat gathers the data to the host, evaluates asinh on the CPU, and keeps the result on the host unless a downstream operation requests GPU residency.

Is there a precision difference between CPU and GPU outputs?

Both paths operate in the provider's precision (f32 or f64). Small rounding differences may appear near very large magnitudes, but the results stay within MATLAB's tolerance specs.

Can asinh participate in fusion?

Yes. Element-wise fusion templates include asinh, allowing the fusion planner to inline it alongside other unary operations when generating WGSL kernels.

How are character arrays processed?

They are interpreted as their Unicode code points, converted to doubles, and then passed through asinh, producing a numeric array that matches MATLAB's output.

What happens with NaN or Inf values?

NaNs propagate unchanged. Positive and negative infinities map to infinities with the same sign, matching MATLAB's special-case rules.

Can I keep complex results on the GPU?

Currently GPU tensor handles represent real data. When complex values arise, RunMat returns host-resident Value::Complex or Value::ComplexTensor results to remain MATLAB-compatible.

Does asinh support automatic differentiation plans?

Yes. The fusion and acceleration metadata mark asinh as an element-wise operation, so future autodiff infrastructure can reuse the same kernel hooks.

Trigonometry

acos · acosh · asin · atan · atan2 · atanh · cos · cosd · cosh · deg2rad · rad2deg · sin · sind · sinh · tan · tand · tanh

Elementwise

abs · angle · complex · conj · double · exp · expm1 · factorial · gamma · heaviside · hypot · imag · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · sign · single · sqrt · times

Reduction

all · any · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · mean · median · min · nnz · prod · std · sum · trapz · var

Rounding

ceil · fix · floor · mod · rem · round

Factor

chol · eig · lu · qr · svd

Solve

cond · det · inv · linsolve · norm · null · pinv · rank · rcond · rref

Symbolic

digits · int · limit · sym · syms · vpa

Fft

fft · fft2 · fftshift · ifft · ifft2 · ifftshift

Interpolation

interp1 · interp2 · pchip · ppval · spline

Ode

ode15s · ode23 · ode45

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how asinh is executed, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.