Hidden WordScanner
Private scans · No account required

DuckieDai Inverse of Trig

Work out an inverse of a trig function, such as sin^-1(sin(2pi/3)) or cos^-1(sin(5pi/6)), step by step, and see whether the inverse cancels or the answer moves into the inverse's range.

trigonometry · MIT License

Overview

Work out an inverse of a trig function, such as sin^-1(sin(2pi/3)) or cos^-1(sin(5pi/6)), step by step, and see whether the inverse cancels or the answer moves into the inverse's range.

  • Owner-tested on a TI calculator
  • Version 1.0.0
  • 2304 bytes
  • Uses math

Before you run it

  • TI-84 Plus CE Python · No calculator OS or Python App version has been verified.
  • TI Connect CE .py transfer to the Python App; the owner's transfer details were not recorded
  • Angles are typed with pi, such as 2pi/3 or -pi/4, as decimals in radians, or in degrees with deg, such as 120deg.
  • Answers use the principal ranges: sin^-1 and tan^-1 from -pi/2 to pi/2, and cos^-1 from 0 to pi.
  • The inside function is sin, cos, or tan, and the outside is sin^-1, cos^-1, or tan^-1.

Try the DuckieDai calculator screen

Follow the program's prompts and result flow before downloading.

JavaScript is required for the optional browser simulation. Source viewing and downloading remain available without it.

Simulation boundary: This preview uses a reviewed browser adapter. It does not execute the downloaded Python and does not prove TI-Python or calculator compatibility.

Learn the math

How to evaluate sin^-1(sin x), cos^-1(cos x), and other inverse-of-trig expressions

The idea

It is tempting to say sin^-1(sin x) is always x, because the inverse undoes the function. That is only true when x is inside the inverse's range. sin^-1 only ever answers between -pi/2 and pi/2, so sin^-1(sin(2pi/3)) cannot be 2pi/3.

The safe way is two steps. First work out the inside, such as sin(2pi/3) = sqrt(3)/2. Then find the angle in the inverse's range with that value: sin^-1(sqrt(3)/2) = pi/3. The same two steps handle a mixed expression such as cos^-1(sin(5pi/6)).

The formula

sin^-1(sin x) = x only when -pi/2 <= x <= pi/2

cos^-1(cos x) = x only when 0 <= x <= pi

tan^-1(tan x) = x only when -pi/2 < x < pi/2

inside
the trig function applied first, to the angle you type
outside
the inverse applied to the inside value
cancels
the answer is the angle you started with, because it was already in the range

Using the program

Worked example

Evaluate sin^-1(sin(2pi/3)). Choose 1 for sin^-1, 1 for sin, and type 2pi/3.

sin(2pi/3) = sqrt(3)/2, sin^-1(sqrt(3)/2) = pi/3

The program shows Step 1: sin(2pi/3) = sqrt(3)/2, then Step 2: sin^-1(sqrt(3)/2), = pi/3, = 60 deg, and Out of range! Not 2pi/3. The answer is pi/3, the angle in Quadrant I with the same sine.

Evaluate cos^-1(cos(-pi/4)): choose 2, 2, and type -pi/4. cos^-1 answers from 0 to pi, so the program shows = pi/4 and Out of range! Not -pi/4.

A mixed one, cos^-1(sin(5pi/6)): choose 2, 1, and type 5pi/6. The program shows Step 1: sin(5pi/6) = 1/2, then = pi/3 and = 60 deg.

Tips and common mistakes

Where this comes up

Evaluating expressions such as sin^-1(sin x) is a standard inverse trig question in precalculus and trigonometry, and the range idea behind it returns in calculus.

Exact reviewed bytes

Source code

Download .py

