RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • abs
    • angle
    • bsxfun
    • complex
    • conj
    • double
    • erf
    • erfcinv
    • exp
    • expm1
    • factorial
    • flintmax
    • gamma
    • gammaln
    • heaviside
    • hypot
    • idivide
    • imag
    • intmax
    • intmin
    • ldivide
    • log
    • log10
    • log1p
    • log2
    • minus
    • nextpow2
    • plus
    • pow2
    • power
    • rdivide
    • real
    • realmax
    • realmin
    • realsqrt
    • rescale
    • sign
    • single
    • sqrt
    • swapbytes
    • times
    • typecast
    • uint16
    • uint32
    • uint8

log — Compute natural logarithms element-wise in MATLAB and RunMat.

Y = log(X) computes the natural logarithm of each floating-point element of X, including principal-branch complex promotion. Integer, logical, character, and explicit-GPU real-to-complex forms are separately gated RunMat extensions.

Syntax

Y = log(X)

Inputs

NameTypeRequiredDefaultDescription
XAnyYes—Numeric, logical, char, or complex input.

Returns

NameTypeDescription
YNumericArrayElementwise natural-log result.

Errors

IdentifierWhenMessage
RunMat:log:InvalidInputInput cannot be interpreted as numeric, logical, char, or complex data.log: invalid input
RunMat:log:InternalInternal tensor construction or provider interaction failed.log: internal error

How log works

  • log(X) applies the operation element-wise with MATLAB broadcasting rules.
  • In RunMat extension mode, logical values convert to doubles (true → 1.0, false → 0.0) before the logarithm is taken; compatibility mode rejects this extension.
  • In RunMat extension mode, character arrays are interpreted as their numeric code points and return dense double tensors; compatibility mode rejects this extension.
  • Integer input is a RunMat-only extension. All eight integer classes are accepted only when every value is exactly representable in binary64, and the result is double or complex double.
  • Negative real values produce complex results: log([-1 1]) returns [0 + iπ, 0].
  • Complex inputs follow MATLAB's definition: log(a + bi) = log(|a + bi|) + i·atan2(b, a).
  • log(0) returns -Inf, matching MATLAB's handling of the logarithm singularity at zero.

Does RunMat run log on the GPU?

RunMat Accelerate uses the exact owning provider's reduce_min to classify resident real data, then validates any unary_log output for non-aliasing, shape, device, owner, storage, and precision. When complex output or a fallback is required, it downloads through that owner, computes on the host, and restores the result to the same owner when representable while preserving provenance. log is intentionally excluded from fusion until fused execution can represent its complex-domain semantics.

GPU memory and residency

You typically do not need to call gpuArray yourself. RunMat resolves the exact provider that owns the input. Real data can remain resident through reduce_min and unary_log; integer, logical, complex, unsupported-hook, and real-to-complex paths gather through that owner and then restore the correctly typed result when the owner supports its class and precision. Explicit gpuArray input that requires real-to-complex promotion is a RunMat-only extension and is rejected in compatibility mode.

Examples

Natural log of a positive scalar

y = log(exp(3))

Expected output:

y = 3

Understanding log of zero

value = log(0)

Expected output:

value = -Inf

Taking the logarithm of negative values

data = [-1 -2 -4];
result = log(data)

Expected output:

result = [0.0000 + 3.1416i, 0.6931 + 3.1416i, 1.3863 + 3.1416i]

Applying log to complex numbers

z = [1+2i, -1+pi*i];
w = log(z)

Expected output:

w = [0.8047 + 1.1071i, 1.1447 + 1.2626i]

Element-wise log on a matrix living on the GPU

G = gpuArray([1 2; 4 8]);
out = log(G);
result = gather(out)

Expected output:

result = [0.0000 0.6931; 1.3863 2.0794]

Logging character codes

C = 'ABC';
values = log(C)

Expected output:

values = [4.1744 4.1897 4.2047]

