Using sin and cos math functions in bash

gnome

I have a text file contains columns of data like this:

 col1     col2    col3    col4   col5  col6    col7   col8    col9  col10

50.000   7.920    0.509   11.2   2.60  192.7  25.71  0.3490  188.6  17.81
50.170   7.920    0.609   12.2   2.72  211.7  26.17  0.3326  213.8  18.19
50.330   7.920    0.712   14.1   2.92  218.9  28.17  0.3228  215.1  21.73
...

I want to create another delimited text file (a using bash script) derived from the first one which its columns have values as these:

col1      col2      col3      col3*[-sin(col6)]     col3*[-cos(col6)]
...

sin is Sine function and cos is Cosine function in mathematics. How should I do that?

Thanks in advance.

Vytenis Bivainis

My longer version using bc:

awk '{printf "%f * -s (%f);\n", $3, $6}' < input.txt  | bc -l > col4.txt
awk '{printf "%f * -c (%f);\n", $3, $6}' < input.txt  | bc -l > col5.txt
awk '{print $1, $2, $3}' < input.txt | paste -d " " - col4.txt col5.txt

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

math functions sin and cos for angularjs

From Dev

Python math sin/cos coding issue

From Dev

Python math sin/cos coding issue

From Dev

Calculate radius distance using cos/sin including if/then and inner join

From Dev

Doing simple math on the command line using bash functions: $1 divided by $2 (using bc perhaps)

From Dev

Calculate angle of triangle with sin or cos

From Dev

Valid solution for Javascript sin() and cos()?

From Dev

Code for inverse sin, cos and tan

From Dev

using functions with loop in bash

From Dev

Kernel using cos and sin in CUDA fails when I use more 476 threads per block

From Dev

math functions on datatable values, using array maybe?

From Dev

Using Math functions in Entity framework with mysql

From Dev

math functions on datatable values, using array maybe?

From Dev

Alternative to using Python in a BASH script for math

From Dev

Bash math - Dividing a bunch of rows using for statement

From Dev

Is there a way to always start at 0 using math.sin() Lua

From Dev

Java: Possible Loss of Precision When Using `Math.sin()`

From Dev

Sin function without using math.h library

From Dev

How to check if Math.cos(angle) = 0

From Dev

JavaScript - Reverse of Math.cos(30)

From Dev

Is there a standard way to write Cos instead Math.Cos without defining your own Cos function?

From Dev

Using STDistance with Spatial index on SQL Server 2012 is slower then using COS, SIN & ACOS Calculations and gives oval shaped results

From Dev

c++ libstd compute sin and cos simultaneously

From Dev

How are sin and cos implemented hardware wise?

From Dev

maxima tex output to show brackets for sin and cos

From Dev

ReactJS: AnimationValue.interpolate for sin and cos

From Dev

Generating sin/cos on Virtex7 with Vivado

From Dev

regex for cos/sin/tan with inner brackets inside

From Dev

Sin and Cos flipped how did I manage this?

Related Related

  1. 1

    math functions sin and cos for angularjs

  2. 2

    Python math sin/cos coding issue

  3. 3

    Python math sin/cos coding issue

  4. 4

    Calculate radius distance using cos/sin including if/then and inner join

  5. 5

    Doing simple math on the command line using bash functions: $1 divided by $2 (using bc perhaps)

  6. 6

    Calculate angle of triangle with sin or cos

  7. 7

    Valid solution for Javascript sin() and cos()?

  8. 8

    Code for inverse sin, cos and tan

  9. 9

    using functions with loop in bash

  10. 10

    Kernel using cos and sin in CUDA fails when I use more 476 threads per block

  11. 11

    math functions on datatable values, using array maybe?

  12. 12

    Using Math functions in Entity framework with mysql

  13. 13

    math functions on datatable values, using array maybe?

  14. 14

    Alternative to using Python in a BASH script for math

  15. 15

    Bash math - Dividing a bunch of rows using for statement

  16. 16

    Is there a way to always start at 0 using math.sin() Lua

  17. 17

    Java: Possible Loss of Precision When Using `Math.sin()`

  18. 18

    Sin function without using math.h library

  19. 19

    How to check if Math.cos(angle) = 0

  20. 20

    JavaScript - Reverse of Math.cos(30)

  21. 21

    Is there a standard way to write Cos instead Math.Cos without defining your own Cos function?

  22. 22

    Using STDistance with Spatial index on SQL Server 2012 is slower then using COS, SIN & ACOS Calculations and gives oval shaped results

  23. 23

    c++ libstd compute sin and cos simultaneously

  24. 24

    How are sin and cos implemented hardware wise?

  25. 25

    maxima tex output to show brackets for sin and cos

  26. 26

    ReactJS: AnimationValue.interpolate for sin and cos

  27. 27

    Generating sin/cos on Virtex7 with Vivado

  28. 28

    regex for cos/sin/tan with inner brackets inside

  29. 29

    Sin and Cos flipped how did I manage this?

HotTag

Archive