Query - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


NaturalLanguage

  

Query

  

ask a large language model to answer a question in English and math

 

Calling Sequence

Parameters

Description

Examples

References

Compatibility

Calling Sequence

Query(s)

Query(s, mo)

Parameters

s

-

string, question for the large language model.

mo

-

(optional) option of the form model=m, where m is ChatGPT or GPT4.

Description

• 

The Query command sends a query to a large language model, attempting to instruct the model to use both natural language and MathML. Maple tries to split the answer into MathML and non-MathML, parse the MathML, and then print the results on screen. The command does not return anything.

• 

Maple can interface with OpenAI's GPT-4 and ChatGPT models. The default model is GPT-4; you can select ChatGPT by using the model=ChatGPT option, or force use of the GPT-4 model by using the model=GPT4 option. Note that OpenAI may deprecate and disable models, so the set of models supported may change in the future.

  

Note: Large language models often generate inaccurate statements. Please keep this in mind: this is not technology for building a bridge with.

Examples

withNaturalLanguage:

QueryWhat is Pythagoras' Theorem?

Pythagoras' Theorem states that in a right-angled triangle, the square of the length of the hypotenuse (the side opposite the right angle) is equal to the sum of the squares of the lengths of the other two sides. This can be written as: a² + b² = c² where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides. this formula can be represented as:

a2+b2=c2

(1)

QueryHow do I calculate the Sharpe ratio for financial analysis?,model=ChatGPT

To calculate the Sharpe ratio, you need to follow the formula and perform the necessary calculations. Here's an explanation in English and the corresponding MathML representation: 1. Gather the necessary data: Start by obtaining the historical returns of the financial asset or portfolio you want to analyze, as well as the risk-free rate, typically represented by a T-bill or a similar benchmark. 2. Calculate the excess return: Subtract the risk-free rate from the average return of the asset or portfolio. This measures the excess return generated above the risk-free rate. a = Average return of the asset or portfolio b = Risk-free rate Excess return = a - b 3. Calculate the standard deviation of the asset or portfolio: Measure the volatility or risk of the asset or portfolio using the standard deviation of its returns. s = Standard deviation of the asset or portfolio 4. Compute the Sharpe ratio: Divide the excess return by the standard deviation to determine the risk-adjusted return of the asset or portfolio. Sharpe ratio = (a - b) / s The Sharpe ratio provides insights into the risk-adjusted performance of an investment. A higher ratio indicates a better risk-adjusted return, while a lower ratio suggests a lower return relative to the assumed risk. Please note that some of the MathML formulas may not render properly depending on the platform or browser you are using.

(2)

QueryWhat is the volume of a partially filled sphere?

The volume of a partially filled sphere, also known as a spherical cap, can be found using the following formula: V = (πh^2 / 3)*(3r - h) where: - V is the volume of the spherical cap, - h is the depth or height of the liquid in the sphere (from the top of the sphere to the surface of the liquid), and - r is the radius of the sphere. Note that r and h must be in the same units (e.g., all in inches or all in centimeters) for the formula to work.

V=πh23rh3

Remember that this formula considers that the sphere is sitting with its base on a surface and is not so appropriate if the sphere is floating in space.

(3)

References

  

The OpenAI website.

Compatibility

• 

The NaturalLanguage:-Query command was introduced in Maple 2024.

• 

For more information on Maple 2024 changes, see Updates in Maple 2024.