下标变量 [英] Subscripted variables

查看:29
本文介绍了下标变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以强制 Mathematica 独立于未下标变量处理下标变量?进一步来说.比如说,我有以下定义:

Is there any way to force Mathematica to treat subscripted variables independently of their unsubscripted counterparts? More specifically. Say, I have the following definitions:

Subscript[b, 1] = {{1, 2}}
Subscript[b, 2] = {{3, 4}}
b = Join[Subscript[b, 1], Subscript[b, 2]]

现在当我使用

Subscript[b, 1] 

Mathematica 会将其替换为

Mathematica will substitute it with

Subscript[{{1, 2}, {3, 4}},1]

当我希望这些是三个独立的值时,因此更改 b 不会影响 Subscript[b, ..].可能吗?

when I want these to be three independent values, so changing b will not affect Subscript[b, ..]. Is it possible?

推荐答案

在对上一个 SO 问题的回答中,Mathematica 符号和语法模块telefunkenvf14 提到他是

In an answer to a previous SO question, Mathematica Notation and syntax mods, telefunkenvf14 mentioned that he was

希望使用 Notations 来强制 MMA将下标变量视为符号

hoping to use Notations to force MMA to treat subscripted variables as a symbol

这就是这个问题的本质.

which is essentially what this question is about.

WReach 指出 Notation package 可以很简单地使用 Symbolize

WReach pointed out that the Notation package can do this quite simply using Symbolize

Needs["Notation`"];
Symbolize[ParsedBoxWrapper[SubscriptBox["_", "_"]]]

哪里(如 Daniel 的回答)不要太担心上面的 Box 结构,因为您可以使用 Notation 调色板更简单地输入这些内容.

Where (as in Daniel's answer) don't worry too much about the Box structure above as you can use the Notation palette to enter this stuff in more simply.

检查是否一切正常:

In[3]:= Subscript[a, b]//Head
        a = 1
        Subscript[a, b]

Out[3]= Symbol
Out[4]= 1
Out[5]= Subscript[a, b]

In[6]:= Subscript[b, 1] = {{1, 2}}
        Subscript[b, 2] = {{3, 4}}
        b = Join[Subscript[b, 1], Subscript[b, 2]]
Out[6]= {{1, 2}}
Out[7]= {{3, 4}}
Out[8]= {{1, 2}, {3, 4}}

<小时>

注意:以上所有代码均已复制作为输入文本,所以排版SubscriptBoxs已经转换为输入形式Subscripts.但是,Symbolize 在框级别工作,因此需要将测试转换回其 2d 形式.为此,请选择代码(或单元格)并将其转换为标准形式 使用 Cell 菜单或 快捷方式Ctrl-Shift-N.具有上述所有代码的笔记本应该看起来像


Note: all of the above code has been copied as Input Text, so the typeset SubscriptBoxs have been converted to the input form Subscripts. However, the Symbolize works at the box level, so the tests need to be converted back to their 2d forms. To do this, select the code (or cells) and convert it to standard form by using the Cell menu or the shortcut Ctrl-Shift-N. The notebook with all the above code should look like

这篇关于下标变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