ABSTRACT: Here we present a new function called GenerateInequalitiesList, written in the Wolfram programming language, to create a random list of inequalities with their respective solutions. The code that defines this function mainly uses the native functions RandomInteger, RandomChoice, Reduce and Surd, in addition to paradigms such as functional programming and programming based on rules and patterns, typical of symbolic programming languages. CITATION (original article): Jiménez-Vilcherrez, J.K., Ipanaqué-Chero, R., Velezmoro-León, R., Velásquez-Fernández, M.F. (2024). A Mathematica Function to Get a List of Random Inequalities and Their Respective Solution Sets. In: Guarda, T., Portela, F., Diaz-Nafria, J.M. (eds) Advanced Research in Technologies, Information, Innovation and Sustainability. ARTIIS 2023. Communications in Computer and Information Science, vol 1935. Springer, Cham. https://doi.org/10.1007/978-3-031-48858-0_4

Introduction

Determining the solution set for inequalities in

is a crucial step and an important achievement for many high school students and college students. In fact, it is one of the first topics included in most advanced basic mathematics courses, within the chapter on the real number system [23].
Nowadays, many computer programs, both paid and free, offer functions to solve different types of inequalities [21,6,7,1]. There are also online calculators that provide detailed step-by-step solutions to various scientific problems, including inequalities [13,5].
Several of these programs have been incorporated into the classroom, and the results have proven to be favorable in the learning process, surpassing those obtained with traditional teaching methods [2,3,4,10,8,11,12].
Although these tools solve inequalities effectively, none offer the ability to automatically generate lists of exercises with their respective solutions. In an advanced basic mathematics course, teachers need to assign tasks to their students (possibly to several groups) and provide them with answers to exercises to correct the work done. Having a tool that allows automatically generating lists of exercises with their solutions would be extremely useful, saving time for the teacher who would otherwise have to devise, type and solve each exercise individually.
Here we presents a new function called GenerateList, coded in the Wolfram programming language [22], the same one used in the Mathematica software [9,21]. With this tool, a random list of inequalities and/or equalities (with the number of elements desired by the user) can be created along with their corresponding solutions. To program it, native functions such as RandomInteger [17], RandomChoice [16], Reduce [18] and Surd [20] were used, as well as functional and rule- and pattern-based programming paradigms [14,19], common in symbolic languages. The listability attribute of the arithmetic operators (addition, subtraction, multiplication and division) incorporated in Mathematica [15] was also taken advantage of.

The New Function: GenerateList

