### Troubleshooting

## Problem

Can SPSS compute an inverse cosine? I have a variable called X in my active data file, where cos(Y) = X . I want SPSS to compute Y, i.e., arccos(x).

## Resolving The Problem

SPSS does not have an arccos function, but there are functions for inverse sine (arcsin(x)) and inverse tan (arctan(x)) and these can be used to take advantage of some identities and produce an arccos function for X. The arcsin function in spss is ARSIN(x). The arctan function is ARTAN(x), where x can be a variable name, an arithmetic function, or a numeric value.

The identity we will use is:

arcsin(x) + arccos(x) = Pi/2 .

To compute Pi in SPSS, we can use the fact that tan(Pi/4) = 1 and

SPSS will return a value equal to Pi/4 for ARTAN(1). So, to compute

the new variable ARCCOSX as the arccos of the existing variable X,

we can use the command:

IF RANGE(x,-1,1) arccosx = 2*ARTAN(1) - ARSIN(x) .

EXECUTE.

If X is outside of the domain [-1, 1], then ARCCOSX will be system missing. You could run a COMPUTE command without specifying the domain of X in an IF condition, but warnings would be printed in your output for cases that are outside the domain.

To compute ARCCOSX using the program menus, specify Transform>Compute. Enter ARCCOSX (or your preferred variable name) in the Target variable box. Enter

2*ARTAN(1) - ARSIN(x)

in the Numeric Expression box. Click the If button and then click the radio dial "Include if case satisfies condition". In the box underneath that dial, type

RANGE(x,-1,1)

Click Continue and then OK.

## Historical Number

18646

### Document Information

**Modified date:**

16 April 2020

## UID

swg21476208