Ask Your Question
0

evaluate sin(x) in terminal

asked 2014-01-20 13:24:50 -0600

nks gravatar image

updated 2014-11-29 20:44:29 -0600

mether gravatar image

Write a shell script that calculates suumation of ( sqtr(sin(x)) ) for x =1 to n, where n is user input. I'm unable to evaluate sin(x) using any command tools in terminal.

Any reply will be highly obliged.

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
2

answered 2014-01-21 13:32:05 -0600

nks gravatar image

echo "s($angle)" | bc -l

edit flag offensive delete link more
0

answered 2014-01-20 13:47:52 -0600

skytux gravatar image

You can use bc (basic calculator) inside shell scripts. Sorry that I can't give you an example right now, but if you read the documentation it will be easy to implement:

bc manual

bc wikipedia

HTH,

Germán.

edit flag offensive delete link more
0

answered 2014-01-20 15:52:12 -0600

q2dg gravatar image

Look "Math library" section of bc's manpage. This post is also useful: http://phoxis.org/2009/12/23/floatmat...

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-01-20 13:24:50 -0600

Seen: 122 times

Last updated: Jan 21 '14