1

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?

  • 3
    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. – Leonid Shifrin May 08 '21 at 20:35
  • 5
    There are a number of alternative "E"s that you can redefine. E.g. [ScriptCapitalE], [DoubleStruckCapitalE], [CapitalEpsilon] – mikado May 08 '21 at 20:38
  • 3
    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! – bill s May 08 '21 at 21:26
  • 5
    @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. – Daniel Lichtblau May 08 '21 at 21:43
  • 1
    This sounds like a typical XY problem. What are you trying to do with your re-defined E? – Roman May 09 '21 at 09:41
  • Better to get used to using lowercase variables. – Nicholas G May 09 '21 at 12:53
  • @Roman My program reads the input data for the elastic modulus from a CSV file. Assume that the user enters E as a parameter for the elastic modulus. Mathematica will interpret it as the Euler's number. – Mostafa Saber May 09 '21 at 17:27
  • 2
    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. – Daniel Lichtblau May 09 '21 at 17:43

1 Answers1

2
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.

Bill Watts
  • 8,217
  • 1
  • 11
  • 28