You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/SolveSimpleMathProblemUsingAIAgent.md
+9-10Lines changed: 9 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,11 +43,12 @@ In this example, use an LLM to find the smallest root of a second\-order polynom
43
43
- Find the smallest real number from a list of two numbers.
44
44
## Compute Roots of Second\-Order Polynomial
45
45
46
-
The `solveQuadraticEquation` function takes the three coefficients of a quadratic polynomial as input and uses the [`roots`](https://www.mathworks.com/help/matlab/ref/roots.html) function to return a column vector containing the two roots.
46
+
The `solveQuadraticEquation` function takes the three coefficients of a quadratic polynomial as input and uses the [`roots`](https://www.mathworks.com/help/matlab/ref/roots.html) function to return a column vector containing the two roots. The LLM used in this example uses textual representations of tool call results in JSON format. Roots of polynomials can be complex, but JSON does not support complex numbers. Therefore, specify the roots as strings.
The `smallestRealNumber` function computes the smallest real number from a list of two numbers. The LLM used in this example expresses tool calls, including input parameters, in JSON format. Roots of polynomials can be complex, but JSON does not support complex numbers. Therefore, specify the roots as strings and convert them back into numbers using the [`str2double`](https://www.mathworks.com/help/matlab/ref/str2double.html) function.
66
+
The `smallestRealNumber` function computes the smallest real number from a list of two numbers. The LLM used in this example expresses tool calls, including input parameters, in JSON format. As JSON does not support complex numbers, specify the roots as strings and convert them back into numbers using the [`str2double`](https://www.mathworks.com/help/matlab/ref/str2double.html) function.
[Thought] To find the smallest root of the quadratic equation \(x^2 + 2x - 3 = 0\), I will first solve the quadratic equation to find both roots. Then, I will determine the smallest root.
257
-
258
-
I will start by solving the quadratic equation.
257
+
[Thought] I will solve the quadratic equation x^2 + 2x - 3 = 0 to find its roots.
259
258
[Action] Calling tool 'solveQuadraticEquation' with args: "{\"a\":1,\"b\":2,\"c\":-3}"
260
-
[Observation] Result from tool 'solveQuadraticEquation': [-3.0000000000000004,0.99999999999999978]
261
-
[Thought] I have found the roots of the equation to be approximately -3 and 1. Now, I will identify the smallest root between these two values.
259
+
[Observation] Result from tool 'solveQuadraticEquation': ["-3","1"]
260
+
[Thought] I will find the smallest root from the roots -3 and 1.
262
261
[Action] Calling tool 'smallestRealNumber' with args: "{\"x1\":\"-3\",\"x2\":\"1\"}"
263
262
[Observation] Result from tool 'smallestRealNumber': -3
264
-
[Thought] The smallest root of the quadratic equation \(x^2 + 2x - 3 = 0\) is -3. I will now provide this as the final answer.
263
+
[Thought] The smallest root is -3. I will now provide the final answer.
265
264
```
266
265
267
266
@@ -272,7 +271,7 @@ disp(agentResponse);
272
271
```
273
272
274
273
```matlabTextOutput
275
-
The smallest root of the equation \(x^2 + 2x - 3 = 0\) is -3.
274
+
The smallest root of the equation x^2 + 2x - 3 = 0 is -3.
0 commit comments