不懂数学别想靠GPT-4o实现飞跃!

目录

01 数学不好不配玩GPT?!

​编辑02 网友们指出图表存在「幻觉」




使用ChatGPT一年半,陶哲轩有什么感想呢?

最近,这位数学领域的领军人物陶哲轩总结了ChatGPT对他数学研究的影响。



令人惊讶的是,他发现AI在数学研究中的作用有限,但却大大提高了他在编码和制作图表等次要任务上的效率。

所以,进行数学研究还是需要扎实的数学基础,单靠AI是不够的。

01 数学不好不配玩GPT?!


对于数学不够好的人来说,AI的帮助可能也不如预期那么大。

陶哲轩提到,使用Python的matplotlib.pyplot库后,他现在可以更轻松地创建定性图表,说明更多非正式关系。



没体验过OpenAI最新版GPT-4o?快戳最详细升级教程,几分钟搞定:
升级ChatGPT-4o Turbo步骤icon-default.png?t=N7T8https://www.zhihu.com/pin/1768399982598909952

如何使用WildCard正确方式打开GPT-4o,目前 WildCard 支持的服务非常齐全,可以说是应有尽有!

官网有更详细介绍:WildCard


在此之前,他只能通过文字或手绘草图来表达这些关系。



他发现一个有效的工作流:先向ChatGPT请求一个简化的代码示例,然后自己调整和修改代码,直到输出符合预期为止。

通过几轮对话,他在几分钟内就能得到所需的图表。



陶哲轩总结道,AI在他的主要数学研究领域帮助有限,但在编码和制作图表等次要任务上大大提高了他的能力,同时提升了他在一般任务中的水平,至少达到了初学者的水准。


他还指出,对于那些擅长编程但不太精通数学的人来说,AI的作用可能没那么显著。

陶哲轩和ChatGPT的对话,具体如下——


 

陶哲轩问:「在Python中,我知道如何使用pyplot软件包制作单个图形。有没有方法可以用Python制作多个图形的幻灯片或动画图像?

比如,制作一个幻灯片,展示函数$x$, $x^2$, $x^3$, $x^4$在区间$x \in [0,1]$上的图形。」

ChatGPT回答:「是的,你可以使用matplotlib包中的matplotlib.animation模块,在Python中创建多个图形的幻灯片或动画图像。」

接下来,ChatGPT就给出了创建该函数动画的具体步骤,详细给出了代码——

  • Install matplotlib if you haven't already:
pip install matplotlib
  • Use the following code to create an animation:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

# Define the range for x
x = np.linspace(0, 1, 400)

# Define the functions
functions = [lambda x: x, lambda x: x**2, lambda x: x**3, lambda x: x**4]

# Create a figure and axis
fig, ax = plt.subplots()
line, = ax.plot(x, functions[0](x))

# Set axis labels and title
ax.set_xlabel('x')
ax.set_ylabel('f(x)')
ax.set_title('Animated Functions')

# Initialize the animation function
def init():
    line.set_ydata([np.nan] * len(x))
    return line,

# Update the animation function
def update(frame):
    line.set_ydata(functions[frame](x))
    ax.set_title(f'Function: $x^{frame+1}$')
    return line,

# Create the animation
ani = animation.FuncAnimation(
    fig, update, frames=len(functions), init_func=init, blit=True, repeat=True, interval=1000
)

# Save the animation as a gif
ani.save('animated_functions.gif', writer='imagemagick')

plt.show()

同时, ChatGPT还给出了相应解释:

解释:

  • 导入必要的模块:我们导入numpy用于数值运算、pyplot绘图和animation创建动画的模块。
  • 定义 x 的范围:我们创建一个x从 0 到 1 的数组,其中包含 400 个点。
  • 定义函数:我们使用一个 lambda 函数列表来表示XXX,X2x^2X2,X3x^3X3, 和X4x^4X4。
  • 创建图形和轴:我们创建一个用于绘图的figax并初始化一条线图。
  • 设置轴标签和标题:我们标记轴并为图表设置标题。
  • 初始化动画函数:init函数设置动画的初始状态。
  • 更新动画函数:update函数更新每一帧的线图的 y 数据。
  • 创建动画:我们使用创建动画FuncAnimation,指定图形、更新函数、帧数和其他参数。
  • 保存动画:我们使用将动画保存为 GIF imagemagick

确保您的系统上安装了 ImageMagick,以便将动画保存为 GIF。

这将创建函数的动画 GIFXXX,X2x^2X2,X3x^3X3, 和X4x^4X4在间隔内[0,1][0,1][ 0 ,1 ]。

ChatGPT给出的答案很好,但每个动画中只能显示一个函数。

为了达到目的,陶哲轩进一步提问道:「如果我想让每个动画显示两个函数呢?例如,第一帧显示$x$和$x^2$,第二帧显示$x^2$和$x^3$,第三帧显示$x^3$和$x^4$。」

ChatGPT表示:「要在动画的每一帧显示两个函数,可以修改代码,为每一帧绘制两条线。」

接下来,ChatGPT还是给出了详细的代码。

  • Install matplotlib if you haven't already:
pip install matplotlib
  • Use the following code to create the animation with two functions per frame:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

# Define the range for x
x = np.linspace(0, 1, 400)

# Define the functions
functions = [lambda x: x, lambda x: x**2, lambda x: x**3, lambda x: x**4]

# Create a figure and axis
fig, ax = plt.subplots()
line1, = ax.plot(x, functions[0](x), label='$x$')
line2, = ax.plot(x, functions[1](x), label='$x^2$')

# Set axis labels and title
ax.set_xlabel('x')
ax.set_ylabel('f(x)')
ax.legend()
ax.set_title('Animated Functions')

