piping file and providing function

Hey,
I guess it is very easy what I am trying to do, but I don't know how...
cat input.dat |awk '{
	function acos(x) { return atan2(sqrt(abs(1-x*x)), x) }
	function asin(x) { return atan2(x, sqrt(abs(1-x*x))) }
	function pi() { return 2*asin(1);}
	gamma=acos(($1*$1)/(2*$3*$1))
	print gamma
}'

That was my idea, but of course it doesn't work. Does someone know how to implement functions while piping an file...?
And sorry for the question, but I am not able to solve it... Thanks for any help,
Ergy

Comments

Sign In or Register to comment.