mm531
====
Subject: Rotation of twisted line for SurfaceOfRevolution
A one parameter [x(t),y(t),z(t)] 3D skewed line can be rotated
producing surface revolved around zaxis, that need not be only a two
parameter meridian. The following example doable in Mathematica on the
same command may perhaps be instructive.
< {1,1.3,1}];
====
Subject: Re: Interrupt[] without confirmation
Abort[]
?
Jens
Mukhtar Bekkali schrieb im
> How to interrupt evaluation without confirmation
> dialog box, i.e. as if
> hitting alt+. Interrupt[] gives confirmation
> box.
>
====
Subject: Re: Interrupt[] without confirmation
Use Abort[]. See the help for more details
yehuda
> How to interrupt evaluation without confirmation dialog box, i.e. as if
> hitting alt+. Interrupt[] gives confirmation box.
====
Subject: Re: Two related question. Question 1
Vlad
====
Subject: Re: simple set operations
Try this:
tbl = Table[i^2, {i, 0, 10}]
{0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100}
MemberQ[tbl, 5]
False
MemberQ[tbl, 25]
True
>Original Message
====
>Subject: simple set operations
hey all,
I'm hesitant to ask these questions (because they are so simple) but
after
>a
>15 minute search through the docs I'm getting nowhere, so here goes:
1) what's the easiest way to generate a list of elements? ie:
'a' .. 'h' == { a,b,c,d,e,f,g,h }
2) Is there a quick way to check whether an element is in a set?
if ('a' == (any('a','b','c','d')) { print a is in a,b,c,d; }
The first one I see could possibly be done by 'Array', but I don't see
how
>
>the '#' refers to the generation of numbers, but there seems to be no
>corresponding 'letter' symbol.
>As for #2, the easiest way would be through an overloading of the '=='
>operator,
>but again, that doesn't seem to work..
>Ed
====
Subject: Quadratic Form Contours
does anybody know a simple way to calculate 2D ellipsoids in x={x1,x2}
of a quadatric form solving xAx=b for a graphical output, i.e. contour
lines of the quadrtic form expressed as the Graphics primitive Ellipsoid?
I suppose that the option ParameterConfidenceRegion of NonlinearRegress
does something like that, but how?
best,
joerg
====
Subject: Re: mml files
There are a number of possible ways to take geometry data from
Mathematica and convert it to CAD files for machining or rapid
prototyping. As you discovered DXF and IGES are not good solutions. If
you have access to CAD software, like Pro/Engineer, Catia, etc, you can
generate text files with Mathematica which contain lists of points that
define crosssectional surfaces of your solids. Most CAD systems will
let you read in these cross sections and then let you interpolate
smooth surfaces through them and tesselate them. The CAD system then
will offer a number of export format possibilities  right up to
generating tool paths. You might ask, why bother with Mathematica when
you have CAD software  the answer is Mathematica can easily generate a
far greater variety of curves than any of the CAD products. Even when
they offer a programming interface for user defined curves, they
typically only offer basic mathematical functions. The CAD software
however offers GUI based tools for modifying geometry (drilling holes,
putting on chamfers, etc) that would be hard to do in Mathematica, so
if you have to integrate a mathematically defined curve or surface into
an assembly  you probably will find a CAD tool to be essential.
If you want to generate a simple CAD file in Mathematica, this is
possible, but as you discovered, the present Export routines do not
make air tight descriptions of surfaces, which are required for rapid
prototyping. I complained about this to WRI some years ago, but support
 either read back into memory the Stereolithography (STL) file that
Mathematica can generate from Graphics3D objects, and equivalence it,
or build your own STL file from scratch. These are probably about the
same difficulty. In either case you will need an equivalencer  a
routine which detects duplicate nodes and edges, and then rearranges
the data to eliminate them. The best place to start for the
equivalencer would be Roman Maeder's equivalencing routines which
Google will find in the Mathematica Journal, and probably is in his
books. I have done this but can't post it here. It works, but the
performance is slow compared to generation of STL files by the
dedicated CAD products.
There is another approach that may be feasible depending on the
geometry and your familiarity with machining.
You could write a routine which lets Mathematica write Gcode, which
are the instructions most milling machines use. Gcode is just a list
of coordinates of the cutter, with a few minor add ons. This is easy if
the part can be made by what is called 2.5 D machining, where the z
axis simply offsets between cuts and the part is mostly all convex.
There are some fancy examples of machining with Mathematica at
www.mathematicausers.org. Tool path generation for 4 or 5 axis
machining rapidly becomes a very challenging problem that would make a
nice hobby project for someone with an interest in geometry.
STEP files are probably the most reliable and convenient means of
getting CAD data from one system to another, but I have not heard of
anyone writing a STEP generator for Mathematica. That would be very
useful.
Christopher Purcell
Sensors & Actuators Group
DRDCAtlantic, 9 Grove St., PO Box 1012,
Dartmouth NS B2Y 3Z7 Canada
Work Email chris.purcell@drdcrddc.gc.ca
Work Tel 9024263100 x389 Fax 9024269654
Home Tel 9024649248
Home Email christopherpurcell@mac.com
AIM/iChatAV: cffrc
I am using Mathematica to create 3D files that I now want to send to
> be machined. I thought that .dxf or stl files would be good enough but
> they are asking me for an IGES file. Apparantly when Mathematica
> exports a DXF it breaks it up into triangles which are then read as
> separate surfaces making the generation of a program for a CNC machine
> impossible as there are millions of triangles in the curved surfaces I
> need to machine. Mathematica can export as .mml (MathML). Is this
> helpful? What would you suggest?
Alan Notis
>
====
Subject: Axes origin for 3D Plots
How can you set the axes origin for 3D plots ?
Jeffrey S. Pattavina
8603430482 (home)
8608369379 (cell)
ptvn@sbcglobal.net
====
Subject: Re: Axes origin for 3D Plots
you can write your own 3d axes, but the default 3d
axes are always
on the bounding box of the object.
Jens
Jeffrey Pattavina schrieb
How can you set the axes origin for 3D plots ?
> Jeffrey S. Pattavina
8603430482 (home)
> 8608369379 (cell)
> ptvn@sbcglobal.net
>
====
Subject: Re: Re: Complex Oddity
John,
Is your example illustrative of your typical case?
Why not just...
f = E^(I*d)
ComplexExpand[Abs[f]^2]
1
David Park
djmp@earthlink.net
http://home.earthlink.net/~djmp/
I use Jones matrices to evaluate optical circuits and always need to
find the intensity of two interfering electric fields. The intensity
(or brightness) of a field is found as a positive real value from a
complex field as the field times the complex conjugate of the field.
As you can see below, Mathematica gives yet another complex value when
one does this straightforward multiplication instead of the real value
that, I might add, is drilled into all students at the first glimpse of
root(1). For several weeks I struggled to use Mathematica in my
circuit evaluation until one inspired Saturday, after several pots of
coffee, dumb luck and iteration brought forth Intensity[expr_]:= below.
I don't know why it works, I don't know how it works, and I
don't know another way to do the job, but, even as ugly as it is, at
least it works and it works very quickly. Importantly, it also gives
me answers as cosines with arguments that are (real)sums and
differences of characteristic delays, misalignments, and phase
modulation terms.
f=E^(I*d)
In[1]:=
f*Conjugate[f]
Out[1]=
E^ (I*d  I*Conjugate[d])
In[2]:=
Intensity[expr_]:=
TrigReduce[ExpToTrig[expr*TrigToExp[ComplexExpand[Conjugate[ExpToTrig[expr]]
]]]]
In[3]:=
Intensity[f]
Out[3]=
1
With this solution in hand, as an optical engineer, I now have the
luxury of wondering 1) exactly what mathematical elegance (or utility)
is gained by Mathematica's assumption that every variable is always
complex, and 2) why there is apparently no way in Mathematica to
globally define a variable as a real number (i.e., its own conjugate).
John Feth
> correctly. Now I know one facet of working with complex numbers. I
don't
> feel much better about this however. I received one email that said
this
> was my fault for not reading the documentation closely enough. This
problem
> came up in the book Mathematica for Physics second edition by
Zimmerman
> and Olness. They solve a problem using the Complex[a_,b_]>a rule, ( see
> page 91) but not the b part. The b part was my idea. Now I know why
they
> didn't solve for the imaginary part this way. They get the imaginary
part
> by subtracting the real part from the complex expression and dividing by
I.
> How many other gotchas are hidden in the code, waiting to bite the unwary
> and relatively new user? What documentation tells about this kind of a
> problem or do I just have to find them for myself by hopefully catching
the
> errors as they occur?
John Reed
>
====
Subject: Re: Constrained Optimization
Caspar,
Don't you need to maximize over two variables?
f[x_, y_] := (x  x^2) y
Maximize[{f[x, y], 1/5 <= x <= 2/5, y > 0}, {x, y}]
{Infinity, {x > Indeterminate, y > Indeterminate}}
You still obtain an error message but that is because there is no maximum
on
the domain.
If you restrict the y domain you will obtain a maximum.
Maximize[{f[x, y], 1/5 <= x <= 2/5, 0 < y <= 10}, {x, y}]
{12/5, {x > 2/5, y > 10}}
David Park
djmp@earthlink.net
http://home.earthlink.net/~djmp/
I'd like to do constrained optimization with Mathematica 5.1 on a
function that is defined piecewise. Unfortunately Maximize[] does not
work as I expected. A short & simple example to illustrate:
f[x_,y_]:= (xx^2) y
Maximize[{f[x, y], 1/5 <= x <= 2/5, y > 0}, x]
As a result I get:
The objective function (xx^2) y contains a nonconstant expression y
independent of variables {x}.
Obviously for this Maximization, knowing that y > 0 I can do the
following to get the desired value for x:
Maximize[{xx^2, 1/5 <= x <= 2/5}, x]
Out[]= {6/25, {x > 2/5}}
Is there a way to achieve this without manual intervention? The reason
is, that the functions I want to Maximize are defined Piecewise with
several constraints...
Caspar
====
Subject: Re: label origin on plot
The method of showing part of a frame does not give felicitous results
if, e.g, the plot of 1  x^2 is to be done on domain from 1 to 1.
If you open just about any calculus text, e.g., to a 2D graph plot,
you'll see axes going through the pont (0, 0) and with that point
labelled with a single 0. It's unfortunate that Mathematica does not
provide an option to Plot to reproduce this wellestablished behavior.
It's just plain annoying that one has to resort to the workaround of
using an Epilog with a Text primitive.
> I'm a little surprised. With a standard Axes plot it does not seem
possible
> to get the zero ticks labeled.
Plot[1  x^2, {x, 0, 1}];
Extending the lower plot range and even explicitly labeling the ticks
still
> does not work.
Plot[1  x^2, {x, 0, 1},
> Ticks > {Table[{i, i}, {i, 0, 1, 0.2}], Table[{i, i}, {i, 0, 1,
0.2}]},
> PlotRange > {{0.05, 1}, {0.05, 1}}];
But using a Frame (which is generally better anyway) and extending the
lower
> plot range will label the zero points.
Plot[1  x^2, {x, 0, 1},
> Frame > True,
> PlotRange > {{0.01, 1}, {0.01, 1}}];
If you don't want to show the entire Frame you can use...
Plot[1  x^2, {x, 0, 1},
> Frame > {True, True, False, False},
> PlotRange > {{0.01, 1}, {0.01, 1}}];
David Park
> djmp@earthlink.net
> http://home.earthlink.net/~djmp/
> In a 2dimensional plot, Mathematica typically does not label the
> origin. I would like X=0 to be labeled as 0. Is this possible?
>

