Skip to content

SawtoothWave ​

The sawtooth wave: x - floor(x), period 1, range [0, 1).

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageSawtoothWave!
SawtoothWave(x)x - floor(x), unit period, range [0, 1).
SawtoothWave({min, max}, x)the sawtooth rescaled to vary from min to max, unit period.
Typed signatures
TypePackageApplies
(real | vector<real^2>, real?) -> numberanalyticalways

Domain: Elementary functions

Details
  • Unlike FractionalPart, which keeps the sign of x, SawtoothWave(x) is always in [0, 1) -- SawtoothWave(-1/4) is 3/4, not -1/4.
  • The range form takes the range FIRST, x second -- SawtoothWave({min, max}, x) -- matching Wolfram's own argument order for this family.

Examples

Basic #
live ↗
InSawtoothWave(0)\mathrm{SawtoothWave}(0)Out00
live ↗
InSawtoothWave(13)\mathrm{SawtoothWave}(\frac{1}{3})Out13\frac{1}{3}
Scope #

Always nonnegative, unlike FractionalPart

live ↗
InSawtoothWave(−14)\mathrm{SawtoothWave}(-\frac{1}{4})Out34\frac{3}{4}

Rescaled to a {min, max} range

live ↗
InSawtoothWave([0,10],12)\mathrm{SawtoothWave}(\bigl\lbrack0, 10\bigr\rbrack, \frac{1}{2})Out55

An exact irrational input: the branch is decided numerically, but the result stays exact

live ↗
InSawtoothWave(−π)\mathrm{SawtoothWave}(-π)Out4−π4-π

Known value · Frac(x) = x - Floor(x); Floor(-π) = -4, so Frac(-π) = 4 - π

A huge exact argument stays unevaluated: a double can't resolve 10^20·π's fractional part to certify a branch, so this declines rather than risk a wrong one

live ↗
InSawtoothWave(1020π)\mathrm{SawtoothWave}(10^{20}π)OutSawtoothWave(100 000 000 000 000 000 000π)\mathrm{SawtoothWave}(100\,000\,000\,000\,000\,000\,000π)
Properties #

Period 1

live ↗
InSawtoothWave(13)=SawtoothWave(513)\mathrm{SawtoothWave}(\frac{1}{3})=\mathrm{SawtoothWave}(5\frac{1}{3})OutTrue\mathrm{True}
About
Examples7
Checked againstWolfram Language 6 agree1 differ
CrosswalkWolfram Language