Solve sin(θ) = x in the range a ≤ θ ≤ b
Mathematica, 60 bytes
NumberForm[t/.NSolve[Sin[t/180Pi]==#&<=t<=#3,{t}],{9,3}]&
input
[0, -1080, 1080]
output
{-1080.000,-900.000,-720.000,-540.000,-360.000,-180.000,0.000,180.000,360.000,540.000,720.000,900.000,1080.000}
Fortran 95 (gfortran), 180 bytes
#define G >=i)write(*,'(f9.3)')
#define H read(*,*)
program a
H x
H i
H j
o=ASIN(x)*57.2957
p=o-180+o
q=o-360*999
do
r=q-p
if(r<=j.and.r G r
if(q>=j)exit
if(q G q
q=q+360
enddo
end
Structure ungolfed:
program a
implicit none
real :: x
integer :: i
integer :: j
real :: o
real :: r
real :: q
real :: p
read(*,*) x
read(*,*) i
read(*,*) j
o=ASIN(x)*57.2957
p=o-180+o
q=o-360*999
do
r=q-p
if(r<=j.and.r >=i) then
write(*,'(f9.3)') r
endif
if(q>=j) then
exit
endif
if(q >=i) then
write(*,'(f9.3)') q
endif
q = q + 360
end do
end program a
APL, 51 46 40 39 bytes
3 bytes saved thanks to @KritixiLithos
6 7 bytes saved thanks to @Adám
{3⍕⍵/⍨1E¯6>|⎕-1○○⍵÷180}⊢+1E3÷⍨(⍳1001×-)
Called as a dyad with a
as left argument and b
as right argument, prompts for x
.
Requires ⎕IO←0
.
How?
⊢+1E3÷⍨(⍳1001×-) ⍝ build the range a to b with step of 0.001
1001×- ⍝ 1001 * (b - a)
⍳ ⍝ range
1E3÷⍨ ⍝ divide every element by 1000
⊢+ ⍝ add a back
{3⍕⍵/⍨1E¯6>|⎕-1○○⍵÷180} ⍝ filter the solutions
○⍵÷180 ⍝ convert to radian - π * ⍵ / 180
1○ ⍝ compute sine
|⎕- ⍝ distance from x
1E¯6> ⍝ small enough
⍵/⍨ ⍝ compress with the original list
3⍕ ⍝ format to 3 decimal places