Reputation: 1
I wrote this code but didn't get the output
#!/bin/bash
echo $1 $2
x=$1
y=$2
#echo "sum is $(($x+$y))"
#z=echo "r is $((($1*$1)+($2*$2)))"
#print z
z=$((($x*$x)+($y*$y)))
a=$((($y)/($x)))
echo "scale=5; sqrt($z)" | bc
b=`echo - | awk '{print (('$a' * 3.14159))}'`
k=`echo - | awk '{print (tan('$y'))}'`
echo $k
Upvotes: 0
Views: 167
Reputation: 10133
#!/bin/bash
bc -l <<< "x=$1; y=$2; sqrt(x*x + y*y); a(y/x)"
The first line of the output is r and the second line is theta in radians.
Upvotes: 1