How to find arcsin for a coulmn containg values?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to find arcsin for a coulmn containg values?
# 8  
Old 09-04-2015
Hello Dinesh,

Following may help you in same.
Code:
cat values2
37.5    40.96950085
37.5    40.57708713
37.5    40.20572099
37.5    39.85599077
37.5    39.52847075
37.5     39.22371731
37.5     38.94226496
37.5    38.68462227
37.5    38.45126786
awk 'BEGIN{OFS="\t";print "VALUES:" OFS OFS OFS "reverse sine"} {A=$1/$2;print $0 OFS atan2(A, sqrt(1-A * A))}' OFS="\t" values2 2>/dev/null

Output will be as follows.
Code:
VALUES:                 reverse sine
37.5    40.96950085     1.15629
37.5    40.57708713     1.17885
37.5    40.20572099     1.20184
37.5    39.85599077     1.22524
37.5    39.52847075     1.24905
37.5     39.22371731    1.27323
37.5     38.94226496    1.29779
37.5    38.68462227     1.32268
37.5    38.45126786     1.3479

Where values2 is the Input_file I have used, hope this helps.

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 9  
Old 09-04-2015
Hello R. Singh,

Thanks for the code. It worked for me.

Thanks,
Dinesh.n
# 10  
Old 09-04-2015
Quote:
Originally Posted by dinesh.n
I want the value of inverse sin.
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.

I hope this helps.


/PS: You posted this in the meantime:
Quote:
I want the first column to be divided by the second column and then i want to find arcsin for this values.
So this point is moot.

bakunin
# 11  
Old 09-04-2015
And, if you want to try it in ksh directly without awk:
Code:
#!/bin/ksh
printf '%15s %15s %15s %15s\n' "x" "y" "x/y" "arcsine(x/y)"
while read x y
do	printf '%15.10f %15.10f %15.10f %15.10f\n' "$x" "$y" "$((x/y))" "$((asin(x/y)))"
done < file

producing, with your latest data:
Code:
              x               y             x/y    arcsine(x/y)
 -37.5000000000   40.9695008500   -0.9153150325   -1.1562894523
 -37.5000000000   40.5770871300   -0.9241668797   -1.1788488014
 -37.5000000000   40.2057209900   -0.9327030849   -1.2018367803
 -37.5000000000   39.8559907700   -0.9408874118   -1.2252407460
 -37.5000000000   39.5284707500   -0.9486832981   -1.2490457726
 -37.5000000000   39.2237173100   -0.9560542083   -1.2732346025
 -37.5000000000   38.9422649600   -0.9629640196   -1.2977876235
 -37.5000000000   38.6846222700   -0.9693774373   -1.3226828775
 -37.5000000000   38.4512678600   -0.9752604293   -1.3478960944

This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find the X highest values in a list depending on the values of another list with bash/awk?

Hi everyone, This is an exemple of inpout.txt file (a "," delimited text file which can be open as csv file): ID, Code, Value, Store SP|01, AABBCDE, 15, 3 SP|01, AABBCDE, 14, 2 SP|01, AABBCDF, 13, 2 SP|01, AABBCDE, 16, 3 SP|02, AABBCED, 15, 2 SP|01, AABBCDF, 12, 3 SP|01, AABBCDD,... (1 Reply)
Discussion started by: jeremy589
1 Replies

2. Shell Programming and Scripting

Extract Lines Containg a Keyword

Hi , I have two files, say KEY_FILE and the MAIN_FILE. I am trying to read the KEY_FILE which has only one column and look for this column data in the MAIN_FILE to extract all the rows that have this key. I have written a script to do so, but somehow it is not returning all the rows ( It... (4 Replies)
Discussion started by: Sheel
4 Replies

3. Shell Programming and Scripting

find values between values in two different fields

Hi, I need help to find values between two different fields based on $6 (NUM) AND $1 (CD), within the same ID. The result should show the values between the NUMs which will be extracted from within $3 and $2 in data.txt file below. data.txt ex 139 142 Sc_1000004 ID 4 CD ... (2 Replies)
Discussion started by: redse171
2 Replies

4. UNIX for Dummies Questions & Answers

pattern containg ' search and replace

Hi guys I'm new to this forum so please help me in this I have a file where i need to replace a pattern value=' ' with the pattern value='abc' and moreover that abc value must be passed from some variable say i assign name=abc and use name as the value to replace instead of the direct string... (10 Replies)
Discussion started by: sundarj
10 Replies

5. Shell Programming and Scripting

replace value with double quotes of specific coulmn value in csv file

Hi, I am trying to replace a specific column values in a csv file with double quotes. Example: SNO,NAME,ZIPCODE,RANK 1,Robert,74538,12 2,Sam,07564,13 3,Kim, Ed,12345,14 Desired Output: SNO,NAME,ZIPCODE,RANK 1,Robert Ken,74538,12 2,Sam Mik,"07564",13 3,"Kim, Ed",12345,14 I... (3 Replies)
Discussion started by: techmoris
3 Replies

6. Shell Programming and Scripting

output nohup file containg the PID

Hi to everybody. Is it possible to nohup a process and redirect the output to a file containing the PID? E.g. if nohup filename > out.nohup associate the PID=8074 to filename, is it possible to call the output file something like out_8074.nohup instead of out.nohup? By this way it would... (0 Replies)
Discussion started by: plsrn
0 Replies

7. Shell Programming and Scripting

How to merge different coulmn of differnt files

hello gurus , i want to merge different column from two different file. file struture is below. file 1 ------- ~information is given Name class section A 5 b B 7 C D 8 A file 2 (10 Replies)
Discussion started by: rahul sharma11
10 Replies

8. Shell Programming and Scripting

Create Summary file containg information

Folks, I have multiple files in a folder containing some information (there is around 100 of them). What I would like to do would be able to import some of the information into a summary text file so that it will be easier to read a glance. The name of the files all start with the naming... (4 Replies)
Discussion started by: lodey
4 Replies

9. Shell Programming and Scripting

Paste coulmn wise

Hello, I need few clarification in types of paste command ussage in coulmn mode : In a directory i have few file distinguished as *.cpu *.vmem and *.mem and have coulmn entries like first cpu file 89576 89576 89576 89576 89576 89576 89576 second cpu file 46312 46312 46312 (3 Replies)
Discussion started by: er_aparna
3 Replies
Login or Register to Ask a Question