https://twitter.com/solove_math/status/1035480802144833536
==ここからコード==
using Plots
function func2(n)
return [1.0/(2.0*Float64(n) - 1.0),-1.0/(4.0*Float64(n) - 2.0) ,-1.0/(4.0*Float64(n)) ]
end
function func1(n)
return [1.0/(2.0*Float64(n) - 1.0),-1.0/(2.0*Float64(n) )]
end
function main()
n = 60
y = 0.0
y2= 0.0
arr_y = zeros(Float64,n, 2)
#arr_x = zeros(Int64,n)
arr_x = 1:n
for i in 1:n/2
y = func1(i)
arr_y[2*Int64(i)-1,1]= y[1]
arr_y[2*Int64(i) ,1]= y[2]
end
for i in 1:n/3
y = func2(i)
arr_y[3*Int64(i)-2,2]= y[1]
arr_y[3*Int64(i)-1,2]= y[2]
arr_y[3*Int64(i) ,2]= y[3]
end
for i in 2:n
arr_y[i,1]= arr_y[i,1] + arr_y[i-1,1]
arr_y[i,2]= arr_y[i,2] + arr_y[i-1,2]
end
plt = plot(arr_x,arr_y)
gui(plt)
readline()
end
main()
==ここまでコード==
0 件のコメント:
コメントを投稿