Symbolic toolbox trims final “dot” from symbol name

妖精的绣舞 提交于 2021-01-27 16:42:38

问题


I encountered weird behaviour of the symbolic toolbox of octave, where a symbolic variable ending in -dot looses the final dot-suffix.

pkg load symbolic;
clear, clc;
syms xxxdot
syms % Symbolic variables in current scope: xxxdot
xxxdot % xxxdot = (sym) xxx

I only stumbled upon it, because I had the same variable with and without the suffix -dot. But note that if another symbolic variable is defined without the final -dot, Octave symbolic will not merge them. So the math is still correct:

pkg load symbolic;
clear, clc;
syms xxxdot xxx % Symbolic variables in current scope: xxxdot xxx
xxxdot + xxx % ans = (sym) xxx + xxx

Does anyone have an idea where this comes from?

I am using Octave 4.2.2-1ubuntu1, octave-symbolic 2.6.0-3build1 (Ubuntu 18.04, Kernel 4.15.0-101-generic)


回答1:


I would guess you are running the graphical interface.

If you run octave on the terminal, you will see certain unicode characters that seem to be truncated from the GUI.

This functionality is not well documented (at all, actually), but have a look at the following pages to get an idea of what is happening:

  • https://octave.sourceforge.io/symbolic/function/sympref.html (look at the display section)
  • https://octave.sourceforge.io/symbolic/function/@sym/pretty.html

Essentially, it seems that octave / symbolic is smart enough to understand a variable name is followed by a valid latex-like 'notation' modifier, like dot, hat, tilde, ddot, dddot, ddddot, and represents the variable accordingly:

octave:1> sym('xdot'), sym('xddot'), sym('xdddot'), sym('xddddot'), sym('xhat'), sym('xtilde')
ans = (sym) ẋ
ans = (sym) ẍ
ans = (sym) x⃛
ans = (sym) x⃜
ans = (sym) x̂
ans = (sym) x̃

(actually, the unicode doesn't seem as good on StackOverflow, but it looks ok in the terminal).

As sympref suggests, if you don't like this behaviour (or if you're on the GUI and it doesn't work, duh), you can change it, e.g. sympref display ascii or sympref display flat.

Having said that, I would encourage you to do your community duty and report the lack of output for the GUI as a bug on the octave bug tracker. :)
I'm sure it's not intentional, and probably has more to do with lack of full support for unicode in the terminal used for the GUI...



来源:https://stackoverflow.com/questions/62772201/symbolic-toolbox-trims-final-dot-from-symbol-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!