View source below, copy it when JavaScript is available, or download the exact .py bytes.

  1. from math import sin,cos,tan,asin,acos,atan,pi,sqrt
  2. def clr():print("\n"*11)
  3. def pg():input("[enter]");clr()
  4. def ex(v):
  5. if abs(v)<1e-9:return "0"
  6. if abs(v)>9999:return "%.6g"%v
  7. g="-" if v<0 else "";q=v*v
  8. for r in range(1,201):
  9. p=round(q*r)
  10. if p and abs(q-p/r)<1e-8*r:
  11. n=p*r;k=1;i=2
  12. while i*i<=n:
  13. while n%(i*i)==0:n//=i*i;k*=i
  14. i+=1
  15. a,b=k,r
  16. while b:a,b=b,a%b
  17. k//=a;r//=a
  18. t=(str(k) if k>1 or n==1 else "")+("" if n==1 else "sqrt("+str(n)+")")
  19. return g+t+("/"+str(r) if r>1 else "")
  20. return "%.6g"%v
  21. def rad(v):
  22. for d in range(1,13):
  23. k=round(v/pi*d)
  24. if abs(v/pi-k/d)<1e-8:
  25. if k==0:return "0"
  26. a=("-" if k<0 else "")+("" if abs(k)==1 else str(abs(k)))+"pi"
  27. return a if d==1 else a+"/"+str(d)
  28. return "%.6g"%v
  29. def ang(s):
  30. s=s.lower().replace(" ","").replace("*","").replace("(","").replace(")","")
  31. if s[-3:]=="deg":return float(s[:-3])*pi/180
  32. if "pi" in s:
  33. a,b=s.split("pi");a={"":"1","-":"-1"}.get(a,a);v=float(a)*pi
  34. if b:v/=float(b[1:])
  35. return v
  36. return float(s)
  37. def pick(p,v):
  38. while 1:
  39. c=input(p).strip()
  40. if len(c)==1 and c in v:return c
  41. clr();print("INVERSE OF TRIG\n like sin^-1(sin(pi/3))\n __\n ___(o )> quack!\n \\ <_. )\n `---'\nDuckieDai (TM)\nhiddenwordscanner.com");pg()
  42. I=("sin^-1","cos^-1","tan^-1");F=("sin","cos","tan")
  43. while 1:
  44. o=pick("OUTSIDE (inverse):\n1 sin^-1\n2 cos^-1\n3 tan^-1\n0 Exit\n> ","0123")
  45. if o=="0":break
  46. o=int(o)-1;i=int(pick("INSIDE:\n1 sin 2 cos 3 tan\n> ","123"))-1
  47. try:
  48. x=ang(input("Angle (pi/3, 2pi/3,\n-pi/4, 120deg)? "))
  49. if not abs(x)<1e300:raise ValueError
  50. except (ValueError,ZeroDivisionError):print("Type like 2pi/3 or 120deg");pg();continue
  51. clr();L=I[o]+"("+F[i]+"("+rad(x)+"))"
  52. if i==2 and abs(cos(x))<1e-12:print(L+"\ntan("+rad(x)+") undefined\n= UNDEFINED");pg();continue
  53. v=(sin,cos,tan)[i](x)
  54. if abs(v)<1e-12:v=0.0
  55. if o<2 and abs(v)>1+1e-12:print(L+"\n= UNDEFINED");pg();continue
  56. v=max(-1,min(1,v)) if o<2 else v;t=(asin,acos,atan)[o](v)
  57. print(L+"\nStep 1: "+F[i]+"("+rad(x)+") = "+ex(v)+"\nStep 2: "+I[o]+"("+ex(v)+")\n= "+rad(t)+"\n= "+"%.6g"%(t*180/pi)+" deg")
  58. if o==i:print("In range: cancels" if abs(t-x)<1e-9 else "Out of range! Not "+rad(x))
  59. print("Range: "+("0 to pi" if o==1 else "-pi/2 to pi/2"));pg()
  60. print("Quack! DuckieDai (TM)\nhiddenwordscanner.com")
Filename
INVOF.py
Size
2304 bytes
SHA-256
493871c1bcd06ff62f94b6dba304df91ea6748a101d65b323c3833fae7793574

Usage

Inputs

  • The outside inverse: 1 sin^-1, 2 cos^-1, 3 tan^-1, or 0 to exit
  • The inside function: 1 sin, 2 cos, 3 tan
  • The angle, such as pi/3, 2pi/3, -pi/4, or 120deg

Outputs

  • Step 1, the inside value, exact when it is a fraction or a fraction times a square root
  • Step 2, the inverse of that value, in radians as a multiple of pi when it is one, and in degrees
  • In range: cancels, or Out of range! when the inverse and the function match but the angle is outside the range
  • The range of the outside inverse, or UNDEFINED

Units: Angles in radians, as multiples of pi, or degrees.

Assumptions and limitations

Assumptions

  • Angles are typed with pi, such as 2pi/3 or -pi/4, as decimals in radians, or in degrees with deg, such as 120deg.
  • Answers use the principal ranges: sin^-1 and tan^-1 from -pi/2 to pi/2, and cos^-1 from 0 to pi.

Constraints

  • The inside function is sin, cos, or tan, and the outside is sin^-1, cos^-1, or tan^-1.
  • inf, nan, and angles of 1e300 or more in size are refused with Type like 2pi/3 or 120deg.

Known failures

  • Values larger than 9999, such as tan of an angle very close to pi/2, are shown as 6-digit decimals.
  • A radian answer that is not a multiple of pi over 1 to 12 is shown as a decimal.

Compatibility and review

Review status
Owner-tested on a TI calculator
Tested on
Owner reports personally running this program on a TI-84 Plus CE Python calculator; the test date, OS version, and Python App version were not recorded
What happened
Owner reported pass on the calculator for the owner's original. For publication, inf, nan, and angles of 1e300 or more are refused instead of stopping the program, and values larger than 9999 are shown as decimals so tan of an angle near pi/2 no longer takes minutes. Every other answer is unchanged; this exact file has not yet been rerun on a calculator.
Dependencies
math
Suggested calculator name
INVOF — you can give it another valid, unique name when you transfer it
Desktop test cases
Not available for this interactive-only source

This exact source auto-launches an interactive calculator session, so compatibility evidence comes from the recorded physical-device review rather than an importable desktop fixture.

Transfer and launch

Download the .py file, send it to your calculator with TI Connect CE as INVOF or another name, then open the Python App and try the worked example on this page first. This release has no verified calculator OS or Python App version; treat transfer and execution as unverified until independently tested.

Full installation and troubleshooting guide. Check your teacher's or exam's rules before using any program.

Version history

Did a DuckieDai program help with your homework? Every program here is free. If you would like to say thanks, you can leave a tip on Cash App ($duckiedai214) or read what tips pay for.

Independent compatibility resource: Hidden Word Scanner is independent and is not affiliated with or endorsed by Texas Instruments. TI product names describe compatibility only.

Action-count privacy: Successful downloads, preview starts, and preview completions increment same-origin aggregate counters, and so does a Yes or No answer about whether the program worked. Your browser notes that you answered; that note is never sent to the site. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.