:

## Using natural language models in Maple

Maple 2023

Hi everyone,

I'd like to draw your attention to a package we recently uploaded to the Maple Cloud, here. You can download the package from the linked Cloud page, or directly from here as a workbook file: NaturalLanguage.maple. I'll include a lightly edited version of the "cover sheet" that introduces the package below. I have left the first four sections folded closed - you can see those in the linked Maple Cloud page or the workbook - because I think the last section is the most interesting.

Using natural language models in Maple

This package explores using large language models such as ChatGPT for processing natural language in Maple. Let's load the package from source, save it in this workbook, and load it.    Warning, the NaturalLanguage package is an experimental package designed as an interface to publicly available large language models such as ChatGPT. Use of this package is entirely at the user's risk. Results may be inconsistent, misleading, or flat out incorrect. (1)

We note there is a warning: we will see output of large language models, which will often include inaccurate statements. Please keep this in mind - this is not (yet?) technology that you want to use to build a bridge!

We also note that there are five publically exposed commands. Let's look at them in turn.

 RawQuery
 Query
 GetMath
 GetCommand

Explain

 • The command asks the given model to explain the item in the query. After an explanation, you can ask for more detail by issuing the command , , , , , or minor variations. The item you ask about can be a mathematical expression, equation, list of equations, or a string.
 • The default model is GPT-4; you can select the other model by using the option, or forcing use of the GPT-4 model by using the option. Note that OpenAI may deprecate and disable models, so the set of models supported may change in the future.

display(Explain(x^2+y^2=1)); This equation represents a circle with a radius of 1 centered at the origin (0,0) on a coordinate plane.

display(Explain(more)); The equation x^2 + y^2 = 1 represents a circle in a two-dimensional plane (specifically, a Cartesian plane). The center of the circle is at the origin of the coordinates (0,0) and its radius is 1. This is because any point (x, y) on the circle is a distance r (the radius) away from the center, and by the Pythagorean theorem, this distance is given by the square root of (x^2 + y^2). The fact that x^2 + y^2 = 1 implies that the radius r = sqrt(1) = 1. This fundamental equation is also the unit circle in trigonometry, where angles are measured in radians. The coordinates (x, y) represent the cosine and sine of the angle respectively. The unit circle is a crucial concept in trigonometry, complex number theory, and calculus. It simplifies many mathematical concepts and provides a geometric interpretation of a variety of phenomena in physical sciences and engineering.

display(Explain(Re(exp(x*I + y*I)) = Re(exp(x*I)) * Re(exp(y*I)) - Im(exp(x*I)) * Im(exp(y*I)))); The equation seems to be using Euler's formula, which states that e^(ix) = cos(x) + i*sin(x). The 'Re' refers to the real part of a complex number, and 'Im' refers to the imaginary part. So, if you put Euler's formula in there your equation is equivalent to cos(x + y) = cos(x)cos(y) - sin(x)sin(y), which is basically the well-known trigonometric formula for the cosine of a sum. In a nutshell, it's dealing with the trigonometric identities and properties of exponential functions with complex numbers.

display(Explain("go on", model = ChatGPT)); The given equation appears to be dealing with the real part of a complex exponential expression. Let's break it down step by step to understand its meaning: 1. The equation involves the expression e^(i*x+i*y), where e represents Euler's number (~2.718), i is the imaginary unit (√(-1)), and x and y are real numbers. 2. The expression e^(i*x+i*y) can be rewritten using Euler's formula: e^(i*x+i*y) = cos(x+y) + i*sin(x+y). This is a complex number in the form a + bi, where 'a' represents the real part (Re) and 'b' represents the imaginary part (Im). 3. The real part of e^(i*x+i*y) is, therefore, Re(e^(i*x+i*y)) = cos(x+y). 4. The right side of the equation consists of the product of two complex exponential expressions: Re(e^(i*x))*Re(e^(i*y))-Im(e^(i*x))*Im(e^(i*y)). 5. The expression Re(e^(i*x)) represents the real part of e^(i*x), which is cos(x), and Im(e^(i*x)) represents the imaginary part of e^(i*x), which is sin(x). 6. Similarly, Re(e^(i*y)) represents the real part of e^(i*y), which is cos(y), and Im(e^(i*y)) represents the imaginary part of e^(i*y), which is sin(y). 7. Therefore, the right side becomes: (cos(x)*cos(y)) - (sin(x)*sin(y)). So, the equation Re(e^(i*x+i*y)) = Re(e^(i*x))*Re(e^(i*y))-Im(e^(i*x))*Im(e^(i*y)) essentially states that the real part of e^(i*x+i*y) (i.e., cos(x+y)) is equal to the real part of e^(i*x) (i.e., cos(x)) multiplied by the real part of e^(i*y) (i.e., cos(y)), minus the imaginary part of e^(i*x) (i.e., sin(x)) multiplied by the imaginary part of e^(i*y) (i.e., sin(y)). In simpler terms, the equation is connecting the real part of the sum of two complex exponential expressions with the product of the real parts and the difference of the imaginary parts of those individual expressions.

