MathGroup Archive 2009

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

Search the Archive

Re: Re: writing a function that would print the

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97874] Re: [mg97665] Re: [mg97609] writing a function that would print the
  • From: Syd Geraghty <sydgeraghty at me.com>
  • Date: Tue, 24 Mar 2009 05:32:44 -0500 (EST)
  • References: <200903170956.EAA16955@smc.vnet.net>

Hi Bobby & Maxim,

Thanks for the post on echo and the integral below.

I have modified it a little below and hope the changes will motivate a  
more robust solution from you or the group.

The desire is to get TraditionalForm output for LHS & RHS in the case  
of an integral as discussed by Maxim Rytin in:

Snip     
*****************************************************************************

From: 	m.r at inbox.ru
Subject: [mg97874] [mg97837] Re: How to deal with this integral
Date: 	March 23, 2009 2:03:59 AM PDT

It's not as fun when you know the answer, but you can evaluate the
integral by making the change of variables u == a + b, v == a b. The
(u, v) region is given by

In[1]:= Reduce[t > 0 && b > a > 0 && 1/a + 1/b < 4 t && a + b == u &&
a b == v,
{u, v}, {a, b}, Reals]

Out[1]= t > 0 && u > 1/t && u/(4 t) < v < u^2/4

(we're integrating over b > a, where the substitution function is one-
to-one).

In[2]:= Assuming[t > 0, 2 Integrate[v E^-u/Sqrt[u^2 - 4 v],
     {u, 1/t, Infinity}, {v, u/(4 t), u^2/4}]] /.
  HoldPattern@ MeijerG[{{}, {a_}}, {{b_, c_}, {}}, z_] :>
   z^b E^-z HypergeometricU[a - c, b - c + 1, z] // FullSimplify

Out[2]= (E^(-(1/(2 t))) (BesselK[1, 1/(2 t)] + (1 + 2 t) BesselK[2, 1/
(2 t)]))/(16 t^3)

Maxim Rytin
m.r at inbox.ru

End Snip      
*****************************************************************************

The two variants on echo are:


Clear[sydecho]
SetAttributes[sydecho, HoldFirst]
sydecho[x_] :=
  TraditionalForm@Print[TraditionalForm@HoldForm@x, " = ", x]

&

Clear[sydechotrad]
SetAttributes[sydechotrad, HoldFirst]
sydechotrad[x_] :=
  TraditionalForm@
   Print[TraditionalForm@HoldForm@x, " = ", TraditionalForm[x]]

I hope it will be clear from the following cases what I would like to  
achieve but cannot yet get quite to my satisfaction.

1)

sydecho[2 Integrate[
    v E^-u/Sqrt[u^2 - 4 v], {u, 1/t, Infinity}, {v, u/(4 t), u^2/4}]]

2)

sydechotrad[
  2 Integrate[
    v E^-u/Sqrt[u^2 - 4 v], {u, 1/t, Infinity}, {v, u/(4 t), u^2/4}]]

and for the full integral with assumptions and conditions on the form  
of the solution:

3)

sydecho[Assuming[t > 0,
     2 Integrate[
       v E^-u/Sqrt[u^2 - 4 v], {u, 1/t, Infinity}, {v, u/(4 t),
        u^2/4}]] /.
    HoldPattern@MeijerG[{{}, {a_}}, {{b_, c_}, {}}, z_] :>
     z^b E^-z HypergeometricU[a - c, b - c + 1, z] // FullSimplify]

4)

sydechotrad[
  Assuming[t > 0,
     2 Integrate[
       v E^-u/Sqrt[u^2 - 4 v], {u, 1/t, Infinity}, {v, u/(4 t),
        u^2/4}]] /.
    HoldPattern@MeijerG[{{}, {a_}}, {{b_, c_}, {}}, z_] :>
     z^b E^-z HypergeometricU[a - c, b - c + 1, z] // FullSimplify]


I cannot paste the TraditionalForm outputs to completely illustrate  
the results I want
but evaluating the cases above should indicate what I am looking for.

Cheers ... Syd

PS With so many people having rich text editors now would it be  
possible to include
formatted output and graphs in posts to the group in the near future?


Syd Geraghty B.Sc, M.Sc.

sydgeraghty at mac.com

Mathematica 7.0.1 for Mac OS X x86 (64 - bit) (18th February 2009)
MacOS X V 10.5.6
MacBook Pro 2.33 GHz Intel Core 2 Duo  2GB RAM





On Mar 18, 2009, at 2:54 AM, DrMajorBob wrote:

> Clear[echo]
> SetAttributes[echo, HoldFirst]
> echo[x_] := Print[ToString@HoldForm@x, " = ", x]


  • Prev by Date: Re: Commutators with boson operators
  • Next by Date: Re: Recursive algorithm
  • Previous by thread: Re: writing a function that would print the name of a
  • Next by thread: Calling functions with huge arguments