## Big Math problem

I am developing a project in plain C++ using VS2010, I need to calculate the arc cosine of a real value (can be out of -1;1 range, so need to deal with complex numbers) and compare it with a double to see whether or not a threshold is satisfied

To make things clear, I need to convert this code (which works in matlab)
Code:
```   % dotprods is a vector of real values

tempvar=acos(dotprods); % inverse cosine, some of these values are complex

[vals,indx] = sort(tempvar);  % Take inverse cosine and sort results

% value compare
if (vals(1) < threshold * secondvalue)
% condition is TRUE
else
% condition is FALSE
end```

Unfortunately the acos function does not work with complex numbers.

I tried to arrange things this way:

Code:
```for(int j...) // cycle values of the vector
{
// dotprods is a ublas double vector with real values

complex<double> c(0,1);	// i
complex<double> one(1,0);    // 1

complex<double> _acos = -c*log(dotprods[j]+c*pow(one-pow(dotprods[j],2),1/2));

// here there is a cycle to sort values

if( abs(_acos) < threshold * secondvalue) // threshold and secondvalue are double
// TRUE
else
// FALSE
}```

The problem is that the formula I wrote (should be equal to arccosine function theorically) is not working. Results are wrong.

Can I use something like "cacos" function in a VS2010 C++ program?