小编era*_*189的帖子

为什么我收到错误SyntaxError:此代码的语法无效

这是python中的代码,它计算f (x) =? ((-1)*x)/(x*x+n*n)
n从1到无穷大......正确到0.0001,范围1 <x <100,步长为0.1.
但我得到一个语法错误,因为我是python编程的新手...

    from scipy import *
    from matplotlib.pyplot import *
    x=arange(0.1,100,0.1)
    f=zeros(len(x))
    s=-1
    for n in range (1,10000):
        t=s*x/(x*x+n*n)
        f +=t
        s =-s
        if max(abs(t))< 1e-4
            break
    for xx in c_[x,f]:
        print "%f    %f" % (xx[0],xx[1])
Run Code Online (Sandbox Code Playgroud)

python scipy python-2.7

1
推荐指数
1
解决办法
923
查看次数

标签 统计

python ×1

python-2.7 ×1

scipy ×1