RunMat
GitHub

sinh — Hyperbolic sine of scalars, vectors, matrices, or N-D tensors (element-wise).

Y = sinh(X) computes the hyperbolic sine of every element in X, treating angles as real numbers and extending naturally to complex values.

How sinh works in RunMat

  • Works on scalars, vectors, matrices, and N-D tensors with MATLAB broadcasting semantics.
  • Logical inputs are converted to double precision (true → 1.0, false → 0.0) before evaluation.
  • Complex inputs follow the analytic definition sinh(a + bi) = sinh(a)cos(b) + i·cosh(a)sin(b), propagating NaN/Inf components independently.
  • Character arrays are converted to their numeric code points prior to evaluation, returning double arrays of the same size.
  • Empty arrays return empty results that respect MATLAB’s shape semantics.

How sinh runs on the GPU

When RunMat Accelerate is active, tensors that already reside on the GPU stay there. Providers that implement unary_sinh execute the operation entirely on the device (and fused elementwise kernels can inline sinh as part of a larger expression). If the active provider lacks this hook, RunMat gathers the data back to the host, computes the result, and re-uploads only when later operations require GPU residency.

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 kernels (such as unary_sinh). Manual gpuArray / gather calls remain supported for MATLAB compatibility or when you need to pin residency before interacting with external code.

Examples

Compute the hyperbolic sine of a scalar value

y = sinh(1)

Expected output:

y = 1.1752

Apply sinh to each element of a vector

x = linspace(-1, 1, 5);
y = sinh(x)

Expected output:

y = [-1.1752 -0.5211 0 0.5211 1.1752]

Evaluate sinh on a matrix

A = [0 1; 2 3];
B = sinh(A)

Expected output:

B = [0 1.1752; 3.6269 10.0179]

Compute the hyperbolic sine on the GPU

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

Expected output:

result = [0.2526 0.5211; 0.8223 1.1752]

Work with complex inputs

z = 1 + 2i;
w = sinh(z)

Expected output:

w = -0.4891 + 1.4031i

FAQ

When should I use sinh?

Use sinh for hyperbolic sine transformations, signal-processing workflows, and analytic continuations where the hyperbolic trigonometric family is required.

Does sinh work with complex numbers?

Yes. The real and imaginary parts are evaluated using the analytic definition sinh(a + bi) = sinh(a)cos(b) + i·cosh(a)sin(b).

What happens if the provider does not implement unary_sinh?

RunMat gathers the GPU tensor to host memory, performs the computation on the CPU, and leaves the result on the host unless later operations require GPU residency.

Can sinh participate in fusion?

Yes. The fusion planner can inline sinh inside elementwise groups, generating WGSL kernels that execute directly on the GPU.

Does sinh respect MATLAB broadcasting rules?

It operates elementwise and therefore respects the same scalar-expansion (broadcasting) semantics as other MATLAB math functions in RunMat.

Are integers preserved?

Inputs are promoted to double precision before evaluation. To keep data in integer form, perform downstream casting explicitly.

How does sinh handle NaN or Inf values?

Hyperbolic functions propagate NaN and Inf components consistently with MATLAB. For complex inputs, each component is treated independently.

Can I combine sinh with other hyperbolic functions?

Yes. sinh, cosh, and tanh will share the same residency rules. Fused expressions can include any combination of elementwise builtins.

Is there a GPU warmup penalty?

Providers may warm up pipelines during initialization. If unary_sinh is unavailable, the CPU fallback ensures correctness without warmup.

These functions work well alongside sinh. Each page has runnable examples you can try in the browser.

sin, cos, tan, gpuArray, gather, acos, acosh, asin, asinh, atan, atan2, atanh, cosh, tanh

Open-source implementation

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

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.

  • Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
  • Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
  • A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.

Getting started · Benchmarks · Pricing

Try RunMat — free, no sign-up

Start running MATLAB code immediately in your browser.