I submitted to ChatGPT 4 several ordinary differential equations with different levels of complexity and always ChatGPT 4 proposed correct solutions. But with an equation ChatGPT 4 found some difficulties: the first time it told me that there was no analytical solution, the second time it provided me with a blatantly wrong solution, the third time it gave me the correct solution.
The equation is:
The right solution is:
\(y(x) = log(c_1 + e^x) \)you can see this is the solution using Wolfram Alpha following this link: https://www.wolframalpha.com/input?i=y%27+%3D+e%5E%28x-y%29
First attempt
My prompt was:
First of all there was an interesting thing: ChatGPT 4 showed an error (namely “Error analyzing”) and the following answer:
On the error “Error analyzing” there was a linkable element that showed the underlying python code generated by ChatGPT 4 to solve the equation. This is the code:
# Redefine the first-order differential equation y' = e^(x - y)
first_order_differential_equation = Eq(y.diff(x), exp(x - y))
# Solve the first-order differential equation
first_order_solution = dsolve(first_order_differential_equation)
first_order_solution
Second attempt
After that answer I typed this prompt:
and ChatGPT 4 answered:
1. Rearrange the Equation:
- Start with \(y’ = e^{x – y} \).
- To solve this equation, we aim to separate the variables \(y \) and \(x \). This means getting all \(y \) terms on one side of the equation and all \(x \) terms on the other.
- We can rewrite the equation as \(e^y \, dy = e^x \, dx \)
- Next, integrate both sides of the equation. The integral of \(e^y \, dy \) is \(\int e^y \, dy = e^y \), and the integral of \(e^x \, dx \) is \(\int e^x \, dx = e^x \).
- After integration, we get \(e^y = e^x + C \), where C is the constant of integration.
- Finally, solve for \(y \) by taking the natural logarithm of both sides to get \(y = x + \ln(C) \), where \(\ln(C) \) represents an arbitrary constant.
The proposed solution is obviously wrong.
THIRD attempt
So I invited ChatGPT 4 to review the steps with this prompt:
and ChatGPT 4 answered:
1. Rearrange the Equation for Separable Form:
- The given equation is \(y’ = e^{x – y} \).
- To make it separable, we need to express it in the form \(f(y) \, dy = g(x) \, dx \).
- We can rewrite the equation as \(e^y \, dy = e^x \, dx \).
- Integrate both sides of the equation.
- The integral of \(e^y \, dy \) is \(\int e^y \, dy \), and the integral of \(e^x \, dx \) is \(\int e^x \, d \).
- After integration, we have \(\int e^y \, dy = \int e^x \, dx \).
- The integral \(\int e^y \, dy \) is \(e^y \) and the integral \(\int e^x \, dx \) is \(e^x \).
- Thus, the equation becomes \(e^y = e^x + C \), where \(C \) is the constant of integration.
- To solve for \(y \), we rearrange the equation: \(e^y = e^x + C \).
- Taking the natural logarithm of both sides gives us \(y = \ln(e^x + C) \).
and this time the proposed solution is the right one.
Conclusion
The legitimate question is: can ChatGPT 4 solve mathematical problems? As we saw yes, it can solve them, and I before writing this place I proposed a dozen differential equations and ChatGPT 4 has always found the right solution at the first attempt. However, ChatGPT 4 is not designed to solve mathematical problems (as seen in this post that two wrong solutions were proposed before having the right one), so in my opinion, you should not blindly trust the result, but first ask ChatGPT 4 to explain the steps and check all the steps carefully.
In the next post we will show how to use the Wolfram Plugin for ChatGPT and then we will have the combination of two tools: ChatGPT 4 operates on the natural language part, Wolfram Alpha takes care of the mathematical problem solving part.
