mm703
===
Subject: Re: Getting good results with NDSolve?
something is fishy with your expression:
dg/dt = Norm(Grad g) * Laplacian(Grad g / Norm (Grad g))
On the left side you have a scalar.
On the right side you have Laplacian(Grad g ...) what is a vector.
Maybe you mean Div( Grad g / Norm (Grad g))?????
Daniel
> If I want to solve a PDE of three variables (t,x,y) on the region {0,1}^3,
how can I tell NDSolve to have, say a resolution of N x N points for (x,y)
and a resolution of M for t? I find that if I just reduce the max points for
t, then NDSolve quits before gets to the end of the interval. Maybe there is
a way to tell NDSolve to trash some intermediate results and just keep every
Mth point?
> The equation i'm using is dg/dt = Norm(Grad g) * Laplacian(Grad g / Norm
(Grad g))
> where we're looking for g(t,x,y), and the righthand derivatives are taken
only with respect to x and y. My initial value g(0,x,y) had been generated
from a ListInterpolationI'm guessing this is the best way to use a bitmap
as the inital value.
> Christopher Arthur
===
Subject: Re: How to hide a cell?
> Sometimes it is a good idea to hide the input cells.
> How can I hide a cell, except for set the CellOpen property to false ?
> Or can I make the brackets of closes cells more tiny?
If you want to hide the input cell completley, so that nothing about it is
te be seen within the FrontEnd. This is possible with using the Options
CellOpen>False,
ShowCellBracket>False
Which will leave just some horizontal empty space within the Notebook. You
might want to even make the Cell non selectable etc. and it is also
possible to decrease the horizontal space by formatting, if you want that.
hth
albert
===
Subject: Re: UpValues for expressions headed by a string
> First question: is it possible to assign an upvalue to a string?
No
> Second question: why doesn't unprotecting String with
> Unprotect[String];
> bar /: wiggle[b_bar?barQ] := First[b]  5;
> Protect[String]
> work?
Because TagSetDelayed wants a symbol as its first argument and bar
is not a symbol it's a string.
> Last, is it, in general, a bad idea to create data types headed with a
> string, either because of situations like the one given here or for
> some other, additional reasons?
I'm not sure what advantage having a head that's a string confers.
If you are getting your heads from a set of strings, as long as they
don't evaluate to some other type than symbol just use ToExpression
and ToString to use it as a symbol where necessary and a string where
that's the appropriate interpretation.
As you can see the pattern matcher prefers to work with things that
are symbols so if you are planning on manipulating your heads you
sacrifice a lot of built in functionality by not leaving them as
symbols.
Ssezi
===
Subject: Re: general nth term of series
> Is there a way in mathematica to obtain the general term of a taylor
> series expansion?
> !(G[u_, x_] = 1/v((1  2*x*u + u^2)))
> Series[G[u, 0], {u, 0, 8}]
> Ash
Ash,
Use SeriesTerm from the package RSolve:
Needs[DiscreteMath`RSolve`]
In[15]:=
SeriesTerm[G[u,x],{u,0,n}]//OutputForm
Out[15]//OutputForm=
KroneckerDelta[2 + n]  2 x KroneckerDelta[1 + n] + KroneckerDelta[n]

