1
$\begingroup$

By default, E is used to represent the Euler's number in Mathematica. I need the variable E to behave just like other undefined variables in my code. When I run the commands

Unprotect[E]
Clear[E]

the variable E remains black, which means it still holds a value. Next, If I run

1.0E

Mathematica gives

2.71828

How can I completely clear this predefined value?

$\endgroup$
8
  • 3
    $\begingroup$ Your example's result is governed by numeric evaluation, the N function. You can define (after Unprotecting E), e.g. N[E] = 0, and that would change the result in your example. As a result, E will acquire so-called NValues: NValues[E] will not be empty list. But I'd think twice before doing such hard redefinitions for such a fundamental constant as E, it can have all kinds of unobvious consequences for your Mathematica session / calculations. $\endgroup$ – Leonid Shifrin May 8 at 20:35
  • 5
    $\begingroup$ There are a number of alternative "E"s that you can redefine. E.g. [ScriptCapitalE], [DoubleStruckCapitalE], [CapitalEpsilon] $\endgroup$ – mikado May 8 at 20:38
  • 3
    $\begingroup$ I don't think it makes sense to encourage beginners to unprotect fundamental constants. Let's make Pi equal to 3 -- it would make geometry much easier! $\endgroup$ – bill s May 8 at 21:26
  • 5
    $\begingroup$ @BillS Can we make E into 2 3/4? It takes around two hours and forty five minutes to cut down a modest-sized tree, so this qualifies as a natural logger rhythm. $\endgroup$ – Daniel Lichtblau May 8 at 21:43
  • 2
    $\begingroup$ There are far safer ways to do this than to redefine (or undefine) E. Check ref/format/CSV in the documentation (Help > Wolfram Documentation, then enter "CSV"). With "Numeric"->False (or Automatic, I think) you get strings rather than numbers. StringReplace can then change occurrences of the character E into something else. $\endgroup$ – Daniel Lichtblau May 9 at 17:43
2
$\begingroup$
Unprotect[E]
Remove[E]

E = .5
(*0.5*)

1.0 E
(*0.5*)

On the other hand after removing E

EsceeEsc//N

(*2.71828*)

This works, but it is a very bad idea.

The easiest way to get E back to the proper value is to Quit.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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