I have a column of values and i need to find arcsin for evry value in this column. I am very new to shell scripting and would be glad to receive any help regarding this. Also i want them to be saved in the next column.
Desired output:
# #
a arcsin(a)
b arcsin(b)
c arcsin(c)
d arcsin(d)
Thanks for the info. I keep forgetting code tags. You can find a sample of my input file. Actually my original file will contain more then 50k lines in a column.
I am able to calculate the arcsin using python script. But large part of my code is in shell and it would great if i am able to do the same using shell.
Given that the domain of values for the arcsine function is -1 <= x <= 1 and most of your values are not in that range, I'm not sure why we should bother.
And, you haven't told us what operating system or shell you're using.
If you have a 1993 or later version of ksh on your system, the following is a simple way to do what you requested:
#!/bin/ksh
while read x
do printf '%15.10f %15.10f\n' "$x" "$((asin(x)))"
done < file
which, with your sample input in file with blank lines removed, produces the output:
The domain of the inverse sinus (arcsine) function ranges from -0.5 \pi to + 0.5 \pi, (+90 deg - -90 deg; with corresponding sinus values from -1 to +1, as Don Cragun has already pointed out). Values above or below ~1.6 (roughly 0.5 \pi) make still no sense therefore.