Library reference

Tangent

Tangent is rise divided by horizontal run. Multiply it by the horizontal distance to find the rise. A 45-degree angle is about 0.7854 radians.

tan

Simple example

Use an angle of zero radians.

Start0
Result0.0
lesson.mojo
from std.math import tan

def main() raises:
    print(tan(Float64(0.0)))
Output
0.0
Advertisements

Everyday examples

A model hill rises at 45 degrees over two horizontal metres. How high is it?

Start0.7853981633974483
Result2.0
lesson.mojo
from std.math import tan

def main() raises:
    print(2.0 * tan(Float64(0.7853981633974483)))
Output
2.0

A drawing shows a roof at 45 degrees across a three-metre horizontal run. What rise should be marked?

Start0.7853981633974483
Result3.0
lesson.mojo
from std.math import tan

def main() raises:
    print(3.0 * tan(Float64(0.7853981633974483)))
Output
3.0

A flat board runs five metres across the floor. How much does it rise?

Start0
Result0.0
lesson.mojo
from std.math import tan

def main() raises:
    print(5.0 * tan(Float64(0.0)))
Output
0.0
Run the example
Terminal
mojo lesson.mojo
Official documentation