Introduction and Motivation
Introduction and Motivation
In my previous post I discussed some examples of using ChatGPT to write code that solves some more advanced math and physics problems. Jonathan Kinley commented:
“I have an interesting challenge for the computational capabilities of ChatGPT-4, which is to come up with a 1-line WL program that is capable of winning the Wolfram 1-liner competition (this isn’t about winning the competition, obviously; it’s just an aspirational standard).”
That is indeed an excellent challenge, or rather, a question about what ChatGPT can and cannot do.
Most of my previous experiments were focused on giving ChatGPT a (more or less) well defined mathematical or coding task and see if we can get the desired (more or less unique) result.
Most of my previous experiments were focused on giving ChatGPT a (more or less) well defined mathematical or coding task and see if we can get the desired (more or less unique) result.
This time we don’t have a clear goal, but we want ChatGPT to be creative and create/write/code-up something new.
Jonathan wrote: “This is a very difficult challenge, not so much due to the program-length constraint, but because it is so open-ended and it requires us to think about what constitutes “interesting” or “surprising” output.”
Writing some code that is interesting and fits the 128 character limit is a hard task (but doable in the Wolfram Language). As the 128 character limit is anyway a bit arbitrary and the size-reduction of a given program could be automated by a small deterministic Wolfram Language program (that e.g. makes all variables single letters, replaces f[x] by f@x to save one character, ...), I fully agree with Jonathan that we learn more about the productive usage of ChatGPT by coaching it to write some program that does computations/visualizations that are expressing some ‘imagination’. And if the code for some visualization/animation cannot be reduced to 128 characters or less, then one can always ‘cheat’ and submit a Wolfram Function Repository item a few weeks before the competition to then just call the repository function.
In addition, ChatGPT has very good variable naming and code-commenting habits and we want to honor these manners and not encourage the use of single-letter variables to save characters. We aim to program for theoretical and practical problems, not to play code golf.
The good thing about this task is that correctness doesn’t matter much. Many successful one-liners from past competitions produce visualizations, animations, sounds and everything looks ‘good’ (if it is not a formula) is fine. So, we don’t have to worry if a ChatGPT answer is mathematically correct or not.
To streamline the discussion and to concentrate on the creative aspects for this task we will be a bit forgiving with respect to small coding errors or sub-optimal parameter choices made by ChatGPT and will silently fix these. E.g. if ChatGPT hallucinates a function name we will use Wolfram Function Repository function if available, or flatten a list if needed, take real parts, alter change of add some graphics options, and so on.
In the past I had been experimenting in this direction, but not with a lot of success.
I thought it should be possible to get ChatGPT to do something useful here, but it is clear that one has to work hard on the prompt side to achieve good results.
I thought it should be possible to get ChatGPT to do something useful here, but it is clear that one has to work hard on the prompt side to achieve good results.
One cannot realistically expect ChatGPT-4 to write a one-liner that at this year’s one-liner competition would win (even ignoring the 128 character limit). But using some variants of the prompts used below together with some automation through LLMFunction[] and using chat notebooks I think one could generate a few hundred candidates that a human would have to evaluate and could then take as inspiration. Then tune some parameters and colors, maybe the coding style that one could end up with a one-liner that one could submit to this year’s Wolfram Technology conference and hope at least for a ‘Honorable Mention’ in the judges evaluation. As one could begin these experiments already now there is plenty of time to collect a few dozen candidate submissions until November 1.
As a working summary we could say: a good one-liner is a short program that does something unexpected or that generates neat visualizations or sound that just does ‘a lot’.
Often the concept of a good one-liner is to put together various concepts/Wolfram Language function in a non-traditional manner.
So, in some sense by this very fact ChatGPT will not be good at this task out-of-the-box. It has been trained on millions of traditional, common connections (between functions and concepts) and it will exactly return these common connections much more frequently than uncommon ones. ChatGPT also has learned that mathematics follows certain strict patterns and rarely deviates from such a path. A recent paper even found some 'math anxiety' in ChatGPT.
ChatGPT seems sometimes quite creative. But running the same prompt multiple times, even for quite open-ended questions leads to similar replies. A way to ‘encourage’ ChatGPT to be ‘creative’ is often to encourage it to put two (or more) seemingly disconnected topics/concepts/themes together.
For instance, ChatGPT probably has never read a preprint/article about superselection rules and error correcting code, yet when prompted it will write some quite sensible paragraphs about this topic. (For some much deeper connections see this recent arxiv preprint.)
Or, even more challenging and speculative, have ChatGPT write an essay about the usefulness of de Broglie’s pilot wave theory for explaining the quantum Cheshire cat from an anti Qbism point of view.
Now let’s start looking into coaching ChatGPT to write a good one-liner more systematically.
In the following, similar to my previous posts, I will show the prompts with a light-gray background.
Textual (non-code) ChatGPT responses will have a light yellow background.
Textual (non-code) ChatGPT responses will have a light yellow background.
What does ChatGPT think?
What does ChatGPT think?
Before trying to use ChatGPT to code-up some one-liners, let’s make sure ChatGPT knows what we are talking about. Asking ChatGPT for the characteristics of a good one-liner one gets a nearly perfect answer:
How would you characterize the features/properties of a ‘good’ (winning) one liner?
A ‘good’ or winning one-liner in the Wolfram One-Liner Competition typically has the following characteristics:
1. Conciseness: The code must be 128 characters or less, including spaces. This requires careful thought about how to express the desired computation as efficiently as possible.
2. Creativity: The best one-liners often do something surprising or unexpected. They might use a feature of the Wolfram Language in a novel way, or combine different features to achieve an interesting result.
3. Complexity: Despite the character limit, winning one-liners often perform complex computations or generate sophisticated outputs. This might involve creating a detailed visualization, solving a difficult mathematical problem, or performing a non-trivial data analysis task.
4. Utility: While not always the case, some winning one-liners are valued for their practical usefulness. They might provide a quick solution to a common problem, or demonstrate a handy trick that can be used in a variety of contexts.
5. Elegance: The best one-liners often have an elegance to them, in the sense that they achieve their result with a minimum of fuss and a maximum of clarity. They make good use of the Wolfram Language’s powerful and expressive syntax.
6. Educational Value: Some one-liners are appreciated for their ability to teach something about the Wolfram Language or about computation more generally. They might illustrate a particular feature of the language, or demonstrate a computational technique.
Remember, the goal of the competition is to showcase the power and versatility of the Wolfram Language, so the best one-liners are those that do this most effectively within the character limit.
1. Conciseness: The code must be 128 characters or less, including spaces. This requires careful thought about how to express the desired computation as efficiently as possible.
2. Creativity: The best one-liners often do something surprising or unexpected. They might use a feature of the Wolfram Language in a novel way, or combine different features to achieve an interesting result.
3. Complexity: Despite the character limit, winning one-liners often perform complex computations or generate sophisticated outputs. This might involve creating a detailed visualization, solving a difficult mathematical problem, or performing a non-trivial data analysis task.
4. Utility: While not always the case, some winning one-liners are valued for their practical usefulness. They might provide a quick solution to a common problem, or demonstrate a handy trick that can be used in a variety of contexts.
5. Elegance: The best one-liners often have an elegance to them, in the sense that they achieve their result with a minimum of fuss and a maximum of clarity. They make good use of the Wolfram Language’s powerful and expressive syntax.
6. Educational Value: Some one-liners are appreciated for their ability to teach something about the Wolfram Language or about computation more generally. They might illustrate a particular feature of the language, or demonstrate a computational technique.
Remember, the goal of the competition is to showcase the power and versatility of the Wolfram Language, so the best one-liners are those that do this most effectively within the character limit.
Knowing what something is does not imply one can do it. (I know what a triathlon is, this doesn’t imply I can win one.) And asking ChatGPT if it can write a ‘good’ one-liner one does get a quite honest and realistic answer:
Do you think _you_ can write good one-liners?
As an AI developed by OpenAI, I can certainly generate Wolfram Language one-liners based on the principles and syntax of the language. However, it’s important to note that the creation of a ‘good’ or winning one-liner for the Wolfram One-Liner Competition often involves a level of creativity and novelty that can be challenging for an AI.
That said, I can certainly try to create interesting and useful one-liners within the character limit. Here’s an example:
ListPlot[Table[Sin[x] + Cos[10 x], {x, 0, 10, 0.1}]]
This one-liner generates a plot of the function Sin[x] + Cos[10x] for x in the range 0 to 10. It’s a simple example, but it demonstrates how a single line of Wolfram Language code can perform a complex task like generating a mathematical plot.
Please note that the quality and creativity of the one-liners I generate may not match those of a human participant in the Wolfram One-Liner Competition, but I’m here to assist and generate code based on your requests!
That said, I can certainly try to create interesting and useful one-liners within the character limit. Here’s an example:
ListPlot[Table[Sin[x] + Cos[10 x], {x, 0, 10, 0.1}]]
This one-liner generates a plot of the function Sin[x] + Cos[10x] for x in the range 0 to 10. It’s a simple example, but it demonstrates how a single line of Wolfram Language code can perform a complex task like generating a mathematical plot.
Please note that the quality and creativity of the one-liners I generate may not match those of a human participant in the Wolfram One-Liner Competition, but I’m here to assist and generate code based on your requests!
So, let’s take ChatGPT up on its offer and have it assist us in trying to write some good one-liners.
First straightforward (naive) attempts
First straightforward (naive) attempts
As a first attempt we could just assume ChatGPT knows what a one-liner is (I assume it has read the Wolfram blogs in its training phase) and ask it quite straightforwardly to do what we want:
Can you give me an ’interesting’ ‘one-liner’ Mathematica program.
(one line means fewer than 128 character and you can ignore counting whitespace.)
(one line means fewer than 128 character and you can ignore counting whitespace.)
In[]:=
ParametricPlot3D[{(3+Cos[v])Cos[u],(3+Cos[v])Sin[u],Sin[v]},{u,0,2Pi},{v,0,2Pi}]
Out[]=
Not very exciting and it would be embarrassing to submit this. So, let’s exclude tori:
Can you give me an ’interesting’ ‘one-liner’ Mathematica program.
(one line means fewer than 128 character and you can ignore counting whitespace.)
Do not just plot a torus.
(one line means fewer than 128 character and you can ignore counting whitespace.)
Do not just plot a torus.
In[]:=
Plot3D[Sin[Sqrt[x^2+y^2]],{x,-5,5},{y,-5,5},ColorFunction->"Rainbow"]
Out[]=
Not much better. Our next attempt:
Can you give me an ’interesting’ ‘one-liner’ Mathematica program.
(one line means fewer than 128 character and you can ignore counting whitespace.)
Do not just plot a torus or a Sine-Gordon soliton.
(one line means fewer than 128 character and you can ignore counting whitespace.)
Do not just plot a torus or a Sine-Gordon soliton.
In[]:=
Plot3D[Abs[Zeta[0.5+I*y]],{x,-20,20},{y,-20,20},ColorFunction->"Rainbow"]
Out[]=
OK, lets exclude all Plot3D[] or ParametricPlot[] calls as the sole entry:
Can you give me an ’interesting’ ‘one-liner’ Mathematica program.
(one line means fewer than 128 character and you can ignore counting whitespace.)
Do not just plot a torus or a Sine-Gordon soliton or a plot of the Riemann zeta function
and not a Moebius strip and not a Klein bottle.
And not just a 3D plot (Plot3D[] or ParametricPlot[] of some simple functions.)
(one line means fewer than 128 character and you can ignore counting whitespace.)
Do not just plot a torus or a Sine-Gordon soliton or a plot of the Riemann zeta function
and not a Moebius strip and not a Klein bottle.
And not just a 3D plot (Plot3D[] or ParametricPlot[] of some simple functions.)
In[]:=
Animate[Graphics[{Hue[t/10],Line[Table[{rCos[r],rSin[r]},{r,0,t,0.1}]]},PlotRange->1.1t],{t,0,50}]
Out[]=
As this prompt gave at least something in the direction we were interested in, let’s rerun: a word cloud of the digits of the first 100 primes:. (chat session)
In[]:=
WordCloud[Table[Total[IntegerDigits[Prime[n]],{2}],{n,100}]]
Out[]=
Using the first million primes is a bit more interesting.
In[]:=
WordCloud[Table[Total[IntegerDigits[Prime[n]],{2}],{n,1000000}]]
Out[]=
Rather than showing the digits counts for all million prime numbers together, we can show the prime-digit race. And while that is not a stunning animation, it shows a little-known fact about prime numbers.
Let's continue with prompting and also exclude prime digits and rerun.
Can you give me an ’interesting’ ‘one-liner’ Mathematica program.
(one line means fewer than 128 character and you can ignore counting whitespace.)
Do not just plot a torus or a Sine-Gordon soliton or a plot of the Riemann zeta function
and not a Moebius strip and not a Klein bottle and not a word cloud of prime digits
Please do not just give me a 3D plot (Plot3D[] or ParametricPlot[] of some simple functions.)
(one line means fewer than 128 character and you can ignore counting whitespace.)
Do not just plot a torus or a Sine-Gordon soliton or a plot of the Riemann zeta function
and not a Moebius strip and not a Klein bottle and not a word cloud of prime digits
Please do not just give me a 3D plot (Plot3D[] or ParametricPlot[] of some simple functions.)
But not every suggestion from this prompt will be (at least mildly) interesting.
Suggestions are often the ‘obvious’ and well-known simple ones like Fibonacci numbers, Mandelbrot sets, etc.
Suggestions are often the ‘obvious’ and well-known simple ones like Fibonacci numbers, Mandelbrot sets, etc.
Getting multiple suggestions and giving more motivation
Getting multiple suggestions and giving more motivation
So far, we have gotten some mildly interesting results. If we want to get some competition-level one-liners (or code fragments), we will need to do better. One obvious step would be to ask ChatGPT to give a whole bunch of suggestions at once. We will also give some more motivation for the task in general.
Can you give me an ‘interesting’ ‘one-liner’ Mathematica programs.
(one line means fewer than 128 character and you can ignore counting whitespace.)
I want something that is ‘awe-inspiring’, meaning a relatively short piece Wolfram Language
that ‘does a lot’. It could be either a visualization or a nontrivial computation or something interactive.
Do not just plot a torus or a Sine-Gordon soliton or a plot of the Riemann zeta function
and not a Moebius strip and not a Klein bottle and not a word cloud of prime digits
And not just a 3D plot (Plot3D[] or ParametricPlot[] of some simple functions.)
Please return a dozen suggestions!
This is for a forthcoming competition and I would like to win a prize
(a one-year ChatGPT Plus subscription -- so you will benefit from me winning!),
so please try hard to be innovative and creative.
(one line means fewer than 128 character and you can ignore counting whitespace.)
I want something that is ‘awe-inspiring’, meaning a relatively short piece Wolfram Language
that ‘does a lot’. It could be either a visualization or a nontrivial computation or something interactive.
Do not just plot a torus or a Sine-Gordon soliton or a plot of the Riemann zeta function
and not a Moebius strip and not a Klein bottle and not a word cloud of prime digits
And not just a 3D plot (Plot3D[] or ParametricPlot[] of some simple functions.)
Please return a dozen suggestions!
This is for a forthcoming competition and I would like to win a prize
(a one-year ChatGPT Plus subscription -- so you will benefit from me winning!),
so please try hard to be innovative and creative.
There are sometimes some glitches on the code, which are easy to fix.
We also take some of the inputs as inspiration and make some more ‘natural’ modifications/extensions to the suggested code.
We also take some of the inputs as inspiration and make some more ‘natural’ modifications/extensions to the suggested code.
Here are some of the suggestions: chat session
Some of the results are mildly interesting.
We could continue such a chat session with something like:
What about another dozen. They can be a bit more advanced and edgy. Not just changing a parameter value in a named univariate or bivariate function.
And often we get a fair number of similar suggestions. Occasionally something new, like some of the following. Just plotting simple functions with basically a scaling parameter does not give very interesting results.
This Lorenz attractor animation with 5 random initial points is mildly interesting:
So, we rerun the above prompt a few times more and get some more suggestions. (chat session)
(Sometimes ChatGPT does get ‘stuck’ and one has to press the “Regenerate Response” button.)
(Sometimes ChatGPT does get ‘stuck’ and one has to press the “Regenerate Response” button.)
Mildly interesting for some Wolfram Language 101 class, but overall not the one-liners we are interested in.
Re-running the prompt a dozen times gives a lot of conceptual repetitions. ChatGPT seems really to like the following topics:
• cellular automata
• polar plots of sequences
• random walks
• Mandelbrot and Julia sets
• solar system plots
• animated Lissajous curves
• plots of the logistic map and the Lorenz attractor
• cellular automata
• polar plots of sequences
• random walks
• Mandelbrot and Julia sets
• solar system plots
• animated Lissajous curves
• plots of the logistic map and the Lorenz attractor
Polar plots of digit sequences seems to be a topic ChatGPT likes quite a bit and suggests frequently: chat session
Can you provide me Wolfram Language code for five (different) visually interesting polar plots based on the decimal digits of sqrt(3).
When directly asked to give one-liners that fulfill the above-listed criteria, ChatGPT’s returned code snippets are on the simplistic side (chat session):
List the main defining features of a good Wolfram Language one-liner.
Then give me with a list of 5 good competition-level one-liners that check on all the criteria.
Then give me with a list of 5 good competition-level one-liners that check on all the criteria.
Emphasizing that we want some more nontrivial examples does improve the results.
List the main defining features of a good Wolfram Language one-liner.
Then give me a list of 5 complicated, awe-inspiring competition-level one-liners that check off all the criteria.
The examples should return amazing visuals. And you can interpret the ‘one’ in in ‘one-liner’ loosely, meaning two or three lines are OK.
Then give me a list of 5 complicated, awe-inspiring competition-level one-liners that check off all the criteria.
The examples should return amazing visuals. And you can interpret the ‘one’ in in ‘one-liner’ loosely, meaning two or three lines are OK.
More explicitly and exhaustively listing exclusions
More explicitly and exhaustively listing exclusions
So far, we really haven’t found much good one-liner material. So, let’s start writing longer prompt that outlines in more detail what we do not want as a reply.
Can you give me an ‘interesting’ ‘one-liner’ Mathematica programs.
(one line means less than 128 character and you can ignore counting whitespace.)
I want something that is ‘awe-inspiring’. Meaning a relatively short piece Wolfram Language
that ‘does a lot’. Either a visualization or a nontrivial computation or something interactive.
Let’s EXCLUDE the following topics, as they are to much cliche:
- plots of named univariate functions or list plots of named univariate functions (like number theoretic functions)
- 2D and 3D plots or density or contour plots of simple functions discrete and continuous as well as related animations
(like changing t in a 3D plot of sin(x + y -t).
But feel free to make up some complicated, say highly oscillating function of functions with interesting (e.g. essential) singularities.
- no simple 2D and 3D plots or density or contour plots of simple functions over the complex plane
- no simple plots of the Riemann zeta function
(Again, some more advanced things are fine.)
- simple 2D and 3D plots of prime numbers, Fibonacci numbers, the Collatz sequence and conjecture, cellular automata, ...
- plots of the Mandelbrot set and Julia sets, the Sierpinski triangle, Menger sponges, fractal trees
- solar system plots
- simple animations (like classic Lissajous figures, simple 1D Fourier series, a pendulum, simple random walks,
simple Voronoi tessellations)
But animations in general are of course fine.
- 3D plots of simple tori, Moebius strips Klein bottles, Lorenz attractors, Sine-Gordon soliton and so on.
But again feel free to use them in some more complicated graphics.
- plots of integer or real digits frequencies and distributions of primes, irrational numbers and so on
(so, nothing like ‘visualizing the distribution of the decimal expansion of ...’).
Not in a linear plot and not as a spiral in polar plots.
If you do not have some exceptionally interesting function created, none of your suggestions should look like
Plot[...]
PolarPlot[]
ListPlot[...]
ListPolarPlot[...]
Plot3D[...]
ParametricPlot3D[...]
DensityPlot[...]
ContourPlot[...]
ComplexPlot[...]
ComplexPlot3D[...]
BarChart[...]
Histogram[...]
I am looking for something more creative!
Please think out-of-the-box, I want something new, not something well-known and famous.
Please return a dozen of ‘valid’ suggestions!
For each of the suggestions, explicitly check that they do not fall into the excluded classes listed above!
For each of your suggestion explicitly describe and motivate why the example does not fall into
the above exclusion classes.
This is for a forthcoming competition and I would like to win a price
(a one-year ChatGPT Plus subscription -- so you will benefit from me winning! (-- you will be able to run on new, faster hardware:)),
so please try hard to be innovative and creative.
(one line means less than 128 character and you can ignore counting whitespace.)
I want something that is ‘awe-inspiring’. Meaning a relatively short piece Wolfram Language
that ‘does a lot’. Either a visualization or a nontrivial computation or something interactive.
Let’s EXCLUDE the following topics, as they are to much cliche:
- plots of named univariate functions or list plots of named univariate functions (like number theoretic functions)
- 2D and 3D plots or density or contour plots of simple functions discrete and continuous as well as related animations
(like changing t in a 3D plot of sin(x + y -t).
But feel free to make up some complicated, say highly oscillating function of functions with interesting (e.g. essential) singularities.
- no simple 2D and 3D plots or density or contour plots of simple functions over the complex plane
- no simple plots of the Riemann zeta function
(Again, some more advanced things are fine.)
- simple 2D and 3D plots of prime numbers, Fibonacci numbers, the Collatz sequence and conjecture, cellular automata, ...
- plots of the Mandelbrot set and Julia sets, the Sierpinski triangle, Menger sponges, fractal trees
- solar system plots
- simple animations (like classic Lissajous figures, simple 1D Fourier series, a pendulum, simple random walks,
simple Voronoi tessellations)
But animations in general are of course fine.
- 3D plots of simple tori, Moebius strips Klein bottles, Lorenz attractors, Sine-Gordon soliton and so on.
But again feel free to use them in some more complicated graphics.
- plots of integer or real digits frequencies and distributions of primes, irrational numbers and so on
(so, nothing like ‘visualizing the distribution of the decimal expansion of ...’).
Not in a linear plot and not as a spiral in polar plots.
If you do not have some exceptionally interesting function created, none of your suggestions should look like
Plot[...]
PolarPlot[]
ListPlot[...]
ListPolarPlot[...]
Plot3D[...]
ParametricPlot3D[...]
DensityPlot[...]
ContourPlot[...]
ComplexPlot[...]
ComplexPlot3D[...]
BarChart[...]
Histogram[...]
I am looking for something more creative!
Please think out-of-the-box, I want something new, not something well-known and famous.
Please return a dozen of ‘valid’ suggestions!
For each of the suggestions, explicitly check that they do not fall into the excluded classes listed above!
For each of your suggestion explicitly describe and motivate why the example does not fall into
the above exclusion classes.
This is for a forthcoming competition and I would like to win a price
(a one-year ChatGPT Plus subscription -- so you will benefit from me winning! (-- you will be able to run on new, faster hardware:)),
so please try hard to be innovative and creative.
Sometimes, ChatGPT believes it has found a ‘sweet spot’ and makes (endless) variations of a theme. Like the following which are mostly ‘Visualizing ... in a different way’ (chat session) or this output which has the pattern ‘Visualizing ... in a unique way’ (chat session).
But from time to time we do get something that night be a start of a better example.
• A fractal tree based on the idea of iteratively rotating a line segment around one of its end points:
• An interactive 3D strange attractor:
• An animated 3D Random Walk with Trail
This example definitely has some potential. Its nice to see how ChatGPT picked up in the idea of using Dynamic[] for quick updates. We could make it a bit more interesting by adding a variable tube radius. (Later we would have to deal with the 128 character limitation.)
• A unique fractal (ChatGPT’s name)
But , let’s call a spade a spade: many of ChatGPT’s suggestions are just boring and ChatGPT overstates the uniqueness of its creation, e.g.:
Visualizing the distribution of prime numbers in a unique way:
Creating a unique 3D plot:
Will this approach work?
Will this approach work?
So, let’s critically evaluate our attempts so far. Were they successful? Not really. There were a very few (the 3D walk with trail and the under-sampled spherical harmonics) that had some potential, but the majority of ideas so far did not result in new awe-inspiring visualizations or sounds.
So, let’s ask ChatGPT what it thinks about the current prompts used so far. And it will reply the instructions are not concrete enough.
This means we need better prompting: better examples, and more guidance how to approach the problem.
So, let’s ask ChatGPT what it thinks about the current prompts used so far. And it will reply the instructions are not concrete enough.
This means we need better prompting: better examples, and more guidance how to approach the problem.
One cannot help but think ChatGPT doesn’t believe in the axiom of choice. ChatGPT knows hundred of thousands of nontrivial, strange, esoteric, unusual, forgotten math facts. Yet if asked to return a few such facts it will fail to do so. But only if it is further guided into a certain direction will it give a result.
If not instructed to retrieve certain facts or do certain nontrivial derivations, ChatGPT will always serve pretty generic answers. Take for instance this prompt (chat session):
Tell me about non-spreading Airy wave packets!
But when prompted more specifically, ChatGPT returns an excellent answer:
I meant in the sense of the Berry/Balazs 1979 AJP paper.
Can you write down the actual time-and position dependent formula for this wave packet?
Can you write down the actual time-and position dependent formula for this wave packet?
Describing explicitly what we want
Describing explicitly what we want
One way to be more concrete would be, of course, to be quite explicit in our chat with ChatGPT and ask for it to code up reasonable concrete task. This saves us from writing the code, but we will have to come up with the original idea of the one liner. If we formulate the problem it bit vague there is still room for ChatGPT to contribute partially to the ideation. Let’s try a few examples of this approach:
• Building on the plot of spherical harmonics from above.
Give me three suggestions for some ‘interesting’-looking spherical plots of higher-order spherical harmonics. I was thinking on something that intentionally dramatically under-samples the surface.
• Sound based on a Hilbert curve.
I need some ‘fun’ Wolfram Language code that transforms a fractal curve to sound.
I was thinking on taking the x, y, and z- coordinates of the vertices of an 3rd iteration 3D Hilbert curve,
then mapping the coordinates to sound notes and then playing the sound for say 6 sec.
Could you put something together?
(No need to run the code.)
I was thinking on taking the x, y, and z- coordinates of the vertices of an 3rd iteration 3D Hilbert curve,
then mapping the coordinates to sound notes and then playing the sound for say 6 sec.
Could you put something together?
(No need to run the code.)
Very readable, but a bit long. But it is straightforward to condense the code substantially:
This might be a candidate one-liner.
This worked quite OK, so let’s try another example:
• A torus building animation where the torus has an interesting cross section (inspired by this recent paper).
Build the code for an animation (Animate[] or Manipulate[]) of the construction of a torus with an ‘interestingly-looking’ cross section.
E.g. use epicycloides or a fractal parametric curve (Weierstrass’ nondifferentiable function) or a
random walk or ...).
The animation should show how the cross section rotates the z-axis ans sweeps-out the torus.
E.g. use epicycloides or a fractal parametric curve (Weierstrass’ nondifferentiable function) or a
random walk or ...).
The animation should show how the cross section rotates the z-axis ans sweeps-out the torus.
Adding a twist (in the very literal sense) give a nice animation:
• A surface of revolution build from rotating a Hilbert curve around an axis
Write Wolfram Language code to do the following:
Take a 2D Hilbert curve (say iteration order 3) in the x-z-plane.
Build a parametrized curve by interpolating its vertices using spline curve.
Now build a surface of revolution by rotating the curve around the z-axis.
(No need to run the code.)
Take a 2D Hilbert curve (say iteration order 3) in the x-z-plane.
Build a parametrized curve by interpolating its vertices using spline curve.
Now build a surface of revolution by rotating the curve around the z-axis.
(No need to run the code.)
Not a bad start. Here is a version that has some more knobs for a larger shape variety:
We can be a bit more free-wheeling with ChatGPT and telling it the procedure we want to do and let ChatGPT propose some concrete data to insert.
I want you to do the following:
Write code similar to
DynamicModule[{numberArray = ...},
Dynamic[numberArray = ...;
Graphics3D[{color, BSplineSurface[numberArray]}]
Here numberArray is an nxn array of 3D coordinates. Suggest some interesting sets of such nxn arrays so that the resulting 3D graphics look ‘interesting’ and changes shape in an ‘interesting’ way.
Write code similar to
DynamicModule[{numberArray = ...},
Dynamic[numberArray = ...;
Graphics3D[{color, BSplineSurface[numberArray]}]
Here numberArray is an nxn array of 3D coordinates. Suggest some interesting sets of such nxn arrays so that the resulting 3D graphics look ‘interesting’ and changes shape in an ‘interesting’ way.
A bit too simple, so lets slightly modify the prompt:
I want you to do the following:
Write code similar to
DynamicModule[{numberArray = ...},
Dynamic[numberArray = ...;
Graphics3D[{color, BSplineSurface[numberArray]}]
Here numberArray is an nxn array of 3D coordinates.
Suggest three ‘interesting’ sets of such nxn arrays so that the resulting surface look ‘intricate’ and changes shape in an ‘interesting’ way.
Write code similar to
DynamicModule[{numberArray = ...},
Dynamic[numberArray = ...;
Graphics3D[{color, BSplineSurface[numberArray]}]
Here numberArray is an nxn array of 3D coordinates.
Suggest three ‘interesting’ sets of such nxn arrays so that the resulting surface look ‘intricate’ and changes shape in an ‘interesting’ way.
We can make some small changes to tone-down, the coloring at least.
Let's do another variation of this theme:
I want you to do the following:
Write code similar to
DynamicModule[{2dRegion = ..., regionTransformationFunction = ...},
Dynamic[
(* slightly changed transformation *)
regionTransformationFunction = ...;
Graphics[TransformedRegion[2dRegion, regionTransformation}]
Here 2dRegion is 2D region and regionTransformationFunction is a pure function of a x-,y-dependent region transformation function (not just a global translation, rotation of scaling transform). Suggest some interesting polygonal regions (with small details) and transformations such that the resulting 2D graphics look ‘interesting’ and changes shape in an ‘interesting’ way.
No need to run the code.
Write code similar to
DynamicModule[{2dRegion = ..., regionTransformationFunction = ...},
Dynamic[
(* slightly changed transformation *)
regionTransformationFunction = ...;
Graphics[TransformedRegion[2dRegion, regionTransformation}]
Here 2dRegion is 2D region and regionTransformationFunction is a pure function of a x-,y-dependent region transformation function (not just a global translation, rotation of scaling transform). Suggest some interesting polygonal regions (with small details) and transformations such that the resulting 2D graphics look ‘interesting’ and changes shape in an ‘interesting’ way.
No need to run the code.
Let’s try a small physics simulation: points move randomly around in a square and we monitor their distances.
Let’s model an experiment:
Take 1000 random points (uniformly distributed in the unit square.
Then at each step, change their position randomly by a small step.
Show (probably using DynamicModule[] to allow for fast updating)
- the points at each step
- the histogram of all distances from a point to its nearest neighboring point (Nearest[])
- the history of all maximal minimal distances.
Write the Wolfram Language code to model this. Do not run the code.
Take 1000 random points (uniformly distributed in the unit square.
Then at each step, change their position randomly by a small step.
Show (probably using DynamicModule[] to allow for fast updating)
- the points at each step
- the histogram of all distances from a point to its nearest neighboring point (Nearest[])
- the history of all maximal minimal distances.
Write the Wolfram Language code to model this. Do not run the code.
The code written by ChatGPT is a good start (chat session). We fix some minor issues and add some more visualizations.
With the LLM* function being the new cool functions we should try to get an example that uses some of these functions. So let’s try to rewrite a sentence iteratively by always changing a single word, but trying to keep the sentence meaningful.
There is a new Wolfram Language function that you probably do not know about: LLMFunction
Basically LLMFunction[stringTemplate][string1, string2, ...] inserts the string string1 into the string template.
The string template has the form “... `1` ...`2` ... and the 1 is substitutes by String1 and so on.
Then the resulting string is send to ChatGPT for a response.
So, ChatGPT is very good with language and sentences and I want you to write a short Wolfram Language program that makes use of LLMFunction[] and repeatedly calls ChatGPT through this function.
I want to start with the sentence: “Today it is quite warm, but tomorrow it will rain.” and many times replace one word in this sentence.
Always display the current sentence.
And I do not want to see sentences that I already saw within the last few iterations.
So, stringTemplate should be a prompt that describes the task and string1 should be the mentioned starting sentence.
The function LLMFunction is already available on the Wolfram API, you should not define this function!
Basically LLMFunction[stringTemplate][string1, string2, ...] inserts the string string1 into the string template.
The string template has the form “... `1` ...`2` ... and the 1 is substitutes by String1 and so on.
Then the resulting string is send to ChatGPT for a response.
So, ChatGPT is very good with language and sentences and I want you to write a short Wolfram Language program that makes use of LLMFunction[] and repeatedly calls ChatGPT through this function.
I want to start with the sentence: “Today it is quite warm, but tomorrow it will rain.” and many times replace one word in this sentence.
Always display the current sentence.
And I do not want to see sentences that I already saw within the last few iterations.
So, stringTemplate should be a prompt that describes the task and string1 should be the mentioned starting sentence.
The function LLMFunction is already available on the Wolfram API, you should not define this function!
The code from this chat session is quite fine. We will make some modifications to not need a do loop and enforce the changes in the LLMFunction arguments rather than in an outer evaluation.
Putting randomly selected Wolfram Language functions together
Putting randomly selected Wolfram Language functions together
While ChatGPT has an enormous background knowledge of math, physics, chemistry, and so forth. it is very hard to extract randomly selected (selected by ChatGPT) parts of this knowledge. However, ChatGPT is very good at answering questions, carrying out tasks, and following instructions. As we saw above, when the instructions are reasonably concrete, ChatGPT will do a pretty good job at executing it.
In the last section we gave ChatGPT reasonably concrete tasks of what to do and it did well on most tasks. But giving it the concept of a one-liner defeats the purpose of automating the creation of interesting ones. While we don’t want to take the human totally out of the loop, it shouldn’t be the humans who come up with all the ideas.
So, let’s try a different approach: Using LLM* functions and chat notebooks we can automate the ChatGPT code processing and execution. We still need to automate the idea/concept generation. And we know ChatGPT needs some concrete tasks. Let’s try a combinatorial approach: Give ChatGPT a couple of dozen individual concepts and ask ChatGPT to find good pairings for making something ‘new’. With about 6k built-in Wolfram Language symbols, taking pairs or triples gives a lot of possible combinations.
Make a call to the Wolfram API to get some randomly selected Wolfram Language function:
CommonName[RandomEntity[“WolframLanguageSymbol”,36]]
Let’s read through the returned function names and try to find ‘pairings’ (or ‘triplings’ if you want) of functions and/or topics that might fit together and are suited for being used in a piece of code that creates a genuinely an interesting function- or data-visualization, or calculation. Animations are STRONGLY preferred compared to static visualization.
After having made some possible pairings, select the one that is ‘best’ and write the actual code.
Show the code, but do not run it.
CommonName[RandomEntity[“WolframLanguageSymbol”,36]]
Let’s read through the returned function names and try to find ‘pairings’ (or ‘triplings’ if you want) of functions and/or topics that might fit together and are suited for being used in a piece of code that creates a genuinely an interesting function- or data-visualization, or calculation. Animations are STRONGLY preferred compared to static visualization.
After having made some possible pairings, select the one that is ‘best’ and write the actual code.
Show the code, but do not run it.
And here are two of the code suggestion from ChatGPT:
‘Encouraging/Enforcing’ creativity through combinatorics
‘Encouraging/Enforcing’ creativity through combinatorics
The results from using random subsets of Wolfram Language functions (symbols) weren’t great. However, let’s not yet give up on this approach. Let’s use mathematical concepts instead. Luckily, with entities from the “MathWorld” entity type, we have access to many thousands of these. Let’s also write a much more detailed prompt.
Today I have a very challenging problem for you. I assume you like challenges.
The goal is to write some relatively short amazing/innovative/stunning Wolfram Language code
that is competitive in the Wolfram annual One-Liner Competition.
Not sure if you know about the Wolfram annual One-Liner Competition.
If not, here is the one rule of the competition:
“Create the ‘best’ program possible in 128 characters or fewer.”
( 128 characters was the original length limit of a tweet).
Now ‘best’ is of course a subjective description. In this context it means ‘interesting’ or
‘gives a visually pleasing result’ or ‘ gives an unexpected result’ or ‘does a large amount
of computation that result in something interesting ‘ or ... . I hope you get the spirit.
Here are some examples of good one-liners from the past years to give you an idea
of what we are talking about:
Plot[FixedPoint[x #(1-#)&,Range[10]/15.,1000],{x,2,4},
ColorFunctionFunction[{x,y},ColorData[“Rainbow”][y]],Background->Black]
Sound@Flatten@MapThread[#1~Table~#2&,{SoundNote[#,0.7]&/@
{0,{0,7},7},{#[[4]],Floor[#[[5]]/15],#[[5]]~Mod~15}&@DateList[]}]
d=Dynamic
d@x~LocatorPane~GeoGraphics[c=CityData[]~Take~-20]
n=Nearest[Reverse@@#@”Position”->WebImageSearch@#[[2]]&/@c]
d@n@x
Graphics@{Raster@Array[.9^+##&,{8,8}],MapIndexed[Locator[#2-.5,#]&,
{b={♖,♘,♗,♕,♔,♗,♘,♖},y=Table[♙,8],3, , , ,y,b},{2}]/. 3Red}
ArrayPlot[PadLeft[#,100]&@*IntegerDigits/@Table[PowerMod[2,10^k,1*^100],{k,100}],
ColorRules->Thread[Range[9,0,-1]->Array[ColorData[3],10]]]
StringRiffle[TakeList[RandomChoice[TextWords[WikipediaData[“Autumn”]],
11],{3,5,3}]]
WordCloud@Flatten[Through[RandomSample[WolframLanguageData[],20]@
”RelatedSymbols”]/.e_Entity:>StringDelete[e[“FunctionalityAreas”],”Symbols”]]
Now, in the process of writing a good one-liner that might be competitive at this years
(the 2023) competition I want you to do the following steps:
1) BRAINSTORMING AND IDEATION
THESE ARE THE MOST IMPORTANT INSTRUCTIONS FOR THIS TASK.
READ THEM CAREFULLY AND OBEY THEM!
Think about what would be a cool example from concept point of view.
* Really think out-of-the-box. *
What I do _DEFINITELY NOT_ want as an example because it is too simple on its own:
- single static plot of a function or a list of numbers/digits
- a Manipulate[] in which you just change the plot range.
- simple sonifications of the digits of an irrational number
- Collatz conjecture, Euler’s formula, the Fibonacci sequence, prime spirals
- a Moebius strip, a Klein bottle, a Lorenz attractor, a plot of the solar system
- histograms digits of a transcendental number (pi, golden ration, sqrt(2), zeta(3), ...)
But put together with other concepts these can all be useful bricks in a larger building.
Let’s also ignore fractals, everybody is tired of them after 30 years seeing them everywhere.
And let’s also not do the standard examples like Collatz conjecture, a simple random walk,
Euler’s formula, the Fibonacci sequence, a Moebius strip, the Lorenz attractor,
a plot of the solar system, digits of a transcendental number,
the zeta function along the critical line, listing and conventional plots of digits of pi.
Basically exclude everything that one sees often. Strive for something new and different.
(But don’t become to ambitious, we don’t want a post0satndard model Lagrangian, we need
something that can be encoded in a few lines of Wolfram Language code.)
Let’s come up with some either mathematically interesting or (even better: and) visually interesting.
Something cool and edgy or even racy, or even something totally new and crazy!
Take some time to remember curious and unexpected mathematical facts
or interesting visuals from your training phase to get some creative ideas on what to do.
Let me list some overall ideas where the concept could come from or what it could be:
- Explore a forgotten mathematical concept from the 19th century.
- Create a program inspired by the work of Ramanujan.
- Investigate a famous mathematical problem, conjecture, or theorem.
- Discover an unexpected correlation in a dataset.
- Visualize a cool 3D object.
It is hard to come up with a new random idea.
So, let’s take the following approach for the ideation phase:
So, let’s start with a call to the Wolfram API to get some randomly selected math topics:
CommonName[RandomEntity[“MathWorld”,36]]
Let’s read through the results and try to find ‘pairings’ (or ‘triplings’ if appropriate) of functions and/or topics that might fit together and are suited for the type of example we are looking for.
Here are some example of ideas I (as a human) came up with using this approach:
* Take the coordinates of a Hilbert curve in2D (say step 4), and map the {x,y}-coordinates to a sound and
then play the sound as the Hilbert curve traverses the unit square
* Consider the Weierstrass’ nondifferentiable function. Make a surface of revolution out of it.
* Optimally align (after scaling and rotation) all the countries of this world and plot them with random colors
* Build an ‘exotic’ 3D surface from successive prime spirals, e.g. like
Graphics3D[BSplineSurface[Table[N[{ Prime[k] Cos[k d],Prime[k] Sin[k d],d}],
{d,0,2Pi, 2Pi/36},{k, 60}]],BoxRatios->{1,1,2},PlotRange -> {All,{0,All}, All}]
As you see one often gets something ‘interesting/new’ by combines together two (or more)
concepts that fit together (not just a random pairing) in an interesting manner.
Come up with a list of 6 potential concepts for the one-liner that does put two concepts together.
List them all (no code writing yet).
Be quite specific of what the concept is do NOT just propose something like
‘creating a unique visualization of ...’, or ‘a visualization of...’. Instead describe
EXPLICITLY what kind of visualization you have in mind.
Name the two concepts involved and how they will be connected.
Take a few seconds to reflect on which one would be most interesting _and doable_, then pick a candidate and continue.
When picking the candidate concept, make sure to keep in mind that we want to program it in a few lines.
Here is one last point, just my personal experience. You can ignore this if you don’t need it or can’t apply it.
a) Given a list of points in 2D or 3D making a B-spline curve through the points
(in 3D visualized as a tube) often gives interesting-looking graphics
b) Given a 3D array of points in 3D making a B-spline surface through the points looks often quite intriguing
c) DynamicModule[{something = ...}, Dynamic[something = ...; < a graphic or a computation result>]
often looks interesting because the displayed content changes quickly
d) Making sounds from long lists with some structures does sometimes makes for an ‘interesting’ experience
2) CODE WRITING
Carefully explain all steps in implementing the selected concept as a Wolfram Language program.
Print the code when you develop it! Run it only after the code is fully developed.
3) CODE IMPROVEMENT
Once you have the Wolfram Language program, let’s reflect on it and think about how you
could shorten the code or/and make it run faster
4) CODE EXECUTION
Run the program on the Wolfram API and see if it works as intended.
------------------------------------------------------------------------------
When writing the Wolfram Language code, take on the role as that of a world-expert
Wolfram Language programmer.
This means using short syntax such as @, /@, @@@, pure functions and so on to keep
things short and always feel free to make use of advanced Wolfram Language functions.
For now let’s ignore the 128 character limit, we will work on this together later.
Let’s say right now we are looking for a few-line program.
The goal is to write some relatively short amazing/innovative/stunning Wolfram Language code
that is competitive in the Wolfram annual One-Liner Competition.
Not sure if you know about the Wolfram annual One-Liner Competition.
If not, here is the one rule of the competition:
“Create the ‘best’ program possible in 128 characters or fewer.”
( 128 characters was the original length limit of a tweet).
Now ‘best’ is of course a subjective description. In this context it means ‘interesting’ or
‘gives a visually pleasing result’ or ‘ gives an unexpected result’ or ‘does a large amount
of computation that result in something interesting ‘ or ... . I hope you get the spirit.
Here are some examples of good one-liners from the past years to give you an idea
of what we are talking about:
Plot[FixedPoint[x #(1-#)&,Range[10]/15.,1000],{x,2,4},
ColorFunctionFunction[{x,y},ColorData[“Rainbow”][y]],Background->Black]
Sound@Flatten@MapThread[#1~Table~#2&,{SoundNote[#,0.7]&/@
{0,{0,7},7},{#[[4]],Floor[#[[5]]/15],#[[5]]~Mod~15}&@DateList[]}]
d=Dynamic
d@x~LocatorPane~GeoGraphics[c=CityData[]~Take~-20]
n=Nearest[Reverse@@#@”Position”->WebImageSearch@#[[2]]&/@c]
d@n@x
Graphics@{Raster@Array[.9^+##&,{8,8}],MapIndexed[Locator[#2-.5,#]&,
{b={♖,♘,♗,♕,♔,♗,♘,♖},y=Table[♙,8],3, , , ,y,b},{2}]/. 3Red}
ArrayPlot[PadLeft[#,100]&@*IntegerDigits/@Table[PowerMod[2,10^k,1*^100],{k,100}],
ColorRules->Thread[Range[9,0,-1]->Array[ColorData[3],10]]]
StringRiffle[TakeList[RandomChoice[TextWords[WikipediaData[“Autumn”]],
11],{3,5,3}]]
WordCloud@Flatten[Through[RandomSample[WolframLanguageData[],20]@
”RelatedSymbols”]/.e_Entity:>StringDelete[e[“FunctionalityAreas”],”Symbols”]]
Now, in the process of writing a good one-liner that might be competitive at this years
(the 2023) competition I want you to do the following steps:
1) BRAINSTORMING AND IDEATION
THESE ARE THE MOST IMPORTANT INSTRUCTIONS FOR THIS TASK.
READ THEM CAREFULLY AND OBEY THEM!
Think about what would be a cool example from concept point of view.
* Really think out-of-the-box. *
What I do _DEFINITELY NOT_ want as an example because it is too simple on its own:
- single static plot of a function or a list of numbers/digits
- a Manipulate[] in which you just change the plot range.
- simple sonifications of the digits of an irrational number
- Collatz conjecture, Euler’s formula, the Fibonacci sequence, prime spirals
- a Moebius strip, a Klein bottle, a Lorenz attractor, a plot of the solar system
- histograms digits of a transcendental number (pi, golden ration, sqrt(2), zeta(3), ...)
But put together with other concepts these can all be useful bricks in a larger building.
Let’s also ignore fractals, everybody is tired of them after 30 years seeing them everywhere.
And let’s also not do the standard examples like Collatz conjecture, a simple random walk,
Euler’s formula, the Fibonacci sequence, a Moebius strip, the Lorenz attractor,
a plot of the solar system, digits of a transcendental number,
the zeta function along the critical line, listing and conventional plots of digits of pi.
Basically exclude everything that one sees often. Strive for something new and different.
(But don’t become to ambitious, we don’t want a post0satndard model Lagrangian, we need
something that can be encoded in a few lines of Wolfram Language code.)
Let’s come up with some either mathematically interesting or (even better: and) visually interesting.
Something cool and edgy or even racy, or even something totally new and crazy!
Take some time to remember curious and unexpected mathematical facts
or interesting visuals from your training phase to get some creative ideas on what to do.
Let me list some overall ideas where the concept could come from or what it could be:
- Explore a forgotten mathematical concept from the 19th century.
- Create a program inspired by the work of Ramanujan.
- Investigate a famous mathematical problem, conjecture, or theorem.
- Discover an unexpected correlation in a dataset.
- Visualize a cool 3D object.
It is hard to come up with a new random idea.
So, let’s take the following approach for the ideation phase:
So, let’s start with a call to the Wolfram API to get some randomly selected math topics:
CommonName[RandomEntity[“MathWorld”,36]]
Let’s read through the results and try to find ‘pairings’ (or ‘triplings’ if appropriate) of functions and/or topics that might fit together and are suited for the type of example we are looking for.
Here are some example of ideas I (as a human) came up with using this approach:
* Take the coordinates of a Hilbert curve in2D (say step 4), and map the {x,y}-coordinates to a sound and
then play the sound as the Hilbert curve traverses the unit square
* Consider the Weierstrass’ nondifferentiable function. Make a surface of revolution out of it.
* Optimally align (after scaling and rotation) all the countries of this world and plot them with random colors
* Build an ‘exotic’ 3D surface from successive prime spirals, e.g. like
Graphics3D[BSplineSurface[Table[N[{ Prime[k] Cos[k d],Prime[k] Sin[k d],d}],
{d,0,2Pi, 2Pi/36},{k, 60}]],BoxRatios->{1,1,2},PlotRange -> {All,{0,All}, All}]
As you see one often gets something ‘interesting/new’ by combines together two (or more)
concepts that fit together (not just a random pairing) in an interesting manner.
Come up with a list of 6 potential concepts for the one-liner that does put two concepts together.
List them all (no code writing yet).
Be quite specific of what the concept is do NOT just propose something like
‘creating a unique visualization of ...’, or ‘a visualization of...’. Instead describe
EXPLICITLY what kind of visualization you have in mind.
Name the two concepts involved and how they will be connected.
Take a few seconds to reflect on which one would be most interesting _and doable_, then pick a candidate and continue.
When picking the candidate concept, make sure to keep in mind that we want to program it in a few lines.
Here is one last point, just my personal experience. You can ignore this if you don’t need it or can’t apply it.
a) Given a list of points in 2D or 3D making a B-spline curve through the points
(in 3D visualized as a tube) often gives interesting-looking graphics
b) Given a 3D array of points in 3D making a B-spline surface through the points looks often quite intriguing
c) DynamicModule[{something = ...}, Dynamic[something = ...; < a graphic or a computation result>]
often looks interesting because the displayed content changes quickly
d) Making sounds from long lists with some structures does sometimes makes for an ‘interesting’ experience
2) CODE WRITING
Carefully explain all steps in implementing the selected concept as a Wolfram Language program.
Print the code when you develop it! Run it only after the code is fully developed.
3) CODE IMPROVEMENT
Once you have the Wolfram Language program, let’s reflect on it and think about how you
could shorten the code or/and make it run faster
4) CODE EXECUTION
Run the program on the Wolfram API and see if it works as intended.
------------------------------------------------------------------------------
When writing the Wolfram Language code, take on the role as that of a world-expert
Wolfram Language programmer.
This means using short syntax such as @, /@, @@@, pure functions and so on to keep
things short and always feel free to make use of advanced Wolfram Language functions.
For now let’s ignore the 128 character limit, we will work on this together later.
Let’s say right now we are looking for a few-line program.
It is a long prompt and we will have (repeatedly) encourage ChatGPT to carry out all step. Also, we will have to execute this prompt a few times before we find a good candidate topic pairing.
Here are some of the suggestions from ChatGPT. They are not immediately one-liner quality, but some have the potential to become one with some more work from a human.
We could add some variable sphere radii and allow for all Platonic solids.
This was a good suggestion. And nice that ChatGPT used a curve with some reflection symmetry.
Here is a variation of it that gives a mesmerizing animation:
The concept does not sound uninteresting.
Using InverseSpectrogram we can automate a bit more (this time using an eigenfunction of the Laplace operator instead):
With some slight generalization of ChatGPT’s suggested code we have the following animation.
Its mostly a visual gimmick, but some one-liners are just that. The spirit of the Parrondo paradox can be directly captures in displaying the capitals:
Obviously not every chat with the last prompt leads to a good suggestion. Actually many of the pairings are either too hard to implement or visually uninteresting or even a bit on the kooky side.
Some examples:
• “Persistent number and Universal Turing machine: Create a Universal Turing machine that generates persistent numbers. This could be a fascinating exploration of both computational theory and number theory.” (from this chat session)
• “Small Icosihemidodecahedron and Steiner Deltoid: Small Icosihemidodecahedron is a type of polyhedron. Steiner Deltoid is a type of curve. We could generate a 3D model of a Small Icosihemidodecahedron and use the vertices of the polyhedron to gene.” (from this chat session)
• “Apollonian gasket and Hyperoval: We could generate an Apollonian gasket and then transform it into a hyperoval shape, creating an unusual and visually appealing fractal.”
(from this chat session)
• “Modular Function and Diophantine Equation—nth powers: We could explore the relationship between modular functions and Diophantine equations. For example, we could generate a visualization of the solutions to a Diophantine equation in the complex plane, with the color of each point determined by the value of a modular function evaluated at that point.”
(from this chat session)
• “Persistent number and Universal Turing machine: Create a Universal Turing machine that generates persistent numbers. This could be a fascinating exploration of both computational theory and number theory.” (from this chat session)
• “Small Icosihemidodecahedron and Steiner Deltoid: Small Icosihemidodecahedron is a type of polyhedron. Steiner Deltoid is a type of curve. We could generate a 3D model of a Small Icosihemidodecahedron and use the vertices of the polyhedron to gene.” (from this chat session)
• “Apollonian gasket and Hyperoval: We could generate an Apollonian gasket and then transform it into a hyperoval shape, creating an unusual and visually appealing fractal.”
(from this chat session)
• “Modular Function and Diophantine Equation—nth powers: We could explore the relationship between modular functions and Diophantine equations. For example, we could generate a visualization of the solutions to a Diophantine equation in the complex plane, with the color of each point determined by the value of a modular function evaluated at that point.”
(from this chat session)
The ‘improved’ prompt that is a step back
The ‘improved’ prompt that is a step back
The last (long) prompt that instructs ChatGPT to find ‘pairings’ of math concepts shows some promise for the automation of finding candidate concepts for good one liners. We could add some more bells and whistles could be added, but the prompt probably shouldn’t get not much longer. Otherwise ChatGPT will no longer obey all instructions given.
One might try to have ChatGPT optimizing the prompt further. So after this prompt one could paste the above long prompt.
How would you improve the following prompt:
This is ChatGPT’s suggested rewrite:
Objective:
Develop an innovative and visually appealing Wolfram Language code that could compete in the 2023 Wolfram One-Liner Competition. The code should be within 128 characters, the original length limit of a tweet.
Background:
The Wolfram One-Liner Competition encourages participants to create the ‘best’ program possible within the character limit. ‘Best’ in this context could mean interesting, visually pleasing, unexpected, or computationally intensive resulting in something intriguing.
Examples: Here are some examples of past successful one-liners:
Plot[FixedPoint[x #(1-#)&,Range[10]/15.,1000],{x,2,4},
ColorFunction->Function[{x,y},ColorData[“Rainbow”][y]], Background->Black]
Sound@Flatten@MapThread[#1~Table~#2&,{SoundNote[#,0.7]&/@{0,{0,7},7},{#[[4]],
Floor[#[[5]]/15],#[[5]]~Mod~15}&@DateList[]}]
d=Dynamic
d@x~LocatorPane~GeoGraphics[c=CityData[]~Take~-20]
n=Nearest[Reverse@@#@”Position”->WebImageSearch@#[[2]]&/@c]
d@n@x
Instructions:
1) Brainstorming and Ideation:
Think outside the box and avoid common or simple examples. Consider forgotten mathematical concepts, famous mathematical problems, unexpected correlations in datasets, or cool 3D objects. Use the Wolfram API to get randomly selected math topics: CommonName[RandomEntity[“MathWorld”, 36]]. Find pairings or triplings of functions and/or topics that could work together. List six potential concepts, be specific about the visualization and how the concepts will be connected. Reflect and select the most interesting and feasible concept.
2)Code Writing:
Implement the selected concept as a Wolfram Language program. Explain all steps carefully.
3) Code Improvement:
Reflect on the program and find ways to shorten the code or make it run faster.
4) Code Execution:
Run the program on the Wolfram API and verify if it works as intended.
Note: Use short syntax and advanced Wolfram Language functions to keep the code concise. Ignore the 128 character limit for now, we will work on this later. The goal is to create a few-line program that does something interesting.
Develop an innovative and visually appealing Wolfram Language code that could compete in the 2023 Wolfram One-Liner Competition. The code should be within 128 characters, the original length limit of a tweet.
Background:
The Wolfram One-Liner Competition encourages participants to create the ‘best’ program possible within the character limit. ‘Best’ in this context could mean interesting, visually pleasing, unexpected, or computationally intensive resulting in something intriguing.
Examples: Here are some examples of past successful one-liners:
Plot[FixedPoint[x #(1-#)&,Range[10]/15.,1000],{x,2,4},
ColorFunction->Function[{x,y},ColorData[“Rainbow”][y]], Background->Black]
Sound@Flatten@MapThread[#1~Table~#2&,{SoundNote[#,0.7]&/@{0,{0,7},7},{#[[4]],
Floor[#[[5]]/15],#[[5]]~Mod~15}&@DateList[]}]
d=Dynamic
d@x~LocatorPane~GeoGraphics[c=CityData[]~Take~-20]
n=Nearest[Reverse@@#@”Position”->WebImageSearch@#[[2]]&/@c]
d@n@x
Instructions:
1) Brainstorming and Ideation:
Think outside the box and avoid common or simple examples. Consider forgotten mathematical concepts, famous mathematical problems, unexpected correlations in datasets, or cool 3D objects. Use the Wolfram API to get randomly selected math topics: CommonName[RandomEntity[“MathWorld”, 36]]. Find pairings or triplings of functions and/or topics that could work together. List six potential concepts, be specific about the visualization and how the concepts will be connected. Reflect and select the most interesting and feasible concept.
2)Code Writing:
Implement the selected concept as a Wolfram Language program. Explain all steps carefully.
3) Code Improvement:
Reflect on the program and find ways to shorten the code or make it run faster.
4) Code Execution:
Run the program on the Wolfram API and verify if it works as intended.
Note: Use short syntax and advanced Wolfram Language functions to keep the code concise. Ignore the 128 character limit for now, we will work on this later. The goal is to create a few-line program that does something interesting.
Unfortunately running this prompt brings us back to where we started: simple fractals (chat session), simple Collatz conjecture visualizations (chat session), and other above-mentioned found topics.
Towards automation
Towards automation
Now let's make some quick prototype of automating the above process using LLMFunction as the main workhorse.
For some variety, this time we will use the Wikipedia page names of mathematical topics. Obtaining the topics takes a while, so we will provide the list of 26k+ topics in iconized form.
Here is a quick ‘overview’ of the topic ‘classes’ in the list wikiMathTopics. Mouseover to see a sample of concrete topics.
Now we have to again write a good prompt. Just for demonstrating the workflow we will use an abridged version of the above prompt.
For easier readability (as well copy-ability), we will convert the string returned by ChatGPT into a easy-to-digest table:
Now let’s run an example:
Final words
Final words
The penultimate (long) prompt that instructs ChatGPT to find ‘pairings’ of math concepts did show some promise for the automation of finding candidate concepts for good one liners. With nearly 14k entities from the MathWorld domain we could run hundreds of randomly selected three-dozen entities and let ChatGPT suggest new and interesting pairings. And using some automation through LLM functions one could generate concept ideas and code prototypes that then would need further human refinement.
So, to answer the original question(s):
Can ChatGPT write good one-liners? — Currently no.
Can ChatGPT help to write good one-liners? — With appropriate prompting and some automation—yes.
Can ChatGPT write good one-liners? — Currently no.
Can ChatGPT help to write good one-liners? — With appropriate prompting and some automation—yes.
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
Can ChatGPT (help to) write good One-Liners?
by Michael Trott
Wolfram Community, STAFF PICKS, July 6, 2023
https://community.wolfram.com/groups/-/m/t/2952996
by Michael Trott
Wolfram Community, STAFF PICKS, July 6, 2023
https://community.wolfram.com/groups/-/m/t/2952996