Systemicbeta

Tangent

systemic:core-tanMath

Inputs

NameTypeDescription
DataNumber seriesThe series of angles, in **radians**, to take the tangent of.

Outputs

NameTypeDescription
TanNumber seriesThe tangent of each input angle, which is the slope at that angle.

Cost

6
credits per run
1,000
bars

0.203 + 0.00568·n credits for n bars, rounded up. The marks are each plan's limit of bars.

Description

Tangent (TAN)

The Tangent module returns the tangent of each value in the input series. Sine and cosine stay between −1 and +1, but tangent is unbounded: it is the slope (rise over run) of an angle.

tan⁡(θ)=sin⁡(θ)cos⁡(θ):R→R\tan(\theta) = \frac{\sin(\theta)}{\cos(\theta)} : \mathbb{R} \rightarrow \mathbb{R}

How It Works

flowchart TD
    subgraph Input["Input Data"]
        A["Angles in radians:<br/>θ₁, θ₂, θ₃, ... θₙ"]
    end
    
    subgraph Processing["Tangent Calculation"]
        NP["tan of each value"]
        NAN["Empty value → empty"]
    end
    
    subgraph Output["Result"]
        T["tan(θ₁), tan(θ₂), ... tan(θₙ)"]
        R["Unbounded: can be any real number"]
    end
    
    A --> NP --> NAN --> T --> R

Understanding Tangent

The Slope Interpretation

Tangent measures the slope of a line at angle θ from the horizontal:

Angletan(θ)Meaning
0° (0 rad)0Flat, horizontal line
45° (π/4 rad)1Rises 1 unit for each unit across
60° (π/3 rad)1.732Steeper slope
89°57.29Near vertical, very steep
90° (π/2 rad)±∞Vertical line — undefined

Key Properties

PropertyDescriptionFormula
UnboundedOutput can be any real number−∞<tan⁡(θ)<+∞-\infty < \tan(\theta) < +\infty
PeriodRepeats every π radians (180°)tan⁡(θ+π)=tan⁡(θ)\tan(\theta + \pi) = \tan(\theta)
Odd SymmetryNegating input negates outputtan⁡(−θ)=−tan⁡(θ)\tan(-\theta) = -\tan(\theta)
AsymptotesUndefined at π/2 + kπtan⁡(π2)=undefined\tan(\frac{\pi}{2}) = \text{undefined}

Reference Values

Angle (radians)Angle (degrees)tan(θ)Notes
00°0Flat
π/630°0.577Gentle slope
π/445°1Equal rise/run
π/360°1.732Steep slope
π/290°±∞Vertical asymptote
2π/3120°−1.732Downward steep
π180°0Flat again

⚠️ Critical: Angle Units

This module reads angles in radians, not degrees.

Conversion formula:

radians=degrees×π180\text{radians} = \text{degrees} \times \frac{\pi}{180}
DegreesRadians
45°π/4 ≈ 0.785
90°π/2 ≈ 1.571
180°π ≈ 3.142
360°2π ≈ 6.283

Handling Asymptotes

Near π/2 + kπ, tangent values grow toward ±∞. The module handles these cases:

SituationBehavior
Empty input valueEmpty at the same bar
Near or at an asymptoteVery large finite value, positive or negative

Practical tip: If extreme spikes cause problems, clip or filter values near asymptotes.


Missing Data

When an input bar is empty (for example, a stock series has no bar on a weekend or holiday), the output at that bar is empty. Gaps are never filled: every output value is the tangent of a real input value. The output has the same length as the input, so every value stays on its own bar.


Handling Invalid Inputs

The tangent of an infinite angle (±∞) does not exist, so the output is empty. This differs from missing data, although both give an empty output:

  • Empty input → empty: there was no value to compute from
  • ±Infinity input → empty: there was a value, but its tangent is undefined

Every finite angle gives a tangent. Angles very close to an asymptote give very large finite numbers, never an empty value.


Financial Applications

1. Trend Slope Analysis

Convert the angle of a regression line into a slope to measure trend strength:

flowchart LR
    subgraph PRICE["Price Data"]
        P["Calculate trend<br/>regression angle"]
    end
    
    subgraph TAN["Tangent Module"]
        T["angle → slope"]
    end
    
    subgraph ANALYSIS["Interpretation"]
        S["Slope magnitude =<br/>trend strength"]
    end
    
    P --> T --> S
Slope (tan)Trend Interpretation
0Flat, sideways market
0 to 0.5Weak trend
0.5 to 1Moderate trend (27°–45°)
1 to 2Strong trend (45°–63°)
> 2Extreme/parabolic move

2. Parabolic Move Detection

A very large tan(θ) signals near-vertical price action. This helps with:

  • Detecting parabolic blow-off tops
  • Identifying flash crashes
  • Flagging unsustainable price acceleration

3. Angular Feature Engineering

For machine learning models, turn time or cyclical features into angles, then apply tangent to create slope-based features.


Tangent vs Sine/Cosine

Propertytansin / cos
RangeUnbounded (−∞ to +∞)Bounded (−1 to +1)
Periodπ2π
AsymptotesYes (at π/2 + kπ)No
Best forSlope/steepnessCyclical encoding
StabilityCan spikeAlways bounded

Recommendation: For smooth cyclical encoding, prefer sine/cosine pairs. Use tangent when you need a slope or want to emphasize extreme angles.


Edge Cases

SituationBehavior
Series with no valuesRejected: at least 1 value is required
Single valueReturns a single tangent value
Angle at π/2 + kπVery large finite value
Negative anglestan(−θ) = −tan(θ)
Large anglesPeriodic: the result repeats every π
Empty input valueEmpty at the same bar (gaps are never filled)
±Infinity inputEmpty (the tangent of an infinite angle is undefined)

Examples

Basic Calculation

Input (radians):

[0, π/6, π/4, π/3]

Output:

[0, 0.577, 1.0, 1.732]

With Negative Angles

Input:

[−π/4, 0, π/4]

Output:

[−1, 0, 1]

Further Reading

Rendering diagrams...
© 2026 WanoLabs. All rights reservedBeta v0.1.5