Murray Eisenberg murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 5491020 (H)
University of Massachusetts 413 5452859 (W)
710 North Pleasant Street fax 413 5451801
Amherst, MA 010039305
====
Subject: Re: label origin on plot
As an addendum to this thread, if you have a plot (framed or not) whose
x axis runs from 4 to 4, the 4 point will typically not be labelled
but the +4 point will be (and similarly for y axis).
A workaround for this is PlotRange>{{4.001,4},{}} and etc.
====
Subject: Re: sum the elements of a list
Hi Morris,
you can also use Total[ Divisors[28] ] > 56.
Drago Ganic
>> After I do Divisors[28], I wish to add the elements of the list. How is
>> this
>> possible?
Morris
> Hi Morris,
To do that, you must replace the head List of the list of divisors of
> 28 returned by the command Divisors[28] by the head Plus (or
Times
> if you wanted the product of the divisors for example).
In[1]:= Divisors[28]
Out[1]= {1,2,4,7,14,28}
In[2]:= Plus@@%
Out[2]= 56
In[3]:= Plus@@Divisors[28]
Out[3]= 56
In[4]:= Apply[Plus,Divisors[28]]
Out[4]= 56
/J.M.
>
====
Subject: Re: Re: Related quastions. Question 2
I'm not using a threaded viewer, and neither are many others. That's why the
message you're responding to should be included in YOUR message.
If the thread gets very long, it's fine to edit some of it out, of course.
Bobby
> He is you. I am sorry, I missed the letters Dr.
In fact I wanted to ask you in another thread but could not put the
> message correctly so that it appeared the beginning of a new thread.
Vlad

DrBob@bigfoot.com
====
Subject: Re: FourierTransform
>Integrate[Exp[I*w*t],{t,0,infinity}]
>or more accurate:
>Integrate[Exp[I*w*t], {t, 0, Infinity}, Assumptions >Element[w,Reals]]
>should fail to converge because the integrand is a unit vector whose
>phase changes with constant velocity (with the exception w=0). However,
>Mathematica happily gives the answer:
>I/w
It looks as if Mathematica is computing a finite version of the integral
Integrate[Exp[I*w*t],{t,0,b}]
getting
Exp[I w b]/(I w)  Exp[I w 0]/(I w)
I/w (Exp[I w b]1)
and then fails to do the limit for b>Infinity, assuming that
Exp[ Infinity * something else] is zero
Is this a bug of Integrate or Limit?
cheers,
Peltio
invalid address in reply to. ecc. ecc.
====
Subject: Re: Re: Limit of list
The reason the restricted search did not locate the appropriate
sequence limit information is that SequenceLimit is not mentioned in
the documentation (excepting some error messages). However,
SequenceLimit does have a usage message that is stored in
Mathematica's source code.
Many usage messages are located on support.wolfram.com. One can add
(at the expense of search terms  Google only allows ten) OR
operators to search these messages as well as the default
documentation and book searches:
This Google search might look like:
sequencelimit site:support.wolfram.com OR site:documents.wolfram.com
usage message OR inurl:mathematica
The desired result is the last one on the first page:
http://support.wolfram.com/mathematica/kernel/Symbols/System/SequenceLimit.h
tml
If one types limit of a sequence, which does appear at the link
above, instead of sequencelimit, Google will not find the page because
Google does not have an index of that page's contents as it is too
unimportant to index. Hopefully, by linking it from this popular
mailing list, it will be indexed and thus easier to locate in the
future.
Just as well, I guess, since it can't possibly work.
>>Why not?
Because a finite sequence has an uncountable number of extensions,
>most of which don't converge, others of which converge to anything
>one cares to arbitrarily choose.
Of course. But _real_ questions do not emerge from a vacuum. Their
> context can provide a definite answer to such a question.
SequenceLimit simply gives an answer to the question, What is the
>result of Wynn's epsilon algorithm for this list of numbers?
SequenceLimit gives the limit of a sequence (computed using Wynn's
> epsilon algorithm). Since the poster was asking a question about the
> limit of a sequence, surely SequenceLimit is an appropriately named
> function?
Since I've never heard of the algorithm until now, it's not likely I
>would ask that question.
But surely the question you would ask (not necessarily to
> Mathematica) involves the keyword convergence? If you search for
> this keyword at MathWorld then the second match is to
http://mathworld.wolfram.com/ConvergenceImprovement.html
and there is a link from there to
http://mathworld.wolfram.com/WynnsEpsilonMethod.html
SAT questions that ask, What's the next term in this sequence? are
>written by mathematical morons who (apparently) don't realize all
>the choices are equally valid.
I agree that SAT questions of this type are stupid. However, in
> _real_ problems all the choices are _not_ equally valid  there is
> some extra information to help guide us. Also, it is often that case
> that when one has n terms of a sequence, one can produce additional
> terms if required, to do a sanity check.
There is also another sense in which this type of approach can be
> optimal. In the paper Maximum entropy summation of divergent
> perturbation series by Carl M. Bender, Lawrence R. Mead, and N.
> Papanicolaou (Journal of Mathematical Physics (1987) 28(5):
> 10161018) one can extract sense from a divergent series using
> maximum entropy as guiding principle. The analogy presented there is
> nice: If you heat an object and let it cool down and then measure its
> heat distribution, because the diffusion of heat is a smoothing
> process, there is no unique initial state leading to the observed
> final stated. However, you can use maximum entropy to find the most
> likely initial state. I am arguing that there is an analogy to the
> problem of determining the limit of a sequence (especially one that
> emerges from a real problem). A similar situation is deblurring a
> photograph.
Paul
>On Wed, 1 Jun 2005 15:13:49 +0800, Paul Abbott
SequenceLimit. Another COMPLETELY undocumented feature.
Not COMPLETELY undocumented. Try
?SequenceLimit
>Just as well, I guess, since it can't possibly work.
Why not? SequenceLimit returns the approximation given by Wynn's
>>epsilon algorithm to the limit of a sequence whose first few terms
>>are given by list. This algorithm can give finite results for
>>divergent sequences. As I understand it, SequenceLimit is used by
>>NIntegrate when Method>Oscillatory.
Paul
>
>Bobby
On Tue, 31 May 2005 04:59:40 0400 (EDT), Paul Abbott
Is there a way to find out the convergence point of a list of
numbers?
for example if I have
{1,2,5,6,8,9,10,11,10,11,12,11,12.. and so on}
it will give me something around 1012
Try SequenceLimit:
SequenceLimit[{1,2,5,6,8,9,10,11,10,11,12,11,12}]
Also, if your list is entering a cycle there have been previous
>>MathGroup postings on methods for detecting cycles.
Paul
>
>
>DrBob@bigfoot.com
>
>
>DrBob@bigfoot.com
> 
> ____________________________________________________________________
> Paul Abbott Phone: +61 8 6488 2734
> School of Physics, M013 Fax: +61 8 6488 1014
> The University of Western Australia (CRICOS Provider No 00126G)
> 35 Stirling Highway
> Crawley WA 6009 mailto:paul@physics.uwa.edu.au
> AUSTRALIA http://physics.uwa.edu.au/~paul
Conference Chair for International Mathematica Symposium 2005
> http://InternationalMathematicaSymposium.org/IMS2005/
____________________________________________________________________

Chris Chiasson
http://chrischiasson.com/
1 (810) 2653161
====
Subject: Re: Re: Limit of list
I'll keep SequenceLimit in mind for cases when it might be useful.
And I'll add a liberal dose of salt to whatever it returns to me.
Bobby
> Not COMPLETELY undocumented.
>> Ah. F1 doesn't work, and neither does the recently advertised Google
trick for searching the current documentation online. Unrestricted Google
DOES work, on the other hand, but I didn't try that until now. Sigh...
>> Just as well, I guess, since it can't possibly work.
Why not?
>> Because a finite sequence has an uncountable number of extensions, most
of which don't converge, others of which converge to anything one cares to
arbitrarily choose. SequenceLimit simply gives an answer to the question,
What is the result of Wynn's epsilon algorithm for this list of numbers?
Since I've never heard of the algorithm until now, it's not likely I would
ask that question.
SAT questions that ask, What's the next term in this sequence? are
written by mathematical morons who (apparently) don't realize all the choices
are equally valid.
Bobby
>> [...]
> This is more a matter of pattern recognition (a form of inductive
> reasoning, I guess) than anything else.
The Wynn epsilon approach has the virtue of often giving what one wants.
> Often it fails to do this, but perfection in this fuzzy arena (which
> approaches mind reading, as you note) is implausible.
> Daniel
>

