Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

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

Search the Archive

Re: Hold & Evaluate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129910] Re: Hold & Evaluate
  • From: "djmpark" <djmpark at comcast.net>
  • Date: Mon, 25 Feb 2013 02:21:18 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <4703464.30423.1361680665289.JavaMail.root@m06>

Jakub,

The following evaluates the denominator and then wraps it in a HoldForm.

Table[n/HoldForm @@ {n + 0.1 (n + 1)}, {n, 1, 15}]
% // ReleaseHold

{1/1.2, 2/2.3, 3/3.4 ,4/4.5 ,5/5.6, 6/6.7, 7/7.8, 8/8.9, 9/10., 10/11.1,
11/12.2, 12/13.3, 13/14.4,
14/15.5, 15/16.6}
{0.833333, 0.869565, 0.882353, 0.888889, 0.892857, 0.895522, \
0.897436, 0.898876, 0.9, 0.900901, 0.901639, 0.902256, 0.902778, \
0.903226, 0.903614}

The following Presentations routine isolates Subexpressions by placing them
within Tooltips that indicate they are held expressions and that also give
some control on whether there are parentheses and a key for selective
release. There are many cases, in physics say, where one might want to bind
various constant expressions together and prevent them from being separated
during simplification routines.

<< Presentations`

Table[n/CreateSubexpression[n + 0.1 (n + 1), False], {n, 1, 15}]
% // ReleaseSubexpressions[]

Which gives the same output as above except the denominators of the
fractions have Tooltips of "held" on them.


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/index.html










From: =A9er=FDch Jakub [mailto:Serych at panska.cz]


Dear mathgroup,
I would like to generate sequence in the form:

1/1.2, 2/2.3, 3/3.4, 4/4.5, etc.

It is very simple by a Table function:

Table[n/(n + 0.1 (n + 1)), {n, 1, 15}]

but as there are real numbers in denominators, Mathematica evaluates all and generates something like:

{0.833333, 0.869565, 0.882353, 0.888889, 0.892857, 0.895522, etc.}

How to evaluate numerators and denominators separately and print the sequence in that "fraction like" form?

I tested:

#[[1]]/#[[2]] & /@ Table[{n, n + 0.1 (n + 1)}, {n, 1, 15}] and than used Hold[] and Evaluate[]:

Hold[Evaluate[#[[1]]]/Evaluate[#[[2]]]] & /@  Table[{n, n + 0.1 (n + 1)},
{n, 1, 15}]

But it doesn't work as the Hold has "veto" power over any evaluation.

Thanks in advance for any idea, how to do it

Jakub




  • Prev by Date: Re: Mathematica and Lisp
  • Next by Date: Re: Hold & Evaluate
  • Previous by thread: Re: Hold & Evaluate
  • Next by thread: Re: Hold & Evaluate