最近話題の、chat gpt
僕もいろんなプログラムを書け
とAIに命じては、
本当に打ち返してこられて、
おお、、、
俺にできることはもう少ないな、、、
と絶望している。
今回は、その一端を紹介しよう。
まずは、
グラフの面積の計算をして、
グラフの面積を図示するプログラム(python)
import numpy as np
import matplotlib.pyplot as plt# Define the function to be plotted
def f(x):
return x**2# Calculate the values of the function over a range of x values
x = np.linspace(0, 1, 100)
y = f(x)# Calculate the area under the curve
area = np.trapz(y, x)# Plot the function
plt.plot(x, y)# Fill the area under the curve
plt.fill_between(x, y, alpha=0.5)# Add a title and labels to the plot
plt.title("Area Under the Curve")
plt.xlabel("x")
plt.ylabel("y")# Display the plot
plt.show()# Print the area under the curve
print("Area:", area)
そのままコピーして、
グーグルのコーラボにペーストして実行してみた結果
あああああ、
なんてこった。
プログラミングを勉強する気が失せる。
しかも、こんな丁寧な説明付き。
優秀すぎだぜ、chat gpt
恐れおののくぜ、chat gpt
もう俺は働く必要がない気がする。
もうやけだ。
ちなみに、上のプログラム、関数を多少いじれば、いろんな関数に応用可能である。
例えば、サインとかコサインとか、そんなのは余裕だ。
import numpy as np
import matplotlib.pyplot as plt# Define the function to be plotted
def f(x):
return np.sin(x)+np.cos(x)# Calculate the values of the function over a range of x values
x = np.linspace(0, 1, 100)
y = f(x)# Calculate the area under the curve
area = np.trapz(y, x)# Plot the function
plt.plot(x, y)# Fill the area under the curve
plt.fill_between(x, y, alpha=0.5)# Add a title and labels to the plot
plt.title("Area Under the Curve")
plt.xlabel("x")
plt.ylabel("y")# Display the plot
plt.show()# Print the area under the curve
print("Area:", area)
おーらよっと、というノリで、
こんな計算も秒で可能だ。
もうね、無理。
対抗しようとか、勝とうとか一ミリも思いません。
無理です。勝てへんて。
こんなん、無理やんけ。
どう考えても無理やんけ笑
このブログのデザインも、作ってもらうか?笑