DrBob@bigfoot.com
====
Subject: Re: Re: Limit of list
> I agree that SAT questions of this type are stupid. However, in
> _real_ problems all the choices are _not_ equally valid  there is
> some extra information to help guide us.
What extra information do SAT testtakers have?
None, except that the pattern should be relatively simple, or
testwriters wouldn't expect them to get it. Whatever simple means.
(Different things to different people, I fear.)
And what was the OP's _real_ problem? What extra information does he
have?
We have no clue. His sequence isn't in my copy of Sloane and PLouffe's
Encyclopedia of Integer Sequences, so that may rule out relatively
simple. (Or it may do just the opposite.)
And how would we pass extra information to SequenceLimit?
We can't, can we?
SequenceLimit selects a best match from a small subset of all sequences
that could extend the list. If it uses the wrong subset or the wrong notion
of best, it will return a wrong answer. (Wrong is just as unknowable
as right, of course, but it's much more likely.)
Back to the OP's general question, which was:
> Is there a way to find out the convergence point of a list of numbers?
No.
Bobby
> Just as well, I guess, since it can't possibly work.
> Why not?
Because a finite sequence has an uncountable number of extensions,
>> most of which don't converge, others of which converge to anything
>> one cares to arbitrarily choose.
Of course. But _real_ questions do not emerge from a vacuum. Their
> context can provide a definite answer to such a question.
> SequenceLimit simply gives an answer to the question, What is the
>> result of Wynn's epsilon algorithm for this list of numbers?
SequenceLimit gives the limit of a sequence (computed using Wynn's
> epsilon algorithm). Since the poster was asking a question about the
> limit of a sequence, surely SequenceLimit is an appropriately named
> function?
> Since I've never heard of the algorithm until now, it's not likely I
>> would ask that question.
But surely the question you would ask (not necessarily to
> Mathematica) involves the keyword convergence? If you search for
> this keyword at MathWorld then the second match is to
http://mathworld.wolfram.com/ConvergenceImprovement.html
and there is a link from there to
http://mathworld.wolfram.com/WynnsEpsilonMethod.html
> SAT questions that ask, What's the next term in this sequence? are
>> written by mathematical morons who (apparently) don't realize all
>> the choices are equally valid.
I agree that SAT questions of this type are stupid. However, in
> _real_ problems all the choices are _not_ equally valid  there is
> some extra information to help guide us. Also, it is often that case
> that when one has n terms of a sequence, one can produce additional
> terms if required, to do a sanity check.
There is also another sense in which this type of approach can be
> optimal. In the paper Maximum entropy summation of divergent
> perturbation series by Carl M. Bender, Lawrence R. Mead, and N.
> Papanicolaou (Journal of Mathematical Physics (1987) 28(5):
> 10161018) one can extract sense from a divergent series using
> maximum entropy as guiding principle. The analogy presented there is
> nice: If you heat an object and let it cool down and then measure its
> heat distribution, because the diffusion of heat is a smoothing
> process, there is no unique initial state leading to the observed
> final stated. However, you can use maximum entropy to find the most
> likely initial state. I am arguing that there is an analogy to the
> problem of determining the limit of a sequence (especially one that
> emerges from a real problem). A similar situation is deblurring a
> photograph.
Paul
>> On Wed, 1 Jun 2005 15:13:49 +0800, Paul Abbott
SequenceLimit. Another COMPLETELY undocumented feature.
Not COMPLETELY undocumented. Try
?SequenceLimit
> Just as well, I guess, since it can't possibly work.
Why not? SequenceLimit returns the approximation given by Wynn's
> epsilon algorithm to the limit of a sequence whose first few terms
> are given by list. This algorithm can give finite results for
> divergent sequences. As I understand it, SequenceLimit is used by
> NIntegrate when Method>Oscillatory.
Paul
>
Bobby
On Tue, 31 May 2005 04:59:40 0400 (EDT), Paul Abbott
>
>> Is there a way to find out the convergence point of a list of
numbers?
for example if I have
{1,2,5,6,8,9,10,11,10,11,12,11,12.. and so on}
it will give me something around 1012
Try SequenceLimit:
SequenceLimit[{1,2,5,6,8,9,10,11,10,11,12,11,12}]
Also, if your list is entering a cycle there have been previous
> MathGroup postings on methods for detecting cycles.
Paul
>

>> DrBob@bigfoot.com
>

>> DrBob@bigfoot.com

DrBob@bigfoot.com
====
Subject: Re: simple set operations
Hi Edward,
> I'm hesitant to ask these questions (because they are so
> simple) but after a
> 15 minute search through the docs I'm getting nowhere, so here goes:
1) what's the easiest way to generate a list of elements? ie:
'a' .. 'h' == { a,b,c,d,e,f,g,h }
2) Is there a quick way to check whether an element is in a set?
if ('a' == (any('a','b','c','d')) { print a is in a,b,c,d; }
The first one I see could possibly be done by 'Array', but I
> don't see how  the '#' refers to the generation of numbers,
> but there seems to be no corresponding 'letter' symbol.
> As for #2, the easiest way would be through an overloading of
> the '==' operator,
> but again, that doesn't seem to work..
(1) you need
lst = CharacterRange[a, h];
I'd suggest looking for it by typing ?*Range*. Of the choices, pick the
most obvious.
(2) depending on what you want to do, any of
Cases[lst, a]
Position[lst, a]
MemberQ[lst, a]
Will give you something to work with, although the last might be the
best.
Any of these pop right out of the documentation.
This is not C++. Rather than a 15 minute search, I suggest a longer,
more
detailed examination during which you might learn some Mathematica syntax
and some simple functions.
Dave.
====
Subject: Re: Re: Complex Oddity
f = E^(I*d)
Refine[f*Conjugate[f], Element[d, Reals]]
> I use Jones matrices to evaluate optical circuits and always need to
> find the intensity of two interfering electric fields. The intensity
> (or brightness) of a field is found as a positive real value from a
> complex field as the field times the complex conjugate of the field.
> As you can see below, Mathematica gives yet another complex value when
> one does this straightforward multiplication instead of the real value
> that, I might add, is drilled into all students at the first glimpse of
> root(1). For several weeks I struggled to use Mathematica in my
> circuit evaluation until one inspired Saturday, after several pots of
> coffee, dumb luck and iteration brought forth Intensity[expr_]:= below.
> I don't know why it works, I don't know how it works, and I
> don't know another way to do the job, but, even as ugly as it is, at
> least it works and it works very quickly. Importantly, it also gives
> me answers as cosines with arguments that are (real)sums and
> differences of characteristic delays, misalignments, and phase
> modulation terms.
f=E^(I*d)
In[1]:=
> f*Conjugate[f]
Out[1]=
> E^ (I*d  I*Conjugate[d])
In[2]:=
> Intensity[expr_]:=
>
TrigReduce[ExpToTrig[expr*TrigToExp[ComplexExpand[Conjugate[ExpToTrig[expr]]]
]]]
In[3]:=
> Intensity[f]
Out[3]=
> 1
With this solution in hand, as an optical engineer, I now have the
> luxury of wondering 1) exactly what mathematical elegance (or utility)
> is gained by Mathematica's assumption that every variable is always
> complex, and 2) why there is apparently no way in Mathematica to
> globally define a variable as a real number (i.e., its own conjugate).
> John Feth
> correctly. Now I know one facet of working with complex numbers. I
don't
> feel much better about this however. I received one email that said
this
> was my fault for not reading the documentation closely enough. This
problem
> came up in the book Mathematica for Physics second edition by
Zimmerman
> and Olness. They solve a problem using the Complex[a_,b_]>a rule, (
see
> page 91) but not the b part. The b part was my idea. Now I know why
they
> didn't solve for the imaginary part this way. They get the imaginary
part
> by subtracting the real part from the complex expression and dividing by
I.
> How many other gotchas are hidden in the code, waiting to bite the
unwary
> and relatively new user? What documentation tells about this kind of a
> problem or do I just have to find them for myself by hopefully catching
the
> errors as they occur?
John Reed
>

Chris Chiasson
http://chrischiasson.com/
1 (810) 2653161
====
Subject: Re: Re: Complex Oddity
>I use Jones matrices to evaluate optical circuits and always need to
>find the intensity of two interfering electric fields. The intensity
>(or brightness) of a field is found as a positive real value from a
>complex field as the field times the complex conjugate of the field.
>As you can see below, Mathematica gives yet another complex value when
>one does this straightforward multiplication instead of the real value
>that, I might add, is drilled into all students at the first glimpse of
> root(1). For several weeks I struggled to use Mathematica in my
>circuit evaluation until one inspired Saturday, after several pots of
>coffee, dumb luck and iteration brought forth Intensity[expr_]:= below.
> I don't know why it works, I don't know how it works, and I
>don't know another way to do the job, but, even as ugly as it is, at
>least it works and it works very quickly. Importantly, it also gives
>me answers as cosines with arguments that are (real)sums and
>differences of characteristic delays, misalignments, and phase
>modulation terms.
f=E^(I*d)
In[1]:=
>f*Conjugate[f]
Out[1]=
> E^ (I*d  I*Conjugate[d])
In[2]:=
>Intensity[expr_]:=
>TrigReduce[ExpToTrig[expr*TrigToExp[ComplexExpand[Conjugate[ExpToTrig[expr]
]]]]]
In[3]:=
>Intensity[f]
Out[3]=
>1
With this solution in hand, as an optical engineer, I now have the
>luxury of wondering 1) exactly what mathematical elegance (or utility)
>is gained by Mathematica's assumption that every variable is always
>complex, and 2) why there is apparently no way in Mathematica to
>globally define a variable as a real number (i.e., its own conjugate).
>John Feth
>
>correctly. Now I know one facet of working with complex numbers. I
don't
>>feel much better about this however. I received one email that said
this
>>was my fault for not reading the documentation closely enough. This
problem
>>came up in the book Mathematica for Physics second edition by
Zimmerman
>>and Olness. They solve a problem using the Complex[a_,b_]>a rule, ( see
>>page 91) but not the b part. The b part was my idea. Now I know why
they
>>didn't solve for the imaginary part this way. They get the imaginary
part
>>by subtracting the real part from the complex expression and dividing by
I.
>>How many other gotchas are hidden in the code, waiting to bite the unwary
>>and relatively new user? What documentation tells about this kind of a
>>problem or do I just have to find them for myself by hopefully catching
the
>>errors as they occur?
John Reed
>
I have also struggled with the very same questions, I have found the
TagSet defination invaluable here is how I would deal with your problem
TagSet[d, Im[d], 0];
TagSet[d, Re[d], d];
TagSet[d, Conjugate[d], d];
f[d_] := E^(I*d)
f[d]*Conjugate[f[d]]
>>1
The fundamental question remains why does Mathematica treat all
variables as complex, well the simple answer may be WHY NOT!!. You can
always tell mathematica which variables are real/complex, by giving them
thier identity(shown above) which is the way it is supposed to work,
isn't it? :)
Pratik Desai