This section presents examples in which lists of rational inequalities and/or equalities involving radicals and absolute value are generated. For this, the code of the developed program has been assigned to the function GenerateList.
The function GenerateList incorporates the following options (with their respective default values):
NumberOfExercises->10,MaxNumberOfFactors->3,RationalIneqs->False,
Radicals->False,MaxRadicalIndex->50,AbsoluteValue->False
AbsoluteValueOnly->False,MaxNumberOfAddends->3
RelationalOperators->{Less,Greater,LessEqual,GreaterEqual}
In[]:=
NSurd[x_,n_,k_]:=If[EvenQ[k]&&NumericQ[n],Surd[x+n,k],Surd[n,k]]
In[]:=
GenerateInequalitiesList[x_,OptionsPattern[{NumberOfExercises->10,​​MaxNumberOfFactors->3,RationalIneqs->False,Radicals->False,​​MaxRadicalIndex->50,AbsoluteValue->False,AbsoluteValueOnly->False,MaxNumberOfAddends->3,​​RelationalOperators->{Less,Greater,LessEqual,GreaterEqual}}]]:=​​Module{n,aa,bb,cc,dd,ee,ff,aux,noe,mnof,ri,rr,mri,av,avo,mnoa,ro,h,cte,​​coeff,hh1,hh2,ineq},​​{noe,mnof,ri,rr,mri,av,avo,mnoa,ro}=OptionValue[#]&/@{NumberOfExercises,​​MaxNumberOfFactors,RationalIneqs,Radicals,MaxRadicalIndex,AbsoluteValue,​​AbsoluteValueOnly,MaxNumberOfAddends,RelationalOperators};​​If[avo,​​Return[​​Grid[Table[​​n=RandomInteger[{1,mnoa}];​​bb=RandomChoice[{-5,-4,-3,-2,-1,1,2,3,4,5},n];​​cc=RandomInteger[{-5,5},n];​​h=RandomChoice[Flatten[{ro}]];​​cte=RandomInteger[{-5,5}];​​coeff=RandomChoice[Flatten[{Table[-1,{k,noe}],​​Table[1,{k,noe}]}],n];​​ineq=h[Plus@@Inner[#1*#2&,coeff,Abs[bbx+cc],List],cte];​​{DisplayForm[RowBox[{i,"▪ ",TraditionalForm[ineq]}]],​​DisplayForm[RowBox[{"Sol.:",Reduce[ineq,x,Reals]}]]},​​{i,noe}],​​Spacings{{Automatic,5},Automatic},Alignment{Left,Left}]​​]];​​GridTable​​n=RandomInteger[{1,mnof}];​​aa=RandomInteger[{-5,5},n];​​bb=RandomInteger[{-5,5},n];​​cc=RandomInteger[{-5,5},n];​​h=RandomChoice[Flatten[{ro}]];​​hh1=RandomChoice[Flatten[{If[av,Table[Abs,{k,mri}],{}],​​If[rr,Table[With[{k=k},NSurd[x,#,k]&],{k,2,mri}],{}],​​Table[Identity,{k,mri}]}],n];​​If[ri,​​dd=RandomInteger[{-5,5},n];​​ee=RandomInteger[{-5,5},n];​​ff=RandomInteger[{-5,5},n];​​hh2=RandomChoice[Flatten[{If[av,Table[Abs,{k,mri}],{}],​​If[rr,Table[With[{k=k},NSurd[x,#,k]&],{k,2,mri}],{}],​​Table[Identity,{k,mri}]}],n];​​];​​ineq=h[Times[aux=Times@@Inner[#1[#2]&,hh1,aa
2
x
+bbx+cc,List];​​If[PolynomialExpressionQ[aux,x],Expand[aux],aux],​​Power[If[ri,Times@@Inner[#1[#2]&,hh2,dd
2
x
+eex+ff,List],1],-1]],0];​​{DisplayForm[RowBox[{i,"▪ ",TraditionalForm[ineq]}]],​​DisplayForm[RowBox[{"Sol.:",Reduce[ineq,x,Reals]}]]},​​{i,noe},​​Spacings{{Automatic,5},Automatic},Alignment{Left,Left}​​
The NumberOfExercises option allows the user to choose the number of exercises to generate. With the MaxNumberOfFactors option, the user can indicate the maximum number of factors that will appear in the numerator and the denominator (if any). With the RationalIneqs option, the user can indicate if he wants rational inequalities generated. With the Radicals option, the user can indicate if they wish for factors affected by radicals to appear. With the MaxRadicalIndex option, the user can choose the maximum value of the radical indices (in case he has chosen to include factors affected by radicals). With the AbsoluteValue option, the user can choose if they want factors affected by the absolute value to appear. With the AbsoluteValueOnly option, the user can choose if they only want addends affected by the absolute value to appear. With the MaxNumberOfAddends option, the user can indicate the maximum number of addends that will appear. Finally, with the RelationalOperators option, the user can choose the relational operators they want to appear.
In[]:=
GenerateInequalitiesList[x]
Out[]=
1▪4-3
2
x
≤0
Sol.:x≤-
2
3
||x≥
2
3
2▪6
4
x
-19
3
x
+2
2
x
+20x≥0
Sol.:x≤
1
3
(1-
13
)||0≤x≤
1
3
(1+
13
)||x≥
5
2
3▪-64
4
x
-48
3
x
+16
2
x
+36x+24≥0
Sol.:-
3
2
≤x≤
3
2
4▪5
6
x
-11
5
x
-45
4
x
+23
3
x
+56
2
x
-12x-16≥0
Sol.:x≤-2||-1≤x≤
1
10
(1-
41
)||
1
10
(1+
41
)≤x≤1||x≥4
5▪
6
x
-19
4
x
+22
3
x
-107
2
x
-32x+10≥0
Sol.:x≤
1
2
(-5-
29
)||2-
6
≤x≤
1
2
(-5+
29
)||x≥2+
6
6▪-25
4
x
+15
3
x
-2
2
x
+2x+4≤0
Sol.:x≤
1
5
(1-
11
)||x≥
1
5
(1+
11
)
7▪-
2
x
+4x+5<0
Sol.:x<-1||x>5
8▪9
5
x
+24
4
x
-26
3
x
+76
2
x
-40x+32<0
Sol.:x<-4
9▪-36
6
x
+39
5
x
+87
4
x
-185
3
x
+116
2
x
+68x-80≤0
Sol.:x≤
1
6
(-3-
69
)||
1
8
(3-
73
)≤x≤
1
6
(-3+
69
)||x≥
1
8
(3+
73
)
10▪80
5
x
+72
4
x
+56
3
x
-24
2
x
-16x≥0
Sol.:-
2
5
≤x≤0||x≥
1
2
In[]:=
GenerateInequalitiesList[x,RelationalOperators->{Less,Greater}]
Out[]=
1▪8
4
x
-2
3
x
-
2
x
+11x-10>0
Sol.:x<
1
4
(-1-
17
)||x>
1
4
(-1+
17
)
2▪-3
2
x
-1<0
Sol.:True
3▪4
2
x
-2x+2<0
Sol.:False
4▪-3
6
x
-7
5
x
+16
4
x
+29
3
x
-13
2
x
-34x-12<0
Sol.:x<-3||-1<x<
1
3
(1-
13
)||
1
2
(1-
5
)<x<
1
3
(1+
13
)||x>
1
2
(1+
5
)
5▪-6
4
x
-15
3
x
-
2
x
+20x+12>0
Sol.:-
3
2
<x<-
2
3
||-1<x<
2
3
6▪-2
2
x
-5x+2<0
Sol.:x<
1
4
(-5-
41
)||x>
1
4
(-5+
41
)
7▪-5
2
x
-4x-3<0
Sol.:True
8▪-3
3
x
+18
2
x
-19x+20<0
Sol.:x>5
9▪5
4
x
-22
3
x
-21
2
x
+26x+20>0
Sol.:x<-1||
1
5
(1-
21
)<x<
1
5
(1+
21
)||x>5
10▪-15
6
x
-67
5
x
-28
4
x
-85
3
x
-47
2
x
-22x-24>0
Sol.:
1
2
(-5-
13
)<x<
1
2
(-5+
13
)
In[]:=
GenerateInequalitiesList[x,RelationalOperators->{LessEqual,GreaterEqual,Equal}]
Out[]=
1▪2
2
x
+2x-1≤0
Sol.:
1
2
(-1-
3
)≤x≤
1
2
(-1+
3
)
2▪-5
2
x
-x+20
Sol.:x
1
10
(-1-
41
)||x
1
10
(-1+
41
)
3▪-6
4
x
+13
3
x
-11
2
x
+5x-1≥0
Sol.:
1
2
≤x≤1
4▪2
4
x
-5
3
x
-15
2
x
+x+100
Sol.:x
1
4
(-1-
17
)||x
1
4
(-1+
17
)||x
1
2
(3-
29
)||x
1
2
(3+
29
)
5▪-4
4
x
+23
3
x
-3
2
x
-26x-80
Sol.:x
1
2
(5-
33
)||x
1
2
(5+
33
)||x
1
8
(3-
73
)||x
1
8
(3+
73
)
6▪-75
6
x
-60
5
x
+96
4
x
+48
3
x
+24
2
x
+12x-45≥0
Sol.:
1
10
(-3-
109
)≤x≤-1||
1
10
(-3+
109
)≤x≤1
7▪4
4
x
+15
3
x
+10
2
x
+3x0
Sol.:x-3||x0
8▪-32
5
x
+128
4
x
-264
3
x
+296
2
x
-188x+60≤0
Sol.:x≥1
9▪5
2
x
+2x-40
Sol.:x
1
5
(-1-
21
)||x
1
5
(-1+
21
)
10▪-12
6
x
+33
5
x
+26
4
x
-92
3
x
+81
2
x
-16x-80≤0
Sol.:x≤
1
2
(1-
21
)||
1
8
(3-
73
)≤x≤
1
8
(3+
73
)||x≥
1
2
(1+
21
)
In[]:=
GenerateInequalitiesList[x,Radicals->True,RationalIneqs->True,NumberOfExercises->5,AbsoluteValue->True]
Out[]=
1▪
12
-3
2
x
-x-3
23
2
2
x
+4x+2
3
2
x
+1
(-5
2
x
+4x-5)(
2
x
-x+4)2
2
x
-3x+2
>0
Sol.:False
2▪
5x-2-2
2
x
-4x-5
32
2
2
x
-5x
-4
2
x
+3x-1
≥0
Sol.:x<0||x>
5
2
3▪
26
5
2
x
-4x+2
4
2
x
+4x-2
39
-2x-4
48
-4
2
x
-5
<0
Sol.:False
4▪
5
2
x
-3
-4
2
x
-x+4
≤0
Sol.:x<
1
8
(-1-
65
)||-
3
5
≤x≤
3
5
||x>
1
8
(-1+
65
)
5▪
(5
2
x
-x+5)
26
1-2
2
x