Using log with coding agents

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

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

FAQ

When should I use the log function?⌄

Use log whenever you need the natural logarithm of your data—for example, to linearize exponential growth, compute likelihoods, or transform multiplicative relationships into additive ones.

What happens if the input contains zeros?⌄

log(0) returns negative infinity (-Inf). Entire tensors follow the same rule element-wise.

How are negative real numbers handled?⌄

Negative values automatically promote to complex results: log(-x) returns log(x) + iπ. This matches MATLAB behaviour and avoids losing information compared with returning NaN.

What about tiny floating-point noise producing small negative numbers?⌄

Values that are numerically negative (e.g., -1e-15) are treated just like other negatives and promote to complex outputs. Use abs or max to clip values if you require a purely real result.

Does the GPU implementation support complex outputs?⌄

The real provider hook cannot produce complex output. RunMat therefore gathers through the exact owner, computes the complex result on the host, and restores it to that owner when the provider can represent the complex class. Explicit gpuArray input requiring this extension is rejected in compatibility mode.

Does log accept complex inputs directly?⌄

Yes. Complex scalars and tensors follow the MATLAB definition using magnitude and phase (log(|z|) + i·angle(z)).

Related Math functions

Elementwise

abs · angle · bsxfun · complex · conj · double · erf · erfcinv · exp · expm1 · factorial · flintmax · gamma · gammaln · heaviside · hypot · idivide · imag · intmax · intmin · ldivide · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · realmax · realmin · realsqrt · rescale · sign · single · sqrt · swapbytes · times · typecast · uint16 · uint32 · uint8

Trigonometry

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

Reduction

all · any · bounds · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · maxk · mean · median · min · mink · movmax · movmean · movmedian · movmin · movprod · movstd · movsum · movvar · nnz · prod · rms · std · sum · trapz · var

Structure

bandwidth · isdiag · ishermitian · issymmetric · istril · istriu · symrcm

Signal

blackman · butter · buttord · cheb2ord · conv · conv2 · deconv · downsample · envelope · filter · filtfilt · fir1 · freqz · gauspuls · hamming · hann · hilbert · periodogram · pulstran · pwelch · rectpuls · resample · sawtooth · sinc · spectrogram · square · tripuls · unwrap · upsample · zplane

Rounding

ceil · fix · floor · mod · rem · round

Factor

chol · decomposition · eig · eigs · lu · qr · svd

Solve

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

Optim

coneprog · fminbnd · fminunc · fsolve · fzero · integral · linprog · lsqcurvefit · lsqnonlin · optimoptions · optimset · quad · secondordercone

Ops

cross · ctranspose · dot · mldivide · mpower · mrdivide · mtimes · pagemtimes · pagetranspose · trace · transpose

Symbolic

digits · int · limit · piecewise · sym · syms · vpa

Fft

fft · fft2 · fftn · fftshift · ifft · ifft2 · ifftn · ifftshift

Interpolation

griddedInterpolant · interp1 · interp1q · interp2 · pchip · ppval · spline

Discrete

lcm · primes

Ode

ode15s · ode23 · ode45

Poly

polyder · polyfit · polyint · polyval · roots

Open-source implementation

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

  • View the source for log in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

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.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How log works
  • Does RunMat run log on the GPU?
  • GPU memory and residency
  • Examples
  • Natural log of a positive scalar
  • Understanding log of zero
  • Taking the logarithm of negative values
  • Applying log to complex numbers
  • Element-wise log on a matrix living on the GPU
  • Logging character codes
  • Using log with coding agents
  • FAQ
  • Related Math functions
  • Elementwise
  • Trigonometry
  • Reduction
  • Structure
  • Signal
  • Rounding
  • Factor
  • Solve
  • Optim
  • Ops
  • Symbolic
  • Fft
  • Interpolation
  • Discrete
  • Ode
  • Poly
  • Open-source implementation
  • About RunMat