Terence Tao: Using ChatGPT to write code saves so much time

(Free forever, scan the QR code to join)

Reprinted from: Heart of the Machine

Since using ChatGPT, Tao Zhexuan has come to praise it from time to time.

Mathematician Terence Tao loves ChatGPT so much!

A few months ago, we reported that Terence Tao used ChatGPT to assist in solving math problems. At that time, he felt that although the test results were not satisfactory, he did not have a completely negative attitude towards ChatGPT. He feels that large language models like ChatGPT can be used to do some semi-finished semantic search work in mathematics, that is, use it to generate some hints.

22180c5e20943ccadd17bf86e76b4f9b.png

Tao Zhexuan also believes that “I predict that if used properly, by 2026, AI will become a trusted co-author in mathematical research and many other fields.”

Recently, Tao Zhexuan shared a new experience: using ChatGPT to write Python code to calculate the mathematical problem of Phi non-decreasing sequence. He thinks it is also very valuable.

The premise a while ago was still “future”, and now he has expressed his opinions on ChatGPT’s mathematics. It can be seen that he still has not given up and is still trying to find ways to use large AI models to improve his work efficiency.

2e13490504a50becac27b207d6cd0f12.png

In this experience, the Prompt he used was:

dfe89b4f098348566873dc8fffe83db6.png

In the result of the conversation, ChatGPT explained it first and gave the following Python code:

import math

def phi(n):
    """Compute the Euler totient function for n."""
    result = n
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            while n % i == 0:
                n //= i
            result -= result // i
    if n > 1:
        result -= result // n
    return result

def is_non_decreasing(seq):
    """Check if a sequence is non-decreasing."""
    for i in range(1, len(seq)):
        if seq[i] < seq[i-1]:
            return False
    return True

def longest_non_decreasing_phi_subsequence(n):
    """Find the length of the longest subsequence of {1,...,n} on which phi is non-decreasing."""
    phi_values = [phi(i) for i in range(1, n + 1)]
    max_length = 0
    for i in range(n):
        for j in range(i, n):
            if is_non_decreasing(phi_values[i:j + 1]):
                max_length = max(max_length, j-i + 1)
    return max_length

n=6
print(longest_non_decreasing_phi_subsequence(n))

# Output: 5

In Tao Zhexuan’s view, the generated results have very interesting points. For example, it can generate a very smart program to calculate the totient function. However, there are also calculation deviations in some places.

After using it, Tao Zhexuan thought the result was good enough. “I was able to use the code originally generated by GPT as a starting point to manually generate the code I wanted, which probably saved me about half an hour of work.” In addition, he also said that in the future For similar calculations, he may again turn to GPT to provide the initial code.

In the interaction with readers, we can find that everyone is very welcome to ChatGPT to help write code. Some people say that I don’t know much about code, but with ChatGPT, writing programs from scratch is no longer a problem.

c5fc7dbc8f52307e3ceca243f0857e6b.jpeg

The first generative AI killer application, so scary?

At this time, someone asked: If you are not good at coding, how do you know whether the code generated by ChatGPT is correct?

Tao said, “I don’t code in Python very often, so I haven’t mastered some basic syntax (such as for loops), and there are some subtleties between passing by reference and passing by value, which confuses me. Almost every time, including when I ended up initializing a 2D array incorrectly, I had to debug by manually checking for dynamic updates. So, it helps a lot for me to have almost correct code that already has the correct syntax, otherwise I would have to search through almost every line of code to figure out how to express it exactly.

Rather than writing mathematical proofs (which is more of my domain expertise), I agree with you that the not entirely correct arguments provided by GPT would not be particularly helpful to me. AI-generated content is worse than writing it myself from scratch.

5ba406201a05e12ead148de48e207856.jpeg

Use large models to master unfamiliar professional knowledge. It seems that this is how people will use ChatGPT to improve productivity in the future?

In addition, some people are more concerned about the source of these generated codes? Are there any copyright issues? But it seems really difficult to trace the origin.

727777d3adc061775cc702fdb38f3ac0.png

In your work, will you use ChatGPT to generate code as an assistant?

Reference link:

https://mathstodon.xyz/@tao/110991566012143311

https://chat.openai.com/share/a022e1d6-dddc-4817-8bbd-944a3e742d9f

Finally, it’s advertising time. Let me recommend our member group (you can ignore it if you don’t like it). Currently, there are venture capital angel investors, headhunters, HR, Douyin Vs, emotional bloggers, lawyers, psychological counselors, medical sales, and real estate. Students from insurance, piano teachers, operators, corporate consulting, cross-border e-commerce, construction, Internet industry data analysts, back-end development, python testing and other industries joined.

WeChat consultation: coder_v5 (be sure to note your purpose)


Long press on WeChat to preview content

If you are not satisfied within three days, you can get a direct refund! ! !

5c83420b858fa66de1fb4f24c511ea9a.png

Recommended reading:
Getting Started: The most comprehensive question about learning Python from scratch | Learning Python from scratch for 8 months | Practical projects | This is the shortcut to learning Python
Essential information: Crawling Douban short reviews, the movie "The Next Us" | Analysis of the best NBA players in 38 years | From highly anticipated to word of mouth! Detective Tang 3 is disappointing | Watch the new Legend of Heaven and Slay the Dragon with laughter | The king of lantern riddle answers | Use Python to make a massive sketch of young ladies | Mission: Impossible is so popular, I use machine learning to make a mini recommendation system for movies
Fun: Pinball game | Nine-square grid | Beautiful flowers | Two hundred lines of Python "Tiantian Cool Run" game!
AI: A robot that can write poetry | Colorize pictures | Predict income | Mission: Impossible is so popular, I use machine learning to make a mini movie recommendation system
Gadget: Convert Pdf to Word, easily convert tables and watermarks! | Save html web pages to pdf with one click! | Goodbye PDF extraction charges! | Use 90 lines of code to create the most powerful PDF converter, one-click conversion of word, PPT, excel, markdown, and html | Create a DingTalk low-price ticket reminder! |60 lines of code made a voice wallpaper switcher that I can watch every day! |