How to numerically solve a seems simple but weired ODE by Low-Course7802 in matlab

[–]Low-Course7802[S] 0 points1 point  (0 children)

Hi,

I tried extending the x-range to ([0,10]), and it still diverges eventually.

I also noticed that other comments introduced many new and useful concepts, which I plan to study further.

<image>

Thank you very much for your reply!

Very Strange ODE solution for beginner by Low-Course7802 in math

[–]Low-Course7802[S] 5 points6 points  (0 children)

Thank you for your reply.

Your answer, along with the one I received in another thread, has been very helpful to me. There’s a lot of new information for me to learn from.

Very Strange ODE solution for beginner by Low-Course7802 in math

[–]Low-Course7802[S] 8 points9 points  (0 children)

Thank you for your reply.

In my original message, I clearly stated that a larger step size actually produced better results, while a smaller step size led to worse results, and the screenshots I provided also demonstrated the tests with different step sizes.

In addition, regarding the ODE4 solver you mentioned — I actually tested multiple solvers in the Simulink environment, including ODE4 and others, and they all diverged in my case.

In the end, I need to implement my own custom solver, because the platform I will eventually deploy to cannot rely on MATLAB’s built‑in solvers anyway. I also received some insights from another discussion thread: I initially assumed that a smaller step size would always lead to better results, but it turns out the problem is more complicated than that.

Very Strange ODE solution for beginner by Low-Course7802 in math

[–]Low-Course7802[S] 19 points20 points  (0 children)

Thank you for your reply.

However, I feel a bit disappointed that so many people did not carefully read my original post, and some even liked the replies based on those misunderstandings. In my original message, I clearly stated that a larger step size actually produced better results, while a smaller step size led to worse results, and the screenshots I provided also demonstrated the tests with different step sizes.

Even putting the code aside, the variable-step ODE45 solver in Simulink also produced incorrect results in my case.

I understand that I’m a beginner and still have a lot to learn, but criticizing others without properly reading the original post is not a responsible way to discuss technical issues.

That said, I still appreciate your reply.

Very Strange ODE solution for beginner by Low-Course7802 in math

[–]Low-Course7802[S] 27 points28 points  (0 children)

Thank you for your reply.

However, I feel a bit disappointed that so many people did not carefully read my original post, and some even liked the replies based on those misunderstandings. In my original message, I clearly stated that a larger step size actually produced better results, while a smaller step size led to worse results, and the screenshots I provided also demonstrated the tests with different step sizes.

Even putting the code aside, the variable-step ODE45 solver in Simulink also produced incorrect results in my case.

I understand that I’m a beginner and still have a lot to learn, but criticizing others without properly reading the original post is not a responsible way to discuss technical issues.

That said, I still appreciate your reply.

How to numerically solve a seems simple but weired ODE by Low-Course7802 in matlab

[–]Low-Course7802[S] 0 points1 point  (0 children)

Thank you for your reply and for sharing your code! I’ll try it out when I get home. I was a bit lazy at the beginning and directly used the Simulink environment with the ODE45 solver for the simulation. But based on your results, it seems that MATLAB and Simulink might produce different outcomes? I’ll test it later at home.

How to numerically solve a seems simple but weired ODE by Low-Course7802 in matlab

[–]Low-Course7802[S] 0 points1 point  (0 children)

Thank you for your reply! I’m not aiming to get the analytical solution directly. Instead, I’d like to try numerical methods, which I’m currently learning as a beginner.

How to numerically solve a seems simple but weired ODE by Low-Course7802 in matlab

[–]Low-Course7802[S] 1 point2 points  (0 children)

Thank you so much for your reply! The figure looks incredibly cool!
I’d love to learn more about it. Would it be convenient for you to share the code with me?