← Back to list

Solving inverse trigonometric equations over a specific domain

A-level maths students must learn to solve trigonometric equations over a specified interval in degrees. They quickly have to get…

Aurel Nicolae in Python in Plain English · 2025-12-27 18:36 · 0 claps · 6.7 min read
#trigonometry #sinewave #python #desmos #programming
Open on Medium ↗
Wiki topics: EDU · Education & Learning 💻 · Programming 📐 · Mathematics

Solving inverse trigonometric equations over a specific domain

https://www.desmos.com/calculator/ljbt8khnkp

https://www.desmos.com/calculator/ljbt8khnkp

A-level maths students must learn to solve trigonometric equations over a specified interval in degrees. They quickly have to get acquainted to the inverse trigonometric functions on their calculators which return the corresponding angle for a given ratio. In this context, ‘ratio’ refers to the rote learned mnemonic SOH-CAH-TOA at GCSE.

Table of Contents

Inverse Sine

The inverse sine function* sin¯¹, a.k.a. arcsin and asin,* basically ‘undoes’ the sine function for a given opposite / hypotenuse ratio.

Note, this is not the reciprocal of sine i.e., sin¯¹ y ≠ 1 ÷ (sin y). The reciprocal of sine is called to cosecant,cosec’ or ‘csc’ for short.

For example, given the trigonometric ratio sin x = ½, this computes x = sin¯¹(0.5) which should result in x = 30°.

Use SHIFT + sin buttons on the calculator.

Use SHIFT + sin buttons on the calculator.

As an example, if you are asked for all the possible solutions for sin x = ½ over the domain x ∈ [0°, 720°], then sketching the sine wave or graphing it using an app like desmos is very handy. We can see that the solutions for ratio 0.5 are 30°, 150°, 390° and 510°.

https://www.desmos.com/calculator/goceqzgbfk

https://www.desmos.com/calculator/goceqzgbfk

The general rules to finding all the possible solutions of x satisfying the equation sin x = y over a specified domain are:

  • Use the shift + sin buttons on the calculator for solution x₁ = sin¯¹ y.
  • Note that the arcsine function returns an angle between -90° and 90°.
  • The second solution is given by x₂ = 180° — x₁.
  • Find the rest of the solutions in the domain by adding or subtracting 360° to x₁ and x₂, since it is periodic with period of 360°.

Alternatively, you can use the python code below.

Running the python code for sin x = 0.5 for x in [0°, 720°].

Running the python code for sin x = 0.5 for x in [0°, 720°].

Back to the top

Inverse Cosine

The inverse cosine function cos¯¹, a.k.a. arccos or acos, ‘undoes’ the cosine function for a given adjacent / hypotenuse ratio.

Note, this is not the reciprocal of cosine i.e., cos¯¹ y ≠ 1 ÷ cos y. The receiprocal of cosine is actually called the secant or ‘sec’ for short.

If we have the trigonometric ratio cos x = ½, this computes x = cos¯¹(0.5) which results in x = 60°.

Press SHIFT + cos on the calculator.

Press SHIFT + cos on the calculator.

If you are asked for all the possible solutions for cos x = ½ over the domain x ∈ [0°, 720°], then sketching the cosine wave or graphing it shows that the solutions are 60°, 300°, 420° and 660°.

https://www.desmos.com/calculator/n6m9gmux4z

https://www.desmos.com/calculator/n6m9gmux4z

The general rules to finding all the possible solutions of x satisfying the equation cos x = y over a specified domain are:

  • Use the shift + cos buttons on the calculator for solution x₁ = cos¯¹ y.
  • Note that the arccos function returns an angle between 0° and 180°.
  • The second solution is given by x₂ = -x₁, since the cosine is an even function i.e., symmetric in line x = 0.
  • Find the rest of the solutions in the domain by adding or subtracting 360° to x₁ and x₂, since it is periodic with period of 360°.

Likewise, you are welcome to use the python code below.

Running the python code for cos x = 0.5 for x in [0°, 720°].

Running the python code for cos x = 0.5 for x in [0°, 720°].

Back to the top

Inverse Tangent

The inverse tangent function tan¯¹, a.k.a. arctan or atan, ‘undoes’ the tangent function for a given opposite / adjacent ratio.

