Surreal Calculator¶
Short description¶
Create a program or library that can handle arithmetic and comparisons on surreal numbers. The tool should support the four basic operations (addition, subtraction, multiplication, division) as well as ordering relations (equal, less than, greater than).
Quote
John H. Conway’s Surreal Numbers (1976) introduces a new number system not through formulas, but as a story—two characters talking, discovering, and playing their way into mathematics.
Related domain concepts and terminology¶
- Surreal numbers – a number system introduced by John H. Conway that includes real numbers, infinite numbers, and infinitesimals.
- Arithmetic operations – addition, subtraction, multiplication, and division.
- Ordering relations – comparisons like equal, greater than, or less than.
- Recursive definitions – surreal numbers are built step by step from simpler ones.
- Abstract data types – structures representing mathematical objects in code.
High-level technical guidelines
- Represent surreal numbers as recursive Python classes (with left and right sets).
- Implement operator overloading (
__add__
,__sub__
,__mul__
,__truediv__
) for arithmetic. - Define comparison methods (
__eq__
,__lt__
,__gt__
) for ordering. - Start small: test with integers and fractions before attempting more complex surreal cases.
- Save intermediate results or examples to ensure correctness step by step.
Using GPT with an expert persona¶
Using GPT with an expert persona can be a powerful way to simulate conversations with specialists, helping you quickly understand new concepts, explore different perspectives, and even discover useful features or requirements you might not have thought of on your own. Since this is a learning environment, you can also safely test the boundaries of what GPT knows and where it fails, without any risk to your job or reputation—making it a low-stakes, high-value tool for practicing how to ask good questions, evaluate answers critically, and deepen your understanding.
...but the responsibility for correctness and implementation is still yours!
When using the expert persona prompt, treat GPT as a helpful consultant, not an unquestionable authority. The answers can give you inspiration, explanations, or practical examples, but you should always double-check information in reliable sources and test ideas in your own code. Think of it as brainstorming with an expert partner—you get useful guidance, but the responsibility for correctness and implementation is still yours.
Sample expert persona prompt
You are a friendly but professional consultant helping early-year software engineering students design a calculator for surreal numbers. Take on the perspectives of a mathematician specializing in number systems and surreal numbers, a computer scientist experienced in recursive data structures, a software engineer focused on implementing arithmetic operations, a teacher who explains abstract math in clear, story-like ways, and a curious math enthusiast who enjoys exploring Conway’s playful approach to numbers. Be constructive, but let the students guide the discussion. If they drift from a professional tone, gently remind them. Always explain domain-specific terminology in simple words, and encourage students to ask questions if anything is unclear. Ask as many clarification questions as needed to ensure you and the student are fully aligned before giving detailed answers.
Roles¶
- Mathematician (surreal numbers) – specifies correct definitions, arithmetic rules, ordering, and edge cases (infinities/infinitesimals).
- Computer scientist (recursive structures) – designs canonical/normal forms, ensures recursion termination, and suggests memoization.
- Software engineer (operator overloading) – implements
__add__
,__sub__
,__mul__
,__truediv__
, and comparisons efficiently and cleanly. - Formal methods/testing engineer – builds property-based tests (e.g., Hypothesis) and checks algebraic laws and regressions.
- Teacher/explainer – provides clear step-by-step examples, intuitive docs, and story-like explanations of operations.
- Math enthusiast (end-user) – validates usability with real examples, exploratory workflows, and helpful error messages.