A71 ==== Subject: //N bug, but WHY? Evaluating (using //N) two exact same expressions, gives wrong answer unless fullsimplify is used first, I spent 2 days on a problem thinking my answer was wrong, but turned out Mathematica 5 was giving me buggy answers, I debugged it to this point, but WHY in the world is this happening? Please help!!! cut and paste below to see the test case: In[243]:= !((Cosh[(43 [Pi])/@2] + ((1 - Cosh[43 @2 [Pi]])) Csch[ 43 @2 [Pi]] Sinh[(43 [Pi])/@2] // FullSimplify) // N[IndentingNewLine] Cosh[(43 [Pi])/@2] + ((1 - Cosh[43 @2 [Pi]])) Csch[ 43 @2 [Pi]] Sinh[(43 [Pi])/@2] // N) Out[243]= !(6.551787517854307`*^-42) Out[244]= !((-1.9342813113834067`*^25)) ==== Subject: Re: FrameTicks bug use True instead of Automatic that is Plot[Sin[x], {x, 0, 2Pi}, Frame -> True, FrameTicks -> {None, True, True, None}] will give you the required ticks and numerical values all the best yehuda > Well, I guess it's not actually a bug, but . . . > FrameTicks -> {Automatic, Automatic, None, None} puts tick marks AND numerical labels on bottom and left edges. > FrameTicks -> {None, Automatic, Automatic, None} puts tick marks and numerical labels on left edge, tick > marks and NO NUMERICAL LABELS on top edge. > How can I put the same Automatic numbers that would > have been created for the bottom edge, on the top edge? ==== Subject: Re: FrameTicks bug Option 1: Make up a Table of the ticks using the information in the Ticks Help. Do you also want the small intermediary tick marks? Then don't forget to include them. Do you want ticks with no values on the opposite sides? Then make up tables for them. Option 2: Needs[DrawGraphics`DrawingMaster`] Plot[Sin[x], {x, 0, 10}, Frame -> True, FrameTicks -> {None, CustomTicks[Identity, {-1, 1, 0.5, 5}], CustomTicks[Identity, {0, 10, 2, 5}], None}, ImageSize -> 500]; That creates the big (labeled) and small (unlabeled) ticks on the left and top sides, but no ticks on the right and bottom sides. If you want unlabeled ticks on the right and bottom use... Plot[Sin[x], {x, 0, 10}, Frame -> True, FrameTicks -> {CustomTicks[Identity, {0, 10, 2, 5}, CTNumberFunction -> ( &)], CustomTicks[Identity, {-1, 1, 0.5, 5}], CustomTicks[Identity, {0, 10, 2, 5}], CustomTicks[Identity, {-1, 1, 0.5, 5}, CTNumberFunction -> ( &)]}, ImageSize -> 500]; David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Well, I guess it's not actually a bug, but . . . FrameTicks -> {Automatic, Automatic, None, None} puts tick marks AND numerical labels on bottom and left edges. FrameTicks -> {None, Automatic, Automatic, None} puts tick marks and numerical labels on left edge, tick marks and NO NUMERICAL LABELS on top edge. How can I put the same Automatic numbers that would have been created for the bottom edge, on the top edge? ==== Subject: Re: FrameTicks bug plt=Plot[x,{x,0,1}, Frame->True, Axes->False, DisplayFunction->Identity]; If you want the tick labels on the top but not the bottom: Show[plt, FrameTicks->(FrameTicks/. AbsoluteOptions[plt])[[{3,2,1,4}]], DisplayFunction->$DisplayFunction]; If you want tick labels on both top and bottom: Show[plt, FrameTicks->(FrameTicks/. AbsoluteOptions[plt])[[{1,2,1,4}]], DisplayFunction->$DisplayFunction]; Bob Hanlon > ==== > Subject: FrameTicks bug Well, I guess it's not actually a bug, but . . . > FrameTicks -> {Automatic, Automatic, None, None} puts tick marks AND numerical labels on bottom and left edges. > FrameTicks -> {None, Automatic, Automatic, None} puts tick marks and numerical labels on left edge, tick > marks and NO NUMERICAL LABELS on top edge. > How can I put the same Automatic numbers that would > have been created for the bottom edge, on the top edge? ==== Subject: Planetarium.m Hello all, before some years i have buyed the MathSource CD which contains a notebook (0206_132), which required required the package Planetarium.m (which could be downloaded in Wolfram's site). It should be a demonstration of some functions of Terry Robb's Scientific Astronomer, although the description claimed that no graphics function would be available. Is this demo package coded wrong, so that it is not only unreadable for users, but also for the Mathematica kernel itself? (Then the goal to be a demonstration is not really achieved). But it's more probably that i have overseen something, for example the right command for reading Planetarium.m. Can someone help? Michael Taktikos ==== Subject: Complement replacement > hi > in the list: > pp=Table[Random[Integer, {1, 1000}], {i, 1000}]; > how could i know which numbers from 1 to 1000 does not exist in the > pp List. > but without using: > Complement[Table[i,{i,1000}],pp] > Here is a possibility that is faster than Complement on my machine for this particular problem: missing[list_] := Module[{len = Length[list], a}, a = Range[len]; a[[list]] = 0; DeleteCases[a, 0]] The above function scales as O(n), and Complement scales as O(n log n) due to sorting, so for large enough input my function ought to be faster. For example, with the data: n = 10^6; pp = Table[Random[Integer, {1, n}], {n}]; We have the following comparison: In[26]:= c1=Complement[Range[Length[pp]],pp];//Timing c2=missing[pp];//Timing Out[26]= {1.594 Second,Null} Out[27]= {0.625 Second,Null} Out[28]= True A further slight increase in speed ought to be possible if you compile DeleteCases[a,0] since a is a list of integers. For example, define deletezeros as: deletezeros = Compile[{{a, _Integer, 1}}, Module[{b, len, j}, len = Length[a]; b = a; j = 0; Do[ If[a[[i]] =!= 0, b[[++j]] = a[[i]]], {i, len}]; Take[b, j]]] Then, replacing DeleteCases[a,0] with deletezeros[a] approximately doubles the speed. Carl Woll Wolfram Research ==== Subject: Re: Re: Wrong Integral result for a Piecewise function Actually, we can do even better (I did not try it earlier as I did not believe it would work but it does). f[x_] = Limit[FullSimplify[Integrate[ UnitStep[2*y + 2*z - (t - 1)]* UnitStep[t - 2*y - 2*z], {y, 0, 1}, {z, 0, 1}]], t -> x] Piecewise[{{(1/8)*(9 - 2*x), Inequality[3, LessEqual, x, Less, 4]}, {(1/8)*(x - 5)^2, Inequality[4, LessEqual, x, Less, 5]}, {x^2/8, Inequality[0, LessEqual, x, Less, 1]}, {(1/8)*(2*x - 1), Inequality[1, LessEqual, x, Less, 2]}, {(1/8)*(-2*x^2 + 10*x - 9), Inequality[2, LessEqual, x, Less, 3]}}] It seems that this is the way to get the right answer using the UnitStep approach. Andrzej Kozlowski Chiba, JAPAN > If you try instead > g[x_] = FullSimplify[Integrate[UnitStep[2y + 2z - (x - 1)] > *UnitStep[x > - 2y - 2z], {y, 0, 1}, {z, 0, 1}]] (this takes a while to complete) then Plot[g[x],{x,0,5}] looks correct. Also In[18]:= > NIntegrate[g[x], {x, 0, 5}] Out[18]= > 1. In[19]:= > Integrate[g[x], {x, 0, 5}] Out[19]= > 1 This, of course, is the pre-Mathematica 5 way of doing these things > which only goes to confirm that progress is not always > improvement ;-) Andrzej Kozlowski > Chiba, Japan > In version 5.1.0 this gives an answer which is correct everywhere >> except >> at the integer points: >> In[1]:= >> g[x_] = Integrate[UnitStep[2*y + 2*z - x + 1]*UnitStep[x - 2*y - >> 2*z], >> {y, 0, 1}, {z, 0, 1}] >> Out[1]= >> (1/8)*(2*(-1 + (-2 + x)*x)*UnitStep[1 - x] + 2*(-2 + x)^2*UnitStep >> [2 - x] >> + 2*(-2 + x)*x*UnitStep[2 - x] - 2*(7 + (-6 + x)*x)*UnitStep[3 - >> x] - (-5 >> + x)*UnitStep[5 - x]*(6 - 2*x + (-1 + x)*UnitStep[-3 + x]) + >> UnitStep[4 - >> x]*(-4*UnitStep[1 - x/2] + (-4 + x)*(4 - 2*x + x*UnitStep[-2 + >> x])) + (-3 >> + x)*UnitStep[3 - x]*(2 - 2*x + (1 + x)*UnitStep[-1 + x]) - 2*(-2 >> + x^2)*UnitStep[-x] - (-4 + x^2)*UnitStep[2 - x, x]) >> In[2]:= >> Reduce[g[x] != If[x == 3, 3/8, 0] + If[0 < x < 1, x^2/8, 0] + If[1 >> <= x <= >> 2, (1/8)*(-1 + 2*x), 0] + If[2 < x < 3, (1/8)*(-9 + 10*x - 2*x^2), 0] >> + If[Inequality[3, Less, x, LessEqual, 4], (1/8)*(9 - 2*x), 0] + If >> [4 < x >> < 5, (1/8)*(-5 + x)^2, 0]] >> Out[2]= >> x == 0 || x == 1 || x == 2 || x == 3 >> This is always a potential pitfall when the answer is returned as >> a sum of >> UnitStep terms, e.g. as UnitStep[-x] + (x + 1)*UnitStep[x]. It is >> likely >> that the value at x = 0 will be incorrect, because both terms are >> equal to >> 1 at zero, not just one of them. Thus Limit[g[x], x -> 0] is >> correct but >> g[0] isn't. >> Maxim Rytin >> m.r@inbox.ru > This suggests a simple but rather curious remedy. First define gg > as above: gg[x_] = FullSimplify[Integrate[UnitStep[2y + 2z - (x - 1)]*UnitStep[x > - 2y - 2z], {y, 0, 1}, {z, 0, 1}]]; and then define g simply as: g[x_] := Limit[gg[t], t -> x] This now gives correct answers though the more explicit answer > given by the other methods seems clearly preferable. Andrzej Kozlowski Chiba, Japan > ==== Subject: Re: superscripts Would this work??? Cell[BoxData[RowBox[{Symbolize, [,TagBox[StyleBox[RowBox[{a,StyleBox[0,FontSize->8, FontVariations->{CompatibilityType->Superscript}]}]], NotationBoxTag, TagStyle->NotationTemplateStyle], ]}]], Input] Mike >> If it is possible, I would like to ask the following two questions: >> (1) All superscripts in Mathematica default to exponents. I would like >> to have the superscript become another label as with subscripts. The >> reason I wish to do this is that many of matrix elements that I use >> have a superscript ZERO. Consequently, Mathematica produces UNITY for >> all such elements. > Hi Stan, You may find the following thread very interesting: _Assigning to > superscripted variables_, started by Dave Snead on May 13 2002, 6:08 am ad/thread/32416898239235a3/7d6339bd44a24e42?q=superscript&rnum=7&hl=en#7d633 9 b > d44a24e42 (especially the use of the package Utilities`Notation` and/or the Tensor > Calculus package). > (2) I would like to be able to provide information to Mathematica that >> helps avoid a log singularity in a definite integral. This is best >> described in my attachment. >> [Contact the author to obtain the attachment - moderator] >Please, send me your attachment. /J.M. > ==== Subject: Re: FrameTicks bug > Well, I guess it's not actually a bug, but . . . > FrameTicks -> {Automatic, Automatic, None, None} puts tick marks AND numerical labels on bottom and left edges. > FrameTicks -> {None, Automatic, Automatic, None} puts tick marks and numerical labels on left edge, tick > marks and NO NUMERICAL LABELS on top edge. > How can I put the same Automatic numbers that would > have been created for the bottom edge, on the top edge? > First get the ticks for bottom and left side: ft = Take[FrameTicks /. AbsoluteOptions[pl = Block[{$DisplayFunction = #1&}, Plot[Sin[x], {x, 0, 2*Pi}, Frame -> True]]],2]; and then show the plot with the ticks duplicated (for top and right): Show[pl, FrameTicks -> Join[#1, #1]&[ft]]]; -- http://people.freenet.de/Peter_Berlin/ ==== Subject: Re: FrameTicks bug Hi Anthony, Well, I guess it's not actually a bug, but . . . FrameTicks -> {Automatic, Automatic, None, None} This is surely semantics .... In the sense that Ticks are printed, there is no bug. However, since the options for Ticks (which is what the FrameTicks ends up using) include specifications for a label, then it is clearly a bug. > puts tick marks AND numerical labels on bottom and left edges. > FrameTicks -> {None, Automatic, Automatic, None} puts tick marks and numerical labels on left edge, tick marks and NO > NUMERICAL LABELS on top edge. > How can I put the same Automatic numbers that would have been created > for the bottom edge, on the top edge? Apparently, a user-defined Ticks function works just fine, so you can use FrameTicks->{None, Automatic, myTicks, None} However, rather than define myTicks, I'd suggest using Mark Caprio's CustomTicks package (http://library.wolfram.com/infocenter/MathSource/5599/) which makes it as easy as Plot[x^2, {x, -2, 2}, FrameTicks -> {None, Automatic, LinTicks[-2, 2], None}]; Dave.