4
$\begingroup$

If a value is assigned to a variable that is named by capital K it cannot be deleted. This effect can be observed directly after start of the program.

Is this a bug?

enter image description here

$\endgroup$
9
  • 4
    $\begingroup$ This is why new users should avoid using variable names that start with capital letters. In this case, K is a built-in symbol used by internal functions as a dummy variable for integrals/products/sums, e.g. DSolve[{y'[x] == Sin[Sin[x]]}, y, x]. Of course, you can't delete it! $\endgroup$ Jan 25, 2020 at 22:16
  • 1
    $\begingroup$ Additionally: please do not use the bugs tag in the future for new questions, until other people have confirmed that what you have encountered is a bug. $\endgroup$ Jan 25, 2020 at 22:17
  • 1
    $\begingroup$ @granularbastard Capital letters at the beginning of variables aren't forbidden, they're just a bad idea because you might try to use a built-in symbol (which are all capitalized). $\endgroup$
    – Chris K
    Jan 25, 2020 at 22:25
  • 1
    $\begingroup$ A related thread. $\endgroup$ Jan 26, 2020 at 11:36
  • 1
    $\begingroup$ A hint is that it's black, not blue. @CATrevillian C is used as a dummy variable and it is Protected. $\endgroup$
    – Szabolcs
    Jan 26, 2020 at 16:06

3 Answers 3

8
$\begingroup$

The Wolfram Language currently uses seven single letter capital letters for various core system functions: C, D, E, I, K, N, and O. Mnemonically: OINCKED

The other 19 capital letters are available to use, at least in current versions:

data = {#, Symbol[#], ToExpression[# <> "::usage"]} & /@ CharacterRange["A", "Z"];
Grid[data, Alignment -> Left, Frame -> All, BaseStyle -> "Text"]

enter image description here

Of these seven symbols, K is the only undocumented symbol (in the sense that it does not have a reference page). I would consider that a bug or shortcoming in the documentation.

$\endgroup$
2
  • 3
    $\begingroup$ Also CODE INK - two small meaningful words. Or maybe KODE INC an imaginary company. $\endgroup$ May 4, 2020 at 15:42
  • 1
    $\begingroup$ Peltio was about to give a... saucy mnemonic here, but thankfully he restrained himself. :) $\endgroup$ May 5, 2020 at 1:25
5
$\begingroup$

K is part of the System` context. You were removing symbols from the Global` context only, so K wasn't affected. It could be unset with K=..

That said, when doing interactive work, avoid using any symbols whose name starts with a capital letter, as these may conflict with System symbols or package symbols.

Do not set any value for K and do not attempt to Remove it as this will break things. K is used as the summation index when a generic Sum is returned. An example from the documentation of RSolve:

RSolve[a[n + 1] == a[n] + f[n], a[n], n]

(* {{a[n] -> C[1] + Sum[f[K[1]], {K[1], 0, -1 + n}]}} *)

I do not know why K is not Protected. It seems like it would make sense to protect it as people regularly assign to it by accident.

$\endgroup$
2
$\begingroup$

If K is evaluated then click on "description of K" and you get information:

K is a default generic name for a summation index in a symbolic sum.

The bug is that this information is missing in the help.

$\endgroup$
1
  • 3
    $\begingroup$ To clear K of an assigned value, use K =. $\endgroup$
    – Bob Hanlon
    Jan 26, 2020 at 1:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.