Output result in several columns
Dear Sage users, I have a simple function f(k,x)=Sin(kx). In Sage notebook, I would like to get an output of f(k,x) for x in [0..2*pi,step=0.01] and then for k in [1..10,step=4] (a nested loop). I prefer to get output in an txt-file in several columns as in the following (just numbers):
x f(k1,x) f(k2,x) f(k3,x)
0 0 0 0
0.01 0.01 0.05 0.0899
... ... ... ...
I have tried several codes but without success. I think that the problem of my code is not the Sage but my poor knowledge of Python.
Could somebody tell me how to get output in more correct form?
Firs line of my output is normal, But the next three columns are separated in a not preferred manner:
x=var('x')
html('<!--notruncate-->')
f=file("sage_sinkx.txt","w")
for x in [0..2*pi,step=0.01]:
rows=n(x,digits=4),[n(sin(k*x), digits=3) for k in [1..10,step=4]]
s=table(rows)
f.write(str(s)+ "\n")
print s
f.close()
Let me know please if anybody could help.
Thank to all.