A115
===
Subject: Re: The FinancialData Function
I share your concerns, but hold more hope that Wolfram realise that charging
~$2500 for a license and $500 for Premier Service results in some obligations
to their customers.
That said, I was disappointed that their Tech Support didn't follow up on
the concerns I expressed about 6mths ago - is their statement that
FinancialData is 'experimental' a caveat intended to warn us all that it's
not to be used for serious work? I hope not. We are all now pretty used to
the fact that Mathematica is well written, and that QA/QC is exceptionally
good (despite those who think they or others can do better). Given this, I am
sure they have fully understood just how powerful the curated data facilities
can be for the user. Renegging in the FD function would not be acceptable to
me and I suspect many others.
Now, you mention the data paclets could be at risk and that Yahoo could
suddenly start charging WRI (if they are not already). The solution would be
simple, however, since I know there are many financal data providers out
there who could fill the gap - at a cost.
I would like to hear from WRI about this since its a key issue.
I've never heard of this function, but have one immediate strong
reaction/question:
Is there -- or will there soon be -- a fully open, officially
standardized, fully and openly specified, widely and near universally
accepted, stable, long-term, NON-proprietary set of **formats**
for the data and information that is to be transmitted back
and forth between data providers and data users in this
system?
[Something akin to the more or less open, universal and stable graphics
standards that have emerged over time.]
Lacking that, I wouldn't personally go near this kind of financial data
distribution system and related tools like FinancialData for building
anything that was of any real and continuing importance to me.
Think of mapping data, GPS and topographic data, or satellite imagery
and related software tools as an analogous system. I play with some of
this data, plan journeys using MapQuest, hiking trips using Google Earth
(an incredible tool), etc -- but if someone suddenly decided to change
all the standards for this data, I could still use all my old stored
data and tools -- or just do without. (There would of course be many
important commercial enterprises that would be much more seriously
impacted.)
But then suppose people get important, continuing personal or business
activities deeply involved in an information system that uses tools like
FinancialData; the data providers and Wolfram somehow get cross-wise
commercially; and the data providers threaten to change their formats
just enough to screw Wolfram (and all FinancialData users).
Or, suppose the data providers decide to throw digital rights management
complexities all over their data, as is the case now with music, films,
video -- and the deep pockets financial data providers manage to bribe
Congress to require that all computer tools like FinancialData contain
provisions to enforce these DRM complexities.
This may all come across as paranoid fears, and maybe it is -- but look
what has actually happened in other areas of widely distributed
electronic information distribution . . .
Robert Prince-Wright
Houston
TX, 77006
USA
===
Subject: Re: The FinancialData Function
On Apr 1, 10:19 am, robert prince-wright
> I share your concerns, but hold more hope that Wolfram realise that
charging ~$2500 for a license and $500 for Premier Service results in some
obligations to their customers.
That said, I was disappointed that their Tech Support didn't follow up
on the concerns I expressed about 6mths ago - is their statement that
FinancialData is 'experimental' a caveat intended to warn us all that it's
not to be used for serious work? I hope not. We are all now pretty used to
the fact that Mathematica is well written, and that QA/QC is exceptionally
good (despite those who think they or others can do better). Given this, I am
sure they have fully understood just how powerful the curated data facilities
can be for the user. Renegging in the FD function would not be acceptable to
me and I suspect many others.
Now, you mention the data paclets could be at risk and that Yahoo could
suddenly start charging WRI (if they are not already). The solution would be
simple, however, since I know there are many financal data providers out
there who could fill the gap - at a cost.
I would like to hear from WRI about this since its a key issue.
> I've never heard of this function, but have one immediate strong
> reaction/question:
Is there -- or will there soon be -- a fully open, officially
> standardized, fully and openly specified, widely and near universally
> accepted, stable, long-term, NON-proprietary set of **formats**
> for the data and information that is to be transmitted back
> and forth between data providers and data users in this
> system?
[Something akin to the more or less open, universal and stable graphics
> standards that have emerged over time.]
Lacking that, I wouldn't personally go near this kind of financial data
> distribution system and related tools like FinancialData for building
> anything that was of any real and continuing importance to me.
Think of mapping data, GPS and topographic data, or satellite imagery
> and related software tools as an analogous system. I play with some of
> this data, plan journeys using MapQuest, hiking trips using Google Earth
> (an incredible tool), etc -- but if someone suddenly decided to change
> all the standards for this data, I could still use all my old stored
> data and tools -- or just do without. (There would of course be many
> important commercial enterprises that would be much more seriously
> impacted.)
>
Financial data come in many shapes and colors.
Some data are public domain, but not real time (for ex. 20 min.-
delayed stock prices), other data is not free, but real time (eg. real
time stock prices).
Some data is real time and still free (eg. forex prices).
I am sure WRI complies with all the legal requirements when
distributing financial data.
Things may change in the future, like everything else.
> But then suppose people get important, continuing personal or business
> activities deeply involved in an information system that uses tools like
> FinancialData; the data providers and Wolfram somehow get cross-wise
> commercially; and the data providers threaten to change their formats
> just enough to screw Wolfram (and all FinancialData users).
Or, suppose the data providers decide to throw digital rights management
> complexities all over their data, as is the case now with music, films,
> video -- and the deep pockets financial data providers manage to bribe
> Congress to require that all computer tools like FinancialData contain
> provisions to enforce these DRM complexities.
This may all come across as paranoid fears, and maybe it is -- but look
> what has actually happened in other areas of widely distributed
> electronic information distribution . . .
Robert Prince-Wright
> Houston
> TX, 77006
> USA
===
Subject: Re: Legend with ListDensityPlot
> Equivalent functionality to colorbar in Mathematica?
I'm an author of a package to do this for DensityPlot, ContourPlot,
and Plot3D:
I'd be interested in any helped to extend it to work with List- plots
as well. I haven't got around to it, 'coz I haven't need it yet. You
could always use an interpolating function with the list data as input
to a ContourPlot, I suppose.
Will
===
Subject: Re: Number of monominals
I was installed today upgrade to ver. 6.02 and all working correct now.
My Mathematica first process run during 2 weeks and I was working on 2
process.
ARTUR
Alexey Popkov pisze:
>
>> According to the documentation, the function Length[expr] gives the
>> number of elements in expr.
>> Also The length of a symbol is 0.
>> You have to write it as a list, if you want the expression to be
counted.
>> Length[{f[1]}]
>> The other inputs are working, because Length counts the elements of the
>> function Plus:
>> In[1]:=Length[Plus[f[1],f[2],f[3]]]
>> Out[1]:=3
>> OK!
>> In[2]:=Length[Plus[f[1],f[2]]]
>> Out[2]:=2
>> In[3]:=Length[f[1]]
>> Out[3]:=0
>> I hope, that I could answer your question.
>> Patrick
>>
I can not reproduce such behavour in Mathematica 5.2 and 6.02. How do
> you do that?
> In[1]:= Length[f[1]]
> Out[1]= 1
> __________ NOD32 Informacje 2701 (20071204) __________
Wiadomosc zostala sprawdzona przez System Antywirusowy NOD32
> http://www.nod32.com lub http://www.nod32.pl
===
Subject: Something very simple.....
1. I have a list of sphere centers and radii like this:
sphlst={{{ 5.11, 0.76, -0.32}, 100.39},
{{ 7.18, -1.86, -8.19}, 98.02},
{{26.71, -9.30, -6.85}, 111.27},
{{ 0, 0, 0}, 100.00},
{{ 8.65, 4.28, -3.81}, 103.87}}.
If I do Map[Sphere,sphlst] I get too many braces, like this:
{Sphere[{{ 5.11, 0.76, -0.32}, 100.39}],
Sphere[{{ 7.18, -1.86, -8.19}, 98.02}],
Sphere[{{26.71, -9.30, -6.85}, 111.27}],
Sphere[{{ 0, 0, 0}, 100.00}],
Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]}
and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5].
What simple thing am I missing to remove the extra braces?
(I know I can use Table but isn't there a one-step method?)
Flatten doesn't seem to be useful here, or I'm using it wrong.
2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}.
I want the elements of lsta that do NOT correspond to elements
of lstb, in this case everything from lsta except elements
1,3, and 4: result={b,e,f}.
(lstb won't have entries larger than Length[lsta]).
Steve Gray
===
Subject: Re: Something very simple.....
> 1. I have a list of sphere centers and radii like this:
sphlst={{{ 5.11, 0.76, -0.32}, 100.39},
> {{ 7.18, -1.86, -8.19}, 98.02},
> {{26.71, -9.30, -6.85}, 111.27},
> {{ 0, 0, 0}, 100.00},
> {{ 8.65, 4.28, -3.81}, 103.87}}.
If I do Map[Sphere,sphlst] I get too many braces, like this:
{Sphere[{{ 5.11, 0.76, -0.32}, 100.39}],
> Sphere[{{ 7.18, -1.86, -8.19}, 98.02}],
> Sphere[{{26.71, -9.30, -6.85}, 111.27}],
> Sphere[{{ 0, 0, 0}, 100.00}],
> Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]}
Here is a more complicated pattern match approach, (Apply seems to be the
easiest)
sphlst /. {x : (List[{z__}, n_]) -> Sphere[{z}, n]}
and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5].
> What simple thing am I missing to remove the extra braces?
> (I know I can use Table but isn't there a one-step method?)
> Flatten doesn't seem to be useful here, or I'm using it wrong.
2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}.
> I want the elements of lsta that do NOT correspond to elements
> of lstb, in this case everything from lsta except elements
> 1,3, and 4: result={b,e,f}.
> (lstb won't have entries larger than Length[lsta]).
>
Using the range and complement could be one way
In[113]:=
Extract[lsta, #] & /@ (Complement[Range[Length[lsta]], lstb])
Out[113]= {b, e, f}
Hope this is helpful
Pratik Desai
Wolfram Research
Steve Gray
>
--
===
Subject: Re: Something very simple.....
> 1. I have a list of sphere centers and radii like this:
sphlst={{{ 5.11, 0.76, -0.32}, 100.39},
> {{ 7.18, -1.86, -8.19}, 98.02},
> {{26.71, -9.30, -6.85}, 111.27},
> {{ 0, 0, 0}, 100.00},
> {{ 8.65, 4.28, -3.81}, 103.87}}.
If I do Map[Sphere,sphlst] I get too many braces, like this:
{Sphere[{{ 5.11, 0.76, -0.32}, 100.39}],
> Sphere[{{ 7.18, -1.86, -8.19}, 98.02}],
> Sphere[{{26.71, -9.30, -6.85}, 111.27}],
> Sphere[{{ 0, 0, 0}, 100.00}],
> Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]}
and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5].
> What simple thing am I missing to remove the extra braces?
> (I know I can use Table but isn't there a one-step method?)
> Flatten doesn't seem to be useful here, or I'm using it wrong.
2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}.
> I want the elements of lsta that do NOT correspond to elements
> of lstb, in this case everything from lsta except elements
> 1,3, and 4: result={b,e,f}.
> (lstb won't have entries larger than Length[lsta]).
> Steve Gray
Here is a newbie approach for 1:
> In[26]:=
> (Sphere[Sequence[First[#1],
> Last[#1]]] & ) /@ sphlst
> Out[26]=
> {Sphere[{5.11, 0.76, -0.32},
> 100.39], Sphere[
> {7.18, -1.86, -8.19},
> 98.02], Sphere[{26.71,
> -9.3, -6.85}, 111.27],
> Sphere[{0, 0, 0}, 100.],
> Sphere[{8.65, 4.28, -3.81},
> 103.87]}
Here is a more newbie approach for 2:
> In[19]:=
> Flatten[Extract[lsta,
> Complement[
> (Position[lsta,
> #1] & ) /@ lsta,
> ({{#1}} & ) /@ lstb]]]
> Out[19]=
> {b, e, f}
I hope it helps.
J=E1nos
------
..because Annushka has already bought sunflower oil, and not only
bought it, but spilled it too.
Bulgakov: Master and Margarita
===
Subject: Re: Something very simple.....
1. A pretty ugly solution (explicitly taking the arguments to Sphere and
doing a pattern match), but you get the expected blastomere plot:
In[6]:= g =
Sphere /@ sphlst /. {Sphere[{{a__}, b_}] -> Sphere[{a}, b]}
Out[6]= {Sphere[{5.11, 0.76, -0.32}, 100.39],
Sphere[{7.18, -1.86, -8.19},
98.02], Sphere[{26.71, -9.3, -6.85}, 111.27],
Sphere[{0, 0, 0}, 100.], Sphere[{8.65, 4.28, -3.81}, 103.87]}
In[7]:= Graphics3D[g]
Out[7]= Graphics3D[{Sphere[{5.11, 0.76, -0.32}, 100.39],
Sphere[{7.18, -1.86, -8.19}, 98.02],
Sphere[{26.71, -9.3, -6.85},
111.27], Sphere[{0, 0, 0}, 100.], Sphere[{8.65, 4.28, -3.81},
103.87]}, ImageSize -> {360., 380.88094545077234},
ViewPoint -> {2.6859783732354505, -2.033988326753927,
-0.31370633583051105}, ViewVertical -> {0.4842555587883932,
-0.47728721617137, 0.7967257012534106}]
your 1D example lists (for example it checks to make sure that removalList
is shorter or of equal length to list). But it works for your case
(others' code will almost certainly be much more efficient):
deleteElements[list_ /; Length[Dimensions[list]] == 1, removalList_] :=
Delete[list, Partition[removalList,1]]/;
(Length[removalList]<=Length[list] &&
Length[Dimensions[removalList]] == 1 &&
First@Union@(Positive@removalList) &&
First@Union@(IntegerQ /@ removalList))
In[14]:= deleteElements[{a, b, c, d, e, f}, {1, 3, 4}]
Out[14]= {b, e, f}
Good luck!
> 1. I have a list of sphere centers and radii like this:
sphlst={{{ 5.11, 0.76, -0.32}, 100.39},
> {{ 7.18, -1.86, -8.19}, 98.02},
> {{26.71, -9.30, -6.85}, 111.27},
> {{ 0, 0, 0}, 100.00},
> {{ 8.65, 4.28, -3.81}, 103.87}}.
If I do Map[Sphere,sphlst] I get too many braces, like this:
{Sphere[{{ 5.11, 0.76, -0.32}, 100.39}],
> Sphere[{{ 7.18, -1.86, -8.19}, 98.02}],
> Sphere[{{26.71, -9.30, -6.85}, 111.27}],
> Sphere[{{ 0, 0, 0}, 100.00}],
> Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]}
and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5].
> What simple thing am I missing to remove the extra braces?
> (I know I can use Table but isn't there a one-step method?)
> Flatten doesn't seem to be useful here, or I'm using it wrong.
2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}.
> I want the elements of lsta that do NOT correspond to elements
> of lstb, in this case everything from lsta except elements
> 1,3, and 4: result={b,e,f}.
> (lstb won't have entries larger than Length[lsta]).
> Steve Gray
===
Subject: Re: Something very simple.....
There are some good answers that have been posted. Here is a more
compact option:
Delete[lsta, List/@lstb]
Januk
> 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}.
> I want the elements of lsta that do NOT correspond to elements
> of lstb, in this case everything from lsta except elements
> 1,3, and 4: result={b,e,f}.
> (lstb won't have entries larger than Length[lsta]).
> Steve Gray
===
Subject: Re: Something very simple.....
I want the elements of lsta that do NOT correspond to elements
> of lstb, in this case everything from lsta except elements
> 1,3, and 4: result={b,e,f}.
> (lstb won't have entries larger than Length[lsta]).
The following will do it:
Pick[lsta,
If[MemberQ[lstb, #], False, True] & /@ Range@Length@lsta]
Here is how it works:
lsta = {a, b, c, d, e, f} ; lstb = {1, 3, 4};
(* We build a list of same length as lsta since Pick expects two list of
same length. *)
Range@Length@lsta
{1, 2, 3, 4, 5, 6}
(* We mark what elements must be taken. *)
If[MemberQ[lstb, #], False, True] & /@ Range@Length@lsta
{False, True, False, False, True, True}
(* The final expression is *)
Pick[lsta,
If[MemberQ[lstb, #], False, True] & /@ Range@Length@lsta]
{b, e, f}
--
===
Subject: Re: Something very simple.....
Sphere @@@ sphlst
??
Jens
> 1. I have a list of sphere centers and radii like this:
>
> sphlst={{{ 5.11, 0.76, -0.32}, 100.39},
> {{ 7.18, -1.86, -8.19}, 98.02},
> {{26.71, -9.30, -6.85}, 111.27},
> {{ 0, 0, 0}, 100.00},
> {{ 8.65, 4.28, -3.81}, 103.87}}.
>
> If I do Map[Sphere,sphlst] I get too many braces, like this:
>
> {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}],
> Sphere[{{ 7.18, -1.86, -8.19}, 98.02}],
> Sphere[{{26.71, -9.30, -6.85}, 111.27}],
> Sphere[{{ 0, 0, 0}, 100.00}],
> Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]}
>
> and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5].
> What simple thing am I missing to remove the extra braces?
> (I know I can use Table but isn't there a one-step method?)
> Flatten doesn't seem to be useful here, or I'm using it wrong.
>
> 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}.
> I want the elements of lsta that do NOT correspond to elements
> of lstb, in this case everything from lsta except elements
> 1,3, and 4: result={b,e,f}.
> (lstb won't have entries larger than Length[lsta]).
>
>
> Steve Gray
>
===
Subject: Re: Something very simple.....
> 1. I have a list of sphere centers and radii like this:
>
> sphlst={{{ 5.11, 0.76, -0.32}, 100.39},
> {{ 7.18, -1.86, -8.19}, 98.02},
> {{26.71, -9.30, -6.85}, 111.27},
> {{ 0, 0, 0}, 100.00},
> {{ 8.65, 4.28, -3.81}, 103.87}}.
>
> If I do Map[Sphere,sphlst] I get too many braces, like this:
>
> {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}],
> Sphere[{{ 7.18, -1.86, -8.19}, 98.02}],
> Sphere[{{26.71, -9.30, -6.85}, 111.27}],
> Sphere[{{ 0, 0, 0}, 100.00}],
> Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]}
>
> and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5].
> What simple thing am I missing to remove the extra braces?
> (I know I can use Table but isn't there a one-step method?)
> Flatten doesn't seem to be useful here, or I'm using it wrong.
The following will do it:
Map[Sphere[Sequence @@ #] &, sphlst]
For instance,
In[1]:= sphlst = {{{5.11, 0.76, -0.32},
100.39}, {{7.18, -1.86, -8.19}, 98.02}, {{26.71, -9.30, -6.85},
111.27}, {{0, 0, 0}, 100.00}, {{8.65, 4.28, -3.81}, 103.87}};
Map[Sphere[Sequence @@ #] &, sphlst]
Graphics3D@%
Out[2]= {Sphere[{5.11, 0.76, -0.32}, 100.39],
Sphere[{7.18, -1.86, -8.19}, 98.02],
Sphere[{26.71, -9.3, -6.85}, 111.27], Sphere[{0, 0, 0}, 100.],
Sphere[{8.65, 4.28, -3.81}, 103.87]}
[... graphic deleted ...]
--
===
Subject: Re: Something very simple.....
Just use Apply with level specification {1}:
Apply[Sphere, sphlst, {1}]
{Sphere[{5.11, 0.76, -0.32}, 100.39], Sphere[{7.18, -1.86, -8.19},
98.02],
Sphere[{26.71, -9.3, -6.85}, 111.27], Sphere[{0, 0, 0}, 100.],
Sphere[{8.65, 4.28, -3.81}, 103.87]}
Andrzej Kozlowski
> 1. I have a list of sphere centers and radii like this:
sphlst={{{ 5.11, 0.76, -0.32}, 100.39},
> {{ 7.18, -1.86, -8.19}, 98.02},
> {{26.71, -9.30, -6.85}, 111.27},
> {{ 0, 0, 0}, 100.00},
> {{ 8.65, 4.28, -3.81}, 103.87}}.
If I do Map[Sphere,sphlst] I get too many braces, like this:
{Sphere[{{ 5.11, 0.76, -0.32}, 100.39}],
> Sphere[{{ 7.18, -1.86, -8.19}, 98.02}],
> Sphere[{{26.71, -9.30, -6.85}, 111.27}],
> Sphere[{{ 0, 0, 0}, 100.00}],
> Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]}
and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5].
> What simple thing am I missing to remove the extra braces?
> (I know I can use Table but isn't there a one-step method?)
> Flatten doesn't seem to be useful here, or I'm using it wrong.
2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}.
> I want the elements of lsta that do NOT correspond to elements
> of lstb, in this case everything from lsta except elements
> 1,3, and 4: result={b,e,f}.
> (lstb won't have entries larger than Length[lsta]).
> Steve Gray
>
===
Subject: Re: Something very simple.....
Hi Steve,
> 1. I have a list of sphere centers and radii like this:
sphlst={{{ 5.11, 0.76, -0.32}, 100.39},
> {{ 7.18, -1.86, -8.19}, 98.02},
> {{26.71, -9.30, -6.85}, 111.27},
> {{ 0, 0, 0}, 100.00},
> {{ 8.65, 4.28, -3.81}, 103.87}}.
If I do Map[Sphere,sphlst] I get too many braces, like this:
{Sphere[{{ 5.11, 0.76, -0.32}, 100.39}],
> Sphere[{{ 7.18, -1.86, -8.19}, 98.02}],
> Sphere[{{26.71, -9.30, -6.85}, 111.27}],
> Sphere[{{ 0, 0, 0}, 100.00}],
> Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]}
and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5].
> What simple thing am I missing to remove the extra braces?
> (I know I can use Table but isn't there a one-step method?)
> Flatten doesn't seem to be useful here, or I'm using it wrong.
>
Sphere @@@ sphlst
> 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}.
> I want the elements of lsta that do NOT correspond to elements
> of lstb, in this case everything from lsta except elements
> 1,3, and 4: result={b,e,f}.
> (lstb won't have entries larger than Length[lsta]).
lsta[[ Complement[Range[Length[lsta]], lstb] ]]
hope this helps,
Oliver
Steve Gray
Oliver Ruebenkoenig,
===
Subject: Re: Something very simple.....
Hi Steve,
> 1. I have a list of sphere centers and radii like this:
>
> sphlst={{{ 5.11, 0.76, -0.32}, 100.39},
> {{ 7.18, -1.86, -8.19}, 98.02},
> {{26.71, -9.30, -6.85}, 111.27},
> {{ 0, 0, 0}, 100.00},
> {{ 8.65, 4.28, -3.81}, 103.87}}.
>
> If I do Map[Sphere,sphlst] I get too many braces, like this:
>
> {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}], Sphere[{{ 7.18,
> -1.86, -8.19}, 98.02}], Sphere[{{26.71, -9.30, -6.85}, 111.27}],
> Sphere[{{ 0, 0, 0}, 100.00}],
> Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]}
>
> and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5].
> What simple thing am I missing to remove the extra braces?
> (I know I can use Table but isn't there a one-step method?)
> Flatten doesn't seem to be useful here, or I'm using it wrong.
Apply[Sphere, sphlst, 1] does the trick.
> 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}.
> I want the elements of lsta that do NOT correspond to
> elements of lstb, in this case everything from lsta except
> elements 1,3, and 4: result={b,e,f}.
> (lstb won't have entries larger than Length[lsta]).
For this, I'd use
lstc = lsta[[#]] & /@ lstb
lstd = Complement[lsta, lstc]
but there are undoubtedly other ways.
Dave.
No virus found in this outgoing message.
Checked by AVG.
05:38
===
Subject: Re: Something very simple.....
Hi Steve,
1) you must use Map together with Apply:
Map[Sphere@@#&,sphlst]
2) here we the complement of the indices and then use Part:
lsta[[ Complement[Range[Length[lsta]],lstb]] ]
hope this helps, Daniel
> 1. I have a list of sphere centers and radii like this:
>
> sphlst={{{ 5.11, 0.76, -0.32}, 100.39},
> {{ 7.18, -1.86, -8.19}, 98.02},
> {{26.71, -9.30, -6.85}, 111.27},
> {{ 0, 0, 0}, 100.00},
> {{ 8.65, 4.28, -3.81}, 103.87}}.
>
> If I do Map[Sphere,sphlst] I get too many braces, like this:
>
> {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}],
> Sphere[{{ 7.18, -1.86, -8.19}, 98.02}],
> Sphere[{{26.71, -9.30, -6.85}, 111.27}],
> Sphere[{{ 0, 0, 0}, 100.00}],
> Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]}
>
> and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5].
> What simple thing am I missing to remove the extra braces?
> (I know I can use Table but isn't there a one-step method?)
> Flatten doesn't seem to be useful here, or I'm using it wrong.
>
> 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}.
> I want the elements of lsta that do NOT correspond to elements
> of lstb, in this case everything from lsta except elements
> 1,3, and 4: result={b,e,f}.
> (lstb won't have entries larger than Length[lsta]).
>
>
> Steve Gray
>
===
Subject: Re: conversion of sin to cos
you may simply replace all Sin[x] -> Cos[x-Pi/2]
hope this helps, Daniel
> Hello all,
>
> Here is my problem. I have a very long product of cosines with
> arguments of the form k*Pi, k being integers.
> I want to convert this expression to a sum of cosines. TrigReduce
> works fine, except that it converts cos to sin.
> So, I want all the sin (after the TrigReduce) to be converted to cos
> and the arguments be of the form p*Pi, p being rational of course.
> It has something to do with Hold or HoldAll, but I don't know the
> details. Or perhaps the TrigReduce can be overridden
> somehow.
> Can someone help?
>
===
Subject: Combinatorica`ShowGraph HeadCenter option
In whatever version of Mathematica was current 5 years ago, the
following code displayed a directed graph with the arrows located
half-way along each edge:
< True];
ShowGraph[g, HeadCenter -> 0.5]
In Mathematica 6.0.2 (with Combinatorica` instead of
DiscreteMath`Combinatorica`, of course), the option HeadCenter seems to
be unrecognized, and the arrows remain at their target ends -- in other
words, they appear where they are hardest to see!
Has this change been documented? There is nothing whatsoever about this
in Compatibility/tutorial/DiscreteMath/Combinatorica. Except that this
compatibility guide states, All of the functionality in
DiscreteMath`Combinatorica` is available in the newly created
Combinatorica Package. Plainly that is not the case in so far as
HeadCenter is concerned.
How can one still locate the arrows on the displayed directed graph --
using ShowGraph (which has been generally much simpler to use,
especially for students, in contrast with the newer GraphPlot.
--
Murray Eisenberg murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
===
Subject: Re: Combinatorica`ShowGraph HeadCenter option
Hi Murray,
here is a work around:
g=ShowGraph[Cycle[3,Type->Directed]];
g=g/. x:Arrow[__]->{Arrowheads[{{Automatic,0.5}}],x}
hope this helps, Daniel
> In whatever version of Mathematica was current 5 years ago, the
> following code displayed a directed graph with the arrows located
> half-way along each edge:
>
> < g = SetGraphOptions[Cykcle[3], EdgeDirection -> True];
> ShowGraph[g, HeadCenter -> 0.5]
>
> In Mathematica 6.0.2 (with Combinatorica` instead of
> DiscreteMath`Combinatorica`, of course), the option HeadCenter seems to
> be unrecognized, and the arrows remain at their target ends -- in other
> words, they appear where they are hardest to see!
>
> Has this change been documented? There is nothing whatsoever about this
> in Compatibility/tutorial/DiscreteMath/Combinatorica. Except that this
> compatibility guide states, All of the functionality in
> DiscreteMath`Combinatorica` is available in the newly created
> Combinatorica Package. Plainly that is not the case in so far as
> HeadCenter is concerned.
>
> How can one still locate the arrows on the displayed directed graph --
> using ShowGraph (which has been generally much simpler to use,
> especially for students, in contrast with the newer GraphPlot.
>
===
Subject: Symbolic Quantum Operators for Dirac Notation in Mathematica
About Quantum for Mathematica
( http://homepage.cem.itesm.mx/lgomez/quantum/index.htm )
Now you can define Symbolic Quantum Operators for Dirac Notation in
Mathematica, please see this link:
http://homepage.cem.itesm.mx/lgomez/quantum/defope/defope.html
Before this improvement operators could be defined only through the
explicit
Dirac representation of their =93matrix elements=94 ket-on-bra.
Now operators can be defined trough their operation on a ket. For example,
rising (creation) and lowering (annihilation) operators of the harmonic
oscillator are easily defined and used at the end of the document in this
link
http://homepage.cem.itesm.mx/lgomez/quantum/defope/defope.html
Now the Quantum Random Walk is solved in the documentation by three
different methods, which have different advantages and disadvantages. The
last of these three methods uses the new feature of definition of symbolic
quantum operators:
FIRST: Q. Random Walker: Dirac Notation Approach: beautiful but slow:
http://homepage.cem.itesm.mx/lgomez/quantum/qrwnaive/qrwnaive.html
SECOND: Q. Random Waker: Mathematica Syntax Approach: Fastest but too
specialized:
http://homepage.cem.itesm.mx/lgomez/quantum/qrwefficient/qrwefficient.html
THIRD: Q. Random Walker: Defining-operators approach: beautiful enough and
fast enough, a good compromise:
http://homepage.cem.itesm.mx/lgomez/quantum/qrwbest/qrwbest.html
A colleague, Rub=E9n Dario, is already implementing new exciting Quantum
Mechanics calculations (molecular collisions) using these new features.
To have the new features, you must download the new Quantum.zip
http://homepage.cem.itesm.mx/lgomez/quantum/Quantum.zip
and install this new version according to the instructions in
http://homepage.cem.itesm.mx/lgomez/quantum/installation/installation.html
Enjoy it!
Jose Luis Gomez-Munoz
http://homepage.cem.itesm.mx/lgomez/
===
Subject: Graphics3D, missing part
I am trying to use Mathematica 5.1 to make a fractal tree. I get no
problem for Show[G1,G2,G3], but when I do Show[G, G1, G2, G3], the
problem part of the graph is missing. Have I done something wrong?
Any help is much appreciated.
wshun
coneF = Function[{x, y, z, r, h, t}, {{x + 0.6h*Cos[t], y +
0.6h*Sin[t], z + 0.6h, 0.4r, 0.4h, t}, {x + 0.6h*Cos[t], y +
0.6h*Sin[t], z + 0.6h, 0.4r, 0.6h, Mod[t + 2Pi/3, 2Pi]}, {x +
0.6h*Cos[t], y + 0.6h*Sin[t], z + 0.6h, 0.4r, 0.6h, Mod[t + 4Pi/3,
2Pi]}}]
coneG = Function[A, Flatten[Table[coneF[ Extract[A, {k, 1}],
Extract[A, {k, 2}], Extract[A, {k, 3}], Extract[A, {k, 4}],
Extract[A, {k, 5}], Extract[A, {k, 6}]], {k, Length[A]}], 1]]
DrawCone = Function[A, Table[ParametricPlot3D[{Extract[A, {k, 1}],
Extract[A, {k, 2}], Extract[A, {k, 3}]} + Extract[A, {k, 4}]*(1 - h/
Extract[A, {k, 5}])*{Cos[t], Sin[t], 0} + h*{Cos[Extract[A, {k, 6}]],
Sin[Extract[A, {k, 6}]], 1}, {h, 0, Extract[A, {k, 5}]}, {t, 0, 2Pi}],
{k, Length[A]}]]
A = {{0, 0, 0, 1, 6, 0}}; A1 = coneG[A]; A2 = coneG[A1]; A3 =
coneG[A2];
G = DrawCone[A]; G1 = DrawCone[A1]; G2 = DrawCone[A2]; G3 =
DrawCone[A3]
Show[G, G1, G2, G3]
===
Subject: Re: Graphics3D, missing part
> I am trying to use Mathematica 5.1 to make a fractal tree. I get no
> problem for Show[G1,G2,G3], but when I do Show[G, G1, G2, G3], the
> problem part of the graph is missing. Have I done something wrong?
Note sure what you get with 5.1, but on my system (6.0.2 Mac OS X Intel)
both commands display only a partial graph. Setting the option PlotRange
to All allows Mathematica to draw both plots completely.
Show[G1, G2, G3, PlotRange -> All]
Show[G, G1, G2, G3, PlotRange -> All]
You can see the differences at
http://homepages.nyu.edu/~jmg336/mathematica/graphics3dmissingpart.jpg
HTH,
--
$Version
6.0 for Mac OS X x86 (64-bit) (February 7, 2008)
coneF =
Function[{x, y, z, r, h,
t}, {{x + 0.6 h*Cos[t], y + 0.6 h*Sin[t], z + 0.6 h, 0.4 r, 0.4 h,
t}, {x + 0.6 h*Cos[t], y + 0.6 h*Sin[t], z + 0.6 h, 0.4 r, 0.6 h,
Mod[t + 2 Pi/3, 2 Pi]}, {x + 0.6 h*Cos[t], y + 0.6 h*Sin[t],
z + 0.6 h, 0.4 r, 0.6 h, Mod[t + 4 Pi/3, 2 Pi]}}]
coneG = Function[A,
Flatten[Table[
coneF[Extract[A, {k, 1}], Extract[A, {k, 2}], Extract[A, {k, 3}],
Extract[A, {k, 4}], Extract[A, {k, 5}], Extract[A, {k, 6}]], {k,
Length[A]}], 1]]
DrawCone =
Function[A,
Table[ParametricPlot3D[{Extract[A, {k, 1}], Extract[A, {k, 2}],
Extract[A, {k, 3}]} +
Extract[A, {k, 4}]*(1 - h/Extract[A, {k, 5}])*{Cos[t], Sin[t],
0} + h*{Cos[Extract[A, {k, 6}]], Sin[Extract[A, {k, 6}]],
1}, {h, 0, Extract[A, {k, 5}]}, {t, 0, 2 Pi}], {k,
Length[A]}]]
A = {{0, 0, 0, 1, 6, 0}}; A1 = coneG[A]; A2 = coneG[A1]; A3 =
coneG[A2];
G = DrawCone[A]; G1 = DrawCone[A1]; G2 = DrawCone[A2]; G3 =
DrawCone[A3]
Show[G, G1, G2, G3]
Show[G, G1, G2, G3, PlotRange -> All]
Show[G1, G2, G3]
Show[G1, G2, G3, PlotRange -> All]
===
Subject: Re: Graphics3D, missing part
Show[G, G1, G2, G3, PlotRange -> All]
??
Jens
> I am trying to use Mathematica 5.1 to make a fractal tree. I get no
> problem for Show[G1,G2,G3], but when I do Show[G, G1, G2, G3], the
> problem part of the graph is missing. Have I done something wrong?
>
> Any help is much appreciated.
>
> wshun
>
> coneF = Function[{x, y, z, r, h, t}, {{x + 0.6h*Cos[t], y +
> 0.6h*Sin[t], z + 0.6h, 0.4r, 0.4h, t}, {x + 0.6h*Cos[t], y +
> 0.6h*Sin[t], z + 0.6h, 0.4r, 0.6h, Mod[t + 2Pi/3, 2Pi]}, {x +
> 0.6h*Cos[t], y + 0.6h*Sin[t], z + 0.6h, 0.4r, 0.6h, Mod[t + 4Pi/3,
> 2Pi]}}]
>
> coneG = Function[A, Flatten[Table[coneF[ Extract[A, {k, 1}],
> Extract[A, {k, 2}], Extract[A, {k, 3}], Extract[A, {k, 4}],
> Extract[A, {k, 5}], Extract[A, {k, 6}]], {k, Length[A]}], 1]]
>
> DrawCone = Function[A, Table[ParametricPlot3D[{Extract[A, {k, 1}],
> Extract[A, {k, 2}], Extract[A, {k, 3}]} + Extract[A, {k, 4}]*(1 - h/
> Extract[A, {k, 5}])*{Cos[t], Sin[t], 0} + h*{Cos[Extract[A, {k, 6}]],
> Sin[Extract[A, {k, 6}]], 1}, {h, 0, Extract[A, {k, 5}]}, {t, 0, 2Pi}],
> {k, Length[A]}]]
>
> A = {{0, 0, 0, 1, 6, 0}}; A1 = coneG[A]; A2 = coneG[A1]; A3 =
> coneG[A2];
>
> G = DrawCone[A]; G1 = DrawCone[A1]; G2 = DrawCone[A2]; G3 =
> DrawCone[A3]
>
> Show[G, G1, G2, G3]
>
===
Subject: Re: Graphics3D, missing part
wshun
On Apr 1, 6:39 pm, Jens-Peer Kuska Show[G, G1, G2, G3, PlotRange -> All]
??
Jens
>
===
Subject: Re: Problems with differentiating Piecewise functions
>> If I set up a piecewise function and differentiate it:
>> In[112]:= pw1 = Piecewise[{{x^2, x <= 0}, {x, x > 0}}]
>> Out[112]= [Piecewise] {
>> {x^2, x <= 0},
>> {x, x > 0}
>> }
>> In[113]:= pw1 /. x -> 0
>> Out[113]= 0
>> In[114]:= pw1d = D[pw1, x]
>> Out[114]= [Piecewise] {
>> {2 x, x < 0},
>> {1, x > 0},
>> {Indeterminate, !(*
>> TagBox[True,
>> PiecewiseDefault,
>> AutoDelete->False,
>> DeletionWarning->True])}
>> }
>> In[115]:= pw1d /. x -> 0
>> Out[115]= Indeterminate
>> Then at the joins between the pieces I get Indeterminate values,
>> because the limit x <= 0 has become x < 0 after differentiation.
>> Does
>> anyone know a solution to this problem?
>> Howard.
> What do you mean by a solution to this problem? You have a
> function that is not differentiable at 0 and you would like it's
> derivative to have a value there? You can't expect a solution to a
> problem when you do not tell us what is the problem (except the
> fact
> that not all functions are differentiable - but that's life).
> Note that is your pieceise function is actually differentiable than
> the derivative is defined everywhere:
> pw2 = Piecewise[{{x^2, x <= 0}, {x^3, x > 0}}];
> pw2d = D[pw2, x]
> Piecewise[{{2*x, x < 0}, {0, x == 0}}, 3*x^2]
> This is also as it should be. What else would you expect?
> Andrzej Kozlowski
>> example that I posted (I simplified my problem by cutting and pasting
>> an example from the help file to keep the post short). I am actually
>> fitting cubic splines and the functions are continuous up to the
>> second derivative (at least to the accuracy of machine precision). A
>> better example is:
>> In[54]:= pw[x_] :=
>> Piecewise[{{0.+ 0.007508378277320685 x + 7.561460342471517*10^-7 x^3,
>> x < 50}, {-4.8729206849430454*10^-6 (-125.76959597633721 +
>> x) (1148.1044516606876- 47.50636365246156 x + x^2), 50 <= x}}]
>> In[55]:= pw[x]
>> Out[55]= [Piecewise] {
>> {0.+ 0.00750838 x + 7.56146*10^-7 x^3, x < 50},
>> {-4.87292*10^-6 (-125.77 + x) (1148.1- 47.5064 x + x^2), 50 <= x}
>> }
>> In[56]:= pw[50]
>> Out[56]= 0.469937
>> In[57]:= pw[50 + 10^-30]
>> Out[57]= 0.469937
>> In[58]:= pw[50 - 10^-30]
>> Out[58]= 0.469937
>> In[60]:= pw'[x]
>> Out[60]= [Piecewise] {
>> {0.00750838+ 2.26844*10^-6 x^2, x < 50},
>> {-4.87292*10^-6 (-125.77 + x) (-47.5064 + 2 x) -
>> 4.87292*10^-6 (1148.1- 47.5064 x + x^2), x > 50},
>> {Indeterminate, !(*
>> TagBox[True,
>> PiecewiseDefault,
>> AutoDelete->False,
>> DeletionWarning->True])}
>> }
>> In[61]:= pw'[50]
>> Out[61]= Indeterminate
>> In[62]:= pw'[50 + 10^-30]
>> Out[62]= 0.0131795
>> In[63]:= pw'[50 - 10^-30]
>> Out[63]= 0.0131795
>> Also if you Plot pw or pw' you get an annoying gap in the plot at the
>> join (but strangely not pw''). My guess is that Mathematica is too
>> pedantic about machine precision and is treating each piece as an
>> algebraic equation. However this does not explain why Plot behaves
>> funnily and doesn't help if you are trying to do numerical analysis.
> You are violating one of the most fundamental principles of computer
> algebra: do not mix approximate numbers with symbolic computation.
> More correctly, such mixing requires a great deal of care and
> symbolic algebraic techniques that can deal with approximate numbers
> (and even more so with machine precision input) are still in their
> infancy. (In fact Mathematica is one of the few systems that make it
> to some extent possible). In your case the symbolic technique you
> are using is differentiation of a piecewise function, and this
> cannot be reliably combined with numerical precision input.
> The answer to your problem is simple. Switch from using a mixture of
> symbolic methods and approximate input to a purely numeric setting.
> The best way to do this, I think, is by using FunctionInterpolation.
> So what you need to do is this:
> pw[x_] :=
> Piecewise[{{0. + 0.007508378277320685 x + 7.561460342471517*10^-7 x^3,
> x < 50}, {-4.8729206849430454*10^-6 (-125.76959597633721 +
> x) (1148.1044516606876 - 47.50636365246156 x + x^2), 50 <= x}}]
> f = FunctionInterpolation[pw[x], {x, 0, 80}];
> Plot[f[x], {x, 40, 60}]
> shows a continuous curve
> Plot[f'[x], {x, 40, 60}]
> shows an almost smooth curve, with a slight kink at the break
> point. One could probably play with the options to
> FunctionInterpolation to smoothen it.
> Andrzej Kozlowski
Actually, you can get a smooth looking derivative by using a higher
> interpolation order:
f = FunctionInterpolation[pw[x], {x, 0, 80}, InterpolationOrder -> 10];
Plot[f'[x], {x, 40, 60}]
looks very smooth and so does:
Plot[f''[x], {x, 40, 60}]
Andrzej Kozlowski
FunctionInterpolation but I actually wanted to plot my splines not an
approximation to them. I guess I am asking too much since Piecewise
takes algebraic expressions, unlike FunctionInterpolation, and
therefore must evaluate symbolically.
===
Subject: how change color of directed edges for GraphPlot
I have a directed graph to display using GraphPlot:
a=RotateVertices[EmptyGraph[4],-([Pi]/4)];
a=SetGraphOptions[a,EdgeDirection->True];
a=AddEdges[a,{{1,2},{2,3},{2,4},{3,1},{4,1},{4,3}}];
I want to display it using GraphPlot...
GraphPlot[a, Method -> None, DirectedEdges -> True,
VertexRenderingFunction -> ({Black, Disk[#1, 0.02]} &)]
... but I want the edges and the arrows to be Black and not the default
brown.
How can one do this WITHOUT having to completely rewrite what the
default EdgeRenderingFunction->Automatic option does; that is, I still
want the arrows with their heads in the default position (it looks
something like 2/3 the way along each arrow).
--
Murray Eisenberg murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
===
Subject: Re: changing style of vertices for ShowGraph
But I want to reproduce with GraphPlot some of the old behavior of
DiscreteMath`Combinatorica`ShowGraph (since some other of its behavior
seems to have disappeared in Mathematica 6). Namely, to show the vertex
labels not AT the vertices but rather near the vertices, so that I can
still use solid disks for the vertices.
If I do something like this...
GraphPlot[Cycle[3],Method->Automatic,
VertexLabeling->True,
VertexRenderingFunction->({Black,Disk[#1,0.02],Black,Text[#2,#1]}&)]
... then I get the disks but no labels, because evidently one of the
arguments of Text[#2,#1] -- which one?? (this doesn't seem to be
documented?) -- is giving the location to be AT the vertices.
With some experimentation, I discover that it's argument #1 that gives
the coordinates of the vertex, so I can use something like:
GraphPlot[Cycle[3],Method->Automatic,
VertexLabeling->True,
VertexRenderingFunction->
({Black,Disk[#1,0.02],Black,Text[#2,#1+{0.05,0.05}]}&)]
But this is SO much work for something that was SO simple with ShowGraph!
> Setting the option VertexLabeling->True has no effect when a custom
> definition is provided for VertexRenderingFunction, as VertexLabeling
> only affects how the default rendering function draws the vertices.
> If you want vertex labels provided you need to include that in the
> definition of the custom rendering function.
>
> Look up the documentation for VertexRenderingFunction and
> EdgeRenderingFunction to see what additional arguments are provided.
> The first argument for VertexRenderingFunction is the position of the
> vertex. The second argument is the label. So the following works:
>
> GraphPlot[Cycle[3], Method -> Automatic, VertexLabeling -> True,
> EdgeLabeling -> True, EdgeRenderingFunction -> ({Black, Line[#1]} &),
> VertexRenderingFunction -> ({EdgeForm[{Thickness[0.005], Red}],
> Yellow,
> Disk[#1, 0.04], Black, Text[#2, #1]} &)]
>
> You can drop the option settings for VertexLabeling and EdgeLabeling
> and get the same effect.
>
> As for whether GraphPlot plays well with the Combinatorica graph
> structure, it does handle vertex labels correctly but not edge labels,
> as the following example illustrates. I was personally surprised to
> find that the edge labels were not passed to EdgeRenderingFunction. I
> think this might be a bug.
>
> GraphPlot[
> Graph[{{{1, 2}, EdgeLabel -> e1}, {{2, 3}, EdgeLabel -> e2},
> {{3, 1},
> EdgeLabel -> e3}},
> {{{-0.5, 0.866}, VertexLabel -> a},
> {{-0.5, -0.866}, VertexLabel -> b},
> {{1., 0}, VertexLabel -> c}}],
> EdgeRenderingFunction -> ({Black, Line[#1],
> Text[#3, Mean[#1]]
> } &),
> VertexRenderingFunction -> ({EdgeForm[{Thickness[0.005], Red}],
> Yellow,
> Disk[#1, 0.04], Black, Text[#2, #1]} &)]
>
>
> Jason
>
>
>> Yes, GraphPlot seems to permit making nice vertices (or edges), but
>> then
>> the labeling -- either with a Graph object from Combinatorica or just
>> the kind of graph described by the GraphPlot reference page -- does
>> not
>> seem to admit vertex labels or edge labels, at least so far as I can
>> see. For example, neither of the following displays either vertex
>> labels or edge labels:
>> GraphPlot[Cycle[3], Method -> Automatic, VertexLabeling -> True,
>> EdgeLabeling -> True, EdgeRenderingFunction -> ({Black, Line[#1]} &),
>> VertexRenderingFunction -> ({EdgeForm[{Thickness[0.005], Red}],
>> Yellow, Disk[#1, 0.04]} &)]
>> GraphPlot[{{v1 -> v2, a}, {v2 -> v3, b}, {v3 -> v1, c}},
>> Method -> Automatic, VertexLabeling -> True, EdgeLabeling -> True,
>> EdgeRenderingFunction -> ({Black, Line[#1]} &),
>> VertexRenderingFunction -> ({EdgeForm[{Thickness[0.005], Red}],
>> Yellow, Disk[#1, 0.04]} &)]
>> On the other hand, if I remove he VertexRenderingFunction option, I do
>> see vertex labels on the default (yellow boxes) vertex shapes:
>> GraphPlot[{v1 -> v2, a}, {v2 -> v3, b}, {v3 -> v1, c}},
>> Method -> Automatic, VertexLabeling -> True,
>> EdgeLabeling -> True, EdgeRenderingFunction -> ({Black, Line[#1]}
>> &)]
>> GraphPlot[Cycle[3], Method -> Automatic, VertexLabeling -> True,
>> EdgeLabeling -> True, EdgeRenderingFunction -> ({Black, Line[#1]} &)]
>> Of course this now defeats the purpose of using GraphPlot so as to get
>> exactly the kind of vertex shapes that VertexRenderingFunction, above,
>> provides.
>> Similarly with EdgeRenderingFunction.
>> The kernel function GraphPlot doesn't seem to mesh very well with
>> Combinatorica's graph functions. This all still seems only half-
>> baked.
> Take a look at GraphPlot, the graph rendering function that is built
> into the Mathematica kernel. I switched from using ShowGraph to
> GraphPlot after realising that it was (a) faster and (b) easier to
> customise. Here's what you want:
GraphPlot[
> Cycle[3],
> Method -> None,
> EdgeRenderingFunction -> ({Black, Line[#1]} &),
> VertexRenderingFunction -> ({EdgeForm[{Thickness[0.005], Red}],
> Yellow,
> Disk[#1, 0.04]} &)
> ]
You need to specify Method->None, otherwise GraphPlot will override
> the
> specified positions of the vertices in the graph and use its own
> default
> vertex positioning algorithm.
VertexRenderingFunction is what you need to define in order to
> customise
> the appearance of the vertices.
I provided a definition of EdgeRenderingFunction just so that the
> edges
> are rendered in the same way as ShowGraph.
> Jason
--
> J. McKenzie Alexander
> Department of Philosophy, Logic and Scientific Method
> London School of Economics and Political Science
> Houghton Street, London WC2A 2AE
> With Mathematica 6, I can change the default style (medium black
>> disk)
>> for rendering the vertices of a Combinatorica Graph like this:
>> Needs[Combinatorica`]
>> g = Cycle[3];
>> ShowGraph[g, VertexStyle -> Disk[Large], VertexColor -> Red]
>> But how can I, for example, change the vertex style so it is, say, a
>> large yellow disk with a thick red boundary? Or even just change
>> it to
>> be a circle? I tried obvious things like the following, but they
>> cause errors:
>> ShowGraph[g, VertexStyle -> Graphics[Circle[], ImageSize -> 20]]
>> --
>> Murray Eisenberg murray@math.umass.edu
>> Mathematics & Statistics Dept.
>> Lederle Graduate Research Tower phone 413 549-1020 (H)
>> University of Massachusetts 413 545-2859 (W)
>> 710 North Pleasant Street fax 413 545-1801
>> Amherst, MA 01003-9305
>
> Please access the attached hyperlink for an important electronic
> communications disclaimer:
> http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm
> --
>> Murray Eisenberg murray@math.umass.edu
>> Mathematics & Statistics Dept.
>> Lederle Graduate Research Tower phone 413 549-1020 (H)
>> University of Massachusetts 413 545-2859 (W)
>> 710 North Pleasant Street fax 413 545-1801
>> Amherst, MA 01003-9305
>
> --
> Dr J. McKenzie Alexander
> Department of Philosophy, Logic and Scientific Method
> London School of Economics and Political Science
> Houghton Street, London WC2A 2AE
>
>
>
>
> Please access the attached hyperlink for an important electronic
communications disclaimer:
http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm
>
--
Murray Eisenberg murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
===
Subject: Re: Something very simple.....
Steve,
Try,
Sphere@@#&/@sphlst
and,
Complement[lsta,lsta[[lstb]]]
maarten
Steve Gray
unner.com> cc:
===
Subject: Something very
simple.....
01/04/2008
10:19
1. I have a list of sphere centers and radii like this:
sphlst={{{ 5.11, 0.76, -0.32}, 100.39},
{{ 7.18, -1.86, -8.19}, 98.02},
{{26.71, -9.30, -6.85}, 111.27},
{{ 0, 0, 0}, 100.00},
{{ 8.65, 4.28, -3.81}, 103.87}}.
If I do Map[Sphere,sphlst] I get too many braces, like this:
{Sphere[{{ 5.11, 0.76, -0.32}, 100.39}],
Sphere[{{ 7.18, -1.86, -8.19}, 98.02}],
Sphere[{{26.71, -9.30, -6.85}, 111.27}],
Sphere[{{ 0, 0, 0}, 100.00}],
Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]}
and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5].
What simple thing am I missing to remove the extra braces?
(I know I can use Table but isn't there a one-step method?)
Flatten doesn't seem to be useful here, or I'm using it wrong.
2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}.
I want the elements of lsta that do NOT correspond to elements
of lstb, in this case everything from lsta except elements
1,3, and 4: result={b,e,f}.
(lstb won't have entries larger than Length[lsta]).
Steve Gray
===
Subject: Defining a Play[] function for Drawbar Organ Emulation
Although I have no problem PLOTing such a function as this, I cannot
get it to work with the Play[] function. Can anyone help? This is
based on the 11-drawbar organ stops used on some hammond organs (such
as the X-66 model) which I am trying to emulate for additive synthesis
output in a future Demonstration Project (I am using Mathematica 6).
ElevenDrawbars[f_, d_String] :=
Module[{d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, h10, d11, h11, z},
d = StringTake[d, {1}] <> StringTake[d, {2}] <> StringTake[d, {4}]
<>
StringTake[d, {5}] <> StringTake[d, {6}] <> StringTake[d, {7}] <>
StringTake[d, {9}] <> StringTake[d, {10}] <>
StringTake[d, {11}] <> StringTake[d, {13}] <>
StringTake[d, {14}];
d1 = ToExpression[StringTake[d, {1}]];
d2 = ToExpression[StringTake[d, {2}]];
d3 = ToExpression[StringTake[d, {3}]];
d4 = ToExpression[StringTake[d, {4}]];
d5 = ToExpression[StringTake[d, {5}]];
d6 = ToExpression[StringTake[d, {6}]];
d7 = ToExpression[StringTake[d, {7}]];
d8 = ToExpression[StringTake[d, {8}]];
d9 = ToExpression[StringTake[d, {9}]];
d10 = ToExpression[StringTake[d, {10}]]; h10 = d11/2;
d11 = ToExpression[StringTake[d, {11}]]; h11 = d11/2;
z = N[2 Pi];
Play[d1 Sin[1/2 f x z] + d2 Sin[3/2 f x z] + d3 Sin[f x z] +
d4 Sin[2 f x z] + d5 Sin[3 f x z] + d6 Sin[4 f x z] +
d7 Sin[5 f x z] + d8 Sin[6 f x z] + d9 Sin[8 f x z] +
d10 Sin[7 f x z] + h10 Sin[9 f x z] + d11 Sin[10 f x z] +
h11 Sin[12 f x z], {x, 0, z}, SampleDepth -> 16,
SampleRate -> 44100]]
I get the following error statements:
In[30]:= ElevenDrawbars[440, 00 8845 041 00]
During evaluation of In[30]:= Set::setraw: Cannot assign to raw
object 00 8845 041 00. >>
During evaluation of In[30]:= Sound::ssnm: A good PlayRange could not
be found since most of the samples are not evaluating to machine-size
real numbers. >>
Out[30]= Sound[SampledSoundFunction[!(*
TagBox[
RowBox[{CompiledFunction, [,
RowBox[{
RowBox[{{, Play`Time7, }}], ,,
RowBox[{Block, [,
RowBox[{
RowBox[{{,
RowBox[{x, =,
RowBox[{0.`, , +,
RowBox[{0.000022675736961451248`, , Play`Time7}]}]}], }}],
,,
RowBox[{
RowBox[{(,
RowBox[{
RowBox[{(,
RowBox[{
RowBox[{d1$2049, ,
RowBox[{Sin, [,
FractionBox[
RowBox[{440, , x, , z$2049}], 2], ]}]}],
+,
RowBox[{d2$2049, ,
RowBox[{Sin, [,
FractionBox[
RowBox[{3, , 440, , x, , z$2049}], 2],
]}]}],
+,
RowBox[{d3$2049, ,
RowBox[{Sin, [,
RowBox[{440, , x, , z$2049}], ]}]}], +,
RowBox[{d4$2049, ,
RowBox[{Sin, [,
RowBox[{2, , 440, , x, , z$2049}], ]}]}],
+,
RowBox[{d5$2049, ,
RowBox[{Sin, [,
RowBox[{3, , 440, , x, , z$2049}], ]}]}],
+,
RowBox[{d6$2049, ,
RowBox[{Sin, [,
RowBox[{4, , 440, , x, , z$2049}], ]}]}],
+,
RowBox[{d7$2049, ,
RowBox[{Sin, [,
RowBox[{5, , 440, , x, , z$2049}], ]}]}],
+,
RowBox[{d8$2049, ,
RowBox[{Sin, [,
RowBox[{6, , 440, , x, , z$2049}], ]}]}],
+,
RowBox[{d9$2049, ,
RowBox[{Sin, [,
RowBox[{8, , 440, , x, , z$2049}], ]}]}],
+,
RowBox[{d10$2049, ,
RowBox[{Sin, [,
RowBox[{7, , 440, , x, , z$2049}], ]}]}],
+,
RowBox[{h10$2049, ,
RowBox[{Sin, [,
RowBox[{9, , 440, , x, , z$2049}], ]}]}],
+,
RowBox[{d11$2049, ,
RowBox[{Sin, [,
RowBox[{10, , 440, , x, , z$2049}],
]}]}], +,
RowBox[{h11$2049, ,
RowBox[{Sin, [,
RowBox[{12, , 440, , x, , z$2049}],
]}]}]}], )}],
+, 0.`}], )}], , 1.`}]}], ]}],
,, <-CompiledCode->}], ]}],
False,
Editable->False]), 277088, {44100, 16}]]
Can ANYONE help correct my ElevenDrawbars function to avoid this
problem?
Benjamin Tubb
brtubb@pdmusic.org
===
Subject: Mixed Numerical Derivatives
How can I come up with the Hessian of a function, at a particular
point, which can only be evaluated numerically? If I had a symbolic
function, I could do something like
In[123]:=
D[x^3 + z*y^-1 + z^(1/2), {{x, y, z}, 2}] /. {x -> 3, y -> 5,
z -> 12}
Out[123]= {{18, 0, 0}, {0, 24/
125, -1/25}, {0, -1/25, -1/(96 Sqrt[3])}}
The function I'm interested in, though, can only be calculated
numerically. Using ND, I can find the diagonal elements of the
Hessian:
In[92]:= rules = Last[
FindMaximum[{Total[logPr[vdt, ddt, var, #] & /@ testData], ddt > 0,
var > 0}, {{vdt, .9}, {ddt, 120}, {var, 90}}]]
Out[92]= {vdt -> 0.95945, ddt -> 151.097, var -> 103.255}
In[111]:= Needs[NumericalCalculus`]
In[124]:= ND[
Total[logPr[vdtp, ddt, var, #] & /@ testData] /. rules, {vdtp, 2},
Evaluate[vdt /. rules]]
Out[124]= -64.4011
But what about the off diagonal elements?
===
Subject: Obscure limitation of shorthand f' notation for Derivative
The shorthand f' notation for Derivative:
f''''
>> Derivative[4][f]
Equivalently,
ToExpression[f <> Table[', {4}]]
>> Derivative[4][f]
Now, Derivative can represent derivatives of high order:
Derivative[32768][f]
>> Derivative[32768][f]
But,
ToExpression[f <> Table[', {32767}]]
>> Derivative[32767][f]
ToExpression[f <> Table[', {32768}]]
>> Derivative[-32768][f]
Evidently a short int is overflowing somewhere.
===
Subject: PysankyEasterEggsP.nbp $Aborted
Michael Trott's PysankyEasterEggsP.nbp downloaded from
www.mathematicaguidebooks.org shows $Aborted when loaded into Mathematica.
No hint was given as to why.
Using SetOptions[Dynamic,SynchronousUpdating->False] as suggested in
tutorial/IntroductionToDynamic if you have something slow in a Dynamic did
not help.
The Dynamic Timeout note of 21-Nov-2007 in this newsgroup the
explained how to set DynamicEvaluationTimeout whereas the online
documentation did not.
AbsoluteOptions[$FrontEnd,DynamicEvaluationTimeout] reports
{DynamicEvaluationTimeout->6.}
Using SetOptions[$FrontEnd,DynamicEvaluationTimeout->60] (a 60 second
timeout) allowed the demo to load properly.
Note that the FrontEnd's init.m file stores this value so the value will
remain even after restarting Mathematica.
It would have been very helpful if a message had been issued stating that a
timeout had occurred and what to do about it.
DynamicEvaluationTimeout can also be set by choosing the Edit menu's
Preferences... dialog and clicking the [Open Option Inspector] button under
the |Advanced| tab.
Expand [+] Cell Options and click on Evaluation Options.
DynamicEvaluationTimeout appears near the bottom.
Click on the value and enter 60 to make the same change shown above.
Click on the X on the left to remove the setting and restore the
default.
Note that this is all done with Show option values at the top of the
dialog set to [Global Preferences].
It is also possible to select just that cell or PysankyEasterEggsP.nbp so
that the DynamicEvaluationTimeout setting only applies there. To do that:
1) Disable Dynamic Updating Enabled in the Evaluation menu.
2) Load PysankyEasterEggsP.nbp, select the cell.
3) Choose the Format menu's Options Inspector...
4) Set DynamicEvaluationTimeout to 60 as stated above.
5) Enable Dynamic Updating Enabled in the Evaluation menu.
It does not seem not possible to re-evaluate the cell once it has displayed
$Aborted.
Q.E.D.
===
Subject: Write documentation for 6.0 under Solaris
There seems to be very little documentation about how to write
documentation for 6.0.
I found this
http://homepage.cem.itesm.mx/lgomez/createMathematica6AddOn/createMathematic
a6AddOn.html
but it did not seem to work for me. I found something quite recently
added to the Wolfram site recently which was an example added in the
last month or so I think. It had a link to an alpha version of
Workbench 1.2, but the link did not work. But that was only for
Windows/Mac.
Are there any plans to make it possible to write documentation if one
uses Solaris - or for that matter, HP-UX or similar? I thought
Mathematica was supposed to be multi-platform, but some of the add-on
packages and workbench do not support all platforms.
I would think the ability to write documentation needs to be in the
front end and mutli-platform and should not need other packages such
as workbench which only run on a subset of platforms.
===
Subject: Re: Problem with FourierParameters
Am 1. Apr 2008 um 00:55 schrieb Devendra Kapadia:
>>
> I get a wrong result using FourierParameters:
>
> FourierTransform[f, x, w]
> InverseFourierTransform[%, w, x]
>
> gives
>
> 1/2 Sqrt[[Pi]/2] (Sign[1 - w] + Sign[1 + w])
> Sin[x]/x
>
> which is what I expected. But with the setting of FourierParameters:
>
> FourierTransform[f, x, w, FourierParameters -> {1, -1}]
> InverseFourierTransform[%, w, x, FourierParameters -> {1, -1}]
>
> gives
>
> 1/2 [Pi] Sign[1 - w] + 1/2 [Pi] Sign[1 + w] <--- This is OK
> 0 <--- Bug?
>
> Other functions e.g. f=1/(1+x^2) transform correctly in both cases.
>
> Gruss Peter
>
>> Hello Peter,
>>
>> The answer given by InverseFourierTransform for your example with
>> FourierParameters -> {1, -1} is indeed incorrect.
>>
>> We use symbolic integration for computing the inverse transform
>> in both the cases given above. The incorrect answer appears to
>> be caused by the fact that the output from FourierTransform in
>> the second case is not in factored form. Hence, a partial
>> workaround for the problem is to use Factor in the call
>> to InverseFourierTransform, as shown below:
>>
>>
>> In[2]:= FourierTransform[Sin[x]/x, x, w, FourierParameters -> {1, -1}]
>> Pi Sign[1 - w] Pi Sign[1 + w]
>> Out[2]= -------------- + --------------
>> 2 2
>>
>> In[3]:= InverseFourierTransform[Factor[%], w, x,
>> FourierParameters -> {1, -1}]
>> Sin[x]
>> Out[3]= ------
>> x
>>
>>
>> caused by it.
>>
>>
>> Devendra Kapadia,
>> Wolfram Research, Inc.
> I experimented a bit with different FourierParameters and it seems that
the
> wrong answer always comes up, if the first parameter (a) ist not 0. Can
you
> confirm this?
Sincerly,
Peter Breitfeld
> --
> ==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
> Peter Breitfeld | http://www.pBreitfeld.de
> Kreuzgasse 4, 88348 Bad Saulgau | PGP/GPG Key gibt's hier
Yes, the problem is also seen with other numerical values of 'a'
in FourierParameters -> {a,b}, but the example seems to work fine
if we allow 'a' to remain symbolic as shown below:
In[2]:= FourierTransform[Sin[x]/x, x, w, FourierParameters -> {a, -1}]
-1 + a
Pi Sqrt[(2 Pi) ] (Sign[1 - w] + Sign[1 + w])
Out[2]= -------------------------------------------------
2
In[3]:= Simplify[InverseFourierTransform[%, w, x, FourierParameters ->
{a, -1}], Im[a] == 0]
Sin[x]
Out[3]= ------
x
-Devendra
===
Subject: Re: Problem with FourierParameters
Am 1. Apr 2008 um 00:55 schrieb Devendra Kapadia:
> I get a wrong result using FourierParameters:
>> FourierTransform[f, x, w]
>> InverseFourierTransform[%, w, x]
>> gives
>> 1/2 Sqrt[[Pi]/2] (Sign[1 - w] + Sign[1 + w])
>> Sin[x]/x
>> which is what I expected. But with the setting of FourierParameters:
>> FourierTransform[f, x, w, FourierParameters -> {1, -1}]
>> InverseFourierTransform[%, w, x, FourierParameters -> {1, -1}]
>> gives
>> 1/2 [Pi] Sign[1 - w] + 1/2 [Pi] Sign[1 + w] <--- This is OK
>> 0 <--- Bug?
>> Other functions e.g. f=1/(1+x^2) transform correctly in both cases.
>> Gruss Peter
> Hello Peter,
The answer given by InverseFourierTransform for your example with
> FourierParameters -> {1, -1} is indeed incorrect.
We use symbolic integration for computing the inverse transform
> in both the cases given above. The incorrect answer appears to
> be caused by the fact that the output from FourierTransform in
> the second case is not in factored form. Hence, a partial
> workaround for the problem is to use Factor in the call
> to InverseFourierTransform, as shown below:
> In[2]:= FourierTransform[Sin[x]/x, x, w, FourierParameters -> {1, -1}]
Pi Sign[1 - w] Pi Sign[1 + w]
> Out[2]= -------------- + --------------
> 2 2
In[3]:= InverseFourierTransform[Factor[%], w, x,
> FourierParameters -> {1, -1}]
Sin[x]
> Out[3]= ------
> x
> inconvenience
> caused by it.
> Devendra Kapadia,
> Wolfram Research, Inc.
I experimented a bit with different FourierParameters and it seems
that the wrong answer always comes up, if the first parameter (a) ist
not 0. Can you confirm this?
Sincerly,
Peter Breitfeld
--
==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
Peter Breitfeld | http://www.pBreitfeld.de
Kreuzgasse 4, 88348 Bad Saulgau | PGP/GPG Key gibt's hier
===
Subject: Re: Problem with FourierParameters
Am 1. Apr 2008 um 00:55 schrieb Devendra Kapadia:
> I get a wrong result using FourierParameters:
FourierTransform[f, x, w]
> InverseFourierTransform[%, w, x]
gives
1/2 Sqrt[[Pi]/2] (Sign[1 - w] + Sign[1 + w])
> Sin[x]/x
which is what I expected. But with the setting of FourierParameters:
FourierTransform[f, x, w, FourierParameters -> {1, -1}]
> InverseFourierTransform[%, w, x, FourierParameters -> {1, -1}]
gives
1/2 [Pi] Sign[1 - w] + 1/2 [Pi] Sign[1 + w] <--- This is OK
> 0 <--- Bug?
Other functions e.g. f=1/(1+x^2) transform correctly in both cases.
Gruss Peter
> Hello Peter,
>> The answer given by InverseFourierTransform for your example with
>> FourierParameters -> {1, -1} is indeed incorrect.
>> We use symbolic integration for computing the inverse transform
>> in both the cases given above. The incorrect answer appears to
>> be caused by the fact that the output from FourierTransform in
>> the second case is not in factored form. Hence, a partial
>> workaround for the problem is to use Factor in the call
>> to InverseFourierTransform, as shown below:
>> In[2]:= FourierTransform[Sin[x]/x, x, w, FourierParameters -> {1, -1}]
>> Pi Sign[1 - w] Pi Sign[1 + w]
>> Out[2]= -------------- + --------------
>> 2 2
>> In[3]:= InverseFourierTransform[Factor[%], w, x,
>> FourierParameters -> {1, -1}]
>> Sin[x]
>> Out[3]= ------
>> x
>> inconvenience
>> caused by it.
>> Devendra Kapadia,
>> Wolfram Research, Inc.
The real problem comes about that Mathematica does not
InverseFourierTransform Sign[1-w] correctly!!! It seams that internally a
rule is defined to InverseFourierTransform Sign[1+w]+Sign[1-w] such that
one need to factor out the rest before. If instead Mathematica where able
to InverseFourierTransform Sign[1-w] no such rules would be necessary at
all!!! I'm confused by the idea to implement special rules before the more
elementary ones work -- this lead to bugs which appear almost at random.
Here two distinct bugs:
(I)
In[1]=InverseFourierTransform[Sign[w],w,x,FourierParameters->{1,-1}]
Out[1]=I/(Pi*x) + DiracDelta[x] - 2*Pi*DiracDelta[x]
should be I/(Pi*x) [actually the principal value of it]
why the 2*Pi in the last term [otherwise the two DiracDelta would
the next bug I show with the standard FourierParameters, it is also
present with FourierParameters->{1, -1} but then it is Qobscured by bug(I)
(II)
In[2]=InverseFourierTransform[Sign[1 - w], w, x]
Out[2]=((2*I)*Cos[x] - 2*Sin[x])/(Sqrt[2*Pi]*x)
should be ((2*I)*Cos[x] + 2*Sin[x])/(Sqrt[2*Pi]*x)
These bugs (I)&(II) where already present in 5.2. They are quite severe
as Fourier transforms of this type appear quite often in many applications.
Fabian
===
Subject: Re: Problem with FourierParameters
> I get a wrong result using FourierParameters:
FourierTransform[f, x, w]
> InverseFourierTransform[%, w, x]
gives
1/2 Sqrt[[Pi]/2] (Sign[1 - w] + Sign[1 + w])
> Sin[x]/x
which is what I expected. But with the setting of FourierParameters:
FourierTransform[f, x, w, FourierParameters -> {1, -1}]
> InverseFourierTransform[%, w, x, FourierParameters -> {1, -1}]
gives
1/2 [Pi] Sign[1 - w] + 1/2 [Pi] Sign[1 + w] <--- This is OK
> 0 <--- Bug?
Other functions e.g. f=1/(1+x^2) transform correctly in both cases.
Gruss Peter
>
Hello Peter,
The answer given by InverseFourierTransform for your example with
FourierParameters -> {1, -1} is indeed incorrect.
We use symbolic integration for computing the inverse transform
in both the cases given above. The incorrect answer appears to
be caused by the fact that the output from FourierTransform in
the second case is not in factored form. Hence, a partial
workaround for the problem is to use Factor in the call
to InverseFourierTransform, as shown below:
In[2]:= FourierTransform[Sin[x]/x, x, w, FourierParameters -> {1, -1}]
Pi Sign[1 - w] Pi Sign[1 + w]
Out[2]= -------------- + --------------
2 2
In[3]:= InverseFourierTransform[Factor[%], w, x,
FourierParameters -> {1, -1}]
Sin[x]
Out[3]= ------
x
caused by it.
Devendra Kapadia,
Wolfram Research, Inc.
===
Subject: Re: Mathematica notebooks the best method
I agree with everything below but to tell the truth I can't see what
is supposed to be the point of this entire thread. If one wants to
write a research paper using Mathematica and submit it to a print or
on-line journal one needs only to convert it to pdf and it should then
be acceptable in many cases it would be (assuming of course that the
contents are good enough). If one wants in addition to provide people
who are able to use Mathematica with live calculations one can put a
Mathematica notebook for download on a web page. I can't see why
anyone should wish for more or argue against this. The rest seems to
me a complete waste of time and effort and some of what I have read I
actually found quite funny (comical) though I assume it was meant to
be serious.
A completely different issue is whether academic institutions should
provide their students with the opportunity to discover the (in my
opinion) very remarkable possibilities offered by the latest version
of Mathematica. That's all that my own response was concerned with.
This is a real issue while a discussion of publishing standards is a
waste of time.
I should like to repeat that I have yet to meet a student who would
complain about the lack of a printed manual and I think using that as
an argument against Mathematica is a perfect example of the sort of
academic attitude I referred to in my first response.
Andrzej Kozlowski
> djvu vs. pdf: no big deal. Tex vs. Mathematica: BIG deal!
With djvu and pdf, it's merely a matter of the final format in which
> the
> document appears and is disseminated.
With (La)TeX and Mathematica, there's a crucial difference in the
> entire
> authoring process. Among other things:
(1) (La)TeX concentrates upon the logical structure of the document,
> whereas Mathematica from the start involves the actual appearance of
> the
> document.
(2) Typing math markup is typically quicker in (La)TeX than in
> Mathematica, as it avoids Control-key sequences (unless one is using
> an
> editor where such sequences are used as shortcuts) or at least uses
> shorter keystroke-only sequences.
(3) Mathematica allows live calculations in the document itself,
> whereas TeX does not (except of the most primitive kind).
> Exception: a
> specialized TeX+CAS system.
(4) Mathematica creates graphics of all sorts directly in the
> document, whereas with the exception of a limited number of native or
> package add-on graphics types, graphics must be imported into a TeX
> document from an external source (such as Mathematica)!
There are two other another differences:
(5) One can have an entire TeX document preparation system --
> editor,
> TeX engine plus packages, viewer, and converter (dvi to ps or pdf,
> e.g.)
> -- for free. Needless to say, Mathematica is not free.
(6) The source code for TeX and many or most of the supporting
> utilities is open source; this is certainly not the case for
> Mathematica.
>> ...I would like to point out that publishing standards are not
>> set in stone. For several years I have witnessed PDF visibly loosing
>> ground to djvu in the mathematical preprint area. I like with many
>> other things I learned about it first form students, who quickly
>> understood its technical superiority over PDF (most of all, much
>> smaller file size). Now I see that a number of on-line mathematics
>> journals are offering djvu as an alternative to pdf.
--
> Murray Eisenberg murray@math.umass.edu
> Mathematics & Statistics Dept.
> Lederle Graduate Research Tower phone 413 549-1020 (H)
> University of Massachusetts 413 545-2859 (W)
> 710 North Pleasant Street fax 413 545-1801
> Amherst, MA 01003-9305
>
===
Subject: Re: Mathematica notebooks the best method for technical
Mathematica notebooks are the best method there is for
technical communications
This statement is certainly true as it stands.
Journals or some universities may not adopt it as a standard for some
valid reasons, but notebooks are certainly superior to any type of
non-live technical document .
I think David Park was thinking more at private technical
communications. As long as both parties use mathematica, exchanging
notebooks is by far the best way to communicate.
As far as journal publication is concerned, probably the best strategy
would be: publish using the accpted standards (latex, pdf,ect) but
mention in the paper that a notebook with the relevant calculations is
available online somewhere.
===
Subject: Re: Mathematica notebooks the best method for technical
On 1 Apr, 09:20, Mariano Su=E1rez-Alvarez
> Indeed. I would not be able to describe such an effort
> with any other term apart from misguided.
Very misguided.
> Essentially
> proprietary formats cannot possibly be considered as a
> the simple fact that Mathematica, say, is absurdly expensive
> for most of the world, to rather more complicated issues
> (for example, one can never tell when the whimsical ires
> of whatever be the superpower of the day, any day, may decide
> to forbid selling, say, Mathematica to country X in order
> to `fight Y' for whatever value X has at the time---terrorists,
> peadophiles, and so on.), to so many other issues...
It simply cannot withstand any analysis.
-- m
The only way I could see this happening is if Wolfram Research
released the front end under the GPL or similar. Then it might, but
even then it is far from clear it would and I personally doubt it
would.
===
Subject: Re: Mathematica notebooks the best method for technical
> Mathematica notebooks are the best method there is for
> technical communications
Would this were true. It's not.
Making Mathematica notebooks become the primary method for both
> preparing *and communicating* technical communications (broadly
> interpreted to include teaching, writing, presentations, and
> publications) in both the academic and professional worlds might be a
> laudable goal, and a number of people (David Park very much included)
> have put sincere and laudable efforts into trying to make it be the case.
Sorry, it's _not_ going to happen.
Wolfram is partly to blame for this -- very much including the currently
> ongoing version 6 documentation disaster.
But there are also very major and fundamental reasons why this goal very
> possibly should not happen, or should not be attempted, or simply could
> never happen in any case.
To focus on just one aspect of this topic (out of many), I would point
> out that major professional societies have (since Isaaac Newton's time!)
> carried the burden of developing two of the major worldwide channels of
> technical and scientific communications, namely scientific and technical
> journals (and archives), and scientific and technical meetings
And, these societies are struggling to adapt, and in many ways
> successfully adapting, today to the Internet, electronic technologies,
> open access, and other emerging complexities of information
> transmission and communication. It's an expensive and
> resource-consuming struggle
The primary communication methods or formats for user input of
> technical material to essentially all such journals and meetings today
> -- user input being of course the primary source for all such
material
> -- are TeX (or LaTeX), PDF, and (unfortunately, but it's the reality) MS
> Word.
I've been heavily involved with a couple of these societies, and a close
> observer at least, if not a major contributor, to the major and
> stressful evolution of professional society publication and meeting
> activities and methods in recent years. I've also been a heavy personal
> user of Mathematica since I heard Steven Wolfram introduce version 1 to
> an overflowing auditorium at my university several decades ago.
I can only say that I would be a vehement opponent of any proposal
> within these societies to divert resources to an effort to add
> Mathematica notebooks to the format list above.
[And, given the current situation, I'd be a vehement opponent of any
> efforts within my university to spend university resources on making
> Mathematica a *preferred* and heavily university-supported computational
> and communications technology within my university.]
Indeed. I would not be able to describe such an effort
with any other term apart from misguided. Essentially
proprietary formats cannot possibly be considered as a
the simple fact that Mathematica, say, is absurdly expensive
for most of the world, to rather more complicated issues
(for example, one can never tell when the whimsical ires
of whatever be the superpower of the day, any day, may decide
to forbid selling, say, Mathematica to country X in order
to `fight Y' for whatever value X has at the time---terrorists,
peadophiles, and so on.), to so many other issues...
It simply cannot withstand any analysis.
-- m
===
Subject: Re: Something very simple.....
For the first question, use any one of these:
Sphere @@@ sphlst
Sphere @@ # & /@ sphlst
Apply[Sphere, sphlst, 1]
For the second question:
lsta = {a, b, c, d, e, f};
lstb = {1, 3, 4};
lsta[[Complement[Range[Length[lsta]], lstb]]]
{b,e,f}
Assuming that lstb is sorted as shown
Fold[Delete[#1, #2] &, lsta, Reverse[lstb]]
{b,e,f}
Fold[Drop[#1, {#2}] &, lsta, Reverse[lstb]]
{b,e,f}
Bob Hanlon
> 1. I have a list of sphere centers and radii like this:
>
> sphlst={{{ 5.11, 0.76, -0.32}, 100.39},
> {{ 7.18, -1.86, -8.19}, 98.02},
> {{26.71, -9.30, -6.85}, 111.27},
> {{ 0, 0, 0}, 100.00},
> {{ 8.65, 4.28, -3.81}, 103.87}}.
>
> If I do Map[Sphere,sphlst] I get too many braces, like this:
>
> {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}],
> Sphere[{{ 7.18, -1.86, -8.19}, 98.02}],
> Sphere[{{26.71, -9.30, -6.85}, 111.27}],
> Sphere[{{ 0, 0, 0}, 100.00}],
> Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]}
>
> and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5].
> What simple thing am I missing to remove the extra braces?
> (I know I can use Table but isn't there a one-step method?)
> Flatten doesn't seem to be useful here, or I'm using it wrong.
>
> 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}.
> I want the elements of lsta that do NOT correspond to elements
> of lstb, in this case everything from lsta except elements
> 1,3, and 4: result={b,e,f}.
> (lstb won't have entries larger than Length[lsta]).
>
>
> Steve Gray
>
===
Subject: Re: Factorial equations
> Who know how is possible with use Mathematica solving equations
> involving factorials e.g
> Solve[n! + n == 726, n]
My difficult problem to solving is
> x=n
> y=n!
find function f(x,y) such
> f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]=246,
> f[6,6!]=1103, f[7,7!]=5247
> values are generated by procedure
> ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}];
> m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a
Who can help in find formula or do above procedure much quickest I
> will
> be greatfull !
> Best wishes
> ARTUR
In this particular case you can find all the solutions using
FindInstance:
FindInstance[n! + n == 726 && Element[n, Integers] && n > 0, {n}]
{{n -> 6}}
and
FindInstance[n! + n == 726 && Element[n, Integers] && n > 0 && n != 6,
{n}]
{}
which means that 6 is a solution and there is no other positive
integer solution.
Now about your probem. First, your procedure does not make sense. Your
function f is a function of two variables but it your procedure you
have an f[n]. Secondly, the problem as stated is trivial for
Mathematica and one does not need any procedures. This will do:
f[x_, y_] =
Together[InterpolatingPolynomial[{{{1, 1!}, 1}, {{2, 2!}, 2}, {{3,
3!}, 5},
{{4, 4!}, 59}, {{5, 5!}, 246}, {{6, 6!}, 1103}, {{7, 7!},
5247}}, {x, y}]]
(1/141478298898)*(1235040757839*x^3 - 6971716404999*x^2 +
135058984529*y*x + 12699232479546*x - 27342188*y^2 -
692985197547*y -
6263124978282)
Now you can check that
Apply[f[##1] & , Table[{n, n!}, {n, 1, 6}], {1}]
{1, 2, 5, 59, 246, 1103}
Andrzej Kozlowski
===
Subject: Re: Factorial equations
Just as Solve will tell you, there IS no algebraic solution to problems
like that.
We can do pretty well with numerical methods, though:
Clear[f]
f[s_] := FindRoot[n + Gamma[n + 1] == s, {n, 3}]
f[726]
{n -> 6.}
f[600]
{n -> 5.89694}
Bobby
> Who know how is possible with use Mathematica solving equations
> involving factorials e.g
> Solve[n! + n == 726, n]
My difficult problem to solving is
> x=n
> y=n!
find function f(x,y) such
> f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]== 246,
> f[6,6!]=1103, f[7,7!]=5247
> values are generated by procedure
> ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}];
> m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a
Who can help in find formula or do above procedure much quickest I will
> be greatfull !
> Best wishes
> ARTUR
>
--
DrMajorBob@longhorns.com
===
Subject: Re: Factorial equations
> Who know how is possible with use Mathematica solving equations
> involving factorials e.g
> Solve[n! + n == 726, n]
>
> My difficult problem to solving is
> x=n
> y=n!
>
> find function f(x,y) such
> f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]=246,
> f[6,6!]=1103, f[7,7!]=5247
> values are generated by procedure
> ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}];
> m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a
>
> Who can help in find formula or do above procedure much quickest I will
> be greatfull !
> Best wishes
> ARTUR
>
This is all quite confusing.
It is not hard to write a solver for equations of the
form, say, n+n!==constant. To get an idea of how you might
go about it, see (for example)
But this will not help with what I believe is your goal,
to find a closed form for terms in your sequence A007878
from the OEIS. I've no idea as to whether there is a
concise closed form for this sequence.
I also do not see why you have a function of two variables,
since you only use one. That is, it is not clear why you
work with f(n,n!) rather then just f(n). There may be a
good reason, but if so you did not show it.
Also you left out a term in your sequence: the fourth
one is actually 16.
As for computing it faster, the time is pretty much all spent
in the discriminants. Some trial and error lead me to use the
Bezout matrix formulation, as that seems fastest. Note that I
also explicitly expand, since there is no guarantee these will
be computed in expanded form.
Timing[aa = Table[
k = Array[f,s+1,0].x^Range[0,s];
m = Discriminant[k, x, Method->SylvesterMatrix];
Length[Expand[m]], {s,1,8}]]
Out[20]= {24.11, {0, 2, 5, 16, 59, 246, 1103, 5247}}
The zero for the first term is because the discriminant of
f[0] + x*f[1] is 1, and 1, being an atom in Mathematica, has
length of zero. This may be related to ome recent questions you
posted to the news group.
Finally I will say that there might be better/faster ways to
compute these discriminants (say, faster determinant code than
what Mathematica now has).
Daniel Lichtblau
Wolfram Research
===
Subject: Re: Factorial equations
>> Who know how is possible with use Mathematica solving equations
>> involving factorials e.g
>> Solve[n! + n == 726, n]
>> My difficult problem to solving is
>> x=n
>> y=n!
>> find function f(x,y) such
>> f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]=246,
>> f[6,6!]=1103, f[7,7!]=5247
>> values are generated by procedure
>> ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}];
>> m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a
>> Who can help in find formula or do above procedure much quickest I
>> will
>> be greatfull !
>> Best wishes
>> ARTUR
In this particular case you can find all the solutions using
> FindInstance:
FindInstance[n! + n == 726 && Element[n, Integers] && n > 0, {n}]
> {{n -> 6}}
and
> FindInstance[n! + n == 726 && Element[n, Integers] && n > 0 && n !=
> 6, {n}]
> {}
which means that 6 is a solution and there is no other positive
> integer solution.
Actually, this can be done more simply by using Reduce:
Reduce[n! + n == 726 && Element[n, Integers] && n > 0, {n}]
n==6
As for the second half, it now seems to me that by function you
probably mean a polynomial with integer coefficients (?), in which
case the polynomial below is not a satisfactory answer. However, since
I still have no idea what your actual problem is (or why you believe
that such a polynomial with integer coefficients exists) I will leave
this problem to others.
Andrzej Kozlowski
> Now about your probem. First, your procedure does not make sense.
> Your function f is a function of two variables but it your procedure
> you have an f[n]. Secondly, the problem as stated is trivial for
> Mathematica and one does not need any procedures. This will do:
f[x_, y_] =
> Together[InterpolatingPolynomial[{{{1, 1!}, 1}, {{2, 2!}, 2}, {{3,
> 3!}, 5},
> {{4, 4!}, 59}, {{5, 5!}, 246}, {{6, 6!}, 1103}, {{7, 7!},
> 5247}}, {x, y}]]
> (1/141478298898)*(1235040757839*x^3 - 6971716404999*x^2 +
> 135058984529*y*x + 12699232479546*x - 27342188*y^2 -
> 692985197547*y -
> 6263124978282)
Now you can check that
Apply[f[##1] & , Table[{n, n!}, {n, 1, 6}], {1}]
> {1, 2, 5, 59, 246, 1103}
> Andrzej Kozlowski
===
Subject: Re: Factorial equations
As for the first question (solving equations with factorials), Ted
Ersek's RootSearch function works wonders:
In[11]:= RootSearch[n! + n == 726, {n, 2, 10}]
Out[11]= {{n -> 6.}}
The package is available here:
http://library.wolfram.com/infocenter/MathSource/4482/
Hope that helps a bit!
> Who know how is possible with use Mathematica solving equations
> involving factorials e.g
> Solve[n! + n == 726, n]
My difficult problem to solving is
> x=n
> y=n!
find function f(x,y) such
> f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]=246,
> f[6,6!]=1103, f[7,7!]=5247
> values are generated by procedure
> ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}];
> m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a
Who can help in find formula or do above procedure much quickest I will
> be greatfull !
> Best wishes
> ARTUR
--
Curtis Osterhoudt
cfo@remove_this.lanl.and_this.gov
PGP Key ID: 0x4DCA2A10
Please avoid sending me Word or PowerPoint attachments
See http://www.gnu.org/philosophy/no-word-attachments.html
===
Subject: Factorial equations
Who know how is possible with use Mathematica solving equations
involving factorials e.g
Solve[n! + n == 726, n]
My difficult problem to solving is
x=n
y=n!
find function f(x,y) such
f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]=246,
f[6,6!]=1103, f[7,7!]=5247
values are generated by procedure
ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}];
m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a
Who can help in find formula or do above procedure much quickest I will
be greatfull !
Best wishes
ARTUR
===
Subject: Re: Factorial equations
> My difficult problem to solving is
> x=n
> y=n!
>
> find function f(x,y) such
> f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]=246,
> f[6,6!]=1103, f[7,7!]=5247
> values are generated by procedure
> ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}];
> m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a
>
> Who can help in find formula or do above procedure much quickest I will
> be greatfull !
Though I am not sure to have fully grasped what you try to achieve, the
following approach for computing the coefficients is about 10 times
faster that the expression above (and clearer).
Clear[f, g]
g[0] = f[0];
g[n_Integer?Positive] := g[n] = g[n - 1] + f[n] x^n
myFun[n_Integer?Positive] :=
Length@Resultant[g[n], D[g[n], x], x, Method -> BezoutMatrix]
Table[myFun[n], {n, 1, 8}]
{1, 2, 5, 16, 59, 246, 1103, 5247}
We use a recursive definition with memoization (i.e. the intermediate
results are saved, avoiding to be computed again after their first
computation) to compute the polynomials.
Also, most of the CPU time is spent computing *Resultant*, so we use the
method *BezoutMatrix*, method which seems to be the fastest for this
problem. For instance,
1103 (n = 7) is computed in 1.1337 second (vs 4.95693 seconds for the
Automatic method)
5247 (n = 8) is computed in 15.8515 second (vs 136.098 seconds for the
Automatic method)
Below, you will find some timings that show where the CPU spend its time
among the different part of the expression and also a speed comparison
among the different algorithms available to compute *Resultant*.
In[6]:= Clear[f, g]
g[0] = f[0];
g[n_Integer?Positive] := g[n] = g[n - 1] + f[n] x^n
myFun[n_Integer?Positive] := Length@Resultant[g[n], D[g[n], x], x]
Table[{g[n] // Timing // First, D[g[n], x] // Timing // First,
Resultant[g[n], D[g[n], x], x] // Timing // First,
myFun[n] // Timing}, {n, 1, 8}]
Out[10]= {{0.000037, 0.000016, 0.000045, {0.00003, 1}}, {0.000021,
0.00001, 0.000199, {0.000169, 2}}, {0.000024, 0.000012,
0.000666, {0.000644, 5}}, {0.000025, 0.000012,
0.003941, {0.003926, 16}}, {0.000033, 0.000016,
0.037161, {0.036293, 59}}, {0.000044, 0.000022,
0.309441, {0.318596, 246}}, {0.000051, 0.000026,
4.89827, {4.95693, 1103}}, {0.000053, 0.000029,
122.954, {136.098, 5247}}}
In[11]:= Table[
Timing[Length@
Resultant[g[n], D[g[n], x], x, Method -> #]] & /@ {Automatic,
Modular , Subresultants, BezoutMatrix, SylvesterMatrix}, {n, 1,
5}]
Out[11]= {{{0.000072, 1}, {0.000029, 1}, {0.000027, 1}, {0.000026,
1}, {0.000026, 1}}, {{0.000186, 2}, {0.005394, 2}, {0.000147,
2}, {0.000523, 2}, {0.00017, 2}}, {{0.000655, 5}, {0.009401,
5}, {0.000249, 5}, {0.001269, 5}, {0.000657, 5}}, {{0.004164,
16}, {0.375798, 16}, {0.000979, 16}, {0.003623, 16}, {0.003861,
16}}, {{0.039217, 59}, {17.702, 59}, {0.020984, 59}, {0.016298,
59}, {0.038365, 59}}}
In[12]:= Table[
Timing@Length@
Resultant[g[n], D[g[n], x], x, Method -> BezoutMatrix], {n, 1,
8}]
Out[12]= {{0.000087, 1}, {0.000568, 2}, {0.001319, 5}, {0.003843,
16}, {0.016913, 59}, {0.106776, 246}, {1.1337, 1103}, {15.8515,
5247}}
Hope this helps,
--
===
Subject: Re: Factorial equations
Hi Artur,
here is a somewhat faster method where we use Discriminant with the
option Method-> BezoutMatrix:
n=7;
poly=Plus@@Table[Symbol[c<>ToString[i]] x^i,{i,0,n}];
Length@Discriminant[poly,x,Method-> BezoutMatrix]
hope this helps, Daniel
> Who know how is possible with use Mathematica solving equations
> involving factorials e.g
> Solve[n! + n == 726, n]
>
> My difficult problem to solving is
> x=n
> y=n!
>
> find function f(x,y) such
> f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]=246,
> f[6,6!]=1103, f[7,7!]=5247
> values are generated by procedure
> ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}];
> m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a
>
> Who can help in find formula or do above procedure much quickest I will
> be greatfull !
> Best wishes
> ARTUR
>
>
===
Subject: Re: Factorial equations
> Who know how is possible with use Mathematica solving equations
> involving factorials e.g
> Solve[n! + n == 726, n]
You could use *Reduce* and tell Mathematica that n is a positive
integer. For instance,
In[1]:= Reduce[n! + n == 726 && n >= 0, n, Integers]
Out[1]= n == 6
(* We check this is the correct result, indeed. *)
In[2]:= n! + n == 726 /. ToRules@%
Out[2]= True
HTH,
--
===
Subject: Re: same color above a treshold
> in ArrayPlot or ContourPlot, I need to color the points exceeding a
> certain treshold with the same color (say red).
> I guess that could be done defining an appropriate ColorFunction...
> but I cannot work it out.
Here is several possibilities among many others, using replacement rule,
ColorFunction, and ColorRules.
data = {{1, 0.5, 0, 0.3}, {1, 1, 0.2, 0.3}, {1, 0, 1, 0.7}};
ArrayPlot[data] (* default colors for comparison *)
ArrayPlot[data /. _?(# > 0.5 &) -> Orange]
ArrayPlot[data, ColorFunction -> (Hue[Clip[#, {0, 0.5}]] &)]
ArrayPlot[data, ColorRules -> {_?(# > .5 &) -> Orange, _ -> Green}]
ArrayPlot[data, ColorRules -> {_?(# > .5 &) -> Orange}]
HTH,
--
===
Subject: Re: Any body can help me solve the equation with piecewise
function
> I have a problem to solve, but it seems not easy because of the
piecewise function involved. I am wondering how we should deal with
piecewise function when solving an equation or doing optimization.
>
> To give you an simple example, the piecewise function is f(x)= 3x
if x<0; f(x)= 0 if x>=0. And I want to solve the equation f(x)+6=0.
>
> I actually define the piecewise function at first using Which and
then try to use NSolve to solve it. However, NSolve doesn't work
through.
>
> Anybody know how should I solve this kind of problem generally in
Mathematica? Of course, for this simple example, we can divide it into
two cases and then compare the solutions after solving the two cases.
Yet my problem is more general and involves more than 3 piecewise
functions, thus a lot of possible cases to deal with. So any command
or function to deal with this kind of general problem?
First, note that there exists several obvious ways to define a
piecewise function in Mathematica such as *Piecewise*, *Which*,
*Switch*, *If*, etc., and some less obvious ways such as *Boole*,
*UnitStep*, *Clip*, *InterpolatingFunction* to name a few. Which one to
choose depends on the version of Mathematica you are using, the
familiarity you have with them, what you try to achieve, and also
evaluation speed. Therefore, it is hard to tell what in general one
should use without taking in account the problem to be solved and its
context.
Second, note that some solvers are designed to deal specifically with
piecewise and piecewise-related function (*Reduce*, *Simplify*,
*Minimize*, to name a few) whereas some others are not (*Solve* for
instance).
Third, note that there exists two classes of solvers --- symbolic
(Solve, Reduce, DSolve, Minimize. ...) and numeric (NSolve, NSolve,
NMinimize, ...) ---, each type using different algorithms and yielding
exact or approximate solutions, respectively.
Finally, here is an example using the function you gave in your post
(the output from Mathematica have been commented out (**)).
Clear[f]
f[x_] := Piecewise[{{3 x, x < 0}, {0, x >= 0}}]
Reduce[f[x] + 6 == 0, x] (* x == -2 *)
f[x] + 6 == 0 /. ToRules@% (* True *)
Solve[f[x] + 6 == 0, x]
(*
During evaluation of In[4]:= Solve::eqf: x<0 is not a well-formed
equation. >>
Solve[6 + [Piecewise] {
{3 x, x < 0}
} == 0, x]
*)
Simplify[f[x] + 6 == 0] (* 2 + x == 0 *)
Solve[%, x] (* {{x -> -2}} *)
Plot[f[x] + 6, {x, -10, 10}] (* ... discarded plot ... *)
--
--
===
Subject: Re: Any body can help me solve the equation with piecewise
function
>I have a problem to solve, but it seems not easy because of the
>piecewise function involved. I am wondering how we should deal with
>piecewise function when solving an equation or doing optimization.
>To give you an simple example, the piecewise function is f(x)= 3x if
>x<0; f(x)= 0 if x>=0. And I want to solve the equation f(x)+6=0.
>I actually define the piecewise function at first using Which and
>then try to use NSolve to solve it. However, NSolve doesn't work
>through.
>Anybody know how should I solve this kind of problem generally in
>Mathematica?
How about using Reduce? For example,
In[1]:= f[x_] = Piecewise[{{3 x, x < 0}, {0, x >= 0}}];
In[2]:= Reduce[f[x] + 6 == 0, x]
Out[2]= x == -2
===
Subject: How to put text on a curved surface?
I would like to put Mathematica on a curved surface, e.g. a torus.
Can anyone help here?
with friendly greetings,
P_ter
===
Subject: optimization
I'm quite new to mathematica, and I am not sure how to optimize
following algorithm (see .nb in link below). Simulation generates 2 time
series, and takes quite a long time to generate series for w>1000
even if you try to run the code with w0, it takes few minutes)
http://staff.utia.cas.cz/barunik/optimization.nb
My question is, if it is possible somehow to optimize the algorithm so
Jozef
===
Subject: setting elements of an array based on a condition
I have one array, W, which for testing purposes has 25 rows and 50 columns.
There are two more things I want to accomplish with this:
1) I want to set all elements of W which are smaller than zero to zero.
2) Then I want to calculate the sum of the elements in each column of W.
How can I do this?
The code below shows how I get to W.
Claus
X = RandomReal[{0, 1}, 50];
Y = RandomReal[{0, 1}, 50];
BinWidth = 0.2;
Radius = 0.2;
xyzVals2 = Table[
{i/(1/BinWidth) + (BinWidth/2)
, j/(1/BinWidth) + (BinWidth/2)
}
, {i, 0, (1/BinWidth) - 1}
, {j, 0, (1/BinWidth) - 1}];
RasterPtsVals = Partition[Flatten[xyzVals2], 2]
RasterX = RasterPtsVals[[All, 1]]
RasterY = RasterPtsVals[[All, 2]]
XDiffSq = (RasterX - a /. a -> X)^2;
YDiffSq = (RasterY - b /. b -> Y)^2;
Dist = Sqrt[(XDiffSq + YDiffSq)];
W = 1 - (Dist/Radius)
===
Subject: Re: SetOptions[Plot, BaseStyle :> myBaseStyle] does not work
myBaseStyle = {FontFamily -> Helvetica};
SetOptions[Plot, BaseStyle -> myBaseStyle];
work as expected.
Jens
> Why doesn't the following work?
myBaseStyle = {FontFamily -> Helvetica};
> SetOptions[Plot, BaseStyle :> myBaseStyle];
> Plot[Sin[x], {x, 0, 10}]
It seems that myBaseStyle does not get evaluated before plotting. Is
> this a bug? Using Plot[Sin[x], {x, 0, 10}, BaseStyle :> myBaseStyle]
> does work.
The old TextStyle option used exactly this pattern, and PerformanceGoal=
> and DisplayFunction still use it.
>
===
Subject: Re: CurrentValue
CurrentValue[nb, SelectionData]
where nb is the NotebookObject of the notebook you are interested in.
--David
http://scientificarts.com/worklife/
CurrentValue[SelectionData] works for selections in the evaluation
> notebook:
Button[label,
> With[{repeated = ToString@CurrentValue@SelectionData},
> NotebookApply[EvaluationNotebook[],
> f[ <> repeated <> , <> repeated <> ]]]]
How to use CurrentValue for other notebooks than the evaluation
> notebook?
> CurrentValue[NotebookSelection[nb]] does not work.
Hannes Kesler
===
Subject: Re: Request for Collective Wisdom...
Here is my advice.
Create a notebook template and use it as a starting point for all
notebooks in mathematica.
File: BasicNotebook.nb
Main Title
Introduction
This is the introduction text
Initialization
If[Length[Names[Global`*]] > 0, Remove[Global`*]]
Off[General::spell, General::spell1]
Off[Solve::ifun]
Loading Modules
Needs[MyPackage`]
Constants
myconstantA = 123
123
Functions
myfunction[x_] = x^6 + 3*x + 11
11 + 3*x + x^6
Main Body
a = 107;
b = N[Sqrt[a]]
10.344080432788601
Closing
This is the closing remarks for the basic notebook template
===
Subject: Re: CurrentValue
CurrentValue[SelectionData] works for selections in the evaluation
> notebook:
Button[label,
> With[{repeated = ToString@CurrentValue@SelectionData},
> NotebookApply[EvaluationNotebook[],
> f[ <> repeated <> , <> repeated <> ]]]]
How to use CurrentValue for other notebooks than the evaluation
> notebook?
> CurrentValue[NotebookSelection[nb]] does not work.
Hannes Kesler
For a palette, you would do it like this...
CreatePalette@
Button[label,
With[{repeated =
ToString[CurrentValue[InputNotebook[], SelectionData]]},
NotebookApply[InputNotebook[],
f[ <> repeated <> , <> repeated <> ]]]]
You can't use InputNotebook[] in a regular notebook because the
act of clicking on the button will make the notebook containing
the button the InputNotebook[]. Palettes don't have this property.
But, of course, it would work fine for any explicit NotebookObject[].
John Fultz
jfultz@wolfram.com
User Interface Group
Wolfram Research, Inc.
===
Subject: Re: Display commands in a package
>> You can do the following:
>> << BarCharts`
>> ?BarCharts`*
> V6.02 XP machine.
With a fresh kernel this works ok - no error messages.
> << BarCharts`
But in response to this line
> ?BarCharts`*
I get:
Syntax::sntxf: ? cannot be followed by BarCharts`*.
Syntax::tsntxi: BarCharts`* is incomplete; more input is
> needed.
Syntax::sntxi: Incomplete expression; more input is needed.
Do you have any thoughts on why my machine won't respond
>
Just to clarify: I thought you were asking about listing symbols in a
package, and _not_ loading a package.
I made a mistake here. Instead of
>> << BarCharts`*
I meant
? BarCharts`*
which lists all symbols in the BarCharts context.
>> or
>> Information[BarCharts`*]
>> instead.
> work either. But I stumbled into a line that does work:
>
> Needs[BarCharts`]
>
> This is just one of the peculiar things about my
> installation; no idea why commands others use don't work
>
===
Subject: Expression manipulation
When trying to simplify an expression by hand, one carries out various
kinds of steps:
1. Replace a subexpression that occurs repeatedly by a single symbol.
2. Multiply numerator and denominator of some subexpression by the
same factor.
3. Cancel particular factors in numerator and denominator of some
subexpression.
4. Gather together two subexpressions that were added together, and
rewrite with a common denominator.
5. Remove common factors.
etc. etc. etc.
Using Part, one can of course access any particular subexpression. But
this is time-consuming and clumsy. I find that I need trial and error
to access the correct subexpression. Once I've accessed it, I often
have difficulty in persuading Mathematica to perform the desired
operation. And then I have trouble putting the subexpression back into
place. It's something like 20 times slower than working with pencil
and paper. HOWEVER pencil and paper calculations are more prone to
stupid arithmetic errors, particularly if the computation is a long
one.
I have been unable to find a convenient way of doing this in
Mathematica. I use version 5.2, but because of my University's site
license, I have access to more recent versions. Would it help to
change?
Can anyone point me to a tutorial where experts use Mathematica to do
a typical pencil and paper computation?
don't look at the newsgroup very often.
David
===
Subject: Re: Expression manipulation
David,
You should be able to do all the manipulations using Mathematica. You should
learn how to use rule based programming, commands such as MapAt, Apart,
Together, Cancel. HoldForm and of course Simplify.
Still, Mathematica is often very theoretically oriented and lacks some of
the practical operations often used. The Presentations package, at my web
site below, has a 'Manipulations' section that contains some practical
additions. Sometimes these are useful in manipulating expressions and
sometimes useful to get expressions in particular standard forms for display
in reports or to match a textbook expression.
If you want to keep a particular subexpression together as a unit you can
wrap it in a HoldForm. This prevents routines like Simplify from splitting
it up. Presentations has a CreateSubexpression and a ReleaseSubexpressions
routines that allow you to wrap a subexpression in a tagged Tooltip. This
works just as well as a HoldForm and allows you to see what the
subexpressions are.
FactorOut can be used to remove a factor from an expression - even if the
factor is not initially in the expression. For example, you can pull a
factor out of a matrix and wrap the matrix in a HoldForm all in one
operation.
MultiplyByOne will multiply the numerator and denominator of an expression
by the same factor and Simplify, or perform any other specified operations
MapLevelParts and MapLevelPatterns will map an operation onto a subset of
level parts in an expression. The most common use is to apply some function
to a selected subset of terms in a sum.
LinearBreakout[f1,f2,...][v1,v2,..][expr] will break out the linear terms of
any expressions within expr that have heads matching the patterns fi over
variables matching the patterns vj.
PushOnto is a much improved version of the Through command that will push a
list of arguments onto specific functions.
HoldOp[operation][expr] will prevent an explicit operation in expr from
being evaluated but will evaluate the arguments of the operation. It is
useful when operation has a number of definitions with it, but you want to
see what the expression looks like before these definitions are applied.
EvaluateAtPattern will evaluate specific patterns in held expressions.
Here is an example of using some of these routines to manipulate an
expression as you might do it 'by hand':
a + b + c
% // MapLevelParts[CreateSubexpression, {{1, 3}}]
d % // Expand
% // FactorOut[sub]
% // ReleaseSubexpressions[]
a + b + c
b + (a + c) where (a+c) has a tag and Tooltip 'held'.
b d+d (a + c) where d did not Distribute across the subexpression.
(d+(b d)/(a+c)) (a+c) factoring out the subexpression (a+c), even though it
is not a true 'factor'.
(a+c) (d+(b d)/(a+c)) releasing the subexpression keeps the overall
structure.
Finally, I might mention the annoying tendency of Mathematica to get more
minus signs into standard expressions than you might wish. One way to
correct this is just to Map Minus onto two factors in a product. For
example:
3 - a (c - b)
MapAt[Minus, %, {{2, 1}, {2, 3}}]
3 - a (-b + c)
3 + a (b - c)
--
David Park
djmpark@comcast.net
http://home.comcast.net/~djmpark/
> When trying to simplify an expression by hand, one carries out various
> kinds of steps:
> 1. Replace a subexpression that occurs repeatedly by a single symbol.
> 2. Multiply numerator and denominator of some subexpression by the
> same factor.
> 3. Cancel particular factors in numerator and denominator of some
> subexpression.
> 4. Gather together two subexpressions that were added together, and
> rewrite with a common denominator.
> 5. Remove common factors.
etc. etc. etc.
Using Part, one can of course access any particular subexpression. But
> this is time-consuming and clumsy. I find that I need trial and error
> to access the correct subexpression. Once I've accessed it, I often
> have difficulty in persuading Mathematica to perform the desired
> operation. And then I have trouble putting the subexpression back into
> place. It's something like 20 times slower than working with pencil
> and paper. HOWEVER pencil and paper calculations are more prone to
> stupid arithmetic errors, particularly if the computation is a long
> one.
I have been unable to find a convenient way of doing this in
> Mathematica. I use version 5.2, but because of my University's site
> license, I have access to more recent versions. Would it help to
> change?
Can anyone point me to a tutorial where experts use Mathematica to do
> a typical pencil and paper computation?
don't look at the newsgroup very often.
David
>
===
Subject: Re: Expression manipulation
You might find David Park's no-cost Expression Manipulation package
useful. It includes a nice tutorial notebook on its use. (If you're
running it with Mathematica 6.0, you'll need to let the Version Advisory
scan locate two places in the tutorial notebook that need the
compatibility updating it suggests.)
Another possibility, although not no-cost, is Park's big Presentations
bundle. It includes a Manipulations package that includes, I believe,
some or all of the functionality of that Expression Manipulation
package. Among the dozen or so functions it defines or extends are:
CompleteTheSquare
FactorOut
MultiplyByOne
This last directly accomplishes one of the tasks you listed --
multiplying numerator and denominator by the same quantity.
For both, see:
http://home.comcast.net/~djmpark/Mathematica.html
> When trying to simplify an expression by hand, one carries out various
> kinds of steps:
> 1. Replace a subexpression that occurs repeatedly by a single symbol.
> 2. Multiply numerator and denominator of some subexpression by the
> same factor.
> 3. Cancel particular factors in numerator and denominator of some
> subexpression.
> 4. Gather together two subexpressions that were added together, and
> rewrite with a common denominator.
> 5. Remove common factors.
>
> etc. etc. etc.
>
> Using Part, one can of course access any particular subexpression. But
> this is time-consuming and clumsy. I find that I need trial and error
> to access the correct subexpression. Once I've accessed it, I often
> have difficulty in persuading Mathematica to perform the desired
> operation. And then I have trouble putting the subexpression back into
> place. It's something like 20 times slower than working with pencil
> and paper. HOWEVER pencil and paper calculations are more prone to
> stupid arithmetic errors, particularly if the computation is a long
> one.
>
> I have been unable to find a convenient way of doing this in
> Mathematica. I use version 5.2, but because of my University's site
> license, I have access to more recent versions. Would it help to
> change?
>
> Can anyone point me to a tutorial where experts use Mathematica to do
> a typical pencil and paper computation?
>
> don't look at the newsgroup very often.
>
> David
>
--
Murray Eisenberg murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
===
Subject: Re: Expression manipulation
Hello David,
I believe there is a tutorial approximately titled Simplifying
Expressions in the documentation for 5.2. Your items 2-5 can be done
automatically by methods described in that tutorial . The expression
you get may not be exactly the form you would choose when using pencil
and paper.
Item 1 requires a longer answer and a bit more finesse. Replacements
of subexpressions can be done with Replace and Rules. However, for
not-very-long expressions, you can copy paste the entire expression
and then select and over-write subexpressions. I don't like this
second method so much because it is prone to mistakes---and a bad
habit to break---so I recommend looking at the Rule-Replace methods.
Craig
> When trying to simplify an expression by hand, one carries out various
> kinds of steps:
> 1. Replace a subexpression that occurs repeatedly by a single symbol.
> 2. Multiply numerator and denominator of some subexpression by the
> same factor.
> 3. Cancel particular factors in numerator and denominator of some
> subexpression.
> 4. Gather together two subexpressions that were added together, and
> rewrite with a common denominator.
> 5. Remove common factors.
etc. etc. etc.
Using Part, one can of course access any particular subexpression. But
> this is time-consuming and clumsy. I find that I need trial and error
> to access the correct subexpression. Once I've accessed it, I often
> have difficulty in persuading Mathematica to perform the desired
> operation. And then I have trouble putting the subexpression back into
> place. It's something like 20 times slower than working with pencil
> and paper. HOWEVER pencil and paper calculations are more prone to
> stupid arithmetic errors, particularly if the computation is a long
> one.
I have been unable to find a convenient way of doing this in
> Mathematica. I use version 5.2, but because of my University's site
> license, I have access to more recent versions. Would it help to
> change?
Can anyone point me to a tutorial where experts use Mathematica to do
> a typical pencil and paper computation?
don't look at the newsgroup very often.
David
--
W. Craig Carter
===
Subject: Re: Expression manipulation
> When trying to simplify an expression by hand, one carries out various
> kinds of steps:
> 1. Replace a subexpression that occurs repeatedly by a single symbol.
> 2. Multiply numerator and denominator of some subexpression by the
> same factor.
> 3. Cancel particular factors in numerator and denominator of some
> subexpression.
> 4. Gather together two subexpressions that were added together, and
> rewrite with a common denominator.
> 5. Remove common factors.
>
> etc. etc. etc.
>
> Using Part, one can of course access any particular subexpression. But
> this is time-consuming and clumsy. I find that I need trial and error
> to access the correct subexpression. Once I've accessed it, I often
> have difficulty in persuading Mathematica to perform the desired
> operation. And then I have trouble putting the subexpression back into
> place. It's something like 20 times slower than working with pencil
> and paper. HOWEVER pencil and paper calculations are more prone to
> stupid arithmetic errors, particularly if the computation is a long
> one.
>
> I have been unable to find a convenient way of doing this in
> Mathematica. I use version 5.2, but because of my University's site
> license, I have access to more recent versions. Would it help to
> change?
>
> Can anyone point me to a tutorial where experts use Mathematica to do
> a typical pencil and paper computation?
>
I prefer pen and paper to Mathematica when manipulating simple
expressions. Mathematica is useful when working with large expressions,
e.g. high-order polynomials or rational functions, etc.
Don't use Part during interactive work. Instead take a look at
ReplaceAll, Together, Expand, ExpandAll, Cancel, etc. Or just copy and
paste when you need to extract a particular subexpression.
http://reference.wolfram.com/mathematica/guide/FormulaManipulation.html
> don't look at the newsgroup very often.
This just tells us that you don't really care about the reply ... so
fewer people will bother to answer ...
===
Subject: Re: PlotLegend not working properly in my Mathematica 6
I did evaluate Needs[PlotLegends`] first but it still didn't work. My
version is 6.0.0.
===
Subject: Re: issues with unit package
I encountered most of the questions discussed here several years ago
and implemented an extension to the combined Units, PhysicalConstants
and Notation packages called Accelerator`ConstantsUnits`.
Among other things, it contains a function ToFundamentalSI which
reduces all expressions containing units to a (unique) canonical form
in terms of the four fundamental SI units. In the process it
replaces things like Sqrt[Meter^2] by Meter but without doing a
PowerExpand on the full expression. This has been implemented in the
upgrade of the package for Mathematica Version 6.
Version 4.0 of the package (for Mathematica V6) is essentially
complete and can be obtained from me on request by email. I will
release it more generally when I get time.
John Jowett
> Why won't Mathematica when using the Units package eliminate reciprocal
=
units? Consider an example from E&M, finding the wavelength correspondin=
g to a frequency:
> < < In[1]:=
> Freq=100*^6 Hertz;
> Wavelength=SpeedOfLight/Freq
> Out[1]=(149896229*Meter)/(50000000*Hertz*Second)
> In[2]:=N[Wavelength]
> Out[2]=(0.299792*Meter)/(Hertz*Second)
> i.e. Mathematica doesn't know that Meter/(Hertz Second) should reduce
to=
Meter. Shouldn't this be handled?
> Another example; shouldn't Mathematica reduce expressions in consistent
=
units to a single result? Example:
> In[5]:=3 Ohm + 1 Volt/Ampere
> Out[5] = 3 Ohm + 1 Volt/Ampere
> Why not 4 Ohm, or 4 Volt/Ampere? After all, the documentation entry =
for Ohm says it's equivalent to Volt / Ampere, so it's reasonable that
Mathe=
matica would be aware of that relationship. Doing SI[] or MKS[] on those =
expressions doesn't change anything.
> Maybe the Units package doesn't extend to manipulating variables with
qu=
antities that have units. Am I missing something here?
I don't think that a completely automatic reduction of units would be
> possible. But it would be nice if the Units package provided a function=
> to convert units to one or more canonical forms.
This will work in many (but not all) cases:
toCanonical[expr_] := SI[expr] //. Units`Private`$ToFundamental
In[5]:= toCanonical[3 Ohm + 1 Volt/Ampere]
> Out[5]= (4 Kilogram Meter^2)/(Ampere^2 Second^3)
In[6]:= toCanonical[(0.299792*Meter)/(Hertz*Second)]
> Out[6]= 0.299792 Meter
It is not always clear what the appropriate unit is in certain
> situations. For example what is the appropriate unit for the torque?
> Joule is certainly correct dimensionally, but is it reasonable to use
it?-=
Hide quoted text -
- Show quoted text -
===
Subject: Re: Region for ListPlot3D
> Below I give a set of 3D points and attempt to plot them as a surface
> using ListPlot3D. I also plot the points directly using Graphics3D.
> The data fill a region that is approximately a trapezium except that
> one side is concave. ListPlot3D extrapolates the concave side out to
> the convex hull of the x -y coordinates thus giving a false impression
> of the surface. How can I make the plotting region conform to the data
> and exclude the extrapolation?
>
I just noticed that you have a regular matrix of 3D points. What you
really need is not ListPlot3D, but a ListParametricPlot3D, that AFAIK
does not exist.
So here's a very simple implementation:
listParametricPlot3D[points_, opt___?OptionQ] := Module[{xx, yy},
{yy, xx} = Take[Dimensions[points], 2];
Graphics3D[GraphicsComplex[Join @@ points,
Polygon[
Join @@
Table[{1 + i + xx j, 2 + i + xx j, 2 + i + xx (j + 1),
1 + i + xx (j + 1)}, {j, 0, yy - 2}, {i, 0, xx - 2}]
]], opt]
]
Fancy stuff like VertexNormals or interpolation is not handled.
listParametricPlot3D[pp] will create the plot you're looking for.
Here's another example:
listParametricPlot3D[
Table[{Cos[u] Cos[v], Cos[u] Sin[v], Sin[u]},
{u, -Pi/2, Pi/2, Pi/14}, {v, 0, 2 Pi, 2 Pi/28}],
Boxed -> False, SphericalRegion -> True
]
>
> pp = {{{0, 0, 0}, {5, 0, 0},
> {10, 0, 0}, {14, 0, 0},
> {19, 0, 0}, {24, 0, 0},
> {29, 0, 0}, {33, 0, 0},
> {38, 0, 0}, {43, 0, 0},
> {48, 0, 0}},
> {{0, 53, 3}, {5, 53, 3},
> {10, 53, 3}, {14, 53,
> 3}, {19, 53, 3},
> {24, 53, 3}, {29, 53,
> 3}, {33, 53, 3},
> {38, 53, 3}, {43, 53,
> 3}, {48, 53, 3}},
> {{0, 107, 18}, {5, 107,
> 19}, {10, 107, 19},
> {14, 107, 19},
> {19, 107, 19},
> {24, 107, 18},
> {29, 107, 18},
> {33, 107, 18},
> {38, 107, 18},
> {43, 107, 18},
> {48, 107, 18}},
> {{0, 160, 81}, {5, 160,
> 81}, {10, 160, 81},
> {15, 160, 80},
> {20, 160, 80},
> {25, 160, 80},
> {30, 160, 80},
> {35, 160, 79},
> {40, 160, 79},
> {45, 160, 79},
> {50, 160, 79}},
> {{0, 213, 142},
> {6, 213, 142},
> {12, 213, 141},
> {18, 213, 141},
> {25, 213, 140},
> {31, 213, 140},
> {37, 213, 140},
> {43, 213, 139},
> {49, 213, 139},
> {56, 213, 138},
> {62, 213, 138}},
> {{0, 267, 93}, {9, 267,
> 93}, {18, 267, 93},
> {27, 267, 93},
> {36, 267, 93},
> {45, 267, 93},
> {54, 267, 92},
> {63, 267, 92},
> {72, 267, 91},
> {82, 267, 91},
> {91, 267, 90}},
> {{0, 320, 60}, {13, 320,
> 60}, {26, 320, 60},
> {40, 320, 60},
> {53, 320, 59},
> {66, 320, 59},
> {79, 320, 58},
> {92, 320, 58},
> {105, 320, 58},
> {118, 320, 58},
> {132, 320, 57}},
> {{0, 373, 40}, {18, 373,
> 40}, {36, 373, 40},
> {54, 373, 40},
> {72, 373, 40},
> {90, 373, 40},
> {108, 373, 40},
> {126, 373, 40},
> {144, 373, 40},
> {162, 373, 40},
> {180, 373, 40}},
> {{0, 427, 29}, {23, 427,
> 29}, {47, 427, 29},
> {70, 427, 29},
> {93, 427, 29},
> {116, 427, 29},
> {140, 427, 29},
> {163, 427, 28},
> {186, 427, 28},
> {210, 427, 28},
> {233, 427, 28}},
> {{0, 480, 22}, {29, 480,
> 22}, {58, 480, 22},
> {87, 480, 22},
> {116, 480, 22},
> {145, 480, 22},
> {174, 480, 22},
> {203, 480, 22},
> {232, 480, 22},
> {260, 480, 22},
> {289, 480, 22}},
> {{0, 533, 17}, {35, 533,
> 17}, {70, 533, 17},
> {104, 533, 17},
> {139, 533, 17},
> {174, 533, 17},
> {209, 533, 17},
> {244, 533, 17},
> {278, 533, 17},
> {313, 533, 17},
> {348, 533, 17}}};
===
Subject: Re: Region for ListPlot3D
Hello Hugh,
I can't see how ListPlot3D isn't doing what you wish--sorry if I am
missing something obvious.
viz:
ppf = Flatten[pp, 1]
gc = GraphicsComplex[ppf, Table[Sphere[i, 5], {i, Length[ppf]}]];
g1 = Graphics3D[{Orange, gc}]
g2 = ListPlot3D[ppf]
Show[g2, g1]
g3 = ListPlot3D[Flatten[pp, 1], InterpolationOrder -> 3]
Show[g3, g1]
WCC
> Below I give a set of 3D points and attempt to plot them as a surface
> using ListPlot3D. I also plot the points directly using Graphics3D.
> The data fill a region that is approximately a trapezium except that
> one side is concave. ListPlot3D extrapolates the concave side out to
> the convex hull of the x -y coordinates thus giving a false impression
> of the surface. How can I make the plotting region conform to the data
> and exclude the extrapolation?
> pp = {{{0, 0, 0}, {5, 0, 0},
> {10, 0, 0}, {14, 0, 0},
:
:
> {348, 533, 17}}};
g1 = Graphics3D[{Point[Flatten[pp, 1]]},
> PlotRange -> All]
g2 = ListPlot3D[Flatten[pp, 1]]
Show[g1, g2]
>
--
W. Craig Carter
===
Subject: Re: Region for ListPlot3D
> Below I give a set of 3D points and attempt to plot them as a surface
> using ListPlot3D. I also plot the points directly using Graphics3D.
> The data fill a region that is approximately a trapezium except that
> one side is concave. ListPlot3D extrapolates the concave side out to
> the convex hull of the x -y coordinates thus giving a false impression
> of the surface. How can I make the plotting region conform to the data
> and exclude the extrapolation?
>
>
> Hugh Goyder
>
>
> pp = {{{0, 0, 0}, {5, 0, 0},
> {10, 0, 0}, {14, 0, 0},
> {19, 0, 0}, {24, 0, 0},
> {29, 0, 0}, {33, 0, 0},
> {38, 0, 0}, {43, 0, 0},
> {48, 0, 0}},
> {{0, 53, 3}, {5, 53, 3},
> {10, 53, 3}, {14, 53,
> 3}, {19, 53, 3},
> {24, 53, 3}, {29, 53,
> 3}, {33, 53, 3},
> {38, 53, 3}, {43, 53,
> 3}, {48, 53, 3}},
> {{0, 107, 18}, {5, 107,
> 19}, {10, 107, 19},
> {14, 107, 19},
> {19, 107, 19},
> {24, 107, 18},
> {29, 107, 18},
> {33, 107, 18},
> {38, 107, 18},
> {43, 107, 18},
> {48, 107, 18}},
> {{0, 160, 81}, {5, 160,
> 81}, {10, 160, 81},
> {15, 160, 80},
> {20, 160, 80},
> {25, 160, 80},
> {30, 160, 80},
> {35, 160, 79},
> {40, 160, 79},
> {45, 160, 79},
> {50, 160, 79}},
> {{0, 213, 142},
> {6, 213, 142},
> {12, 213, 141},
> {18, 213, 141},
> {25, 213, 140},
> {31, 213, 140},
> {37, 213, 140},
> {43, 213, 139},
> {49, 213, 139},
> {56, 213, 138},
> {62, 213, 138}},
> {{0, 267, 93}, {9, 267,
> 93}, {18, 267, 93},
> {27, 267, 93},
> {36, 267, 93},
> {45, 267, 93},
> {54, 267, 92},
> {63, 267, 92},
> {72, 267, 91},
> {82, 267, 91},
> {91, 267, 90}},
> {{0, 320, 60}, {13, 320,
> 60}, {26, 320, 60},
> {40, 320, 60},
> {53, 320, 59},
> {66, 320, 59},
> {79, 320, 58},
> {92, 320, 58},
> {105, 320, 58},
> {118, 320, 58},
> {132, 320, 57}},
> {{0, 373, 40}, {18, 373,
> 40}, {36, 373, 40},
> {54, 373, 40},
> {72, 373, 40},
> {90, 373, 40},
> {108, 373, 40},
> {126, 373, 40},
> {144, 373, 40},
> {162, 373, 40},
> {180, 373, 40}},
> {{0, 427, 29}, {23, 427,
> 29}, {47, 427, 29},
> {70, 427, 29},
> {93, 427, 29},
> {116, 427, 29},
> {140, 427, 29},
> {163, 427, 28},
> {186, 427, 28},
> {210, 427, 28},
> {233, 427, 28}},
> {{0, 480, 22}, {29, 480,
> 22}, {58, 480, 22},
> {87, 480, 22},
> {116, 480, 22},
> {145, 480, 22},
> {174, 480, 22},
> {203, 480, 22},
> {232, 480, 22},
> {260, 480, 22},
> {289, 480, 22}},
> {{0, 533, 17}, {35, 533,
> 17}, {70, 533, 17},
> {104, 533, 17},
> {139, 533, 17},
> {174, 533, 17},
> {209, 533, 17},
> {244, 533, 17},
> {278, 533, 17},
> {313, 533, 17},
> {348, 533, 17}}};
>
> g1 = Graphics3D[{Point[Flatten[pp, 1]]},
> PlotRange -> All]
>
> g2 = ListPlot3D[Flatten[pp, 1]]
>
> Show[g1, g2]
This is a pretty nasty way of doing it, but at least it works ...
Show[ListPlot3D[#, Mesh -> None] & /@ (Join @@ # & /@
Partition[pp, 2, 1]), PlotRange -> All]
===
Subject: plot primes only
hi everyone!
a quick one:
how can i tell mathematica to only list the primes from a list of data
and omit the others?
primeQ only tells me the boolean result
thanx
markus
www.humanchaos.net
===
Subject: Re: plot primes only
Hello Marcus,
This may what you are looking for:
data = Range[10]
primesdata = Select[data, PrimeQ]
Or this,
data = Table[{i, Log[i]}, {i, 1, 100000}];
primesdata = Select[data, PrimeQ[#[[1]]] &];
ListPlot[primesdata]
Craig
> hi everyone!
a quick one:
> how can i tell mathematica to only list the primes from a list of data
> and omit the others?
> primeQ only tells me the boolean result
> thanx
> markus
www.humanchaos.net
--
W. Craig Carter
===
Subject: Re: plot primes only
In[695] = list = Table[i, {i, 1, 100}];
In[690]= Select[list, PrimeQ[# ] &]
Out[690]= {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59,
61,
67, 71, 73, 79, 83, 89, 97}
Tom Dowling
> hi everyone!
a quick one:
> how can i tell mathematica to only list the primes from a list of data
> and omit the others?
> primeQ only tells me the boolean result
> thanx
> markus
www.humanchaos.net
===
Subject: Re: plot primes only
> hi everyone!
>
> a quick one:
> how can i tell mathematica to only list the primes from a list of data
> and omit the others?
> primeQ only tells me the boolean result
>
>
Select[list, PrimeQ]
===
Subject: Re: plot primes only
data = Select[Table[i, {i, 1, 100}], PrimeQ]
??
Jens
> hi everyone!
>
> a quick one:
> how can i tell mathematica to only list the primes from a list of data
> and omit the others?
> primeQ only tells me the boolean result