Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: unevaluated expression

  • To: mathgroup at smc.vnet.net
  • Subject: [mg77157] Re: [mg77114] unevaluated expression
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Tue, 5 Jun 2007 06:33:15 -0400 (EDT)
  • References: <200706040747.DAA06077@smc.vnet.net>

juliok at verizon.net wrote:

>How do you write a function such as
>   example[f_]:= ......
>
>so that when entering example[#^2] Mathematica will respond with
>
>integral_symbol x^2 dx = x^3 /3
>
>where integral_symbol is the standard math symbol, exponents are
>superscripts, etc. I tried Hold[], Unevaluated[], nothing seems to
>work.
>
>Thanks
>
>
>Julio
>
>  
>
You should use example[#^2&] instead of example[#^2]. Here is one 
possibility:

example[f_] :=  With[{integrand = f[x]}, HoldForm[Integrate[integrand, 
x]] == Integrate[f[x], x]]

Tests:

In[29]:= example[#^2 &]
Out[29]= \[Integral]x^2\[DifferentialD]x\[LongEqual]x^3/3

In[30]:= example[Sqrt]
Out[30]= \[Integral]Sqrt[x]\[DifferentialD]x\[LongEqual](2 x^(3/2))/3

In[31]:= example[Sin]
Out[31]= \[Integral]sin(x)\[DifferentialD]x\[LongEqual]-cos(x)

Carl Woll
Wolfram Research


  • Prev by Date: Rotate and Normal
  • Next by Date: Inverse, numerical precision, simulation dynamical system
  • Previous by thread: unevaluated expression
  • Next by thread: Re: unevaluated expression