display(Explain(Re(sigma) < 0)); The inequality "Re(sigma) < 0" is a statement in complex number theory. It is saying that the real part (Re) of a complex number sigma is less than zero. This means that the complex number is to the left of the imaginary axis in the complex number plane. This kind of inequality is often used in the study of complex functions, in areas such as control systems or signal processing in electrical engineering, and also in number theory and the study of dynamical systems in mathematics.

display(Explain(continue)); The inequality "Re(sigma) < 0" is typically related to the field of complex numbers. Here, "Re" stands for the real part of a complex number and "sigma" is usually used to represent a complex number. So, "Re(sigma) < 0" is saying that the real part of the complex number sigma is negative. Complex numbers are usually written in the form a + bi, where a and b are real numbers and i is the imaginary unit. The "Re" in "Re(sigma)" refers to the a part of this form, i.e. the real part of the complex number. This inequality is often found in fields like control systems engineering or signal processing. For instance, in control systems, all the poles of a stable system must have a negative real part. Another context you might come across this inequality is in complex analysis, one might examine the region where the real part of a complex function is negative. So, the inequality "Re(sigma) < 0" expresses that a complex number is in the left half of the complex plane, which is often crucial for the stability of many systems in engineering.

display(Explain("The Maple command simplify")); The Maple command "simplify" is used to simplify mathematical expressions. In Maple, this command applies various rules to reduce an equation or expression to its simplest or most compact form. For example, if you have an equation like `(x^3 - x^2)/x^2`, using the simplify command would reduce it to `x - 1`. It simplifies algebraic expressions, performs factorization, combines like terms, cancel out common factors, etc. The general syntax is `simplify(expr)`, where `expr` is the expression that you want to simplify. The simplified expression is returned as output. Please note that the simplifications made by this command are based on general rules and may not always give the expected results for some specific expressions due to the complexity of mathematical simplifications.

display(Explain(continue, model=ChatGPT)); The Maple command "simplify" is used to simplify mathematical expressions. It takes an expression as input and attempts to find a simplified form by applying various algebraic rules and simplification techniques. When you use the "simplify" command, Maple applies a series of simplification steps, which can include: 1. Expanding and factoring polynomials: This step expands products of terms and factors out common terms. 2. Simplifying fractions: The command simplifies fractions by canceling common factors in the numerator and denominator. 3. Simplifying trigonometric expressions: Maple applies trigonometric identities to simplify expressions involving trigonometric functions. 4. Simplifying logarithmic and exponential expressions: The command applies rules of logarithms and exponents to simplify expressions with these functions. 5. Simplifying square roots and radicals: It simplifies square roots by expressing them in simplest radical form. 6. Simplifying expressions involving absolute values: Maple simplifies absolute value expressions by considering different cases based on the sign of the argument. 7. Applying mathematical identities and rules: The command uses various mathematical identities and rules to simplify expressions further. The "simplify" command in Maple is very powerful and can handle a wide range of mathematical expressions. However, it may not always produce the most simplified form, as simplification can sometimes be a subjective task. In such cases, you can try using other commands or options available in Maple to refine the simplification process. To use the "simplify" command in Maple, you can simply type "simplify(expression)" where "expression" represents the mathematical expression you want to simplify. The weight of a W10X54 beam refers to the weight specification of a beam in the W Beam series, commonly used in construction and engineering projects. The nomenclature "W10X54" is decoded as follows: - W: it stands for 'wide flange', a type of structural steel beam where the flanges are parallel to each other. - 10: it indicates the nominal depth of the wide flange, which is about 10 inches. - 54: it indicates the weight of the beam per linear foot, which is about 54 pounds. So, a W10X54 beam weighs 54 pounds per foot. "Weight of a W10X54 beam" refers to the weight of a specific kind of structural steel beam used in construction and architecture. The "W" stands for "wide flange", which is a particular type of I-beam. The "10" means the nominal depth of the beam in inches (also known as its height when standing upright). The "54" represents the beam's weight per foot in pounds. In other words, for every foot of length the beam has, it weighs 54 pounds.  So if you have a W10X54 beam that is 10 feet long, its total weight would be 540 pounds (10 feet times 54 pounds per foot). Please note that these are nominal dimensions and may not exactly match the true dimensions of the beam due to manufacturing variables. What do you think? Will this be an important part of mathematical software in the near future, or are we still far away from that point? We'd love to hear your opinions. ﻿