2
x
+4x-4
(-4
2
x
-2x+1)(
2
x
-2x)
17
-2
2
x
+x+1
>0
Sol.:-
1
2
<x<0||
1
4
(-1+
5
)<x<
1
2

References

[1] Anastassiou, G. and Mezei, R.: Numerical Analysis Using Sage. Springer, 2015.
[2] Ardiç, M. and Isleyen, T.: High School Mathematics Teachers’ Levels of Achieving Technology Integration and In-Class Reflections: The Case of Mathematica. Universal Journal of Educational Research, v5 n12B p1-17 2017.
[3] Ardiç, M. and Isleyen, T.: Secondary School Mathematics Teachers’ and Students’ Views on Computer Assisted Mathematics Instruction in Turkey: Mathematica Example. Malaysian Online Journal of Educational Technology, 5(1): 46-64, 2017.
[4] Conceição, A. et al.: Mathematica in the classroom: new tools for exploring precalculus and differential calculus. Conferência Nacional sobre Computação Simbólica no Ensino e na Investigação, CESEI2012. Lisboa, 2012.
[5] Course Hero Symbolab Ltd. (2023), Symbolab, https://www.symbolab.com/solver/ (accessed on July 03, 2023).
[6] Garvan, F.: The MAPLE Book. CRC Press, 2001.
[7] Kanagasabapathy, M.: Introduction to WxMaxima for Scientific Computations. BPB Publications, 2018.
[8] Karjanto, N. and Husain, H.: Not Another Computer Algebra System: Highlighting wxMaxima in Calculus. Mathematics 9(12): 1317, 2021.
[9] Maeder, R.: Programming in Mathematica, Third Edition. Addison-Wesley, 1996.
[10] Mohd, A. et al.: Adoption of Wxmaxima Software in the Classroom: Effect on Students’ Motivation and Learning of Mathematics. Malaysian Journal of Mathematical Sciences 8(2): 311-323, 2014.
[11] Makhdum, F.: Effect Of Using Dynamic Graphical Utilities On Students’ Achievements And Attitudes To Enhance Mathematics Teaching And Learning At The Elementary Level InPakistan: EnhancingAndImpeding Factors. Journal of Positive School Psychology 7(1): 106-116, 2023.
[12] Roanes-Lozano, E. et al.: A Proposal for Filling the Gap Between the Knowledge of a CAS and its Application in the Classroom. Applications of Computer Algebra ACA’2007. Computer Algebra in Education: 7-17, 2007.
[13] Wolfram Research (2023), Wolfram Alpha, https://www.wolframalpha.com/ (accessed on July 03, 2023).
[14] Wolfram Research (2022), Functional Programming, Wolfram Language \& System Documentation Center,\\ https://reference.wolfram.com/language/guide/FunctionalProgramming.html (accessed on December 28, 2022).
[15] Wolfram Research (1988), Listable, Wolfram Language function,\\ https://reference.wolfram.com/language/ref/Listable.html (accessed on December 19, 2022).
[16] Wolfram Research (2007), RandomChoice, Wolfram Language function,\\ https://reference.wolfram.com/language/ref/RandomChoice.html (accessed on September 11, 2022).
[17] Wolfram Research (2007), RandomInteger, Wolfram Language function,\\ https://reference.wolfram.com/language/ref/RandomInteger.html (accessed on August 02, 2022).
[18] Wolfram Research (1988), Reduce, Wolfram Language function,\\ https://reference.wolfram.com/language/ref/Reduce.html (accessed on January 13, 2023).
[19] Wolfram Research (2022), Rules \& Patterns, Wolfram Language \& System Documentation Center,\\ https://reference.wolfram.com/language/guide/RulesAndPatterns.html (accessed on July 02, 2023).
[20] Wolfram Research (2012), Surd, Wolfram Language function,\\ https://reference.wolfram.com/language/ref/Surd.html (accessed on February 20, 2023).
[21] Wolfram, S.: The Mathematica Book, Fifth Edition. Wolfram Research, Inc., 2003.
[22] Wolfram, S.: Una Introducción Elemental a Wolfram Language. Wolfram Research, Inc., 2019.
[23] Zill, Dennis G. and Dewar, Jacqueline M.: College Algebra, Third Edition. Jones & Bartlett Learning, 2010.

CITE THIS NOTEBOOK

A Mathematica function to get a list of random inequalities and their respective solution sets​
by Judith K. Jiménez-Vilcherrez, Robert Ipanaqué-Chero, Ricardo Velezmoro-León & Marcela F. Velásquez-Fernández
Wolfram Community, STAFF PICKS, May 10, 2024
​https://community.wolfram.com/groups/-/m/t/3173756