Pratik Desai
Graduate Student
UMBC
Department of Mechanical Engineering
Phone: 410 455 8134
====
Subject: Re: Re: Complex Oddity
> f=E^(I*d)
In[1]:=
> f*Conjugate[f]
Out[1]=
> E^ (I*d  I*Conjugate[d])
In[2]:=
> Intensity[expr_]:=
> TrigReduce[ExpToTrig[expr*TrigToExp[ComplexExpand[Conjugate
> [ExpToTrig[expr]]]]]]
In[3]:=
> Intensity[f]
Out[3]=
> 1
>
In Mathematica 5.0 I get
In[1]:=
ComplexExpand[E^(I d) Conjugate[E^(I d)]]
Out[1]=
1
In[4]:=
f = E^(I d);
ComplexExpand[f Conjugate[f]]
Out[5]=
1
Is the actual expression you're working with different?
> 1) exactly what mathematical elegance (or utility)
> is gained by Mathematica's assumption that every variable is always
> complex
Because that's the most general case and the most general case is
always mathematically appropriate while the special cases require the
user to identify that the case is special. Substituting values into
the general expression will result in the same value as the special
case anyway so there is no problem.
> 2) why there is apparently no way in Mathematica to
> globally define a variable as a real number (i.e., its own conjugate).
This actually comes up in the mailing list pretty frequently (http://
forums.wolfram.com/mathgroup/search/?q=define+variable
+real&restrict=MathGroup&x=0&y=0). Here is a pretty good answer
http://forums.wolfram.com/mathgroup/archive/1999/Nov/msg00163.html.
Ssezi
====
Subject: Re: Complex Oddity
>I use Jones matrices to evaluate optical circuits and always need to
> find the intensity of two interfering electric fields. The intensity
> (or brightness) of a field is found as a positive real value from a
> complex field as the field times the complex conjugate of the field.
> As you can see below, Mathematica gives yet another complex value when
> one does this straightforward multiplication instead of the real value
> that, I might add, is drilled into all students at the first glimpse of
> root(1). For several weeks I struggled to use Mathematica in my
> circuit evaluation until one inspired Saturday, after several pots of
> coffee, dumb luck and iteration brought forth Intensity[expr_]:= below.
> I don't know why it works, I don't know how it works, and I
> don't know another way to do the job, but, even as ugly as it is, at
> least it works and it works very quickly. Importantly, it also gives
> me answers as cosines with arguments that are (real)sums and
> differences of characteristic delays, misalignments, and phase
> modulation terms.
f=E^(I*d)
In[1]:=
> f*Conjugate[f]
Out[1]=
> E^ (I*d  I*Conjugate[d])
In[2]:=
> Intensity[expr_]:=
>
TrigReduce[ExpToTrig[expr*TrigToExp[ComplexExpand[Conjugate[ExpToTrig[expr]]]
]]]
In[3]:=
> Intensity[f]
Out[3]=
> 1
>
Isn't ComplexExpand[f Conjugate[f]] much simpler?
ComplexExpand[f Conjugate[f]]
1
Another idea is to use Simplify with assumptions:
Simplify[f Conjugate[f], Element[d, Reals]]
1
Is there some expr where the above approaches worked poorly for you?
Carl Woll
> With this solution in hand, as an optical engineer, I now have the
> luxury of wondering 1) exactly what mathematical elegance (or utility)
> is gained by Mathematica's assumption that every variable is always
> complex, and 2) why there is apparently no way in Mathematica to
> globally define a variable as a real number (i.e., its own conjugate).
> John Feth
>> problem
>> correctly. Now I know one facet of working with complex numbers. I
>> don't
>> feel much better about this however. I received one email that said
>> this
>> was my fault for not reading the documentation closely enough. This
>> problem
>> came up in the book Mathematica for Physics second edition by
Zimmerman
>> and Olness. They solve a problem using the Complex[a_,b_]>a rule, (
see
>> page 91) but not the b part. The b part was my idea. Now I know why
>> they
>> didn't solve for the imaginary part this way. They get the imaginary
>> part
>> by subtracting the real part from the complex expression and dividing by
>> I.
>> How many other gotchas are hidden in the code, waiting to bite the
unwary
>> and relatively new user? What documentation tells about this kind of a
>> problem or do I just have to find them for myself by hopefully catching
>> the
>> errors as they occur?
John Reed
>
====
Subject: Re: Re: Complex Oddity
Clear[f];
f=E^(I*d);
Simplify[Abs[f],Element[d, Reals]]
1
Abs[f]//ComplexExpand
1
d/: Re[d]:=d;
d/:Im[d]:=0;
Abs[f]
1
Bob Hanlon
>
====
> Subject: Re: Complex Oddity
I use Jones matrices to evaluate optical circuits and always need to
> find the intensity of two interfering electric fields. The intensity
> (or brightness) of a field is found as a positive real value from a
> complex field as the field times the complex conjugate of the field.
> As you can see below, Mathematica gives yet another complex value when
> one does this straightforward multiplication instead of the real value
> that, I might add, is drilled into all students at the first glimpse of
> root(1). For several weeks I struggled to use Mathematica in my
> circuit evaluation until one inspired Saturday, after several pots of
> coffee, dumb luck and iteration brought forth Intensity[expr_]:= below.
> I don't know why it works, I don't know how it works, and I
> don't know another way to do the job, but, even as ugly as it is, at
> least it works and it works very quickly. Importantly, it also gives
> me answers as cosines with arguments that are (real)sums and
> differences of characteristic delays, misalignments, and phase
> modulation terms.
f=E^(I*d)
In[1]:=
> f*Conjugate[f]
Out[1]=
> E^ (I*d  I*Conjugate[d])
In[2]:=
> Intensity[expr_]:=
>
TrigReduce[ExpToTrig[expr*TrigToExp[ComplexExpand[Conjugate[ExpToTrig[
expr]]]]]]
In[3]:=
> Intensity[f]
Out[3]=
> 1
With this solution in hand, as an optical engineer, I now have the
> luxury of wondering 1) exactly what mathematical elegance (or utility)
> is gained by Mathematica's assumption that every variable is always
> complex, and 2) why there is apparently no way in Mathematica to
> globally define a variable as a real number (i.e., its own conjugate).
> John Feth
problem
> correctly. Now I know one facet of working with complex numbers. I
don't
> feel much better about this however. I received one email that said
this
> was my fault for not reading the documentation closely enough. This
problem
> came up in the book Mathematica for Physics second edition by
Zimmerman
> and Olness. They solve a problem using the Complex[a_,b_]>a rule, (
see
> page 91) but not the b part. The b part was my idea. Now I know why
they
> didn't solve for the imaginary part this way. They get the imaginary
part
> by subtracting the real part from the complex expression and dividing by
I.
> How many other gotchas are hidden in the code, waiting to bite the
unwary
> and relatively new user? What documentation tells about this kind of a
> problem or do I just have to find them for myself by hopefully catching
the
> errors as they occur?
John Reed
>
====
Subject: NonlinearFit
Hallo!
I get a series of error messages when trying to do the following
fitting. Does anyone have an explanation for this?
Needs[Statistics`NonlinearFit`];
dataset = {{1.57, 166796}, {3.13, 136002}, {4.7, 65030}, {6.26, 4521},
{7.83,
4318}, {9.39, 49000}, {10.96, 60576}, {12.52,
17297}, {14.09, 18531}, {15.65, 19586}, {17.22, 113782}, {18.78,
162297}, {20.35, 104847}, {21.91, 21690}, {23.48, 26122}, {25.04,
124402}, {26.61, 230890}, {28.17, 268847}, {29.74, 265542},
{31.3,
286730}, {32.87, 347177}, {34.43, 398782}, {36., 405570}, {37.56,
386662}, {39.13, 378862}, {40.69, 375894}, {42.26, 382073},
{43.82,
421963}, {45.39, 513252}, {46.95, 623846}, {48.52, 690012},
{50.08,
717172}, {51.65, 768446}, {53.21, 909624}, {54.78, 1113780},
{56.34,
1300421}, {57.91, 1468149}, {59.47, 1680055}, {61.04, 1970465},
{62.6,
2367746}, {64.17, 2809895}, {65.73, 3264465}, {67.3, 3692246},
{68.86,
4046681}, {70.43, 4277327}, {71.99, 4360413}, {73.56, 4345338},
{75.12,
4362619}, {76.69, 4547432}, {78.25, 4956316}, {79.82, 5597006},
{81.38,
6424912}, {82.95, 7086361}, {84.51, 7292635}, {86.08, 6797194},
{87.64,
5857715}, {89.21, 4739038}, {90.77, 3744384}, {92.34, 2973363},
{93.9,
2428473}, {95.47, 2062134}, {97.03, 1767899}, {98.6, 1540802},
{100.16,
1377719}, {101.73, 1267488}, {103.29, 1165008}, {104.86,
1017071}, {106.42, 862570}, {107.99, 757954}, {109.55, 720299},
{111.12,
679967}, {112.68, 606439}, {114.25, 518329}, {115.81, 472809},
{117.38,
481415}, {118.94, 496234}, {120.51, 471529}, {122.07, 404742},
{123.64,
343763}, {125.2, 312319}, {126.77, 302469}, {128.33, 294309},
{129.9,
280108}, {131.46, 285452}, {133.03, 323044}, {134.59, 364258},
{136.16,
350050}, {137.72, 291175}, {139.29, 221524}, {140.85, 184576},
{142.42,
178082}, {143.98, 168295}, {145.55, 150666}, {147.11, 144994},
{148.68,
163618}, {150.24, 164462}, {151.81, 126623}, {153.37, 88763},
{154.94,
96576}, {156.5, 130508}}
Clear[ny, nyzero, rate];
AL[ny_, nyzero_, rate_] = rate/(rate^2 + 4*Pi^2*(ny  nyzero)^2);
DL[ny_, nyzero_, rate_] =
2*Pi*(ny  nyzero)/(rate^2 + 4*Pi^2*(ny  nyzero)^2);
tmix = 0.006; Imax = 2.9*10^8; freqzero = 78; J = 16; lambda = 45; eta
= 8;
reg = NonlinearRegress[dataset,
Imax*(AL[freq, freqzero + J/2, lambda  eta]*
Exp[(lambda  eta)*tmix] +
AL[freq, freqzero  J/2, lambda + eta]*
Exp[(lambda + eta)*tmix])*Cos[Pi*J*tmix] +
Imax*(DL[freq, freqzero + J/2, lambda  eta]*
Exp[(lambda  eta)*tmix] 
DL[freq, freqzero  J/2, lambda + eta]*
Exp[(lambda + eta)*tmix])*Sin[Pi*J*tmix],
freq, {{Imax, 3*10^8}, {freqzero, 78}, {J, 16}, {lambda, 45},
{eta,
10}}];
u = (BestFitParameters /. reg)
Plot[Imax*(AL[freq, freqzero + J/2, lambda  eta]*Exp[(lambda 
eta)*tmix] +
AL[freq, freqzero  J/2, lambda + eta]*Exp[(lambda +
eta)*tmix])*
Cos[Pi*J*tmix] +
Imax*(DL[freq, freqzero + J/2, lambda  eta]*Exp[(lambda 
eta)*tmix] 
DL[freq, freqzero  J/2, lambda + eta]*
Exp[(lambda + eta)*tmix])*Sin[Pi*J*tmix], {freq, 0,
154.94},
Prolog > {RGBColor[1, 0, 0], PointSize[0.02], Point /@ dataset}];
====
Subject: Re: NonlinearFit
don't set a value for the parameters you wish to
fit.
Here is a working version:
In[24]:=
Clear[ny, nyzero, rate];
AL[ny_, nyzero_, rate_] = rate/(rate^2 +
4*Pi^2*(ny  nyzero)^2);
DL[ny_, nyzero_, rate_] =
2*Pi*(ny  nyzero)/(rate^2 + 4*Pi^2*(ny 
nyzero)^2);
tmix = 0.006; Imax = 2.9*10^8; freqzero = 78; J =
16; lambda = 45; eta = 8;
In[37]:=
Clear[tmix, Imax, freqzero, J, lambda, eta]
model = Imax*(AL[freq, freqzero + J/2, lambda 
eta]*
Exp[(lambda  eta)*tmix] +
AL[freq, freqzero  J/2, lambda + eta]*
Exp[(lambda + eta)*tmix])*Cos[Pi*J*tmix] +
Imax*(DL[freq, freqzero + J/2, lambda 
eta]*Exp[(lambda  eta)*tmix] 
DL[freq, freqzero  J/2, lambda + eta]*
Exp[(lambda + eta)*tmix])*Sin[Pi*J*tmix];
reg = NonlinearRegress[dataset, model,
freq, {{Imax, 3*10^8}, {freqzero, 78}, {J, 16},
{lambda, 45}, {eta,
10}, {tmix, 0.006}}]
u = (BestFitParameters /. reg);
Plot[Evaluate[model /. u], {freq, 0,154.94},
Prolog > {RGBColor[1, 0, 0], PointSize[0.02],
Point /@ dataset}];
Jens
michael schrieb im
> Hallo!
I get a series of error messages when trying to
> do the following
> fitting. Does anyone have an explanation for
> this?
Needs[Statistics`NonlinearFit`];
dataset = {{1.57, 166796}, {3.13, 136002}, {4.7,
> 65030}, {6.26, 4521},
> {7.83,
> 4318}, {9.39, 49000}, {10.96, 60576},
> {12.52,
> 17297}, {14.09, 18531}, {15.65, 19586},
> {17.22, 113782}, {18.78,
162297}, {20.35, 104847}, {21.91, 21690},
> {23.48, 26122}, {25.04,
124402}, {26.61, 230890}, {28.17, 268847},
> {29.74, 265542},
> {31.3,
> 286730}, {32.87, 347177}, {34.43, 398782},
> {36., 405570}, {37.56,
386662}, {39.13, 378862}, {40.69, 375894},
> {42.26, 382073},
> {43.82,
> 421963}, {45.39, 513252}, {46.95, 623846},
> {48.52, 690012},
> {50.08,
> 717172}, {51.65, 768446}, {53.21, 909624},
> {54.78, 1113780},
> {56.34,
> 1300421}, {57.91, 1468149}, {59.47,
> 1680055}, {61.04, 1970465},
> {62.6,
> 2367746}, {64.17, 2809895}, {65.73,
> 3264465}, {67.3, 3692246},
> {68.86,
> 4046681}, {70.43, 4277327}, {71.99,
> 4360413}, {73.56, 4345338},
> {75.12,
> 4362619}, {76.69, 4547432}, {78.25,
> 4956316}, {79.82, 5597006},
> {81.38,
> 6424912}, {82.95, 7086361}, {84.51,
> 7292635}, {86.08, 6797194},
> {87.64,
> 5857715}, {89.21, 4739038}, {90.77,
> 3744384}, {92.34, 2973363},
> {93.9,
> 2428473}, {95.47, 2062134}, {97.03,
> 1767899}, {98.6, 1540802},
> {100.16,
> 1377719}, {101.73, 1267488}, {103.29,
> 1165008}, {104.86,
> 1017071}, {106.42, 862570}, {107.99,
> 757954}, {109.55, 720299},
> {111.12,
> 679967}, {112.68, 606439}, {114.25,
> 518329}, {115.81, 472809},
> {117.38,
> 481415}, {118.94, 496234}, {120.51,
> 471529}, {122.07, 404742},
> {123.64,
> 343763}, {125.2, 312319}, {126.77,
> 302469}, {128.33, 294309},
> {129.9,
> 280108}, {131.46, 285452}, {133.03,
> 323044}, {134.59, 364258},
> {136.16,
> 350050}, {137.72, 291175}, {139.29,
> 221524}, {140.85, 184576},
> {142.42,
> 178082}, {143.98, 168295}, {145.55,
> 150666}, {147.11, 144994},
> {148.68,
> 163618}, {150.24, 164462}, {151.81,
> 126623}, {153.37, 88763},
> {154.94,
> 96576}, {156.5, 130508}}
Clear[ny, nyzero, rate];
> AL[ny_, nyzero_, rate_] = rate/(rate^2 +
> 4*Pi^2*(ny  nyzero)^2);
> DL[ny_, nyzero_, rate_] =
> 2*Pi*(ny  nyzero)/(rate^2 + 4*Pi^2*(ny 
> nyzero)^2);
tmix = 0.006; Imax = 2.9*10^8; freqzero = 78; J
> = 16; lambda = 45; eta
> = 8;
reg = NonlinearRegress[dataset,
> Imax*(AL[freq, freqzero + J/2, lambda 
> eta]*
> Exp[(lambda  eta)*tmix] +
> AL[freq, freqzero  J/2, lambda +
> eta]*
> Exp[(lambda +
> eta)*tmix])*Cos[Pi*J*tmix] +
> Imax*(DL[freq, freqzero + J/2, lambda 
> eta]*
> Exp[(lambda  eta)*tmix] 
> DL[freq, freqzero  J/2, lambda +
> eta]*
> Exp[(lambda +
> eta)*tmix])*Sin[Pi*J*tmix],
> freq, {{Imax, 3*10^8}, {freqzero, 78}, {J,
> 16}, {lambda, 45},
> {eta,
> 10}}];
> u = (BestFitParameters /. reg)
> Plot[Imax*(AL[freq, freqzero + J/2, lambda 
> eta]*Exp[(lambda 
> eta)*tmix] +
> AL[freq, freqzero  J/2, lambda +
> eta]*Exp[(lambda +
> eta)*tmix])*
> Cos[Pi*J*tmix] +
> Imax*(DL[freq, freqzero + J/2, lambda 
> eta]*Exp[(lambda 
> eta)*tmix] 
> DL[freq, freqzero  J/2, lambda +
> eta]*
> Exp[(lambda +
> eta)*tmix])*Sin[Pi*J*tmix], {freq, 0,
> 154.94},
> Prolog > {RGBColor[1, 0, 0],
> PointSize[0.02], Point /@ dataset}];
>
====
Subject: Re: Partition Function
<< DiscreteMath`
Flatten[Permutations /@ Partitions[4], 1]
excellent Paul!
permutations, i just meant the order in which the permutations are
returned is not important, i'd suggest you use the combinatorica
package
====
Subject: Re: Partition Function
> ... According to the documentation, NextPartition[p] gives the
> integer partition following p in reverse lexicographic order.
Now when I try it, even in a fresh Mathematica session, I get...
> nothing. Is this a bug or am I just misusing the function?
Hi. NextPartition works with a previous partition instead of just a number
like 4. I really like this package, but I wish there was better
documentation on these functions. Anyway, here's an example:
Needs[DiscreteMath`Combinatorica`]
Here's a list of partitions:
Partitions[4]
{{4}, {3, 1}, {2, 2}, {2, 1, 1}, {1, 1, 1, 1}}
NextPartition[{2, 2}]
{2, 1, 1}
It may be easier to just start of with the number in list form:
NextPartition[{4}]
{3, 1}
Looks like NextPartition cycles:
NestList[NextPartition, {4}, NumberOfPartitions[4] + 7]
{{4}, {3, 1}, {2, 2}, {2, 1, 1}, {1, 1, 1, 1}, {4}, {3, 1},
{2, 2}, {2, 1, 1}, {1, 1, 1, 1}, {4}, {3, 1}, {2, 2}}
Just another example:
NestList[NextPartition, {4}, NumberOfPartitions[4]  1]
{{4}, {3, 1}, {2, 2}, {2, 1, 1}, {1, 1, 1, 1}}
HTH
Dana DeLouis
====
Subject: OS X Keybindings
hi there,
i've just started using Mathematica 5 on OS X and although it is
fantastic, i am incredibly annoyed with the keybindings... is there any
way i can customise them?
specifically i would like Fn(right arrow) on my iBook (which sends
End) to move the cursor to the end of the line. similarly for Home (to
the start of the line). and if possible, i'd like alt(arrows) to work
like in emacs, where it moves left or right by a word. though those
Home/End keys are a priority.
====
Subject: Re: OS X Keybindings
These are the standard key bindings that all Mac text editors use. If
you really want Windowsstyle key bindings for the Home and End
keys you can edit (after making a backup copy, of course)
/Applications/Mathematica
5.1.app/SystemFiles/FrontEnd/TextResources/Macintosh/KeyEventTranslations.tr
,
changing the following two lines:
Item[KeyEvent[Home], ScrollNotebookStart],
Item[KeyEvent[End], ScrollNotebookEnd],
to:
Item[KeyEvent[Home], MoveLineBeginning],
Item[KeyEvent[End], MoveLineEnd],
altleft and altright (where alt is the option key on Mac keyboards)
should work the way you describe by default (they certainly do for me).
Rob
====
Subject: Re: Constrained Optimization
Hi Caspar,
see below.
sincerely, Daniel
I'd like to do constrained optimization with Mathematica 5.1 on a
> function that is defined piecewise. Unfortunately Maximize[] does not
> work as I expected. A short & simple example to illustrate:
f[x_,y_]:= (xx^2) y
> Maximize[{f[x, y], 1/5 <= x <= 2/5, y > 0}, x]
Maximize is a numerical functions. Therefore, f[,] needs numeric input.
However, y is so far a puer symbol and has no numerical value. If I
understand your problem correctly, y is assumed to be a constant. But in
this case the maximum value depends on the unspecified y.
Mathematica gives you a correct error message.
As a result I get:
> The objective function (xx^2) y contains a nonconstant expression y
> independent of variables {x}.
Obviously for this Maximization, knowing that y > 0 I can do the
> following to get the desired value for x:
Maximize[{xx^2, 1/5 <= x <= 2/5}, x]
> Out[]= {6/25, {x > 2/5}}
Is there a way to achieve this without manual intervention? The reason
> is, that the functions I want to Maximize are defined Piecewise with
> several constraints...
> Caspar
>
====
Subject: Re: Constrained Optimization
Your're right y was meant to be an unknown constant. As I understand
it know, Maximize[] does some sort of numerical optimization. I thought
it would be able to use some concave Programming logic (like
KuhnTucker) to solve this problem for me, returning a list of possible
optima in symbolic form together with the neccessary constraints... But
I admit that maybe this is to much to ask for
Capar
> ...
> Maximize is a numerical functions. Therefore, f[,] needs numeric input.
> However, y is so far a puer symbol and has no numerical value. If I
> understand your problem correctly, y is assumed to be a constant. But in
> this case the maximum value depends on the unspecified y.
> Mathematica gives you a correct error message.
>
====
Subject: Re: Constrained Optimization
>I'd like to do constrained optimization with Mathematica 5.1 on a
>function that is defined piecewise. Unfortunately Maximize[] does
>not work as I expected. A short & simple example to illustrate:
>f[x_,y_]:= (xx^2) y
>Maximize[{f[x, y], 1/5 <= x <= 2/5, y > 0}, x]
>As a result I get: The objective function (xx^2) y contains a
>nonconstant expression y independent of variables {x}.
You can avoid this error by adding y as one of the parameters to be
maximized, i.e., doing
Maximize[{f[x, y], 1/5 <= x <= 2/5, y > 0}, {x,y}]
But this won't be any better since the constraints you've given aren't
adequate to determine a maximum. (For any value of x satisfying your
constraints, f increases linearly with y without bound.)
>Obviously for this Maximization, knowing that y > 0 I can do the
>following to get the desired value for x:
>Maximize[{xx^2, 1/5 <= x <= 2/5}, x]
>Out[]= {6/25, {x > 2/5}}
>Is there a way to achieve this without manual intervention?
You can achieve the same result by doing
Maximize[{f[x, y], 1/5 <= x <= 2/5, y == 0}, {x,y}]
or
Maximize[{f[x, 1], 1/5 <= x <= 2/5}, x]

To reply via email subtract one hundred and four
====
Subject: Printing parts of a cell
Hello
Can one select a part of a cell and print it out?
I tried this (with a cell containing lots of Functions of
a package) and instead of the selected Function in the
cell the whole cell is printed after calling print
selection.
This happens in Mathematica 4.1 as in 5.1.
Copying the part into a new Notebook seems a little
awkward as the soloution.
Detlef
====
Subject: Re:  ClassNotFoundException
Felix,
You are correct about the casue of the problem. When Java deserializes an
object, it tries to load the class of the object using the classloader that
loaded the currentlyrunning class. When you call ois@readObject[], the
code that is performing this call is part of J/Link's internals. J/Link's
own classes are loaded by the application classloader, whereas all
classes loaded from CLASSPATH or J/Linkspecific application directories
are loaded by J/Link's special classloader, called JLinkClassLoader. The
application classloader doesn't know about the classes that
JLinkClassLoader knows about (like the WEKA classes), so it cannot find
them when it tries to deserialize a WEKA object.
The solution is straightforward if you have followed the above line of
reasoning. Simply ensure that the Java code that is calling readObject() is
not part of J/Link itself, but is instead code that was loaded into J/Link
from CLASSPATH or other userlevel locations, so that it will be loaded by
JLinkClassLoader. What this means is that you need to write a trivial class
that calls readObject():
public class Deserializer {
public static Object readObject(java.io.ObjectInputStream ois)
throws Exception {
return ois.readObject();
}
}
Put this class onto your CLASSPATH or anywhere else J/Link looks for user
classes (such as a Java application directory). Then do this:
fis = JavaNew[ java.io.FileInputStream,
C:workmlf_developWEKAalgorithm.mod ];
ois = JavaNew[ java.io.ObjectInputStream, fis ];
LoadJavaClass[Deserializer]; (* Deserializer is now loaded by the
same classloader that loads WEKA classes. *)
algin = Deserializer`readObject[ois]
There might be another way to tell Java which classloader to use when
deserializing your objects, but this trick of creating a J/Linkloaded
utility class to do the job works nicely.
It is probably an oversight that such a utility class is not built into
J/Link (of course, we would have to make sure that this class was loaded by
JLinkClassLoader like user classes are, not like the other internal parts
of J/Link). Perhaps this will be added in the future.
Todd Gayley
Wolfram Research
I have a little trouble with reading a Java object from file which I
>have myself serialized before (from the Mathematica environment). It
>works when I write a respective Java class by hand and execute it from
>command line, but the same code does not work within Mathematica  it
>produces a ClassNotFoundException.
Does anyone here have respective experience with serializing /
>deserializing objects using J/Link?
The point seems to be that I use an extra Java library (WEKA), which
>works perfectly for every other code I have tried so far, including
>serializing, just not for deserializing. But it cannot be WEKA's fault
>(as it works in another environment)  the class loader used in J/Link
>seems to be the problem.
Here is some of the context and code:
>
InstallJava[
> CommandLine > C:Program
FilesJavaj2re1.4.2binjava.exe
> Xmx400m,
> ClassPath > .;C:Program
FilesWekaWeka34weka.jar
>];
(Weka 3.4 provides the extra Java library I use)
This, amongst others, works:
>
algorithm = JavaNew[
> weka.classifiers.functions.MultilayerPerceptron ];
>algorithm@buildClassifier[ wekaDataSet ];
...
os = JavaNew[
> java.io.FileOutputStream,
> C:workmlf_developWEKAalgorithm.mod
>];
>oos = JavaNew[ java.io.ObjectOutputStream, os ];
>oos@writeObject[ algorithm ];
>oos@flush[];
>oos@close[];
This, however, fails:
fis = JavaNew[
> java.io.FileInputStream,
> C:workmlf_developWEKAalgorithm.mod
>];
>ois = JavaNew[ java.io.ObjectInputStream, fis ];
algin = ois@readObject[]
It produces the following error messages:
>
Java::excptn: A Java exception occurred: java.lang.ClassNotFoundException:
>weka.classifiers.functions.MultilayerPerceptron
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Unknown Source)
> at java.io.ObjectInputStream.resolveClass(Unknown Source)
> at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
> at java.io.ObjectInputStream.readClassDesc(Unknown Source)
> at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
> at java.io.ObjectInputStream.readObject0(Unknown Source)
> at java.io.ObjectInputStream.readObject(Unknown Source)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source).
$Failed
I also tried to instantiate the variable 'algin' before reading:
algin = JavaNew[ weka.classifiers.functions.MultilayerPerceptron ];
but that doesn't help either.
>Felix
====
Subject: Re: angry FindMinimum
In fact, that error message is generated because the minimum on this
example is angular, non derivable. If a bit of noise is added to the
data matrix U, the minimum is smooth and FindMinimum works fine.
The real problem comes when the dimensions of U is a lot larger, like
100x10 times. This is when the Kernel gets stuck, using all the memory
available.
====
Subject: Displaying Images on GUI during run time
Hi all,
I am currently stuck on a problem using the GUIKit. I wanted to creat a
panel to display an image. Then I want a Open button to get the
filepath and displays the image in the panel. Another Operation button
to process the image data and then display the final image again in the
same panel.
I have a ImageLabel panel for image display.
GUIRun[
Widget[Frame, {title > Segmentation GUI,
WidgetGroup[{
WidgetGroup[
{Widget[Panel, {
Widget[ImageLabel, {data > Script[ExportString[
ListDensityPlot[img, Mesh > False, FrameTicks > False, PlotRange >
All, AspectRatio > Automatic, DisplayFunction > Identity],
PNG, ConversionOptions > {Transparency > GrayLevel[1]}]],
}, Name > imgDisplay]
Then I created a Open button to get the user selected filepath and set
the string containing the filepath to the imgDisplay (ImageLabel widget).
Widget[Button, {text > Open,
BindEvent[mouseClicked,
Script[imgPath = ToString[
GUIResolve[Script[
Widget[FileDialog, Name > openFileDialog];
SetPropertyValue[{openFileDialog, multiSelectionEnabled},
False];
SetPropertyValue[{openFileDialog, fileSelectionMode},
PropertyValue[{openFileDialog, FILES_ONLY}]];
returnValue = InvokeMethod[{openFileDialog,
showOpenDialog}, Null];
PropertyValue[{PropertyValue[{openFileDialog,
selectedFile}],
path}], Null]]]];
imgTMP = Import[imgPath].8b¥û1, 1, All,
All.8b¥[YAcute];
SetPropertyValue[{imgDisplay, data}, Script[
ExportString[ ListDensityPlot[imgTMP,Mesh>False, FrameTicks>False,
PlotRange>All, AspectRatio>Automatic,DisplayFunction>Identity],
PNG,ConversionOptions>{Transparency>GrayLevel[1]}]]]]]
}, Name > openButton]
This didnt work. I am not sure if I can do this. What is the usual
Goyan
====
Subject: Re: simple set operations
I posted an answer at
http://www.mathematicausers.org:8080/webMathematica/wiki/wiki.jsp?pageN
ame=FAQ_Lists
Where you can also download the code.
Luc
Original Message
====
Subject: simple set operations
hey all,
I'm hesitant to ask these questions (because they are so simple) but
after a
15 minute search through the docs I'm getting nowhere, so here goes:
1) what's the easiest way to generate a list of elements? ie:
'a' .. 'h' == { a,b,c,d,e,f,g,h }
2) Is there a quick way to check whether an element is in a set?
if ('a' == (any('a','b','c','d')) { print a is in a,b,c,d; }
The first one I see could possibly be done by 'Array', but I don't see
how 
the '#' refers to the generation of numbers, but there seems to be no
corresponding 'letter' symbol.
As for #2, the easiest way would be through an overloading of the =
'=='
operator,
but again, that doesn't seem to work..
Ed
====
Subject: Solving double integral without Error function
I have to solve this double integral:
Phi[ q_ ]=Integrate[Integrate[y(xq)f[x,y],{x,0,q}],{y,2,15}]
where
f[ x_ , y_ ]=1/(2 Pi Sqrt[27])Exp{1/54 [4 x^2  6yx  50x + 9y^2 30 y +
325]}
Mathematica 5.1 on windows fumbles a lot and finally stops giving an answer
in q but using the Error function (I am using the Statistics Continuous
distributions module).
The problem with the Error function is that when I combine this function
Phi
into another equation, I can't find a root in q.
Which function of Mathematica should I use which circumvents the Error
function in solving the double integral?
Or, alternately, which root finding function could I use to find even a
numeric instance of q?
To send a mail take the _ and * out.

Xavier
brusset_*_*_*@_*_*_ poms.ucl.ac.be
PhD student
Universit.8e Catholique de Louvain
Belgium
====
Subject: Attempt to generalize a constant
F[t_,mu_]= mu*JacobiSN[t,mu^2] is a function between +/ 1 extreme
limits.
FindRoot[F[t,mu]==1, {mu,1,1.5},MaxIterations> 100 ] works for given t
= Pi/4, solution is (mu> 2.1236).
But when it is attempted to make t as a variable to plot solutions for
a range of t values in:
ImplicitPlot[F[t,mu]==1,{mu,1,1.5},{t,Pi/6,Pi}], it does not compute
fully. TIA for any tips.
====
Subject: adding text to a plot erases plot?
I have the following very annoying problem in generating plots and
other graphic stuff.
I searched the Archives and the Web for help but I was not able to
solve it.
Maybe it is a trivial issue so I really hope someone can help.
When I add a text cell to a plot, it happens that the text cell
like the text cell had a white background that extends indefinitly on
the right and covers the plot.
For instance, a simple command is:
Plot[x,{x,0,1},Epilog>{Text[a line,{0.3,0.5}]}]
The graphic result is Figure1 posted on my webpage
http://pantheon.yale.edu/~mc654/mathproblem/mathproblem.html
The same happens with the Ticks of the Frame (see Figure 2), and also
if I use different ways of adding text to a plot, like
Show[Graphics[{xxx,Text}]] (see Figure 3).
I'm running Mathematica 5.0 on Mac OS X 10.3 (Panther) on an Apple
PowerBook G4.
The problem appeared after a while, so it can be I toggled an option
that I don't remember (unlikely), but I tried a complete reinstallation
of Mathematica without success.
Did anybody hear of the same problem? Can please anybody help?
Marco
  
Marco Cirelli
Sloane Physics Lab  Yale University
217 Prospect St
P.O.Box 208120
New Haven, CT 065208120, USA
phone: +1.203.432 3653
fax: +1.203.432 5419
marco.cirelli@yale.edu
====
Subject: Re: Axes origin for 3D Plots
Jeffrey,
You can't directly set the axis origin in 3D graphics. 3D graphics are
Boxed. The axes are along three perpendicular edges of the box. You can
control the extent of the box by using the PlotRange option. You can
control
which edges of the box carry the axes ticks by using the option AxesEdge.
David Park
djmp@earthlink.net
http://home.earthlink.net/~djmp/
How can you set the axes origin for 3D plots ?
Jeffrey S. Pattavina
8603430482 (home)
8608369379 (cell)
ptvn@sbcglobal.net
====
Subject: Re: label origin on plot
That technique of putting the axis origin very close to, but not at, 0
is workaround to what I consider a Mathematica design deficiency,
namely, not including an option to allow labelling the origin.
I quite agree that axes through the origin is NOT what one typically
sees in science graphs. The fact remains that axes with the origin
labelled with a single 0 is a longstanding convention in mathematics.
(And yes, that can lead to all sorts of clashes of the function graph
with the tick labels, and not just that at 0.)
One should not underestimate the importance of historical convention in
such matters. After all, a very good case can be made that conventional
mathematical notation is really quite bad  replete with ambiguities
and inconsistencies  but to the disappointment of some, an
unambiguous, totally consistent mathematical notation (e.g., that
introduced by K. Iverson) has never made any significant and permanent
inroad into the conventional notation.
> There is another way to 'trick' Mathematica into labeling zero on one of
the
> axes.
Plot[1  x^2, {x, 1, 1},
> AxesOrigin > {0.000001, 0},
> AxesLabel > {x, y}];
Even if calculus books have such plots, I don't think they are so great.
The
> reason is that the ticks and the labeling come right in the middle of the
> curve. I still think a Frame plot is better because it gets all of the
> labeling off of the curve. ... As I have often remarked here, you will be
hard
> pressed to find an Axes plot in Science.

Murray Eisenberg murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 5491020 (H)
University of Massachusetts 413 5452859 (W)
710 North Pleasant Street fax 413 5451801
Amherst, MA 010039305
====
Subject: Re: label origin on plot
Murray,
There is another way to 'trick' Mathematica into labeling zero on one of
the
axes.
Plot[1  x^2, {x, 1, 1},
AxesOrigin > {0.000001, 0},
AxesLabel > {x, y}];
Even if calculus books have such plots, I don't think they are so great.
The
reason is that the ticks and the labeling come right in the middle of the
curve. I still think a Frame plot is better because it gets all of the
labeling off of the curve. The only technical magazine I have access to
today is Science magazine. (I used to be able to visit the NIST library,
which is not too far away, but now it is closed to the general public
because of paranoia.) As I have often remarked here, you will be hard
pressed to find an Axes plot in Science.
David Park
djmp@earthlink.net
http://home.earthlink.net/~djmp/
The method of showing part of a frame does not give felicitous results
if, e.g, the plot of 1  x^2 is to be done on domain from 1 to 1.
If you open just about any calculus text, e.g., to a 2D graph plot,
you'll see axes going through the pont (0, 0) and with that point
labelled with a single 0. It's unfortunate that Mathematica does not
provide an option to Plot to reproduce this wellestablished behavior.
It's just plain annoying that one has to resort to the workaround of
using an Epilog with a Text primitive.
> I'm a little surprised. With a standard Axes plot it does not seem
possible
> to get the zero ticks labeled.
Plot[1  x^2, {x, 0, 1}];
Extending the lower plot range and even explicitly labeling the ticks
still
> does not work.
Plot[1  x^2, {x, 0, 1},
> Ticks > {Table[{i, i}, {i, 0, 1, 0.2}], Table[{i, i}, {i, 0, 1,
0.2}]},
> PlotRange > {{0.05, 1}, {0.05, 1}}];
But using a Frame (which is generally better anyway) and extending the
lower
> plot range will label the zero points.
Plot[1  x^2, {x, 0, 1},
> Frame > True,
> PlotRange > {{0.01, 1}, {0.01, 1}}];
If you don't want to show the entire Frame you can use...
Plot[1  x^2, {x, 0, 1},
> Frame > {True, True, False, False},
> PlotRange > {{0.01, 1}, {0.01, 1}}];
David Park
> djmp@earthlink.net
> http://home.earthlink.net/~djmp/
> In a 2dimensional plot, Mathematica typically does not label the
> origin. I would like X=0 to be labeled as 0. Is this possible?
>

Murray Eisenberg murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 5491020 (H)
University of Massachusetts 413 5452859 (W)
710 North Pleasant Street fax 413 5451801
Amherst, MA 010039305
====
Subject: activating cells
I might have given this post the wrong subject. What I meant is there a way
to press a button (or write a code) so that specific cells will be entered
(shiftenter) at the beginning of the notebook?
I don't want to go through each cell and shiftenter it.
Guy
====
Subject: Re: Print a selection within
Technically, a notebook itself is just an expression, with the same
being true for cells. Find the appropriate way to address a cell
object, and you could use Extract to take out the boxes corresponding
the extracted part as a cell. Off hand, I do not know the code for
doing so.
On 6/3/05, =?ISO88591?Q?Detlef_M=FCller?=@smc.vnet.net
I am using Mathematica 5.1 and I have a very large cell from wich
> i want to print some Detail (here one Function out of a whole bunch
> of Functions defined for a Package).
I discovered, that after marking this Detail and printing it
> into a file, the whole cell (lots of pages) is printed.
Is there an easier way to print out some lines of a cell
> than copying them into an own cell and then printing this
> cell?
Detlef

Chris Chiasson
http://chrischiasson.com/
1 (810) 2653161
====
Subject: Print a selection within
I am using Mathematica 5.1 and I have a very large cell from wich
i want to print some Detail (here one Function out of a whole bunch
of Functions defined for a Package).
I discovered, that after marking this Detail and printing it
into a file, the whole cell (lots of pages) is printed.
Is there an easier way to print out some lines of a cell
than copying them into an own cell and then printing this
cell?
Detlef
====
Subject: Re: simple set operations
> (1) you need
> lst = CharacterRange[a, h];
I'd suggest looking for it by typing ?*Range*. Of the choices, pick the
> most obvious.
(2) depending on what you want to do, any of
> Cases[lst, a]
> Position[lst, a]
> MemberQ[lst, a]
Will give you something to work with, although the last might be the
best.
> Any of these pop right out of the documentation.
This is not C++. Rather than a 15 minute search, I suggest a longer,
more
> detailed examination during which you might learn some Mathematica syntax
> and some simple functions.
>
But that's the point; I, like probably a lot of other users out there are
time constrained. They know analogous things (C++, perl, python, etc), but
don't want to learn mathematica 'from scratch' because they have the time.
That's what a decent cheatsheet (or cheatbook) would do for mathematica;
reach
out to a lot of professionals who don't really have the time to sit down and
learn things from scratch, but need to learn by doing and applying the
knowledge
they have to Mathematica.
A simple, condensed reference guide, something like a in a nutshell book
by O'Reilly would do the trick.
In fact, if anyone wants to write a decent  as yet unwritten  book on
Mathematica, that's what I'd suggest doing; contacting Nancy Abila at
nancya@oreilly.com and suggesting a Mathematica in a nutshell book.
She's the business relations person for the online publishing group  I'm
not sure who her counterpart is on the print side, but she would know.
Anyways, the nutshell series books run from 300600 pages, and its suitable
for parallel development (usually 45 people work on these things) so they
don't
need to take over someone's life, and its nice to be published.
Ed
(ps  I'm not really affiliated with O'Reilly, I'd just like to buy this
book
if it ever got written!)
====
Subject: Re: simple set operations
> hey all,
I'm hesitant to ask these questions (because they are so simple) but after
a
> 15 minute search through the docs I'm getting nowhere, so here goes:
1) what's the easiest way to generate a list of elements? ie:
'a' .. 'h' == { a,b,c,d,e,f,g,h }
2) Is there a quick way to check whether an element is in a set?
if ('a' == (any('a','b','c','d')) { print a is in a,b,c,d; }
The first one I see could possibly be done by 'Array', but I don't see how

> the '#' refers to the generation of numbers, but there seems to be no
> corresponding 'letter' symbol.
> As for #2, the easiest way would be through an overloading of the '=='
operator,
> but again, that doesn't seem to work..
> Ed
>
1) if you want to generate a list containing *symbols* with consecutive
names (that is the way I understood the question), try this
In[1]:=
lst = ToExpression[CharacterRange[a, h]]
Out[1]=
{a, b, c, d, e, f, g, h}
If you just want a list of *numbers* you would go for
In[2]:=
lstnum = Range[8]
Out[2]=
{1, 2, 3, 4, 5, 6, 7, 8}
2) here we go:
In[111]:=
MemberQ[lst, a]
Out[111]=
True
I'm sure you'll figure out, how to use Print[] and If[] to achieve the
wanted behaviour.
Torsten
====
Subject: Re: simple set operations
Hi Ed,
see below.
> hey all,
I'm hesitant to ask these questions (because they are so simple) but after
a
> 15 minute search through the docs I'm getting nowhere, so here goes:
1) what's the easiest way to generate a list of elements? ie:
'a' .. 'h' == { a,b,c,d,e,f,g,h }
I would numerate the elements. It is easier to work with numbers than
with characters. If you want to see the names, you can put the names
in a list or function names and get the name by names[[i]] or
names[i]. To get the list with numbers: Range[n]
2) Is there a quick way to check whether an element is in a set?
if ('a' == (any('a','b','c','d')) { print a is in a,b,c,d; }
MemeberQ will help: MemeberQ[List_of_Elements, Element ]
The first one I see could possibly be done by 'Array', but I don't see how

> the '#' refers to the generation of numbers, but there seems to be no
> corresponding 'letter' symbol.
> As for #2, the easiest way would be through an overloading of the '=='
operator,
> but again, that doesn't seem to work..
> Ed
>
====
Subject: Re: simple set operations
> hey all,
I'm hesitant to ask these questions (because they are so simple) but after
a
> 15 minute search through the docs I'm getting nowhere, so here goes:
1) what's the easiest way to generate a list of elements? ie:
'a' .. 'h' == { a,b,c,d,e,f,g,h }
2) Is there a quick way to check whether an element is in a set?
if ('a' == (any('a','b','c','d')) { print a is in a,b,c,d; }
The first one I see could possibly be done by 'Array', but I don't see how

> the '#' refers to the generation of numbers, but there seems to be no
> corresponding 'letter' symbol.
> As for #2, the easiest way would be through an overloading of the '=='
operator,
> but again, that doesn't seem to work..
> Ed
>
Hi Ed,
Try CharacterRange[a,h], if you really want to generate that
particular list. There are also lots of other ways to generate lists 
using Table, for example.
Your second question can be solved using MemberQ.
I think you may be making the mistake of trying to use Mathematica for a
very specific task before you have mastered enough of it to get a feel
for how it works. You do need to read the book and try the examples a
bit before it clicks!
David Bailey
http://www.dbaileyconsultancy.co.uk
====
Subject: Re: simple set operations
(1) I guess CharacterRange[ a, h ] will do what you want.
(2) should be solved by MemberQ, i.e.
If[ MemberQ[ mylist, a ], Print[ ... ] ];
Best,
Felix
> hey all,
I'm hesitant to ask these questions (because they are so simple) but after
a
> 15 minute search through the docs I'm getting nowhere, so here goes:
1) what's the easiest way to generate a list of elements? ie:
'a' .. 'h' == { a,b,c,d,e,f,g,h }
2) Is there a quick way to check whether an element is in a set?
if ('a' == (any('a','b','c','d')) { print a is in a,b,c,d; }
The first one I see could possibly be done by 'Array', but I don't see how

> the '#' refers to the generation of numbers, but there seems to be no
> corresponding 'letter' symbol.
> As for #2, the easiest way would be through an overloading of the '=='
operator,
> but again, that doesn't seem to work..
> Ed
>
====
Subject: Re: simple set operations
2) what may MemberQ[] do ?
Jens
Edward Peschko schrieb im
> hey all,
I'm hesitant to ask these questions (because
> they are so simple) but after a
> 15 minute search through the docs I'm getting
> nowhere, so here goes:
1) what's the easiest way to generate a list
> of elements? ie:
'a' .. 'h' == { a,b,c,d,e,f,g,h }
2) Is there a quick way to check whether an
> element is in a set?
if ('a' == (any('a','b','c','d')) { print a is
> in a,b,c,d; }
The first one I see could possibly be done by
> 'Array', but I don't see how 
> the '#' refers to the generation of numbers, but
> there seems to be no
> corresponding 'letter' symbol.
> As for #2, the easiest way would be through an
> overloading of the '==' operator,
> but again, that doesn't seem to work..
> Ed
>
====
Subject: Re: simple set operations
cr=CharacterRange[a, h]
{a,b,c,d,e,f,g,h}
MemberQ[cr,a]
True
Bob Hanlon
>
====
> Subject: simple set operations
hey all,
I'm hesitant to ask these questions (because they are so simple) but after
a
> 15 minute search through the docs I'm getting nowhere, so here goes:
1) what's the easiest way to generate a list of elements? ie:
'a' .. 'h' == { a,b,c,d,e,f,g,h }
2) Is there a quick way to check whether an element is in a set?
if ('a' == (any('a','b','c','d')) { print a is in a,b,c,d; }
The first one I see could possibly be done by 'Array', but I don't see how

> the '#' refers to the generation of numbers, but there seems to be no
> corresponding 'letter' symbol.
> As for #2, the easiest way would be through an overloading of the '=='
operator,
> but again, that doesn't seem to work..
> Ed
====
Subject: Re: mml files
Alan, I do all my CNC work with Mathematica.
I can probably help you when I understand better what you are trying to
do. You can email me directly.
Some of my stuff is at:
http://www.mathematicausers.org/webMathematica/wiki/wiki.jsp?pageName==
S
culptures_by_Luc_Barthelet2
Original Message
====
Subject: mml files
I am using Mathematica to create 3D files that I now want to send to be
machined. I thought that .dxf or stl files would be good enough but they
are asking me for an IGES file. Apparantly when Mathematica exports a
DXF it breaks it up into triangles which are then read as separate
surfaces making the generation of a program for a CNC machine impossible
as there are millions of triangles in the curved surfaces I need to
machine. Mathematica can export as .mml (MathML). Is this helpful? What
would you suggest?
Alan Notis
====
Subject: Problem with Hyperlinks
In Mathematica 5.1.0 and 5.1.1, I am having a problem with internal
hyperlinks (i.e., links to another location within the same notebook)
when using Save As Special and saving to HTML (or XML).
I have an example of a notebook posted at
http://www.cem.uvm.edu/~read/math/hyperlinks.nb
The link from the first cell to the bottom of the notebook works fine,
as does the external link to a webpage.
Here is the resulting html page after a SaveAsSpecial (HTML).
http://www.cem.uvm.edu/~read/math/hyperlinks.html
The external link is OK, but the internal link within the page does not
work. If you view the page source, you can see that the syntax for the
internal link is a mess, and there is no named anchor at the bottom of
the page.
A colleague of mine discovered this problem when he tried to save a
large notebook with many internal links into html. (It worked fine a
year ago with an earlier version of Mathematica.) If it comes to it, I
can edit the html for him to get his webpage working, but as I say, it's
a large file with many internal links. Is there any way to get
Mathematica to handle the internal links correctly when saving as html?

Helen Read
Mathematics & Statistics
University of Vermont
====
Subject: Mathematica uses only 50% of processor?
Mathematica uses only 50% of the processor?
I'm running Window XP Home Edition.
Is there any way to increase this to 90% or 100%
====
Subject: Synergetics coordinates from a tetrahedron
You could make a coordinate system from the whole to the parts, based on
the closest packing of spheres, instead of building up from axioms or
reference vectors: rack up a triangle of pool balls on a pool table and
put a smaller triangle of balls on top of the big triangle of balls and
then a smaller triangle on that one, etc., to make a tetrahedron of pool
balls with five balls on each of the six edges, thirty five balls
altogether. Bisect the edges by removing pool balls to make an
octahedron and bisect the edges of the octahedron to make a
cuboctahedron of thirteen balls. The four planes that defined the
tetrahedron could move inward one layer of balls and meet at the origin
of the coordinate system (4D) which is at the center ball of the
cuboctahedron. Three of the four planes cut the bottom fourth plane if
the fourth plane doesn't move from the origin to make triangles in the
plane (3D) and two of the four planes define signed line segments (2D)
if the other two planes do not move from the origin of the coordinate
system. Look up closest packing of spheres on Google to see how everyone
else starts with a coordinate system in mind before they do some packing
and they are very confusing (CCP, FCC, HCP).
Somebody's got to rack'm up and show the process in graphics on the net
with nice gleaming spheres and four translucent planes.
I don't know how to show that with Mathematica.
Cliff Nelson
Dry your tears, there's more fun for your ears,
Forward Into The Past 2 PM to 5 PM, Sundays,
California time, at: http://www.kspc.org/
Don't be a square or a blockhead; see:
http://users.adelphia.net/~cnelson9/