Note, this is not the reciprocal of tangent i.e. tan¯¹ y ≠ 1 ÷ tan y. The reciprocal of the tangent is called to cotangent, ‘cotan’ or ‘cot’ for short.

This is the trickiest function out of the three, as it has asymptotes at 90° and for every multiple of 180° to the right of that, and vice versa for -90°. This simply means that for 90° ± multiples of period 180°, the adjacent is 0 i.e., the tangent ratio is undefined due to diving by 0.

Given that the trigonometric ratio tan x = ½, this computes x = tan¯¹(0.5) which results in x = 26.6° (3 s.f.).

Hold down SHIFT + tan buttons.

Hold down SHIFT + tan buttons.

If you are asked for all the possible solutions for tan x = ½ over the domain x ∈ [-450°, 450°], then plotting the tangent graph shows that the solutions are -333°, -154°, 26.6°, 207° and 387° (3 s.f.).

https://www.desmos.com/calculator/u4i8pxznbv

https://www.desmos.com/calculator/u4i8pxznbv

The general rules to finding all the possible solutions of x satisfying the equation tan x = y over a specified domain are:

  • Use the shift + tan buttons on the calculator for solution x₁ = tan¯¹ y.
  • Note that the arctan function returns an angle between -90° and 90°.
  • Find the rest of the solutions in the domain by adding or subtracting 180° to x₁ , since it is periodic with period of 180°.

As before, you can use the python code below.

Running the python code for tan x = 0.5 for x in [-450°, 450°].

Running the python code for tan x = 0.5 for x in [-450°, 450°].

Back to the top

Python Code

If coding is not your thing and you would rather use the code straight away, please try this link.

In the python code below, I am making extensive use of the math library and their asin, acos and atan functions. After finding the first solution, I then apply the rules as listed above. It’s a process of elimination.

from math import *

def round_sig_fig(x, sig_fig=1):
    return round(x, sig_fig - int(floor(log10(abs(x)))) - 1) if x != 0 else 0

def append_solution(
    solutions, angle, lower_bound, upper_bound, bound_incl, sig_fig=None
):
    if angle not in solutions:
        if bound_incl:
            if angle >= lower_bound and angle <= upper_bound:
                solutions.append(
                    angle
                    if sig_fig is None
                    else round_sig_fig(angle, abs(int(sig_fig)))
                )
        else:
            if angle > lower_bound and angle < upper_bound:
                solutions.append(
                    angle
                    if sig_fig is None
                    else round_sig_fig(angle, abs(int(sig_fig)))
                )

def append_right(
    solutions, angle, period, lower_bound, upper_bound, bound_incl, sig_fig
):
    while angle <= upper_bound:
        angle += period
        append_solution(solutions, angle, lower_bound, upper_bound, bound_incl, sig_fig)

def append_left(
    solutions, angle, period, lower_bound, upper_bound, bound_incl, sig_fig
):
    while angle >= lower_bound:
        angle -= period
        append_solution(solutions, angle, lower_bound, upper_bound, bound_incl, sig_fig)

def arcsin_in_range(ratio, lower_bound, upper_bound, bound_incl=True, sig_fig=3):
    solutions = []
    x1 = degrees(asin(ratio))
    append_solution(solutions, x1, lower_bound, upper_bound, bound_incl, sig_fig)
    append_right(solutions, x1, 360, lower_bound, upper_bound, bound_incl, sig_fig)
    append_left(solutions, x1, 360, lower_bound, upper_bound, bound_incl, sig_fig)

    x2 = 180 - x1
    append_solution(solutions, x2, lower_bound, upper_bound, bound_incl, sig_fig)
    append_right(solutions, x2, 360, lower_bound, upper_bound, bound_incl, sig_fig)
    append_left(solutions, x2, 360, lower_bound, upper_bound, bound_incl, sig_fig)

    return sorted(solutions)

