I created a program in a Jupyter notebook that accepts a single number as input and then displays various properties of the number as a simple text output. I put the following prompt to Google's AI Studio:
The following code is what I created using SageMath. It is designed to accept a single number as input. Typically the number has five digits corresponding to my age in days (I'm currently 27819 days old). I'm using the program to find out interesting numerical facts about this number associated with my diurnal age. By trial and error I've had to limit the number of iterations for various tasks or else the program is too slow or crashes. For example, in finding the home prime for a number I've limited the iterations to just 10. What I want is to improve the output of this code to make it more readable and more informative in terms of additional graphs or charts? Feel free to modify the code to make it more efficient, informative or comprehensible. The code modifications can be in Python or SageMath, whatever is easier for you. I just need the program to run in a Jupyter notebook using an M1 Macbook Air and execute within say a minute or so. Any annotations, charts or tables that will enhance the output of the program will be appreciated. Any additional fun facts about the input number can be added to the program as you see fit. The key challenge is to enhance the output which is currently quite basic and limited to simple text. It's important that spacing between the different sections be consistent and that the various sections are clearly identified. I've added some commentary to each section but this can be expanded or modified if desired.
What followed was something of a nightmare as the resulting code that was produced was full of bugs that AI Studio was never able to fix. Once I did get the code to run but many of the number properties that were displayed in my original code were no longer there. To be fair, it did produce a much improved output for the sections where it did work as can be seen in Figure 1. However, the attempts to get the code to run properly were frustrating and ultimately futile.
![]() |
Figure 1 |
There are numerous alternatives out there and I'll have to turn to them if I want to generate code that works. I tried ChatGPT and it revised the faulty AI Studio code but stopped at line 106 (there are about 875 lines of code) probably because I'd exceeded my free allowance of tokens. So dead end there.
Grok 3 failed to understand that the Jupyter notebook can be set to SageMath 10.3 not just Python 3 and gave the following comments:
The code you provided appears to be written for SageMath, but you're trying to run it in a Jupyter notebook, which typically uses a Python kernel with libraries like Matplotlib. This mismatch is likely causing some of the errors, as SageMath-specific functions and syntax (e.g., latex(), N(), Integer(), and certain mathematical operations) aren't directly compatible with a standard Python environment. Additionally, there are a few other issues that could lead to errors, such as undefined variables, plotting issues, and missing imports.
I'll modify the code to make it compatible with a standard Jupyter notebook environment using Python 3, while preserving its core functionality. I'll replace SageMath-specific functions with equivalent Python alternatives, ensure proper imports, and fix potential glitches.
After Grok 3 turned all the code to Python 3, it was still full of bugs and never managed to execute all the code. I'm getting the feeling that my original code, written in SageMath, is possibly at the core of the problem. When an AI tries to improve the code, using SageMath or Python, then all sorts of glitches arise because of the modifications to my original code. It would be better to build the whole code base from scratch using Python only and indicating exactly what I want. One thing I've realised is that LaTeX can be applied to the Jupyter notebook output to greatly improve readability.
It occurred to me that I lot of my code just reproduces what a site like Numbers Aplenty always publicly provides. I asked Gemini 2.5 Flash the following question:
Is it possible to create Python code that draws on the content of a site like Numbers Aplenty. For example, let's say I enter 27819 into my program. Can I get the program to then access https://www.numbersaplenty.com/27819 and extract some or all of the information from it. For example, one of the properties of the number that the site displays is "It is a junction number, because it is equal to n+sod(n) for n = 27792 and 27801". Can I get this information to show up as output in my code? If it is feasible then could you create the necessary code to do this or explain why this is not possible.
The response was encouraging:
Yes, it is absolutely possible to create Python code that draws on the content of a site like Numbers Aplenty and extracts specific information. This process is commonly known as web scraping. Numbers Aplenty doesn't seem to offer a public API (Application Programming Interface) for directly accessing its data in a structured format. This means we'll need to use web scraping techniques.
It then went on to confidently provide code for doing this but of course it didn't work. Excuses were made and additional programs and drivers were recommended for download to remedy the problem. In short, no go. I should try other AI tools but frankly the whole process has exhausted me. I need a rest.