# Initialize the animation function
def init():
    line1.set_ydata([np.nan] * len(x))
    line2.set_ydata([np.nan] * len(x))
    return line1, line2

# Update the animation function
def update(frame):
    line1.set_ydata(functions[frame](x))
    line2.set_ydata(functions[frame+1](x))
    ax.legend([f'$x^{frame+1}$', f'$x^{frame+2}$'])
    return line1, line2

# Create the animation
ani = animation.FuncAnimation(
    fig, update, frames=len(functions)-1, init_func=init, blit=True, repeat=True, interval=1000
)

# Save the animation as a gif
ani.save('animated_double_functions.gif', writer='imagemagick')

plt.show()

随后ChatGPT照例给出了详细解释:为了在「0,1」的区间上创建($x$和$x^2$,$x^2$和$x^3$,$x^3$和$x^4$)的函数,需要定义x的范围、定义函数、创建图形和坐标轴、初始化动画函数等。

陶哲轩表示:「这样就差不多可以了,但图例似乎无法随动画更新,它会停留在x^3和 x^4。有没有办法在每一帧都更新图例?

针对这个问题,ChatGPT给出了对策,就是通过清除现有图例并创建新的图例,来更新每一帧的图例。

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

# Define the range for x
x = np.linspace(0, 1, 400)

# Define the functions
functions = [lambda x: x, lambda x: x**2, lambda x: x**3, lambda x: x**4]

# Create a figure and axis
fig, ax = plt.subplots()
line1, = ax.plot(x, functions[0](x), label='$x$')
line2, = ax.plot(x, functions[1](x), label='$x^2$')

# Set axis labels and title
ax.set_xlabel('x')
ax.set_ylabel('f(x)')
ax.set_title('Animated Functions')

# Initialize the animation function
def init():
    line1.set_ydata([np.nan] * len(x))
    line2.set_ydata([np.nan] * len(x))
    return line1, line2

# Update the animation function
def update(frame):
    line1.set_ydata(functions[frame](x))
    line2.set_ydata(functions[frame+1](x))
    ax.legend([f'$x^{frame+1}$', f'$x^{frame+2}$'])
    return line1, line2

# Create the animation
ani = animation.FuncAnimation(
    fig, update, frames=len(functions)-1, init_func=init, blit=True, repeat=True, interval=1000
)

# Save the animation as a gif
ani.save('animated_double_functions.gif', writer='imagemagick')

plt.show()

ChatGPT解释道:更新函数中的ax.legend()调用,就可以清除现有图例,并且使用每帧的新标签进行更新了。这样就可以确保,图例反映的是当前显示函数的功能。

陶哲轩继续提问——

「我想让Python绘制一个用数字描述,但用字符串标注的函数图。例如,我想绘制这样一幅图:横轴上标有『今天』、『下周』和『明年』,分别代表x=1、x=2和x=3的位置,纵轴上标有『初级』、『中级』和『专家』,分别代表y=1、y=4和y=9的位置(因此纵向标签的间距并不相等),要绘制的图形是抛物线y=x^2的图形。如何绘制?」

ChatGPT回答:「要绘制横轴和纵轴用字符串标注但与特定数值相对应的图表,可以使用matplotlib库并自定义刻度标签。

  • Install matplotlib if you haven't already:
pip install matplotlib
  • Use the following code to create the plot:
import numpy as np
import matplotlib.pyplot as plt

# Define the numerical values for the x and y positions
x_values = [1, 2, 3]
y_values = [1, 4, 9]

# Define the corresponding string labels for x and y axes
x_labels = ["Today", "Next week", "Next year"]
y_labels = ["Beginner", "Intermediate", "Expert"]

# Define the function to be plotted (y = x^2)
x = np.linspace(1, 3, 100)
y = x**2

# Create a figure and axis
fig, ax = plt.subplots()

# Plot the function
ax.plot(x, y, label='$y=x^2$')

# Set the x and y axis labels
ax.set_xlabel('Time')
ax.set_ylabel('Level')

# Set the x and y axis tick positions and labels
ax.set_xticks(x_values)
ax.set_xticklabels(x_labels)
ax.set_yticks(y_values)
ax.set_yticklabels(y_labels)

# Add a legend
ax.legend()

# Set the title
ax.set_title('Parabola $y=x^2$ with Custom Axis Labels')

# Display the plot
plt.show()

并且给出了相应解释:



02 网友们指出图表存在「幻觉」



在陶哲轩的评论区,有网友指出图表的准确性问题:两条线之间的山谷是什么意思?那里相对位移应该更大才对。

陶哲轩回应道,用手绘涂鸦表达非正式想法是合适的,因为它可以避免AI工具在标准化过程中带来的缺陷。

他解释说,如果想传达复杂关系的图像,手绘图并不方便。



一方面是因为他不擅长手绘,另一方面是因为手绘图无法轻松编辑。

他借助Python可以多次尝试,找到能捕捉细微差别的方法。

例如,他确实有意让初级领域和次级领域之间的山谷在AI的帮助下获得更高的推动力。

在陶哲轩看来,纯数学是他的主要领域,计算机编程是次要技能。

尽管他对设置和安装机器学习软件包没有直接经验,但这些领域与他的专业相邻,所以他将它们放在图的中间位置。


如何使用WildCard正确方式打开GPT-4o,目前 WildCard 支持的服务非常齐全,可以说是应有尽有!

官网有更详细介绍:​​​​​WildCard

推荐阅读:

GPT-4o不仅能写代码,还能自查Bug,程序员替代进程再进一步!

GPT-4替代大学生参加考试,94%成功作弊未被发现!

  • 23
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值