Mathematica: output an expression without evaluating it first

Click For Summary
SUMMARY

The discussion centers on the need for a Mathematica function that prevents the evaluation of expressions, akin to a hypothetical function named DoNotEvaluate[]. Users seek alternatives to achieve this functionality. The suggested functions include HoldForm, HoldAll, HoldComplete, HoldAllComplete, and Unevaluated, which can be used to shield expressions from evaluation while allowing other computations to proceed. These functions are essential for users who require control over expression evaluation in Mathematica.

PREREQUISITES
  • Familiarity with Mathematica syntax and functions
  • Understanding of expression evaluation in Mathematica
  • Knowledge of the purpose and usage of Hold functions in Mathematica
  • Basic experience with Mathematica's documentation and reference materials
NEXT STEPS
  • Research the usage of HoldForm in Mathematica
  • Explore the differences between HoldAll and HoldComplete functions
  • Learn how to use Unevaluated in Mathematica expressions
  • Investigate practical examples of shielding expressions from evaluation in Mathematica
USEFUL FOR

Mathematica users, educators, and researchers who need to manage expression evaluation effectively, particularly those working on symbolic computations or teaching mathematical concepts using Mathematica.

HJ Farnsworth
Messages
126
Reaction score
1
Greetings,

I recently discovered Mathematica's Format function, and it has been of great use to me. However, there is one thing that I want to use it to do, that I have yet to be able to. I could do this easily, though, if there is some Mathematica function that works as follows...

If I put a semicolon after inputting something in Mathematica, it evaluates what I input without outputting the result. The function that I am looking for is sort of the inverse of this.

I will call the function DoNotEvaluate[] for the rest of this post. Some simple input and output examples for the function that I am looking for would be...

Input: DoNotEvaluate[Sqrt[4]]
Output: Sqrt[4] - note that the output is not 2.

Input: DoNotEvaluate[Sqrt[2*2]]
Output: Sqrt[2*2] - note that the output is neither Sqrt[4] or 2.

Input: x=2*2; DoNotEvaluate[Sqrt[x]]
Output: Sqrt[4]

Does anyone know of a Mathematica function, or other Mathematica technique, that does what my made-up DoNotEvaluate[] function does?

Thanks for any help you can give.

-HJ Farnsworth
 
Physics news on Phys.org
Perhaps one of these or some combination?

http://reference.wolfram.com/mathematica/ref/HoldForm.html
http://reference.wolfram.com/mathematica/ref/HoldAll.html
http://reference.wolfram.com/mathematica/ref/HoldComplete.html
http://reference.wolfram.com/mathematica/ref/HoldAllComplete.html
http://reference.wolfram.com/mathematica/ref/Unevaluated.html

There are even more of these, but I don't think the process of shielding some things from evaluation while getting other things done has been explained in any documentation that I have seen.
 
Thank you for the very quick and complete response. That's pretty much what I wanted.

-HJ Farnsworth
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K