質問編集履歴

3

改善と問題の提起

2020/07/28 20:45

投稿

hataki7
hataki7

スコア4

test CHANGED
File without changes
test CHANGED
@@ -65,3 +65,47 @@
65
65
 
66
66
 
67
67
  ```
68
+
69
+
70
+
71
+ 追加変更
72
+
73
+ ```python
74
+
75
+ from scipy.special import kv
76
+
77
+ import matplotlib.pyplot as plt
78
+
79
+ from scipy.integrate import quad
80
+
81
+ import numpy as np
82
+
83
+
84
+
85
+ xs = np.arange(0.0,10,0.1)
86
+
87
+ f = lambda z: kv(5/3,z)
88
+
89
+ F = [quad(f,x,np.inf)[0]*x for x in xs]
90
+
91
+
92
+
93
+
94
+
95
+ with open("test4.txt","w") as f:
96
+
97
+ print(xs,F,file=f)
98
+
99
+ ```
100
+
101
+
102
+
103
+ でtxtに起こせはするけれど,
104
+
105
+ [x=0 0.1 0.2~][F=0.91 0.90 0.89~]
106
+
107
+ になって見づらいので
108
+
109
+ [X=0.1 F=0.90 x=0.2 F=0.89 ~]
110
+
111
+ にしたいです。

2

画像の追加

2020/07/28 20:45

投稿

hataki7
hataki7

スコア4

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  関数F(x)=x∫[x~∞] special.kv(5/3,y)dy の各xの値をtxtに書き込みたい。
2
2
 
3
-
3
+ ![イメージ説明](4bd434f2f9e4fd434fdb72832048e693.png)
4
4
 
5
5
  ```python 
6
6
 

1

誤字の修正

2020/07/28 20:03

投稿

hataki7
hataki7

スコア4

test CHANGED
File without changes
test CHANGED
@@ -1 +1,67 @@
1
1
  関数F(x)=x∫[x~∞] special.kv(5/3,y)dy の各xの値をtxtに書き込みたい。
2
+
3
+
4
+
5
+ ```python 
6
+
7
+ from scipy.special import kv
8
+
9
+ import matplotlib.pyplot as plt
10
+
11
+ from scipy.integrate import quad
12
+
13
+ import numpy as np
14
+
15
+
16
+
17
+ xs = np.linspace(0, 10, 1000)
18
+
19
+ f = lambda z: kv(5/3,z)
20
+
21
+ F = [quad(f,x,np.inf)[0]*x for x in xs]
22
+
23
+
24
+
25
+ x=0.0
26
+
27
+ h=0.001
28
+
29
+
30
+
31
+ with open("test3.txt","w") as f:
32
+
33
+ while x <= 10:
34
+
35
+ x += h
36
+
37
+ print("{:,5f} {:7f}".format(x,F),file=f)
38
+
39
+ print(x,F)
40
+
41
+ ```
42
+
43
+ エラー
44
+
45
+ ```python
46
+
47
+ ---------------------------------------------------------------------------
48
+
49
+ ValueError Traceback (most recent call last)
50
+
51
+ <ipython-input-22-e3787445c636> in <module>
52
+
53
+ 14 while x <= 10:
54
+
55
+ 15 x += h
56
+
57
+ ---> 16 print("{:,5f} {:7f}".format(x,F),file=f)
58
+
59
+ 17 print(x,F)
60
+
61
+
62
+
63
+ ValueError: Invalid format specifier
64
+
65
+
66
+
67
+ ```