如何在 Mathematica 中打印方程

发布于 2024-09-26 19:41:33 字数 269 浏览 7 评论 0原文

如何定义不应计算公式,而应以传统格式显示公式?这里有两个例子,第一个例子按照我想要的方式显示,但第二个例子被简化了。

Print["5. ", Limit[f[x]/g[x], x -> a], "=", Limit[f[x], x -> a]/Limit[g[x], x -> a], ", where ", Limit[g[x], x -> a] != 0];
Print["7. ", Limit[c, x -> a], "=", c]

How do I define that a formula should not be computed, but rather displayed in Traditional format? Here are 2 examples, where the first one is displayed like I want it, but the second one is simplified.

Print["5. ", Limit[f[x]/g[x], x -> a], "=", Limit[f[x], x -> a]/Limit[g[x], x -> a], ", where ", Limit[g[x], x -> a] != 0];
Print["7. ", Limit[c, x -> a], "=", c]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

皇甫轩 2024-10-03 19:41:33

使用 HoldForm 打印表达式而不对其求值。

Print["7. ", HoldForm[Limit[c, x -> a]], "=", c]
(* /*        ^^^^^^^^                      */ *)

Use HoldForm to print an expression without evaluating it.

Print["7. ", HoldForm[Limit[c, x -> a]], "=", c]
(* /*        ^^^^^^^^                      */ *)
夜吻♂芭芘 2024-10-03 19:41:33

这在一定程度上取决于您想要做什么,但如果您只是编写文本,请不要使用 Print。相反,请直接输入文本,确保您使用的是 Text 单元格而不是 Input 单元格。在菜单中,选择:

Format -> Style -> Text

然后输入您想要的内容,例如:

5. Limit[f[x]/g[x], x -> a] == Limit[f[x], x->a]/Limit[g[x], x -> a] where ...

选择要转换为 TraditionalForm 的表达式,然后再次在菜单中选择:

Cell -> ConvertTo -> TraditionalForm

...,您应该得到类似这样的内容:

您可能还会发现有关排版的截屏视频很有用:
http://www.wolfram.com/broadcast/screencasts/ howtoentermathematicaltypesetting/

如果您实际上尝试以编程方式生成TraditionalForm 输出(例如,使用Print),您可能会考虑使用RowTraditionalFormHoldForm

Print[Row[{
   "5. ",
    TraditionalForm[HoldForm[
     Limit[f[x]/g[x], x -> a] == Limit[f[x], x -> a]/Limit[g[x], x -> a]]],
   " where ..."
   }]]

It depends a little bit on exactly what you want to do, but if you're just writing text, don't use Print. Instead, enter the text directly, making sure you are using a Text cell and not an Input cell. In the menu, select:

Format -> Style -> Text

Then type out what you want, like:

5. Limit[f[x]/g[x], x -> a] == Limit[f[x], x->a]/Limit[g[x], x -> a] where ...

Select the expression you want to convert to TraditionalForm and then in the menu again, select:

Cell -> ConvertTo -> TraditionalForm

... and you should get something like this:

You might also find the screencast on typesetting useful:
http://www.wolfram.com/broadcast/screencasts/howtoentermathematicaltypesetting/

If you're actually trying to produce TraditionalForm output programmatically (e.g., with Print) you might consider using Row and TraditionalForm with HoldForm:

Print[Row[{
   "5. ",
    TraditionalForm[HoldForm[
     Limit[f[x]/g[x], x -> a] == Limit[f[x], x -> a]/Limit[g[x], x -> a]]],
   " where ..."
   }]]
等待我真够勒 2024-10-03 19:41:33

如果我理解正确的话——你不需要 Limit[c, x -> a] 待评估。
停止评估的标准方法是使用“Hold”。

  Print["7. ", Hold[Limit[c, x -> a]], "=", c]

但结果并不好:

  7. Hold[Limit[c, x -> a]] = c

HoldForm 命令起到了作用——它保留了求值但不显示:

  Print["7. ", HoldForm[Limit[c, x -> a]], "=", c]
  7. Limit[c, x -> a] = c

If I undestand you correctly -- you don't want Limit[c, x -> a] to be evaluated.
Standart way to stop something from evaluation is to use "Hold".

  Print["7. ", Hold[Limit[c, x -> a]], "=", c]

But the result is not good:

  7. Hold[Limit[c, x -> a]] = c

The HoldForm command does the trick -- it holds evaluation but doesn't show up:

  Print["7. ", HoldForm[Limit[c, x -> a]], "=", c]
  7. Limit[c, x -> a] = c
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文