def arccos_in_range(ratio, lower_bound, upper_bound, bound_incl=True, sig_fig=3):
    solutions = []
    x1 = degrees(acos(ratio))
    append_solution(solutions, x1, lower_bound, upper_bound, bound_incl, sig_fig)
    append_right(solutions, x1, 360, lower_bound, upper_bound, bound_incl, sig_fig)
    append_left(solutions, x1, 360, lower_bound, upper_bound, bound_incl, sig_fig)

    x2 = -x1
    append_solution(solutions, x2, lower_bound, upper_bound, bound_incl, sig_fig)
    append_right(solutions, x2, 360, lower_bound, upper_bound, bound_incl, sig_fig)
    append_left(solutions, x2, 360, lower_bound, upper_bound, bound_incl, sig_fig)

    return sorted(solutions)

def arctan_in_range(ratio, lower_bound, upper_bound, bound_incl=True, sig_fig=3):
    solutions = []
    x1 = degrees(atan(ratio))
    append_solution(solutions, x1, lower_bound, upper_bound, bound_incl, sig_fig)
    append_right(solutions, x1, 180, lower_bound, upper_bound, bound_incl, sig_fig)
    append_left(solutions, x1, 180, lower_bound, upper_bound, bound_incl, sig_fig)

    return sorted(solutions)

def validate_selection(num):
    try:
        return int(num) if int(num) in [0, 1, 2, 3] else -1
    except Exception as e:
        print(e)
        return -1

def eval_expression(expression):
    code = compile(expression, "<string>", "eval")
    if code.co_names:
        raise NameError(f"Use of names not allowed")
    return eval(code, {"__builtins__": {}}, {})

def validate_numbers(num):
    try:
        return float(num)
    except Exception:
        try:
            return eval_expression(num)
        except Exception as e:
            raise Exception(e)

def yn_bool(txt):
    txt = txt.strip()
    if len(txt) == 0:
        # default
        return True
    elif txt[0].upper() in ["N", "F"]:
        return False
    else:
        return True

def main():
    selection = -1  # initialise
    while selection != 0:
        print("Select which inverse trigonometric function you require:")
        print("\t1. asin")
        print("\t2. acos")
        print("\t3. atan")
        print("\t0. exit")

        selection = validate_selection(input("\nChoose 1/2/3/0: "))
        if selection == 0:
            print("Good bye!")
            break
        if selection > 0:
            funcs = ["exit", "asin", "acos", "atan"]
            print("You have selected: {}".format(funcs[selection]))
            ratio = validate_numbers(input("\tEnter the trigonometric ratio: "))
            print("Provide the boundaries for the solution interval")
            lbound = validate_numbers(input("\tEnter lower boundary (in degrees): "))
            ubound = validate_numbers(input("\tEnter upper boundary (in degrees): "))
            incl_bounds = yn_bool(input("\tInclude boundaries? (default=Yes) Y/n: "))

        if selection == 1:
            soln = arcsin_in_range(
                ratio, min(lbound, ubound), max(lbound, ubound), bound_incl=incl_bounds
            )
        elif selection == 2:
            soln = arccos_in_range(
                ratio, min(lbound, ubound), max(lbound, ubound), bound_incl=incl_bounds
            )
        elif selection == 3:
            soln = arctan_in_range(
                ratio, min(lbound, ubound), max(lbound, ubound), bound_incl=incl_bounds
            )
        else:
            print("Instruction unknown.")
        print("\nSolutions: {}".format(soln))
        print()

if __name__ == "__main__":
    main()

You are more than welcome to download the code here. Enjoy! 😎

Back to the top

Bonus — Unit Circle

I chose radians for plotting the unit circle phasors on the left and the sinusoid graph simultaneously on the right. If I had set the x-axis in degrees, the unit circle would have looked oval. This my version of PhET’s trig tour.

https://www.desmos.com/calculator/pakdtco7up

https://www.desmos.com/calculator/pakdtco7up

You can use this to demostrate to your class how the SOH-CAH-TAN ratios are used to build the sine waves.

Back to the top


메타데이터
post_id
fcb4be277ad7
slug
solving-inverse-trigonometric-equations-over-a-specific-domain-fcb4be277ad7
url
https://python.plainenglish.io/solving-inverse-trigonometric-equations-over-a-specific-domain-fcb4be277ad7
canonical_url
https://python.plainenglish.io/solving-inverse-trigonometric-equations-over-a-specific-domain-fcb4be277ad7
author_url
https://medium.com/@the1howie
status
ok
fetched_at
2026-07-13 21:07:34