I tried ChatGPT, and I have mixed impressions. When ChatGPT is right --in an encyclopedic type of information-- it is incredibly accurate and fluid. However, in “full certainty,” ChatGPT also makes mistakes, but because of the “authoritative” style, it might get hard to uncover them.
To answer your question, in the hands of an expert, I believe ChatGPT can be helpful most of the time but also unpredictable: does it take more time to write something from scratch or debug somebody else’s code?
Here is an example dialog that I had yesterday at the ChatGPT Playground. I selected a theme that anybody can follow and appreciate its nuances.
Human: What is the theorem that every even natural number is the sum of two prime numbers?
AI: The theorem you are looking for is called the Goldbach Conjecture. It states that every even natural number greater than 2 can be expressed as the sum of two prime numbers.
Human: How is it proven?
AI: The Goldbach Conjecture has yet to be proven, though it has been tested by mathematicians over the centuries and there is strong evidence that it is indeed true.
Human: List some examples please.
AI: Examples of the Goldbach Conjecture include: 4 = 2 + 2, 6 = 3 + 3, 8 = 3 + 5, 10 = 3 + 7, 12 = 5 + 7, 14 = 3 + 11 and 16 = 3 + 13.
Human: How do I find the two prime numbers that sum up to 100?
AI: The two prime numbers that sum up to 100 are 97 + 3, 89 + 11, 83 + 17, 79 + 21, 73 + 27, 71 + 29, 67 + 33, 61 + 39 and 59 + 41.
Human: How did you do that?
AI: I used a technique called trial division to find all possible combinations of two prime numbers that sum up to 100. I then filtered out the combinations that do not add up to 100, leaving only the valid solutions.
Human: What is the complexity to find them for an arbitrary natural number n?
AI: The complexity of finding the prime numbers that sum up to an arbitrary natural number n is O(\sqrt{n}). This means that the time required to find the prime numbers that sum up to n increases as the square root of n grows.
Human: Please provide a function in Julia that does this.
AI: Sure, here is a function written in Julia that will find the prime numbers that sum up to an arbitrary natural number n:
function find_primes(n)
primes = Array{Int64,1}()
for i in 2:sqrt(n)
if isprime(i) && isprime(n - i)
push!(primes, (i, n - i))
end
end
return primes
end
Besides the problematic push!
, the code above appears correct. But it has a severe bug, the loop bound is wrong!
Human: What is the complexity of this function?
AI: The complexity of this function is O(\sqrt{n}). This means that the time required to run this function increases as the square root of n grows.
Human: What about the complexity of isprime
?
AI: The complexity of the isprime
function is O(n). This means that the time required to run this function increases linearly with respect to the input number.
Human: What is the \sum_{i=2}^{\sqrt{n}} i?
AI: The sum of all the numbers from 2 to \sqrt{n} is given by
\sum_{i=2}^\sqrt{n} i = \frac{(\sqrt{n} - 1)(\sqrt{n} + 2)}{2}.
So assuming the loop bound is correct, the complexity is wrong, because it ignores the cost of isprime
, even tough it is capable to do the symbolic summation (for the wrong bound) correctly.
I will close with a very interesting note. I run this yesterday.
Human: What is the fifth root of 32?
AI: The fifth root of 32 is approximately 1.717.
Human: What is 2 raised to the fifth power?
AI: 2 raised to the fifth power is 32.
Human: What is the fifth root of 32?
AI: The fifth root of 32 is approximately 1.717.
Human: Are you sure?
AI: Yes, I am sure. The fifth root of 32 is approximately 1.717.
But today it is correct!