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
Tried it? Did this program work on your calculator?
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.
TI-84 Plus CE Python · screen preview
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
- Choose the outside inverse, 1 sin^-1, 2 cos^-1, or 3 tan^-1, then the inside function, 1 sin, 2 cos, or 3 tan.
- Type the angle with pi, such as 2pi/3 or -pi/4, or in degrees with deg, such as 120deg. A plain number is read as radians.
- The program shows Step 1, the inside value, and Step 2, the inverse of it, in radians and degrees.
- When the inside and outside match, it says In range: cancels, or Out of range! Not and your angle. It always ends with the outside inverse's range.
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
- Check the range first. If the angle is already inside it, the inverse and the function cancel and you are done.
- For sin^-1, the answer is the angle in Quadrant I or IV with the same sine; for cos^-1, the angle in Quadrant I or II with the same cosine.
- tan^-1(tan(2pi/3)) is -pi/3, not pi/3: tangent repeats every pi, so subtract pi to get into the range.
- If the inside is undefined, such as tan(pi/2), the whole expression is undefined.
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
from math import sin,cos,tan,asin,acos,atan,pi,sqrtdef clr():print("\n"*11)def pg():input("[enter]");clr()def ex(v):if abs(v)<1e-9:return "0"if abs(v)>9999:return "%.6g"%vg="-" if v<0 else "";q=v*vfor r in range(1,201):p=round(q*r)if p and abs(q-p/r)<1e-8*r:n=p*r;k=1;i=2while i*i<=n:while n%(i*i)==0:n//=i*i;k*=ii+=1a,b=k,rwhile b:a,b=b,a%bk//=a;r//=at=(str(k) if k>1 or n==1 else "")+("" if n==1 else "sqrt("+str(n)+")")return g+t+("/"+str(r) if r>1 else "")return "%.6g"%vdef rad(v):for d in range(1,13):k=round(v/pi*d)if abs(v/pi-k/d)<1e-8:if k==0:return "0"a=("-" if k<0 else "")+("" if abs(k)==1 else str(abs(k)))+"pi"return a if d==1 else a+"/"+str(d)return "%.6g"%vdef ang(s):s=s.lower().replace(" ","").replace("*","").replace("(","").replace(")","")if s[-3:]=="deg":return float(s[:-3])*pi/180if "pi" in s:a,b=s.split("pi");a={"":"1","-":"-1"}.get(a,a);v=float(a)*piif b:v/=float(b[1:])return vreturn float(s)def pick(p,v):while 1:c=input(p).strip()if len(c)==1 and c in v:return cclr();print("INVERSE OF TRIG\n like sin^-1(sin(pi/3))\n __\n ___(o )> quack!\n \\ <_. )\n `---'\nDuckieDai (TM)\nhiddenwordscanner.com");pg()I=("sin^-1","cos^-1","tan^-1");F=("sin","cos","tan")while 1:o=pick("OUTSIDE (inverse):\n1 sin^-1\n2 cos^-1\n3 tan^-1\n0 Exit\n> ","0123")if o=="0":breako=int(o)-1;i=int(pick("INSIDE:\n1 sin 2 cos 3 tan\n> ","123"))-1try:x=ang(input("Angle (pi/3, 2pi/3,\n-pi/4, 120deg)? "))if not abs(x)<1e300:raise ValueErrorexcept (ValueError,ZeroDivisionError):print("Type like 2pi/3 or 120deg");pg();continueclr();L=I[o]+"("+F[i]+"("+rad(x)+"))"if i==2 and abs(cos(x))<1e-12:print(L+"\ntan("+rad(x)+") undefined\n= UNDEFINED");pg();continuev=(sin,cos,tan)[i](x)if abs(v)<1e-12:v=0.0if o<2 and abs(v)>1+1e-12:print(L+"\n= UNDEFINED");pg();continuev=max(-1,min(1,v)) if o<2 else v;t=(asin,acos,atan)[o](v)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")if o==i:print("In range: cancels" if abs(t-x)<1e-9 else "Out of range! Not "+rad(x))print("Range: "+("0 to pi" if o==1 else "-pi/2 to pi/2"));pg()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
- 1.0.0 — current version, published . Download this reviewed version
Related learning
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.