Re: arccos function
Carl R. White wrote:
>>
>> arccos(object x) = -arctan(x/sqrt(1-x*x)) + Pi/2
>>
>
>Whether it is or not, that looks like part of my mathbag.e. Could you
>tell me? :)
Yes! the formula above came from mathbag.e. Sorry not to metion your name.
Now, i come to know who prepared this nice routine!
>
>You might like to trap values of 1 and -1 to avoid the error.
>
>procedure arccos(object x)
> if abs(x) > 0.9999999999 then -- this assumes you are using mathbag.e
> if x < 0 then
> return Pi
> else
> return 0
> end if
> else
> return -arctan(x/sqrt(1-x*x)) + Pi/2
> end if
>end procedure
>
Your codes above can be used only when x is atom, not sequences. If the sequence
is transferred to the above codes, i think it cause error.
Euphoria built-in "arctan" accepts any sequence structure as well as atom.
I think some "recursive" technique may be required to get universal version
of arccos which accepts both the atom and sequences...
i think, there may exists some 'general' or 'universal' codes structure
to expand the individual calculation for atom, to any sequence structure...
Bye...
from Lee woo seob...
|
Not Categorized, Please Help
|
|