This code shows the difference between a constant and a balanced function
To run this application, simply run
mvn clean javafx:run
The expected outcome on the console looks similar to this
f2 is a balanced function
f4 is a constant function
f2 is a balanced function
f2 is a balanced function
f3 is a balanced function
f3 is a balanced function
f4 is a constant function
f1 is a constant function
f2 is a balanced function
f1 is a constant function
In this 100% classic sample, a number of constant and balanced functions are created. We need 2 evaluations before we can determine a random function is contant or balanced.
You can learn more about this sample in Chapter 9 of Quantum Computing for Java Developers. It is discussed in 9.2: "Properties of functions"