v
Carl Woll
Wolfram Research
===
Subject: Delayed Evaluation of NDSolve Arguments
is there a way to prevent NDSolve to evaluate its arguments
right on the spot?
Inside my differential equation
x'[t]=F[x[t],t,f[x[t],t]],
I want to use a function f[x,t] which
makes only sense, when called with
numeric arguments.
So everything would be fine, if NDSolve
would evaluate the differential equation
at each time step.
However, the differential equation is only
evaluated once at the beginning, and
then only numerical values are plugged
into the evaluated equation at each time step.
Below is a baby example of my problem
f[t_]:=If[NumericQ[t],1,0];
sol=NDSolve[{x'[t]==f[t],x[0]==0},x[t],{t,0,1}];
x[t]/.sol[[1]]
0.
(* I want x[t]=t ! *)
Any help would be appreciated
Benjamin
===
Subject: Re: Delayed Evaluation of NDSolve Arguments
f[t_?NumericQ] := 1;
sol = NDSolve[{x'[t] == f[t], x[0] == 0}, x[t],
{t, 0, 1}];
Plot[Evaluate[x[t] /. sol[[1]]], {t, 0, 1}]
Jens
ben schrieb im

 is there a way to prevent NDSolve to evaluate
its arguments
 right on the spot?

 Inside my differential equation

 x'[t]=F[x[t],t,f[x[t],t]],

 I want to use a function f[x,t] which
 makes only sense, when called with
 numeric arguments.
 So everything would be fine, if NDSolve
 would evaluate the differential equation
 at each time step.
 However, the differential equation is only
 evaluated once at the beginning, and
 then only numerical values are plugged
 into the evaluated equation at each time step.

 Below is a baby example of my problem

 f[t_]:=If[NumericQ[t],1,0];

 sol=NDSolve[{x'[t]==f[t],x[0]==0},x[t],{t,0,1}];

 x[t]/.sol[[1]]
 0.
 (* I want x[t]=t ! *)

 Any help would be appreciated
 Benjamin

===
Subject: Re: exponential diophantine equations
Oh those signs! I typed +7. Mistake. It should be 7.
Andrea
>>I'm trying to find out how to use Mathematica to find solutions to
>>exponential diophantine equations like the following:
>> (5x)^2  2^k * 3 * (5+k)^2  131 * k + 7 = 0. I want to
>>obtain
>>solutions for x and k. (One solution is x = 31, k = 6, but I didn't
>>find
>>this using Mathematica!)
>Are you sure you have found a solution? I get:
>In[30]:=
>(5x)^2  2^k * 3 * (5+k)^2  131 * k + 7 /.{x>31,k>6}
>Out[30]=
>One can certianly try some educated searches but before starting it
>woudl be better to be sure that this is really the equation you want
>to solve!
>Andrzej Kozlowski
===
Subject: Re: Types in Mathematica, a practical example
>Andrzej Kozlowski, who suggests such a solution, thinks that I am looking
at
>Mathematica from the wrong view point. It is my strong belief that one
>should be able, especially when mathematics is involved, to observe from
as
>many different view points as possible. An item is not really beautiful,
or
>properly designed, if it is not beautiful from all view points. The same
>should apply to Mathematica, and I have also understood that Mathematica
was
>intentionally designed to be wellbehaved when seen from different view
>points. Or?
Could we rephrase wrong to say inefficacious and then say,
*To observe from many points of view is quite efficacious.
*To see how Mathematica can achieve my goal is efficacious and
necessaryif it's a priority and not just idle curiosity about the
language.
*To want Mathematica to achieve my goal my way or the way that my
favorite language does it may be possible, but may also be inefficient
and inefficacious.
*If you're using Mathematica, embrace the Mathematica Way. Zen: Be
Mathematica. :)
I think that's what Andrzej is saying. I suggest this applies to many
discussions on MathGroup.
>I soon learned that there are other ways to achieve similar results,
but still I do >not see any good reason why I cannot force Mathematica
to give the following >response from xa,
The usage of force is what made me write some of this.
> In my previous submission I asked for a way to define/declare list with
> undefined elements. All the answers that I have got indicate that it is
> difficult in the present versions of Mathematica. I would not really enjoy
having to explain to a newbie what error he had
> done if she/he had encountered the same problem as I stated initially. I
> would have to explain that in Mathematica it is necessary to choose
between
> two ways to define matrices and similar structures: Either from bottom
and
> up, e.g. by using Array, or from top and down, e.g. by using Table.
The principle you voiced above applies here: Two different ways of
looking at the task and solving it. Therefore this facet is
efficacious, maybe even elegant.
> In the
> first case, if you give the whole structure a name, it is not possible to
> use the same name as is used for assigning values to the individual
> elements.
Payment for the efficacy; yes it is confusing at first. At first.
> What I would prefer is a new Mathematica word: Undefined.
Before taking another shot at this, we should ask do you need
Undefined, do you need to do it this way? See Help 2.5.5, Making
Definitions for Indexed Objects, which starts:
In many kinds of calculations, you need to set up arrays which
contain sequences of expressions, each specified by a certain index.
One way to implement arrays in Mathematica is by using lists. You can
define a list, say a = {x, y, z, .89¥Ï }, then
access its elements using
a[[i]], or modify them using a[[i]] = value. This approach has a
drawback, however, in that it requires you to fill in all the elements
when you first create the list.
Often, it is more convenient to set up arrays in which you can fill
in only those elements that you need at a particular time. You can do
this by making definitions for expressions such as a[i]....
a[i] = value add or overwrite a value
a[i] access a value
a[i] =. remove a value
?a show all defined values
Clear[a] clear all defined values
Table[a[i], {i, 1, n}] .89¥Åor
.89¥ÅArray[a, n] convert to an
explicit List
You can continue from there; it's a Mathematica Way, but I don't know
that it solves your issues.
Addressing your way below. Maybe I'm repeating myself except for the
upvalues defined, but I'm doing it in the context just given.
> Then I could
> define a list x as
> x = {1,Undefined,2};
> x[[1]] should evaluate to 1 as usual, but for this word Undefined the
list
> part x[[2]] should evaluate to x[[2]], precisely as for an undefined
> unindexed symbol.
> x[[4]] should give the usual error message:
> Part::partw: Part 4 of {1, Undefined, 2} does not exist.
undefined = undefined; (*so that you could globally assign
something to the undefineds, even as you make other assignments
elsewhere & so you get a meaningful token at the undefineds*)
table1 = Table[undefined, {3}]
{undefined,undefined,undefined}
table1[[2]]
undefined
ReplacePart[table1, 2, {3}]
{undefined,undefined,2}
Now with Array
ar1 = Array[u, {3}]
{u[1],u[2],u[3]}
u[1] = 1
1
Do[ u[i]= undefined,{i,2,3} ];
ar1
{1,undefined,undefined}
ar1[[4]]
Part::partw: Part 4 of !({1, u[2], u[3]}) does not exist.
{1,u[2],u[3]} [[4]]
> x[[3]] =. and Clear[x[[3]]] should redefine x as {1,Undefined,Undefined},
> and x = Undefined should be interpreted as x =.
> Could this be implemented by operator overloading or by unprotecting and
> redefining Part?
Whether we modify Part or Clear, better to do it as an upvalue for
reasons mentioned (it's safer than unprotecting Part and you can
define it contextually, which is much more powerful, and won't slow
down Clear or Part in other contexts).
For Array i.e. indexed notation:
Clear[ar1[i_]] ^:= ar1[[i]] = undefined; (*the upvalue*)
Clear[ar1[2]]
undefined
ar1
{1,undefined,u[3]}
For Matrix:
Clear[mat[i_List] ] ^:= With[{matrix = mat, partspec = i},
ReplacePart[matrix, undefined, partspec]]; (* the upvalue *)
mat = Table[x, {4}]
{x,x,x,x}
Clear[mat[{2}]]
{x,undefined,x,x}
> I believe that this could be implemented in Mathematica without
destroying
> compatibility with existing code, since it would be an addedon feature.
And
> my intuition (if that is of any value) tells me that such an addition
would
> have benefits I fail to see.
Well, if your choice is to use Mathematica, just getting it done
efficaciously is enough, and extra benefits may result, esp if you try
to view it in one of the Mathematica Ways.
Best,
Kris
===
Subject: Re: Types in Mathematica, a practical example
>> I feel it as a roundabout way to solve the problem.
>> Andrzej Kozlowski, who suggests such a solution, thinks that I am
>> looking at
>> Mathematica from the wrong view point. It is my strong belief that one
>> should be able, especially when mathematics is involved, to observe
>> from as
>> many different view points as possible. An item is not really
>> beautiful, or
>> properly designed, if it is not beautiful from all view points.
Hi Ingolf,
Then again beauty, as they say, is in the eye of the beholder. I mean an
artist can put a bucket and pail of water and call it installation art,
but that does not really take away from what it is and what it is used
for. I concur with Andrzej, Mathematica (lets leave mathematics aside
for now) allows one to solve problems using different approaches, but
what is the best way is a matter of taste and experience, and to some
degree competence in the sciences (the latter quality I am begining to
appreciate after using Mathematica for about a year now) . And to your
problem of using the lawsofcosines and sines essentially is a algebraic
problem which can be solved using Solve, Reduce, but as to how you do it
is IMHO irrelevant. That is, how you input the variables and such (I
think thats where this type business comes in). Again reitereate my
impression of Mathematica as a R&D tool, which probably does not lend it
self well to making some applications user friendly or interactive.
As to your proposal of using undefined, if I am not mistaken, undefined
is already taken :) .I think it means expressions such as 0/0 or
inf/inf (that is in mathematics ofcourse not in CS)
In response to Ssezi's post, I remember there was a post asking about
clearing subscripted variables last june, here is the thread anyway,
might be useful for your application
Pratik
>> The same
>> should apply to Mathematica, and I have also understood that
>> Mathematica was
>> intentionally designed to be wellbehaved when seen from different view
>> points. Or?
> About mathematics: it seems to me that almost all beautiful solutions
> of difficult problems involve finding the right point of view. Often
> once the right point of view is found the problem is almost solved,
> while from the other wrong points of view the problem looks
> extremely hard and often uninteresting  (usually because it appears
> that the only way to solve it is by a tedious computation or, in the
> case o finite problems, by an exhaustive examination of all possible
> cases).
> About Mathematica: it is true that Mathematica allows many styles of
> programming and that this has many practical advantages, but it
> certainly is not true that all these styles are equally efficient,
> elegant and equally suitable to all types of problems. So if you mean
> that for any problem that one wants to tackle with Mathematica it
> should not matter whether you choose a functional approach, a
> procedural approach, a rewrite rule based approach, a recursive
> approach etc, well this definitely is not true and I do not think it
> is reasonable to expect otherwise. In a similar vein in mathematics
> certain problems are more suited to be tackled with algebraic
> techniques, certain with topological, others with analytic etc.
> About your concrete proposal : I personally do not think it would fit
> in well with the functional style of programming that is usually the
> most natural way to tackle problems involving lists, matrices etc in
> Mathematica and also I do not feel any need for what you are proposing
> and hence do not see any benefit if something of this kind were to be
> implemented in Mathematica. But I am sure that this is just a matter
> of taste, exactly as my preferring certain areas of mathematics to
> others is only a matter of taste.
> Andrzej Kozlowski

Pratik Desai
...Moderation, as well as Regularity of Thinking, so much to be wished for
in the Heads of those who imagine they come into the World only to watch and
govern itâs Motion
Gulliver's Travels
by Jonathan Swift
===
Subject: Re: Types in Mathematica, a practical example
> In my previous submission I asked for a way to define/declare list
> with
> undefined elements.
[deleted]
> What I would prefer is a new Mathematica word: Undefined. Then I
> could
> define a list x as
> x = {1,Undefined,2};
> x[[1]] should evaluate to 1 as usual, but for this word Undefined
> the list
> part x[[2]] should evaluate to x[[2]], precisely as for an undefined
> unindexed symbol.
> x[[4]] should give the usual error message:
> Part::partw: Part 4 of {1, Undefined, 2} does not exist.
> x[[3]] =. and Clear[x[[3]]] should redefine x as
> {1,Undefined,Undefined},
You can already do this:
In[111]:=
myclear[x_[[i_]]]:=x[[i]]=undefined
SetAttributes[myclear,HoldFirst]
x={a,b,c};
myclear[x[[2]]]
x
Out[114]=
undefined
Out[115]=
{a,undefined,c}
> and x = Undefined should be interpreted as x =.
This would be problematic because x=Undefined assigns a value to x,
x=. also assigns x a value but it's a different value, anything that
depended on that behavior would break.
In the sense of a general name for an undefined term, some languages
offer a value called bottom, that would be an interesting addition to
Mathematica but as far as I can tell it's not a common feature of
LISP like languages.
Ssezi
===
Subject: Re: Types in Mathematica, a practical example
> I feel it as a roundabout way to solve the problem.
> Andrzej Kozlowski, who suggests such a solution, thinks that I am
> looking at
> Mathematica from the wrong view point. It is my strong belief that one
> should be able, especially when mathematics is involved, to observe
> from as
> many different view points as possible. An item is not really
> beautiful, or
> properly designed, if it is not beautiful from all view points. The
> same
> should apply to Mathematica, and I have also understood that
> Mathematica was
> intentionally designed to be wellbehaved when seen from different
> view
> points. Or?
About mathematics: it seems to me that almost all beautiful solutions
of difficult problems involve finding the right point of view.
Often once the right point of view is found the problem is almost
solved, while from the other wrong points of view the problem looks
extremely hard and often uninteresting  (usually because it appears
that the only way to solve it is by a tedious computation or, in the
case o finite problems, by an exhaustive examination of all possible
cases).
About Mathematica: it is true that Mathematica allows many styles of
programming and that this has many practical advantages, but it
certainly is not true that all these styles are equally efficient,
elegant and equally suitable to all types of problems. So if you mean
that for any problem that one wants to tackle with Mathematica it
should not matter whether you choose a functional approach, a
procedural approach, a rewrite rule based approach, a recursive
approach etc, well this definitely is not true and I do not think it
is reasonable to expect otherwise. In a similar vein in mathematics
certain problems are more suited to be tackled with algebraic
techniques, certain with topological, others with analytic etc.
About your concrete proposal : I personally do not think it would
fit in well with the functional style of programming that is usually
the most natural way to tackle problems involving lists, matrices etc
in Mathematica and also I do not feel any need for what you are
proposing and hence do not see any benefit if something of this kind
were to be implemented in Mathematica. But I am sure that this is
just a matter of taste, exactly as my preferring certain areas of
mathematics to others is only a matter of taste.
Andrzej Kozlowski
===
Subject: Re: Types in Mathematica, a practical example
In my previous submission I asked for a way to define/declare list with
undefined elements. All the answers that I have got indicate that it is
difficult in the present versions of Mathematica. Maybe such a construction
would be awkward, definitely unnecessary and a way to see Mathematica from
the wrong point of view.
But once upon a time zero was unknown as concept and symbol. Once, but
somewhat later, I did some programming in a language named ASYST (a dialect
of Forth as PostScript also is), where zerolength empty strings were not
allowed. This single design flaw I considered as the largest drawback of
the
the same syndrome.
I would not really enjoy having to explain to a newbie what error he had
done if she/he had encountered the same problem as I stated initially. I
would have to explain that in Mathematica it is necessary to choose between
two ways to define matrices and similar structures: Either from bottom and
up, e.g. by using Array, or from top and down, e.g. by using Table. In the
first case, if you give the whole structure a name, it is not possible to
use the same name as is used for assigning values to the individual
elements.
What I would prefer is a new Mathematica word: Undefined. Then I could
define a list x as
x = {1,Undefined,2};
x[[1]] should evaluate to 1 as usual, but for this word Undefined the
list
part x[[2]] should evaluate to x[[2]], precisely as for an undefined
unindexed symbol.
x[[4]] should give the usual error message:
Part::partw: Part 4 of {1, Undefined, 2} does not exist.
x[[3]] =. and Clear[x[[3]]] should redefine x as {1,Undefined,Undefined},
and x = Undefined should be interpreted as x =.
Could this be implemented by operator overloading or by unprotecting and
redefining Part?
I believe that this could be implemented in Mathematica without destroying
compatibility with existing code, since it would be an addedon feature.
And
my intuition (if that is of any value) tells me that such an addition would
have benefits I fail to see.
As newbie I was curious if I could do something according to the following
idea: Define a triangle by
t = triangle[{3,4,Undefined}, {Undefined, Undefined, Pi/2}]
with a list of the sides as the first argument and a list of the angles as
the second. Then I wanted to write a function, which would give the
following output when applied to t:
In[]= AngleSumTheorem[t]
Out[]= {t[[2,1]]+t[[2,2}]]+Pi/2==Pi}
Then I also should be able to write LawOfSines and LawOfCosines functions,
solve the equations and feed back the values into t. Unfortunately I cannot
do this in Mathematica in this elegant way. Is this to demand too much from
Mathematica?
In the answers I have got, there are some different workarounds suggested
to my initial problem, to correct the following code (see my first letter
below):
a = {{1, 2}, {3, 4}};
x  a /. {x > a}
The first workaround is to use
xx = Array[x, Dimensions[a]]
I know that this is a way to get around the problem in Mathematica, but it
is a clumsy way. I have to have two different entities in the air; x for
assignments of new values to the matrix, and xx as a short form for the
matrix, reading out the values. It is like My name is Bill but call me
Tom. And a clumsy way leads the thinking astray. I have to choose every
time I want to define a matrix: should I use a simple variable definition
or
a double notations as you suggest? It would be much better if the same
notation could be used for the matrix and the elements consistently,
without
having to choose from the beginning if I am going to work with the entity
or
with the elements.
The second workaround is to redefine or manipulate the operator that is
applied to the list or matrix I am working with. For matrices there is a
whole bunch of functions that has to be rewritten, and I do not find this
idea very attractive. I feel it as a roundabout way to solve the problem.
Andrzej Kozlowski, who suggests such a solution, thinks that I am looking
at
Mathematica from the wrong view point. It is my strong belief that one
should be able, especially when mathematics is involved, to observe from as
many different view points as possible. An item is not really beautiful, or
properly designed, if it is not beautiful from all view points. The same
should apply to Mathematica, and I have also understood that Mathematica
was
intentionally designed to be wellbehaved when seen from different view
points. Or?
Kristen W Carlson suggests that I should initialize the matrix to have zero
in all element. No,
a = {{1, 2}, {3, 4}};
x = {{0, 0}, {0, 0}};
x  a /. {x > a}
will clearly not work for me. But a simple way to solve my initial problem
is of course to apply the operations in the right order:
a = {{1, 2}, {3, 4}};
(x /. {x > a})  a
Ingolf Dahl
Sweden
Original Message
===
Subject: Types in Mathematica, a practical example
To MathGroup,
I am not an advocate for strong typing in Mathematica, but consider the
following simple example: I want to see if two matrices are equal. One of
them was the result from some equation, and is given inside a rule. Then I
write some code similar to this:
a = {{1, 2}, {3, 4}};
x  a /. {x > a}
I of course hope to get a matrix filled by zeroes, but if x is undefined,
the following is returned:
{{{{0, 1}, {2, 3}}, {{1, 0}, {1, 2}}}, {{{2, 1}, {0, 1}}, {{3, 2},
{1,
0}}}}
First x was assumed to be a number, and (x  a) was evaluated. Then x was
substituted by the matrix a. No bug in Mathematica, but it was not what I
wanted as user. It is easy to make such a mistake in the programming. Of
course there are many ways to get around this problem, but is there any
reasonably simple way to type x to be a list of lists without
specifying
the elements, in such a way that the above example works?
I could do
ReleaseHold[Hold[x  a] /. {x > a}]
but then we are not in the typing business any longer.
I think this question illuminates one aspect of the typing issue in
Mathematica. I remember that I as a newbie looked for ways to declare
matrices, in such a way that I later could specify matrix elements
onebyone, without initializing them first. I soon learned that there are
other ways to achieve similar results, but still I do not see any good
reason why I cannot force Mathematica to give the following response from
{{x[[1,1]]  1, x[[1,2]]  2},{x[[2,1]]  3, x[[2,2]]  4}}
I am not allowed to Unset or Clear any part of a list either. Why not?
Ingolf Dahl
Sweden
===
Subject: Fwd: Getting good results with NDSolve?
Whoops, yes...that is what I meant...actually that is what I had in
NDSolve:
dg/dt=norm(Grad g)*Div(Grad g/Norm (Grad g))...
Chris
Original Message
===
Subject: Re: Getting good results with NDSolve?
Hi Christopher,
something is fishy with your expression:
dg/dt = Norm(Grad g) * Laplacian(Grad g / Norm (Grad g))
On the left side you have a scalar.
On the right side you have Laplacian(Grad g ...) what is a vector.
Maybe you mean Div( Grad g / Norm (Grad g))?????
Daniel
> The equation i'm using is dg/dt = Norm(Grad g) * Laplacian(Grad g / Norm
(Grad g))
> Christopher Arthur
>
===
Subject: exponential diophantine equations  correction!
Correction. In the example below, I had typed +7. It should have been 7.
I'm trying to find out how to use Mathematica to find solutions to
exponential diophantine equations like the following:
(5x)^2  2^k * 3 * (5+k)^2  131 * k  7 = 0. I want to obtain
solutions for x and k. (One solution is x = 31, k = 6, but I didn't find
this using Mathematica!)
I'm not very skilled in Mathematica. I tried Solve and Reduce but I just
get either
The equations appear to involve the variables to be solved for in an
essentially nonalgebraic way.
or
This system cannot be solved with the methods available to Reduce.
I'm trying to find a way to get at least one or two solutions. Is there a
way in Mathematica to do this? I know that exponential ones are not easy...
Andrea
===
Subject: Re: Pick function
 Original Message 
===
Subject: Pick function
>> Hi All,
>> I have found a strange behavior of the Pick function.
>> Testing data:
>> 
>> In[1]:=
>> l = {1, a > b, x, c > 1, d > e + f, g + h}
Try to use the Pick function:
>> 
>> In[4]:=
>> sel1=Pick[l,l,_>_]
>> Out[4]=
>> {a>b,c>1,d>e+f,0}
designer's of Pick and whether it would not be better if Pick had an
> option specifying the level at which the attempted matching should
> take place, but in any case, it shows that you have to use it carefully.
> Andrzej Kozlowski
The explanation from Andrzej is correct, and I agree the behavior of Pick
can be somewhat confusing at times. The key to remember is that the full
nested structure of the selector (2nd) argument is used.
Having a level specification in Pick is probably not a bad idea, although
it's really intended for use with selectors that have the exact structure of
the result you want. So you could do something like
Pick[l, MatchQ[#, _ > _] & /@ l]
although that wouldn't be very efficient for this particular case.
Oyvind Tafjord
Wolfram Research
===
Subject: Re: Pick function
The problem is caused by the presence of the Plus, i.e., g+h
l = {1, a > b, x, c > 1, d > e + f, g + h};
l2=Range[Length[l]];
Cases[l,_Rule]
{a > b, c > 1, d > e + f}
Pick[l2,l,_Rule]
{2, 4, 5}
l = Most[l]
{1, a > b, x, c > 1, d > e + f}
Pick[l,l,_Rule]
{a > b, c > 1, d > e + f}
Pick[{g+h},{g+h},_Rule]
{0}
Bob Hanlon
===
> Subject: Pick function
> Hi All,
> I have found a strange behavior of the Pick function.
> Testing data:
> 
> In[1]:=
> l = {1, a > b, x, c > 1, d > e + f, g + h}
> Out[1]:=
> {1, a > b, x, c > 1, d > e + f, g + h}
> In[2]:=
> l2=Table[i,{i,Length[l]}]
> Out[2]=
> {1,2,3,4,5,6}
> Now try to select the Rules:
> 
> In[3]:=
> Cases[l,x:(_>_)]
> Out[3]=
> {a>b,c>1,d>e+f}
> OK, this is what I expected.
> but...
> Try to use the Pick function:
> 
> In[4]:=
> sel1=Pick[l,l,_>_]
> Out[4]=
> {a>b,c>1,d>e+f,0}
> In[5]:=
> sel2=Pick[l2,l,_>_]
> Out[5]=
> {2,4,5}
> As you can see, the the first command returned 4 items, but the second
> command returned only 3 items (as expected).
> I really don't understand why there is the last 0 value in sel1
list.
> I expected, that Pick[l,l,_>_] command should return:
> {a>b,c>1,d>e+f}.
> Is here somebody who can explain this strange behavior for me, please?
> Zdenek Buk
===
Subject: Re: Roman Maeder's Classes.m
Except for the Gray book, these pointers are useless in understanding
class.m, i.e., the philosophy of Maeder's OOP implementation in
Mathematica, because they either point to The Mathematica Progamming
(v1), which is out of print, or lead nowhere (there is only an
print book. While we await his response to my effrontery, we could
consider someone buying the book (3 copies are listed on Amazon) and
posting the essence; likewise doing the same from the Gray book.
Or we could ask Andrzej to explain briefly his comments: slightest liking
for
this [Maeder] approach and I prefer the Combinatorica package by far.
This implies that oop is implemented in a superior way in
Combinatorica? Never mind that Andrzej seems to have been worn down by
the Types argumentI mean discussionand switched sides, let's hear
his take on this.
& one wonders how much value a high level perfectionist like Maeder
could feel in classes.m when there is a dearth of info on it and it
hasn't been updated or made more central to the Mathematica Way. One
wonders why it is not featured more prominently in Help or The Book or
the programming courseWRI people please commentor in the many
books on Mathematica by very competent programmers.
Kris
> It is also described in Mastering Mathematica by J. W. Gray (I
> think he is the father of Theo Gray, the creator and developer of
> Mathematica's Front End). There is a chapter on OOP in Mathematica,
> Meader's package is explained and used to create a object oriented
> approach to GraphTheory. I have never had the slightest liking for
> this approach and I prefer the Combinatorica package by far, but the
> book is very good. There have been at least two editions but I have
> no idea if it is out of print or not.
> Andrzej Kozlowski
===
Subject: Re: PackagesJLink graphic string width and height in pixels
Not exactly sure what you're wanting to do, but if you want to frame a box
of
text with a precise width in mathematica graphics, it isn't too difficult
to do in mathematica. Consider this example:
myWidth=200
p=1.00
myMessage=A moment of planetary concordance occurs when the Kepler
harmonies
fit closely into a known musical scale. Here, the scale used is the equal
tempered chromatic, typical of Western music.
desc=Graphics[Text[DisplayForm[FrameBox[Cell[myMessage,Text,PageWidth=my
Width*p,TextJustification=1,FontFamily>Times]]],Scaled[{0.5,0.5}],{0,0}]
];
myDisplay[x_]:=Display[$Display,x,ImageSize=myWidth{1,1}];
Show[desc,DisplayFunction=myDisplay,Frame=True,FrameTicks=None]
where myWidth*p sets the width of the myMessage and the width of the
overall
image. Smaller widths don't result in smaller text, but at least the text
will wordwrap within the box. By adjusting the the Scaled[] coordinates
and
the p=percent of image width you can format fairly neatly.
Chris
Original Message
===
Subject: PackagesJLink graphic string width and height in pixels
has anyone used JLink to calculate the width and height (in pixels) of a
string
to be used in a mathematica 2D graphics?
Luc
Link to the forum page for this post:
http://www.mathematicausers.org/webMathematica/wiki/wiki.jsp?pageName=Speci
al:Forum_ViewTopic&pid=6748#p6748
===
Subject: Re: Types in Mathematica
> I hope it's OK that I put this back into mathgroup. It doesn't
> seem to
> contain anything of a personal nature, nor anything else
> inappropriate for
> the list.
At some point it looks like the list got dropped from recipients. I
wonder how many stalwarts are still along on this journey anyway.
> [...]
> Looks as if we've both lost the original point we were debating.
True
> I will take that as in indication that you do not have a lot of C++
> experience.
I have not done any major programming in C++, but I did do some C++
coding predating the STL. Incidentally Mathematica is not my primary
programming environment; which is much closer to C++ than Mathematica
in spirit.
> As far as understanding the STL, I see no way to gain more than
> a vague notion of how it works without understanding the runtime
> structure of
> the realized collections.
But of what use is that knowledge when compared to similar facilities
in other languages (Java Collections, Ada Generics (or rather Ada
libraries using Ada Generics), etc)? In my opinion it's better to
understand the model than the implementation. And yes, I'm aware
that Java Collections and Ada Generics do not map directly to the
STL, but the STL is a particular implementation of a more general
idea of which collections and generics are also a part.
> But a Complex will always have a real and an imaginary component.
> A Rational
> will always have a numerator and a denominator.
And a List always contains zero or more expressions.
> The point is that knowing that an atom has head Complex tells me what
> kind of thing it is at the user level.
I guess I don't understand why this is any different from things with
head List.
> I'm not sure it's meaningful/useful to assign a type to an atom
> beyond what is
> already implied.
I meant that I can assign a type to things that aren't atoms like
Integer[1] or {1,2,3}.
> Certainly a valid observation worth considering when using Complex
> numbers.
> Even more surprizing to the uninitiated might be Head[Arg[1+I]].
I still consider cases like this to be artifacts of the evaluator.
its head surprising.
> I am coming to realize there is another dimension worth considering
> when
> trying to identify the essential abstract nature of Mathematica.
> We have
> expressions which have a head and zero or more arguments, and we
> have
> symbols capable of holding transformation rules applicable to the
> symbol.
I prefer to think of the rewrite rules as just being given in the
same way as axioms are just given, symbols aren't necessary.
Similarly creating new rules can be thought of as stating theorems
(but significantly not proving them) and they just get added to the
preexisting axioms. This analogy is unintentionally wandering a
little to close to some of the New Kind of Science ideas but it was
the first that came to mind.
> The four types of values that I know of which can be associated
> with a symbol
> are UpValues, OwnValues, DownValues, and SubValues, all of which are
> expressions of one form or another. The behavior of Mathematica
> seems to be
> the Cartesian product of the value dimension, if you will, and the
> expression
> dimension.
Or perhaps a breadth first search along a kind of tree structure (or
perhaps it's more properly a directed graph) formed by this product.
Ssezi
===
Subject: Re: Types in Mathematica
I hope it's OK that I put this back into mathgroup. It doesn't seem to
contain anything of a personal nature, nor anything else inappropriate for
the list.
[...]
Looks as if we've both lost the original point we were debating.
> I'm not really concerned with what the machine representation of
> Mathematica's structures are internally, I'm interested in a
> representation that allows me to reason about programs correctly.
I find it to often be the case that an understanding of internal
representation is helpful in reasoning about how to use the language. It
certainly helps me contemplate expressions in Mathematica to understand them
as trees of pointers whose leaves are atoms.
> Similarly were I using a LISP machine as my processor but writing
> programs in C that are passed through a compiler written in LISP I
> would be similarly uninterested in how the compiler represented C
> structures, or what the machine native structures of the compiler
> program looked like, as long as it behaved in a manner conforming to
> the C specification.
I will take that as in indication that you do not have a lot of C++
experience. Before I really focused on C++ I would have said the same
thing.
Now I realize that C++ requires a certain amount of understanding at the
machine level.
> One might even draw a parallel to C++ and assembler
> where the generalized input form of Mathematica corresponds to C++
> source
> code, and internal form corresponds to assembler instructions.
> Agreed, I think where we'd disagree is in the importance of the
> mapping of C++ source code to assembly.
I've never spent much time looking at the assembly code produced by
compiling
C++, but there are certainly times when understanding how the sourcecode is
represented in the compiled result helps to solve problems and/or increase
efficiency. As far as understanding the STL, I see no way to gain more than
a vague notion of how it works without understanding the runtime structure
of
the realized collections.
> The point was that Atoms in C++ represent the fundamental units of
> data
> storage.
> C++ has atoms? This is a genuine question prompted by laziness in
> not wanting to read through a specification document to find out.
Sorry, that was my mistake. I meant to say Mathematica Atoms.
> The head of an atom is a means of identifying its type, but the
> type really has to do what what's in it.
> Doesn't what's in it have to do with the physical machine, I believe
> that Intel CPUs internally use some form of 80 bit floating point
> format which is converted back and forth to 64 bit constructs when
> doing double precision calculations. When you execute a program on
> an actual machine then what's in it is really an 80 bit value,
> regardless of what the head says.
But a Complex will always have a real and an imaginary component. A
Rational
will always have a numerator and a denominator. I didn't intend the actual
physical representation of the atom in memory. It really doesn't matter if,
say, complex were stored as an angle and a magnitude, or or as a real part
and an imaginary part, so long as I could recover the real and imaginary
parts. The point is that knowing that an atom has head Complex tells me
what
kind of thing it is at the user level.
> That is to say, knowing that an expression has the
> head List does not tell us the nature of what is in the list.
> I know what's in a list, zero or more expressions. I can ask if the
> expressions are atomic and if it is important I can assign types to
> the atoms by their heads. In fact it's not even necessary that they
> be atoms because I can still unambiguously assign a type.
I'm not sure it's meaningful/useful to assign a type to an atom beyond what
is
already implied.
> Knowing that
> an expression has the head Complex, for example, tells us that we can
> extract exactly two meaningful values from it, and how to extract
> these
> values (assuming we know the Mathematica rules for Complex).
> Actually you don't know the types of the values from the head Complex
> beyond that they belong to the Numeric class anymore than you know
> the types of the elements of a List, if there are any, beyond that
> they are of the class expression.
> In[117]:=
> Head[5+6. I]
> Head[Re[5+6. I]]
> Head[Im[5+6. I]]
> Out[117]=
> Complex
> Out[118]=
> Integer
> Out[119]=
> Real
Certainly a valid observation worth considering when using Complex numbers.
Even more surprizing to the uninitiated might be Head[Arg[1+I]].
>> So what's the difficulty?
> affirm my
> original position that Mathematica does have a rudementry type system.
> I still fail to see the problem Integer[1] is of the form Integer
> [Integer[(something that's not very important)]] and 1 is of the form
> Integer[(something that's not very important except that it behaves
> as 1, whatever that is)].
But that is something learned from experience, not from reading A.9.2
> My larger point, which is yet another diversion from the point of the
> thread was that because there is only one type of thing in
> Mathematica and it is the same thing that the evaluator uses as what
> the user reasons about then the ability to write self modifying code
> in Mathematica itself is a necessary consequence. I didn't suggest
> this was a good idea, merely that it was a hint as to the nature of
> type in Mathematica.
There are cases when one benefits by adding downvalues to a symbol during
evaluation. The canonical example is functions that remember values in
recursive algorithms.
> I do not agree with the assertion that there is only one type of
> thing in
> Mathematica. To say everything is an expression fails to address the
> distinct nature of atomic objects with distinct heads. It is
> meaningful
> and clear to consider atomic objects to have distinct types.
> To me it depends on your point of view. Viewed as system of rewrite
> rules, there are only two things which compose Mathematica:
> expressions of form Head[Argument....] and transformation rules which
> map one value of Head[Argument...] onto another.
I am coming to realize there is another dimension worth considering when
trying to identify the essential abstract nature of Mathematica. We have
expressions which have a head and zero or more arguments, and we have
symbols capable of holding transformation rules applicable to the symbol.
The four types of values that I know of which can be associated with a
symbol
are UpValues, OwnValues, DownValues, and SubValues, all of which are
expressions of one form or another. The behavior of Mathematica seems to be
the Cartesian product of the value dimension, if you will, and the
expression
dimension.
Steven
===
Subject: Re: Re: Re: Types in Mathematica
> I meant the value of evaluating the expression.
>> In[1]:= Head[Head[{1,2,3}]]
>> Out[1]= Symbol
> I'm not sure what that's supposed to prove we know that of Head
> [{1,2,3}][[0]] is Symbol but Symbol[List] is not a list.
Well, that makes two of us. I don't really understand what your example
was
intended to demonstrate. Perhaps you were trying to show that Mathematica
does not behave according to naive expectations in some (many) cases.
Though I accept the proposition as a forgone conclusion, your example did
not work for me because the result conformed to my expectation.
>> Hmmm.... That's a very interesting statement. In reality, at that
>> level of
>> detail the description of a Mathematica expression is distinct from
>> the Lisp
>> model. Mathematica expressions are described as being arrays of
>> pointers to
>> other Expressions.
> I believe the point about being arrays of pointers is related to
> implementation efficiency concerns, such as being able to take parts
> of lists in linear time eg:
Indeed. This is exactly why iteration is typically faster in C and C++
than
is recursion. More to the point, it is faster to iterate a pointer value
than it is to dereference a pointer when traversing a linked list. Fact of
the matter is, when Lisp was originally conceived, such considerations were
still years away from being relevant. This serves to highlight the dangers
of naively transferring best practices from languages such as C++ to
Mathematica.
An aside on Lisp. I believe that Mathematica expressions are most similar
to Lisp alists in terms of how Mathematica compares to Lisp.
> The fact that we display
> and write 1 instead of Integer[1] is syntactic sugar as far as I'm
> concerned because at that point we are typically more interested in
> the interpreting Integer[1] as a value which is the result of some
> computation which is really what one is interested in.
>> Out[2]= False
> OK calling it syntactic sugar is a bit extreme, it doesn't change the
> validity of the statement. You cannot create the argument that
> Integer[_] uses to represent an integer, but we know that Integer[_]
> represents an atomic expression so there's no point in wondering
> about what _ is without a head because we cannot create it. Integer
> [1] is evaluated as Integer[Integer[(something)]] so of course Integer
> [1]/=1.
I suspect what we have here is an illdefined rough edge of
Mathematica's
language specification. After having spent some time discussing issues
is to specify the details of a programming language, even when the language
was formally specified at every step of its evolution. It may be virtually
impossible to give an expost facto specification for the Mathematica
programming language.
I believe your intent it to show that all statements in Mathematica are
internally represented in a nested tree structure containing nothing but
arrays of pointers with the first pointer pointing to the head of an
expression and zero or more pointers pointing to the arguments, which are
themselves similarly constructed. I.e., Mathematica is one big glorified
Lukasiewicz (Polish) symbolic calculator.
I agree. Before I read revelant portions of The Mathematica Book
carefully,
I was inclined to call that internal representation the Mathematica
programming language. It appears that such a limited view is not the
intent of Dr. Wolfram. One might even draw a parallel to C++ and assembler
where the generalized input form of Mathematica corresponds to C++ source
code, and internal form corresponds to assembler instructions.
> Especially if you consider the heads of atoms as defining their type,
> which is why I think that is a useful paradigm for reasoning about
> types in Mathematica.
>> I would say that the distinction has more to do with their fundamental
>> characteristics than with the name or symbol attached to them. In
>> particular, the kinds of data they store.
>> Head[Symbol]
>> SymbolName[Symbol]
>> Head[string]
>> Characters[string]
>> Head[12345]
>> IntegerDigits[12345]
>> Head[10/3//N]
>> RealDigits[10/3//N]
>> Head[25/17]
>> Numerator[25/17]
>> Denominator[25/17]
>> Head[E^I GoldenRatio//N]
>> Re[E^I GoldenRatio//N]
>> Im[E^I GoldenRatio//N]
> I'm not sure what you are expecting in these cases so I'm not really
> sure what the point of this exercise is, at any rate
The point was that Atoms in C++ represent the fundamental units of data
storage. Each atom is a 'quantum' of data, to use the German manner of
speaking. The head of an atom is a means of identifying its type, but the
type really has to do what what's in it. In general, the use of
Head
to determin the type of an expression will not provide us this kind of
exact correspondence. That is to say, knowing that an expression has the
head List does not tell us the nature of what is in the list. Knowing that
an expression has the head Complex, for example, tells us that we can
extract exactly two meaningful values from it, and how to extract these
values (assuming we know the Mathematica rules for Complex).
> In[48]:=
> Head[1]
> 1[[0]]
> 1[[1]]
> Out[48]=
> Integer
> Out[49]=
> Integer
> Part specification 1[[ 1 ]] is longer than depth of object.
> Out[50]=
> 1[[1]]
> we begin to understand what makes an expression atomic, it is an
> object of Depth 0. But objects of Depth 0 still have a head, even
> though the arguments are inaccessible.
>> I don't believe I suggested that A.9.2 documents exactly what
>> everything is.
>> I've been rather clear that I do not find the documentation complete.
> You have, but I haven't seen an example of behavior that cannot be
> explained by A.9.2. I will admit that the time complexity of
> algorithms is not what you'd expect from A.9.2 but the behavior with
> respect to types is.
There are many features which are not well communicated in The Mathematica
Book. Some of this is probably due to the closed nature of the product,
and some is due to the difficulty in explaining so many subtle interacting
features, and their consequences.
> Some
> expressions are atomic, and if you want to assign a type to the
> atoms other than expression the best candidate I can see is the head.
>> That's what Wolfram says in the appendix. These [atomic] objects
>> have heads
>> which are symbols that can be thought of as 'tagging' their types. The
>> objects contain 'raw data', which can usually be accessed only by
>> functions
>> specific to the particular type of object. You can extract the head
>> of the
>> object using Head, but you cannot directly extract any of its other
>> parts.
> So what's the difficulty?
original position that Mathematica does have a rudementry type system.
>> C++, however does not have
>> a statement type. It has statements, but statement is not a type.
> I suppose it depends on your perspective, in order to compile or
> execute C++ code one has to be able to reason about the code and in
> order to reason about the code structures like for(;;){...} and void
> op() have to be represented by something and I'd call that something
> which represents them their type.
Perhaps that is valid in a metalinguistic realm, but with C++ there is a
well defined meaning for the term type when applied to constructs of
the
language. The distinction between what is meant by statement and
akin to the distinction between what is meant by sentence and
imperative
sentence.
> Except for the compiler/
> interpreter though there is nothing within C++ which deals with such
> structures directly, but C++ also has typedef _ structures (and int,
> float, etc.) which can be used for explicit manipulation of types of
> objects during execution (or evaluation) of a program.
Not really. These only come into play at compile time. The only runtime
typerelated mechanisms in C++ are virtual functions and RTTI, and these
only apply to a subset of user defined types.
> The
> difference between C++, Java etc. and Mathematica (and to a certain
> extent ML, Haskell etc.) is that at evaluation type the structures
> that correspond to for(;;){...}, void op() etc. can be manipulated by
> the program itself.
Can I actually modify an expression as it is evaluated? Let's consider a
For[] expression. Can you give an example of modifying a For[] expression
as it it evaluated?
> I'm aware that clever hackers can write self modifying code in C++
> with injudicious use of pointers, but those programs typically rely
> on a well defined external environment of linkers, machine
> architecture etc. to work.
I do not consider that to be selfmodifying code. The runtime image
may
be selfmodifying, but that is not the same as saying the source code is
modified as the program executes. To do what Mathematica does in C++ we
would need to create a program that could read its own source code,
manipulate it, invoke a compiler to compile the result, and load the
resulting object code as part of the current execution image. It is
certainly conceivable, and to some extent it is done with Java today.
>> You can't inspect the structure of the function in C++ because it's a
>> function definition and there is no facility for programmatically
>> inspecting the contents of a definition in C++. In Mathematica the
>> contents are stored as an expression in the DownValues which can be
>> modified as any other expression in Mathematica sans restrictions.
>> How does that compare to rtti or having a virtual function table
>> and using
>> virtual funcitons to implement polymorphism?
> There is no need for rtti in Mathematica, again because the type of
> everything is known because there is only one type of thing in
> Mathematica.
I do not agree with the assertion that there is only one type of thing in
Mathematica. To say everything is an expression fails to address the
distinct nature of atomic objects with distinct heads. It is meaningful
and clear to consider atomic objects to have distinct types.
In C++ I can do just about anything I want with RTTI. The mechanism was
intentionally left openended. But let's look at a more compelling analog.
What about Java's facility for introspection? I Java I can access
extensive details about the structure of an object at runtime. I will
grant that I cannot (easily) modify the definition of an existing class in
Java. But I have to ask, how often do we actually modify the original
expression in Mathematica? Is it not far more common to produce a modified
copy of the original expression?
> A C++ program typically (if we're going to be pedantic
> I'll allow for clever hacks) cannot rewrite its virtual function
> table at run time, during Mathematica evaluation I can rewrite the
> body of a function though.
Can you provide an example?
>> You most certainly can get some
>> internal information from an object that way.
> I didn't say you couldn't get any information, I said you can't get
> at the implementation.
It would be far more accurate to say you cannot get at the original
definition. That is quite true, be cause the definition is part of the
sourcecode, and does not exist in the runtime image. But that brings us
back to the fact that C++ is compiled and thus the sourcecode is not, in
general, available to the execution image at runtime.
> (actually is that a requirement? http://root.cern.ch/root/
> Cint.html)
>> That would not pass muster among 99% of C++ programmers.
> I actually posed that question to myself as I was writing then found
> Cint through Google. I didn't even bother to evaluate it, I was just
> interested in the question of whether being compiled was a necessary
> part of the C or C++ specification.
All that is required is that the program behave as if it were run on
the
> there are no facilities for
> programmatically altering statements.
>> There certainly are at compiletime. As a matter of fact that is
>> the entire
>> purpose and function of templates. The are meaningless unless they
>> are
>> transformed into compilable specializations.
> C++ templates don't modify statements, they are used to generate new
> statements at compile time.
C++ templates are used to produce specialization which are modifications of
the original template. The exact form of these specializations can be
computed at compile time. This is called template metaprogramming.
> I cannot take a pointer to an if{a}else
> {b} block and change the value of b.
Allowing for the incorrectness of the notion of taking a pointer to an if
statement, you most *certainly* *can* change the value of b at compile time
in your example. Template metaprogramming is fairly similar to Mathematica
programming.
> I'm not arguing that is a good idea in general, merely that it isn't
> possible.
But it *is* possible. It is the whole essence of generic programming.
> On the other hand, I've noticed a trend in OO graphics programs for
> defining 3 and 4D vectors and matrices as classes and then
> overloading +,,* etc. which leads to inefficient code like
> t=a*b;
> d=c*t
> instead of
> d=a*b*c
>> There is no reason you cannot use the latter expression if you have
>> overloaded
>> * with something reasonable.
> And what is something reasonable? The naive vector3D operator*(a
> vector3D, b vecto3D) {return Vector3D(a.x*b.x,a.y*b.y,a.z*v2.z)}
> requires the creation of an intermediate object in compiling a*b*c to
> hold the result of either a*b or b*c. Mathematica gets around the
> problem using the Listable attribute, C++ gets around it with
> template metaprogramming
Or compiler optimizations, or composite function objects, valarrays, etc.
I
will grant that I like the way Mathematica handles such situations, and
have as an objective finding ways to formalize such techniques in C++.
> (and given your interest in ML perhaps you'd
> appreciate this http://people.cs.uchicago.edu/~jacobm/pubs/
> templates.html) but as far as I'm aware Java can do neither and ends
> up being inefficient.
I'd better stick with Mathematica for now. I took a very sharp turn by
dropping C++ after 18 months of careful study and returning to Mathematica.
I obviously am interested in how programming languages work, and how
Mathematica works as a programming language in the purely academic sense.
But, believe it or not, my primary motivation for spending so much time and
effort on this topic is because I was tired of trying to use Mathematica,
and not getting the results I expected.
This discussion has forced me to examine how I perceive Mathematica, and
how
accurate those perceptions are.

The Mathematica Wiki: http://www.mathematicausers.org/
Math for Comp Sci http://www.ifi.unizh.ch/math/bmwcs/master.html
Math for the WWW: http://www.w3.org/Math/
===
Subject: Re: general nth term of series
SeriesTerm function from the RSolve package.
However, my input got screwed up in copy paste. The
function that I had intended was the generating
function for Legendre polynomials.
G[u_,x_]=(1  2*x*u + u^2)^(1/2)
And the nth term of which, indeed gives me the
Legendre Polynomials in terms of Gamma function. I am
impressed.
How can I decompose this result into two seperate ones
for even and odd values of n. So as to see the things
in a more familiar form using factorials.
Ash
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
===
Subject: Using The Random Function to predict Things
Hi there friends...
I used this line of code typicalList = Table[Random[Integer], {50}] and
got this result...
{1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1}
By generating a few more of these random lists, I'm to predict a similiar
situation: such as how long i would expect to wait for 3 heads in a coin
tossing competition...
any suggestion or help as to what code i could use to do this?
===
Subject: Re: Using The Random Function to predict Things
lst = Table[Random[Integer], {5000000}];
threes = Count[ll = Apply[Plus, Partition[lst, 3,
1], {1}], 3];
and
N[threes/Length[ll]]
gives you the probability for three 1 in turn.
Jens
mathuser schrieb im
 Hi there friends...
 I used this line of code typicalList =
Table[Random[Integer], {50}] and got this
result...

 {1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1,
1, 1, 1, 0, 1, 0, 0, 0, 0,
 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 0, 0, 1, 1, 0, 1}

 By generating a few more of these random lists,
I'm to predict a similiar situation: such as how
long i would expect to wait for 3 heads in a coin
tossing competition...

 any suggestion or help as to what code i could
use to do this?


===
Subject: UMLlike diagrams for Mathematica
I am not a passionate fan of UML. I often find UML to obfuscate rather
than
illuminate. Nonetheless, the basic idea of using graphical representations
to help communicate ideas about programming constructs is a valuable tool.
I once had a professor tell me When you want to understand a problem,
draw
a picture. I believe there is a great deal of value in that advice which
Dr. John A. Wheeler gave me. I find it very surprising that books about
Mathematica often use graphics to provide insight into mathematical
problems, but rarely use diagrams to represent the structure of objects in
Mathematica.
The particular subject I am thinking about is the structure of a Symbol. I
really don't know what the internal structure is. All I know is there is
some kind of hash table holding symbols and their associated values. My
current understanding of symbols in Mathematica is that they consist of (or
are associated with) at least some of the following:
UpValues
DownValues
OwnValues[*]
SubValues
Options
Attributes
internal data
I have been using Mathematica occasionally for over a decade, and am just
now coming to understand the basic ideas of how data and expressions are
represented. I have several books on how to use Mathematica, and I do not
believe any of them provide a reasonably coherent and comprehensive
explanation of what a symbol is, and what can be associated with it. I
cannot think of a single illustration representing a Mathematica symbol in
the way a UML class diagram is used to illustrate the components of a class
or data structure.
Are there any books that provide such a treatment?
[*]Ironically, neither OwnValues nor SubValues appear in the Help Browser
index.

The Mathematica Wiki: http://www.mathematicausers.org/
Math for Comp Sci http://www.ifi.unizh.ch/math/bmwcs/master.html
Math for the WWW: http://www.w3.org/Math/
===
Subject: Re: FixedPoint stops when elements no longer change?
>>In[16]:= l = FixedPointList[Cos, 1.];
>>In[17]:= NumberForm[l, Floor[$MachinePrecision] + 1]
>This is from the commandline UI:
>In[1]:= Information[$MachinePrecision] $MachinePrecision gives the
>number of decimal digits of precision used for
>machineprecision numbers.
>Attributes[$MachinePrecision] = {Protected}
>$MachinePrecision = 15.954589770191003
>Interestingly, I get a different result in the FrontEnd:
>$MachinePrecision=15.9546
This is not a different result. It is the same result displayed differently,
i.e.,
In[37]:=FullForm[$MachinePrecision]
Out[37]:=15.954589770191003`
By default, Mathematica displays only the first 6 digits of machine
precision numbers.

To reply via email subtract one hundred and four
===
Subject: Solve Limitations
Let's suppose that we are interested in the roots analytic expression of
the following function:
In[1] := f = a x + b x^(3/2) + c;
The function Solve could be used:
In[2] := sol = Solve[f==0, x];
Defining the values of the constants a, b, c would return the following
numeric values:
In[3] := froots = Solve[f==0, x]/. {a>1, b>1, c>1} //N
Out[3] = {{x> 2.1479}, {x> 0.57395 + 0.368989 I}, {x> 0.57395 
0.368989 I}}
However, f is not null for those values and therefore, these are not the
roots of f:
In[4] := f/. froots/. {a> 1, b> 1, c> 1} //Chop
Out[4] = {6.2958, 0, 0}
At first, it seems that the function Solve doesn't take appropriately in
consideration the term in square root.
Some idea to obtain the correct analytic solution of f ??? Or, in fact, this
a limitation of the function Solve???
Marcelo Mayall
===
Subject: Re: exponential diophantine equations
Here is one approach. We will need the package:
<< NumberTheory`NumberTheoryFunctions`
Let's start with a primitive approach and then improve it to run much
faster. The primitive approach would be like this. First we write
your equation as
2^k*3*(k + 5)^2 + 131*k + 7 == (5*x)^2
Let us define a function f[k] as follows:
f[k_Integer] := 2^k*3*(k + 5)^2 + 131*k + 7
What we are looking for is values of k for which the the following
are true:
1. f[k] is 0 mod 25.
2. f[k] is a perfect square.
It is easy to write a slow function that looks for such k. First of
all, we need a function f[k_,n_] which efficiently computes Mod[f
[k],n]. Here is this function:
f[k_Integer, p_Integer] :=
Mod[PowerMod[2, k, p]*Mod[3, p]*PowerMod[k + 5, 2, p] + Mod
[131*k + 7,
p], p]
The test for divisibility of f[k] by 25 takes the form
test25[k_Integer] := f[k, 25] == 0
We also need a test to check if a number is a perfect square. Here is
the obvious one:
test1[x_Integer] := IntegerQ[Sqrt[f[x]]]
Now let's define a function that combines both tests:
h = Function[x, Evaluate[And @@ Prepend[{test1[x]}, test25[x]]]];
Let's check that this will work well on the one solution we know:
h[6]
True
On the other hand:
h[7]
False
OK, using this function we can now try to find any solutions for k
between 1 and 10000:
Select[Range[10000],h]//Timing
{36.1681 Second,{6}}
This is rather slow so we try something more sophisticated. Instead
of checking is f[k] is a square root we will check if it is a square
root modulo a prime p. We will use a large number of primes and this
will still be faster than doing an integer check. Here is the test
function:
test[k_Integer, p_Integer] := ReleaseHold[Block[ {$Messages = {}},
Check[SqrtMod[f[k, p], p]; True, False]
]]
I do not have the time at this moment to explain exactly what this
does. The key function is SqrtMod from the NumberTheoryFunctions
package. it computes square roots modulo a prime. Here is now a
function that will check if f[k] of a number is a square module the
first n primes (it also checks if f[k] is divisible by 25)
g[k_] := Function[
x, Evaluate[And @@ Prepend[Table[test[x, Prime[i]], {i, 1, k}],
test25[x]]]]
I am going to use g[200] which checks the first 200 primes.
let7s try the above computation with g[200]:
Select[Range[10000],g[200]]//Timing
{3.41956 Second,{6}}
Note that we still correctly identified the solution 6, but we got it
a lot faster. So we can try looking at larger ranges. If we find a
some possible solutions we still have to run the primitive test on
them to check if they are real solutions and not just solutions
modulo the first 200 primes.
In[21]:=
Select[Range[20000],g[200]]//Timing
Out[21]=
{6.82253 Second,{6}}
Still no luck, but performance seems to scale quite well. I have no
time now to try looking for more solutions (as my lecture will begin
in half an hour) but we know that for k between 1 and 20000 there is
only one solution, which is the one you already knew.
Andrzej Kozlowski
> Oh those signs! I typed +7. Mistake. It should be 7.
> Andrea
> I'm trying to find out how to use Mathematica to find solutions to
> exponential diophantine equations like the following:
> (5x)^2  2^k * 3 * (5+k)^2  131 * k + 7 = 0. I want to
> obtain
> solutions for x and k. (One solution is x = 31, k = 6, but I didn't
> find
> this using Mathematica!)
>> Are you sure you have found a solution? I get:
>> In[30]:=
>> (5x)^2  2^k * 3 * (5+k)^2  131 * k + 7 /.{x>31,k>6}
>> Out[30]=
>> 14
>> One can certianly try some educated searches but before starting it
>> woudl be better to be sure that this is really the equation you want
>> to solve!
>> Andrzej Kozlowski
===
Subject: Re: exponential diophantine equations
The ReleaseHold in the definition of test[k,p] is not needed (it was
needed in my earlier attempt to define this function and I forgot to
remove it) so it should now be:
test[k_Integer, p_Integer] := Block[ {$Messages = {}},
Check[SqrtMod[f[k, p], p]; True, False]
]
Andrzej
> Here is one approach. We will need the package:
> << NumberTheory`NumberTheoryFunctions`
> Let's start with a primitive approach and then improve it to run
> much faster. The primitive approach would be like this. First we
> write your equation as
> 2^k*3*(k + 5)^2 + 131*k + 7 == (5*x)^2
> Let us define a function f[k] as follows:
> f[k_Integer] := 2^k*3*(k + 5)^2 + 131*k + 7
> What we are looking for is values of k for which the the following
> are true:
> 1. f[k] is 0 mod 25.
> 2. f[k] is a perfect square.
> It is easy to write a slow function that looks for such k. First of
> all, we need a function f[k_,n_] which efficiently computes Mod[f
> [k],n]. Here is this function:
> f[k_Integer, p_Integer] :=
> Mod[PowerMod[2, k, p]*Mod[3, p]*PowerMod[k + 5, 2, p] + Mod
> [131*k + 7,
> p], p]
> The test for divisibility of f[k] by 25 takes the form
> test25[k_Integer] := f[k, 25] == 0
> We also need a test to check if a number is a perfect square. Here
> is the obvious one:
> test1[x_Integer] := IntegerQ[Sqrt[f[x]]]
> Now let's define a function that combines both tests:
> h = Function[x, Evaluate[And @@ Prepend[{test1[x]}, test25[x]]]];
> Let's check that this will work well on the one solution we know:
> h[6]
> True
> On the other hand:
> h[7]
> False
> OK, using this function we can now try to find any solutions for k
> between 1 and 10000:
> Select[Range[10000],h]//Timing
> {36.1681 Second,{6}}
> This is rather slow so we try something more sophisticated. Instead
> of checking is f[k] is a square root we will check if it is a
> square root modulo a prime p. We will use a large number of primes
> and this will still be faster than doing an integer check. Here is
> the test function:
> test[k_Integer, p_Integer] := ReleaseHold[Block[ {$Messages = {}},
> Check[SqrtMod[f[k, p], p]; True, False]
> ]]
> I do not have the time at this moment to explain exactly what this
> does. The key function is SqrtMod from the NumberTheoryFunctions
> package. it computes square roots modulo a prime. Here is now a
> function that will check if f[k] of a number is a square module the
> first n primes (it also checks if f[k] is divisible by 25)
> g[k_] := Function[
> x, Evaluate[And @@ Prepend[Table[test[x, Prime[i]], {i, 1, k}],
> test25[x]]]]
> I am going to use g[200] which checks the first 200 primes.
> let7s try the above computation with g[200]:
> Select[Range[10000],g[200]]//Timing
> {3.41956 Second,{6}}
> Note that we still correctly identified the solution 6, but we got
> it a lot faster. So we can try looking at larger ranges. If we find
> a some possible solutions we still have to run the primitive test
> on them to check if they are real solutions and not just solutions
> modulo the first 200 primes.
> In[21]:=
> Select[Range[20000],g[200]]//Timing
> Out[21]=
> {6.82253 Second,{6}}
> Still no luck, but performance seems to scale quite well. I have no
> time now to try looking for more solutions (as my lecture will
> begin in half an hour) but we know that for k between 1 and 20000
> there is only one solution, which is the one you already knew.
> Andrzej Kozlowski
>> Oh those signs! I typed +7. Mistake. It should be 7.
>> Andrea
>> I'm trying to find out how to use Mathematica to find solutions to
>> exponential diophantine equations like the following:
>> (5x)^2  2^k * 3 * (5+k)^2  131 * k + 7 = 0. I want to
>> obtain
>> solutions for x and k. (One solution is x = 31, k = 6, but I didn't
>> find
>> this using Mathematica!)
> Are you sure you have found a solution? I get:
> In[30]:=
> (5x)^2  2^k * 3 * (5+k)^2  131 * k + 7 /.{x>31,k>6}
> Out[30]=
> 14
> One can certianly try some educated searches but before
> starting it
> woudl be better to be sure that this is really the equation you want
> to solve!
> Andrzej Kozlowski
===
Subject: Evaluate[] not needed in With[]
I started looking at Dr. Maeder's _Programming in Mathematica_, and was
doing quite well understanding everything until I got to the first example
in the first section of the first chapter. He gives an example of using
ParametricPlot and tells us Because ParametricPlot evaluates its
arguments
in a nonstandard way, we need to force evaluation of the variable hline by
wrapping in into Evaluate[]. He later tells me I don't need to do that
for a constant in a With[] expression. The following is a cobbled
together example showing both forms:
Clear[z, x, y, cz, hlines, vlines];
z = x + y I;
cz = {Re[z], Im[z]};
hg = With[{hlines = Table[N[cz], {y, 1, 1, 2/8}]},
ParametricPlot[hlines, {x, Pi/2, Pi/2},
DisplayFunction > Identity][[1]]
];
vlines = Table[N[cz], {x, Pi/2, Pi/2, Pi/12}];
vg = ParametricPlot[Evaluate[vlines], {y, 1, 1},
DisplayFunction > Identity][[1]];
Show[Graphics[Join[hg, vg], AspectRatio > Automatic, Axes > True]]
I can read the words, and follow the instructions, but I still don't
understand _why_ the version in the With[] expression doesn't need the
Evaluate[]. Is there a way to _explain_ this behavior, or do I simply need
to memorize the rule by rote?

The Mathematica Wiki: http://www.mathematicausers.org/
Math for Comp Sci http://www.ifi.unizh.ch/math/bmwcs/master.html
Math for the WWW: http://www.w3.org/Math/
===
Subject: Re: Evaluate[] not needed in With[]
With[] does a (clever) ReplaceAll[] of the constants
you give, in its body before the body is evaluated.
This means that the argument of ParametricPlot[] in your
example is replaced by the value of hlines ..
and so you don't need a Evaluate[].
Jens
Steven T. Hatton
schrieb im Newsbeitrag
I started looking at Dr. Maeder's _Programming in
Mathematica_, and was
 doing quite well understanding everything until
I got to the first example
 in the first section of the first chapter. He
gives an example of using
 ParametricPlot and tells us Because
ParametricPlot evaluates its arguments
 in a nonstandard way, we need to force
evaluation of the variable hline by
 wrapping in into Evaluate[]. He later tells me
I don't need to do that
 for a constant in a With[] expression. The
following is a cobbled
 together example showing both forms:

 Clear[z, x, y, cz, hlines, vlines];
 z = x + y I;
 cz = {Re[z], Im[z]};
 hg = With[{hlines = Table[N[cz], {y, 1, 1,
2/8}]},
 ParametricPlot[hlines, {x, Pi/2, Pi/2},
 DisplayFunction > Identity][[1]]
 ];
 vlines = Table[N[cz], {x, Pi/2, Pi/2, Pi/12}];
 vg = ParametricPlot[Evaluate[vlines], {y, 1,
1},
 DisplayFunction > Identity][[1]];
 Show[Graphics[Join[hg, vg], AspectRatio >
Automatic, Axes > True]]

 I can read the words, and follow the
instructions, but I still don't
 understand _why_ the version in the With[]
expression doesn't need the
 Evaluate[]. Is there a way to _explain_ this
behavior, or do I simply need
 to memorize the rule by rote?
 
 The Mathematica Wiki:
http://www.mathematicausers.org/
 Math for Comp Sci
http://www.ifi.unizh.ch/math/bmwcs/master.html
 Math for the WWW: http://www.w3.org/Math/

===
Subject: Re: exponential diophantine equations
Hi Andrea
No problem  mistakes happen. Now I don't know much about diophantine
equations (but would like to know more) so I had a look at your
problem.
The main thing that I know about them is that they are very hard to
solve and that there is no algorithm that can solve general
diophantine equations. With this in mind it is not suprising that
Mathematicas standard commands cannot find a solution.
The approach I took is one of brute force and ignorance . I define a
function  dioph[x,k] that corresponds to your expression. I then loop
over a large number of values for x and k and test the result. Every
pair of x,k values that satisfies your equation gets added to the list:
dioph[x_, k_] := (5 x)^2  2^k*3*(5 + k)^2  131*k  7
Reap[
Do[
Do[
If[dioph[x, k] == 0, Sow[{x, k}];]
, {x, 0, 1000}
]
, {k, 0, 1000}
]]
gave the output
{Null, {{{31, 6}}}}
so this looked at 1002001 possible x,k pairs and found the solution
x=31, k=6. This took about 16 seconds on my machine. This is crude
and could probably be vastly improved but at least it finds solutions.
Recently I have been curious about diophantine equations. Where did
this particular one come from? Why do you want to solve it?
Mike
===
Subject: Re: exponential diophantine equations
*This message was transferred with a trial version of CommuniGate(tm) Pro*
to my faithful PowerBook) and have a few remarks.
The method I sketched below where I used the first 200 primes p to
test if f[k] is a square mod p is an overkill. In fact, it is much
better to use only a few primes at first (perhaps just one) and then
run the function again over the set of primes that get selected,
using different primes, of course. Here is what I did on the train.
First, I redefined the function g as follows:
g[k_:1, l_] := Function[x, Evaluate[And @@ Prepend[
Table[test[x, Prime[i]], {i, k, l}], test25[x]]]]
Now g takes two arguments, with the first one being optional and by
default 1. So g[200] will still test the first 200 primes, but g
[200,200] will just test the 20th prime. The test for divisibility of
f[k] by 25 is always included.
Now this is what I did:
ls=Select[Range[2000000],g[5000,5000]];//Timing
{205.797 Second,Null}
In other words, I first used the 5000 prime (which is 48611) to test
the first 2000000 integers as candidates for k, and collected them in
the list ls. It turned out that ls is pretty large, with around
60,000 numbers (I tested this with Length[ls] but forgot to record
the exact number i got and do not wish to run this again). After that
I run the program again on ls, but with different list of primes:
In[23]:=
ls=Select[ls,g[20]];//Timing
Out[23]=
{109.097 Second,Null}
This time it turned out that:
In[24]:=
Length[ls]
Out[24]=
1
Not surprisingly:
In[25]:=
ls
Out[25]=
{6}
So there seems to be no k under 2000000. We can certainly do much
better than that; the program has so far taken only about 5 and a
half minute to run. But it is already clear that if another solution
exists it will have to be pretty large.
Andrzej Kozlowski
PS. I extended the checked range to 1<=k <=3000000. I think I'll stop
here, as I have very little belief left that anything will be found.
> Here is one approach. We will need the package:
> << NumberTheory`NumberTheoryFunctions`
> Let's start with a primitive approach and then improve it to run
> much faster. The primitive approach would be like this. First we
> write your equation as
> 2^k*3*(k + 5)^2 + 131*k + 7 == (5*x)^2
> Let us define a function f[k] as follows:
> f[k_Integer] := 2^k*3*(k + 5)^2 + 131*k + 7
> What we are looking for is values of k for which the the following
> are true:
> 1. f[k] is 0 mod 25.
> 2. f[k] is a perfect square.
> It is easy to write a slow function that looks for such k. First of
> all, we need a function f[k_,n_] which efficiently computes Mod[f
> [k],n]. Here is this function:
> f[k_Integer, p_Integer] :=
> Mod[PowerMod[2, k, p]*Mod[3, p]*PowerMod[k + 5, 2, p] + Mod
> [131*k + 7,
> p], p]
> The test for divisibility of f[k] by 25 takes the form
> test25[k_Integer] := f[k, 25] == 0
> We also need a test to check if a number is a perfect square. Here
> is the obvious one:
> test1[x_Integer] := IntegerQ[Sqrt[f[x]]]
> Now let's define a function that combines both tests:
> h = Function[x, Evaluate[And @@ Prepend[{test1[x]}, test25[x]]]];
> Let's check that this will work well on the one solution we know:
> h[6]
> True
> On the other hand:
> h[7]
> False
> OK, using this function we can now try to find any solutions for k
> between 1 and 10000:
> Select[Range[10000],h]//Timing
> {36.1681 Second,{6}}
> This is rather slow so we try something more sophisticated. Instead
> of checking is f[k] is a square root we will check if it is a
> square root modulo a prime p. We will use a large number of primes
> and this will still be faster than doing an integer check. Here is
> the test function:
> test[k_Integer, p_Integer] := ReleaseHold[Block[ {$Messages = {}},
> Check[SqrtMod[f[k, p], p]; True, False]
> ]]
> I do not have the time at this moment to explain exactly what this
> does. The key function is SqrtMod from the NumberTheoryFunctions
> package. it computes square roots modulo a prime. Here is now a
> function that will check if f[k] of a number is a square module the
> first n primes (it also checks if f[k] is divisible by 25)
> g[k_] := Function[
> x, Evaluate[And @@ Prepend[Table[test[x, Prime[i]], {i, 1, k}],
> test25[x]]]]
> I am going to use g[200] which checks the first 200 primes.
> let7s try the above computation with g[200]:
> Select[Range[10000],g[200]]//Timing
> {3.41956 Second,{6}}
> Note that we still correctly identified the solution 6, but we got
> it a lot faster. So we can try looking at larger ranges. If we find
> a some possible solutions we still have to run the primitive test
> on them to check if they are real solutions and not just solutions
> modulo the first 200 primes.
> In[21]:=
> Select[Range[20000],g[200]]//Timing
> Out[21]=
> {6.82253 Second,{6}}
> Still no luck, but performance seems to scale quite well. I have no
> time now to try looking for more solutions (as my lecture will
> begin in half an hour) but we know that for k between 1 and 20000
> there is only one solution, which is the one you already knew.
> Andrzej Kozlowski
>> Oh those signs! I typed +7. Mistake. It should be 7.
>> Andrea
>> I'm trying to find out how to use Mathematica to find solutions to
>> exponential diophantine equations like the following:
>> (5x)^2  2^k * 3 * (5+k)^2  131 * k + 7 = 0. I want to
>> obtain
>> solutions for x and k. (One solution is x = 31, k = 6, but I didn't
>> find
>> this using Mathematica!)
> Are you sure you have found a solution? I get:
> In[30]:=
> (5x)^2  2^k * 3 * (5+k)^2  131 * k + 7 /.{x>31,k>6}
> Out[30]=
> 14
> One can certianly try some educated searches but before
> starting it
> woudl be better to be sure that this is really the equation you want
> to solve!
> Andrzej Kozlowski
===
Subject: Re: Generaltracing the solver
In general, I think the methods used by Mathematica are vastly different
from those used in hand calculations. For example, a lot of integration
is done using very complicated objects known as HypergeometricPFQ and
MeierG functions. These are translated back to something simpler (where
possible) before the result is presented.
The problem with your idea is that unless you actually do a fair amount
of math by hand, you don't get the feel for what it really means and how
things work. It may seem a waste of time, but I would encourage you to
bear with it! Perhaps the lecturers should discuss this issue a bit.
Mathematica can be a great help in learning math provided that you don't
just use it to cheat. You can use it to generate examples of similar
problems to the one you are looking at, or to explore more difficult
problems.
David Bailey
http://www.dbaileyconsultancy.co.uk
===
Subject: Re: Types in Mathematica thread
>> I confess I do not understand much of the above, and in particular,
>> the phrase: the value of the value Pi is unique to Euclidian
>> geometry.
> Actually that statement is a bit incorrect. The 2D geometry on the
> surface of
> a bent sheet of paper will also have the value Pi when determined
> by the
> traditional definition.
>> I have always believed that Pi is
>> 4*Sum[(1)^i/(2*i + 1), {i, 0, Infinity}]
> Interesting. I learned that Pi = circumference/diameter long before
> I learned
> of the Taylor series expansion.
>> What is Euclidean about that?
>> If what you have in mind is the fact that the 5th postulate of Euclid
>> is equivalent to the sum of the angles in a triangle being equal to
>> two right angles (180 degrees or Pi in radians) then this is true
>> but the profound significance of this for number theory escapes me.
> As I implied above, that will also apply to any surface which is
> curved in
> only one direction. IOW, no stretching is involved in order to get
> the
> Euclidian surface to conform to the curved surface.
>> Why is not 180 unique to Euclidean geometry? Pi, being a number,
>> lives just as comfortably in the BolyaiGauss geometry or
>> Lobachevski's geometry as in Euclidean geometry.
> Pi also has a geometrical significance as I explained above. The value
> determined for Pi using the geometric definition in a nonEuclidian
> geometry
>  which is what a 3space slice in general relativity is  will in
> general
> not be the same as the value given by the sum you expressed above.
> That
> suggests there is something a priori about spaces in which Pi as
> defined as
> circumference/diameter does have the traditional value.
> Steven
It seems to me that you are simply confused and have not studied
enough mathematics, and these two facts together make you see
profound ideas where there are none. You are also jumping form one
topic (transcendental numbers) to a quite different one (non
Euclidean geometries) hinting that they are somehow related, although
of you never explain how.
Pi of course occurs in formulae in Lobachevsky's geometry in
exactly the same places as in Euclidean geometry. Have you ever seen
any of these formulae? For example the formula for the are of a
circle of radius r is, if I have not made a mistake,
4 *Pi * Sinh^2(r/2)
Of course it is different from the Euclidean one, but there is Pi in
it. You will find Pi in all the other formulae corresponding to those
where there is PI in Euclidean geometry  so in what sense is Pi
uniquely Euclidean? Indeed the formulae of Euclidean geometry are
unique  in the sense that they are not like the nonEuclidean ones 
so what is profound or surprising about that?
Andrzej Kozlowski
===
Subject: Re: Skewness problem
>Skewness[ {0, 7, 7, 6, 6, 6, 5, 5, 4, 1}] results in 1.04137.
>Reversing the data to {1,4,5...} I expected a different skewness,
>because the tails are reversed.
>But again I get 1.04137.
>Is there an error in reasoning?
>Klaus G.
This is not really the case. If I understand your question correctly you
are interested in the skewness of a sample of data points. The skewness
is a property of the sample and not the order in which you write the
points. It is determined by how many points are less than or greater
than the mean and by how much. Look at the definition of skewness and
you will see it is independent of the order of the data points.
LP
===
Subject: Skewness problem
Skewness[ {0, 7, 7, 6, 6, 6, 5, 5, 4, 1}] results in 1.04137.
Reversing the data to {1,4,5...} I expected a different skewness,
because the tails are reversed.
But again I get 1.04137.
Is there an error in reasoning?
Klaus G.
===
Subject: Re: Types in Mathematica thread
> I confess I do not understand much of the above, and in particular,
> the phrase: the value of the value Pi is unique to Euclidian
> geometry.
>> Actually that statement is a bit incorrect. The 2D geometry on the
>> surface of
>> a bent sheet of paper will also have the value Pi when determined
>> by the
>> traditional definition.
> I have always believed that Pi is
> 4*Sum[(1)^i/(2*i + 1), {i, 0, Infinity}]
>> Interesting. I learned that Pi = circumference/diameter long
>> before I learned
>> of the Taylor series expansion.
> What is Euclidean about that?
> If what you have in mind is the fact that the 5th postulate of
> Euclid
> is equivalent to the sum of the angles in a triangle being equal to
> two right angles (180 degrees or Pi in radians) then this is true
> but the profound significance of this for number theory escapes me.
>> As I implied above, that will also apply to any surface which is
>> curved in
>> only one direction. IOW, no stretching is involved in order to
>> get the
>> Euclidian surface to conform to the curved surface.
> Why is not 180 unique to Euclidean geometry? Pi, being a number,
> lives just as comfortably in the BolyaiGauss geometry or
> Lobachevski's geometry as in Euclidean geometry.
>> Pi also has a geometrical significance as I explained above. The
>> value
>> determined for Pi using the geometric definition in a non
>> Euclidian geometry
>>  which is what a 3space slice in general relativity is  will in
>> general
>> not be the same as the value given by the sum you expressed
>> above. That
>> suggests there is something a priori about spaces in which Pi as
>> defined as
>> circumference/diameter does have the traditional value.
>> Steven
> It seems to me that you are simply confused and have not studied
> enough mathematics, and these two facts together make you see
> profound ideas where there are none. You are also jumping form one
> topic (transcendental numbers) to a quite different one (non
> Euclidean geometries) hinting that they are somehow related,
> although of you never explain how.
> Pi of course occurs in formulae in Lobachevsky's geometry in
> exactly the same places as in Euclidean geometry. Have you ever
> seen any of these formulae? For example the formula for the are of
> a circle of radius r is, if I have not made a mistake,
> 4 *Pi * Sinh^2(r/2)
> Of course it is different from the Euclidean one, but there is Pi
> in it. You will find Pi in all the other formulae corresponding to
> those where there is PI in Euclidean geometry  so in what sense is
> Pi uniquely Euclidean? Indeed the formulae of Euclidean geometry
> are unique  in the sense that they are not like the nonEuclidean
> ones  so what is profound or surprising about that?
> Andrzej Kozlowski
Since you attach so much importance to the way you were taught to
think of Pi in school perhaps instead of the formula for the area I
should have sent the one for the length of the circumference of a
circle:
2 Pi Sinh[r]
So Pi is the ration between the length of the circumference and twice
the Sinh of the radius, which still makes it a universal constant for
all circles. Thus if there were any intelligent creatures living in
Lobachevsky's space they would surely discover Pi ;)
Andrzej
===
Subject: Re: Types in Mathematica thread
> I confess I do not understand much of the above, and in particular,
> the phrase: the value of the value Pi is unique to Euclidian
> geometry.
Actually that statement is a bit incorrect. The 2D geometry on the surface
of
a bent sheet of paper will also have the value Pi when determined by the
traditional definition.
> I have always believed that Pi is
> 4*Sum[(1)^i/(2*i + 1), {i, 0, Infinity}]
Interesting. I learned that Pi = circumference/diameter long before I
learned
of the Taylor series expansion.
> What is Euclidean about that?
> If what you have in mind is the fact that the 5th postulate of Euclid
> is equivalent to the sum of the angles in a triangle being equal to
> two right angles (180 degrees or Pi in radians) then this is true
> but the profound significance of this for number theory escapes me.
As I implied above, that will also apply to any surface which is curved in
only one direction. IOW, no stretching is involved in order to get the
Euclidian surface to conform to the curved surface.
> Why is not 180 unique to Euclidean geometry? Pi, being a number,
> lives just as comfortably in the BolyaiGauss geometry or
> Lobachevski's geometry as in Euclidean geometry.
Pi also has a geometrical significance as I explained above. The value
determined for Pi using the geometric definition in a nonEuclidian geometry
 which is what a 3space slice in general relativity is  will in general
not be the same as the value given by the sum you expressed above. That
suggests there is something a priori about spaces in which Pi as defined as
circumference/diameter does have the traditional value.
Steven
===
Subject: Re: Types in Mathematica thread
> I offer an interesting observation about _defining_ Pi as Exp[I Pi]
> = 1.
> That seems to provide a means of distinguishing Euclidean geometry
> from
> nonEuclidean geometries using purely symbolic manipulations. That
> is, and
> I offer no proof, the value Pi is unique to Euclidian geometry. I
> contrast
> this observation with Einstein's assertion in _The Meaning of
> Relativity_
> that ?physicists have been obliged by the facts to bring down from
> the
> Olympus of the a priori ?(the concepts of time and space)?in order to
> adjust them and put them in a serviceable condition?
> I contend that Kant is somewhat vindicated by my observation. This
> is a
> deeply philosophical topic which certainly transcends the
> objectives of
> this newsgroup. So I will not persue it further here, other than
> to say
> that my observation would almost certainly be welcomed by Einstein
> as food
> for though, and not as a refutation of the remainder of his work.
I confess I do not understand much of the above, and in particular,
the phrase: the value of the value Pi is unique to Euclidian
geometry. I have always believed that Pi is
4*Sum[(1)^i/(2*i + 1), {i, 0, Infinity}]
What is Euclidean about that?
If what you have in mind is the fact that the 5th postulate of Euclid
is equivalent to the sum of the angles in a triangle being equal to
two right angles (180 degrees or Pi in radians) then this is true
but the profound significance of this for number theory escapes me.
Why is not 180 unique to Euclidean geometry? Pi, being a number,
lives just as comfortably in the BolyaiGauss geometry or
Lobachevski's geometry as in Euclidean geometry.
I do agree however that you have not refuted Einstein's work.
Andrzej Kozlowski
===
Subject: Re: Re: Types in Mathematica thread
>> Exp[I Pi]==1.
> Yes.
>> In that case would you say that you can also derive I form Pi and
>> E? What do you mean by deriving a number from another number?
> I meant to say that Pi can be defined in terms of E. I am
> assuming the
> definition of complex numbers as a prerequisite. It's something
> that's
> been in the back of my mind for quite some time.
>> But there is no reason at all to think that this would help in
>> deducing that Pi is transcendental form the fact that E is. The
>> fact that neither Lindemann's nor Hilbert could do this using this
>> ancient formula of Euler, which they certainly new, would make most
>> people hesitate in claiming that it should be done once you have
>> got complex numbers as a prerequisite.
>> But if you really have an idea how to deduce that Pi is
>> transcendental from the fact that E is then perhaps you might wish
>> to prove that E+Pi is transcendental because somehow nobody has so
>> far been able to do it.
>> Andrzej Kozlowski
> Although, I have to admit, that if you make use of the Lindemann
> Weierstrass theorem (which was proved by Weierstrass much later than
> Lindemann's proof of the transcendentality of Pi) than indeed
> transcendentality of Pi does follow from the transcendentality of E
> and the relationship Exp[I Pi]= 1. But the LiendemannWeierstrass
> theorem is far from easy to prove; and certainly requires more
> prerequisites than complex numbers, see for example Alan Baker,
> Transcendental Number Theory (which I just have been looking at).
> Andrzej Kozlowski
I offer an interesting observation about _defining_ Pi as Exp[I Pi]= 1.
That seems to provide a means of distinguishing Euclidian geometry from
nonEuclidian geometries using purely symbolic manipulations. That is, and
I offer no proof, the value Pi is unique to Euclidian geometry. I contrast
this observation with Einstein's assertion in _The Meaning of Relativity_
that ?physicists have been obliged by the facts to bring down from the
Olympus of the a priori ?(the concepts of time and space)?in order to
adjust them and put them in a serviceable condition?
I contend that Kant is somewhat vindicated by my observation. This is a
deeply philosophical topic which certainly transcends the objectives of
this newsgroup. So I will not persue it further here, other than to say
that my observation would almost certainly be welcomed by Einstein as food
for though, and not as a refutation of the remainder of his work.

The Mathematica Wiki: http://www.mathematicausers.org/
Math for Comp Sci http://www.ifi.unizh.ch/math/bmwcs/master.html
Math for the WWW: http://www.w3.org/Math/
===
Subject: Re: Re: Types in Mathematica thread
> But if you really have an idea how to deduce that Pi is
> transcendental from the fact that E is then perhaps you might wish to
> prove that E+Pi is transcendental because somehow nobody has so far
> been able to do it.
However; it is amusing that it is trivial to prove that either Pi+E
or Pi*E is transcendental. (This fact is mentioned on MathWorld, but
without a proof, and as I just thought of how to do it I could not
resist posting it, although I am sure many people have seen it).
Consider the polynomial equation
eq = (x  Pi)*(x  E) == 0;
It's roots are Pi and E. If we expand it we get
(Collect[#1, x] & ) /@ ExpandAll[eq]
x^2 + (E  Pi)*x + E*Pi == 0
so if both E+P and E*P are algebraic so are E and P; a contradiction.
So at least one of them is transcendental. This is of course unknown.
So once I realised it was so easy to prove I tried:
Assuming[Element[Pi+E,Algebraics],FullSimplify[Element
[Pi*E,Algebraics]]]
but the answer was disappointing :(
Andrzej Kozlowski