69238

[code]

    from scipy.special import kv
    import matplotlib.pyplot as plt
    from scipy.integrate import quad
    import numpy as np
    import math
    from math import gamma
    
    xs = np.linspace(0, 50, 10000)
    f = lambda z: kv(5/3,z)
    F = [quad(f,x,np.inf)[0]*x for x in xs]
    
    a = gamma(1/3) 
    G = [(4*math.pi/np.sqrt(3)/a)*(x/2)**(1/3) for x in xs]
    H = [((math.pi/2)**(1/2))*(x**(1/2))*(math.exp(-x))for x in xs]
    
    
    def A(x):
        if x <= 5.0*1e-3:
            return (4*math.pi/np.sqrt(3)/a)*(x/2)**(1/3) 
        elif 5.0*1-3 < x < 30:
            return quad(f,x,np.inf)[0]*x
        elif 30 <= x:
            return ((math.pi/2)**(1/2))*(x**(1/2))*(math.exp(-x))
    
    y = [A(i) for i in xs]
    
    fig = plt.figure()
    ax = fig.add_subplot(1,1,1)
    ax.grid()
    ax.plot(xs,y)
    ax.set_xlim(1e-3, 5*1e1)
    ax.set_ylim(1e-3, 1e0)
    ax.set_yscale('log')  
    ax.set_xscale('log')  
    ax.set_title('log')
    ax.set_xlabel('x')
    ax.set_ylabel('')
    plt.show()
    
[/code]

上のように書くと

[![画像の説明をここに入力](https://i.stack.imgur.com/Wjuhx.png)](https://i.stack.imgur.com/Wjuhx.png)

途中で切れてしまう。


CC BY-SA 4.0
2020-08-04T06:21:21.003
69235
2020-08-04T08:09:24.697
41194
question
python jupyter-notebook wsl
F(x)=a (x<5)、F(x)=b(10<x<30) みたいにF(x)が変化するような関数をプロットしたい


`def A(x)`内のelif節の`e`が抜けていたため、該当箇所の`A(x)`の値がNoneになっていました。

誤：`elif 5.0*1-3 < x < 30:`

正：`elif 5.0*1e-3 < x < 30:`


CC BY-SA 4.0
2020-08-04T08:09:24.697
69238
2020-08-04T08:09:24.697
35328
69235
answer