> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-zh/action-shi-yong-zhi-nan/text-and-number/math-execute.md).

# Math execute

Math execute 是用于执行基本数学运算(如加 `+`、减 `-`、乘 `*`、除 `/`)或从现有变量进行复杂算术表达式运算的操作,然后将结果保存到输出变量中。

🎥 查看更多操作指南视频:[点击这里](https://youtu.be/nlEQsaxawt4)。

#### 配置参数:

* Expression(表达式):需要执行的数学运算内容。您可以将具体数字与现有变量结合使用(例如:`(5 + 3) * 2` 或 `$price * $quantity`)。
* Output variable:用于保存计算完成后结果的变量名称。

#### 实际示例 1:计算订单总金额(乘法和加法)

假设您正在制作自动购物或抓取订单数据的脚本。您有一个产品数量变量 `$quantity = 3`,单价变量 `$price = 150000`,以及固定运费 `30000`。

* 配置方式:
  * Expression:填写表达式 `($price * $quantity) + 30000`
  * Output variable:填写保存结果的变量名称 `$totalAmount`。
* 结果:系统将计算出数值 `480000` 并赋值给变量 `$totalAmount`。

<figure><img src="/files/Xx3WZSQlomm6AdoGcZXu" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-zh/action-shi-yong-zhi-nan/text-and-number/math-execute.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
