> Because it depends on how you get there. For instance, > Limit[(1-x)^(1/x), x->0] gives 1/E, while Limit[(1-x)^(1/x^2), x->0] > gives 0. You are correct. However, that last limit claim is somewhat deceptive. Based on it, one might conclude, incorrectly, that the direction of approach to 0 is immaterial. Note that, although Limit[(1-x)^(1/x^2), x->0, Direction-> -1] yields 0, Limit[(1-x)^(1/x^2), x->0, Direction-> +1] yields Infinity. Thus, when Mathematica says that Limit[(1-x)^(1/x^2), x->0] is 0, it is making a hidden assumption of direction of approach. > In fact, you can construct similar examples in which > 1^Infinity = anything you like. Well, yes, as long as you don't like negative values. David > 1^[Infinity] => Indeterminate, unexpected. Naively expected: 1. > > For which reason(s) is 1^[Infinity] defined as Indeterminate? -- ==== > >>Because it depends on how you get there. For instance, >>Limit[(1-x)^(1/x), x->0] gives 1/E, while Limit[(1-x)^(1/x^2), x->0] >>gives 0. > You are correct. However, that last limit claim is somewhat deceptive. > Based on it, one might conclude, incorrectly, that the direction of > approach to 0 is immaterial. Note that, although > Limit[(1-x)^(1/x^2), x->0, Direction-> -1] yields 0, > Limit[(1-x)^(1/x^2), x->0, Direction-> +1] yields Infinity. > Thus, when Mathematica says that Limit[(1-x)^(1/x^2), x->0] is 0, it is > making a hidden assumption of direction of approach. Actually it seems you've discovered a bug in Limit. If we allow complex values, then Limit[(1-x)^(1/x^2), x->0, Direction-> +1] should be 0, which is evident from the graph of Abs[(1-x)^(1/x^2)]. Mathematica gives Infinity for Limit[Abs[(1-x)^(1/x^2)], x->0, Direction-> +1] as well. If we don't allow complex values, then Limit[(1-x)^(1/x^2), x->0, Direction-> +1] can't exist at all (even as Infinity or -Infinity). >>In fact, you can construct similar examples in which >1^Infinity = anything you like. > > Well, yes, as long as you don't like negative values. David Some of my favorite numbers are negative, such as (1 + x I)^(I Pi/Log[1 + x I]) = -1 Note that this has the form 1^Infinity as x->0. >1^[Infinity] => Indeterminate, unexpected. Naively expected: 1. >>For which reason(s) is 1^[Infinity] defined as Indeterminate? > ==== All I can say about my last post on this topic is: Nevermind. I was looking at the graph of Abs[(1-x)^(1/x^2)] near 1 instead of 0. Aargg. Mathematica's answers (Infinity) for both Limit[Abs[(1-x)^(1/x^2)], x->0, Direction-> +1] and Limit[Abs[(1-x)^(1/x^2)], x->0, Direction-> +1] are correct. --- Selwyn > > Actually it seems you've discovered a bug in Limit. If we allow complex > values, then Limit[(1-x)^(1/x^2), x->0, Direction-> +1] should be 0, > which is evident from the graph of Abs[(1-x)^(1/x^2)]. Mathematica gives > Infinity for Limit[Abs[(1-x)^(1/x^2)], x->0, Direction-> +1] as well. If > we don't allow complex values, then Limit[(1-x)^(1/x^2), x->0, > Direction-> +1] can't exist at all (even as Infinity or -Infinity). ==== Dear members, There is an equivalent of Or (||) to be used with patterns: Alternative (|). I couldn't find an equivalent for And (&&) and Not (!). I don't know if they don't exist, or it is just that I can`t find them. ==== Is there a possibility that Mathematica gives me a function to given pairs of values? In other words: I have several pairs like {1, 2}, {2, 4}, {3, 9}. And I what like to know the corresponding function (what is in this example obviously f[x]=x^2). TIA Sven ==== Ok, I thank you for your help. The values {1,2},{2,4},{3,9} were only an example. And the 2 in the first pair should actually be an 1.... But this doesn't matter since you understood the problem. I also knew the problem, that I have to give something like a model for the function... Unfortunatly, I have no idea, how the function looks like. I thought, that Matematica is maybe able to compare these values with known functions (and combinings of them). But it looks like there is no way... Anyway, the real pairs of values are: {{0.5,3.45058},{1,5.3352},{1.5,6.9328},{1.8,7.306},{1.9,7.2962},{2, 7.2163},{2.5,5.8877},{3,3.7307},{3.4464,2.0000},{4,0.6928},{5,0.04575}} At first, I thougt that the function is something like the density function of the standard normal distribution... Thus, I tried the following function (and lots of modifications): (a + e*x)(2[Pi] Exp[0.5 (c*x^d + b)^2]) Unfortunatly, the result wasn't very accurate... I know, that this is not longer a problem a Mathematica, but I just wanted to let you know... Anyway, I thank you all for your help. Sven ==== Sven It may be obvious to you that 1^2=2 (surely not ?), 2^2=4 and 3^2=9, but to me your pairs look like they were derived from the function f[x]=x+x! (that is Factorial[x], not an x followed by an expression of surprise). But I could not find a Mathematica function to support my argument - or to support yours for that matter. I guess you could try Fit and its related functions ... Mark Westwood > > Is there a possibility that Mathematica gives me a function to given > pairs of values? > In other words: I have several pairs like {1, 2}, {2, 4}, {3, 9}. And I > what like to know the corresponding function (what is in this example > obviously f[x]=x^2). ==== I have a lot of different files, containing data (already formatted for mathematica) which is supposed to be imported as tables with names derived from the original file name. Problem being: Scan[(StringDrop[#,-4]=Import[#];DeleteFile[#])&,FileNameList] only gives StringDrop protected..... What I also do not like about the above command is, that the data files are deleted. How can I get what I would like to have? Bettina ==== Does anybody know how to install Postscript Fonts Type 1, using Mathematica 4.2 under Mac OSX 10.1.5? -- Daniel AMIGUET Avenue du L.8eman 59 CH 1005 Lausanne +41 21/728 0730 ==== Not sure what you're asking here. Installation of type 1 fonts has nothing to do with Mathematica. You put them in your Library:Fonts folder. A shot in the dark: I have a feeling your difficulty might be related to the FontType option. Open the Option Inspector, show option values for Global, and look under Formatting Options > Font Options > PrivateFontOptions. Change the setting of FontType to Outline. --- Selwyn Hollis slhollis@mac.com > Does anybody know how to install Postscript Fonts Type 1, using > Mathematica 4.2 under Mac OSX 10.1.5? ==== Dear members, For long calculations, sometimes a message appears, telling the program is out of disk space. The kernel shuts down. I searched the archives for the list, and found a number of postings on this issue, but none of them solved my problem. I have 1.7 G of free space in my internal hard disk, but also have 22 G free in my Buslink USB external hard drive. I would like to use this space for the calculations. In Windows98 (control panel, system, performance, advanced, virtual memory) there is an option to use this space, but it seems like its either internal disk or external disk. I didn't dare to change it to the external disk, because I received a scary message from W98 (you may not be able to restart your computer). If I change the settings, will I be able to restart the PC? Is there a way to use both disks succesively? Is there a way to use the external one, but without restarting the computer? Is it possible to do this directly from Mathematica? , I have 64 MB of RAM. If I increase this, do you think I will get an improvemente in Mathematica performance? I thought it used the hard disk as a regular procedure, and not because the computer ran out of RAM. ----- Original Message ----- 1) Getting as much real memory as possible. It is pretty cheap right now. 2) Checking your calculations to see if you can reduce the amount of memory > used. Depending on what it is that is eating up all the memory, the participants > in this group may be able to help you with (2). Gareth P.S. I note also that you didn't tell us how much real memory you have. If > you don't have much, so that your calculation starts using hard disk space > immediately, it might turn out that with real memory, your calculation does > not take as long as you thought... > For long calculations, sometimes a message appears, telling the program > is out of disk space. The kernel shuts down. > > I searched the archives for the list, and found a number of postings on > this issue, but none of them solved my problem. > > I have 1.7 G of free space in my internal hard disk, but also have 22 G > free in my Buslink USB external hard drive. I would like to use this > space for the calculations. > > In Windows98 (control panel, system, performance, advanced, virtual > memory) there is an option to use this space, but it seems like its > either internal disk or external disk. I didn't dare to change it to > the external disk, because I received a scary message from W98 (you may > not be able to restart your computer). > > If I change the settings, will I be able to restart the PC? Is there a > way to use both disks succesively? Is there a way to use the external > one, but without restarting the computer? Is it possible to do this > directly from Mathematica? ==== , I don't know about Windows in particular (never use it), but while you can use hard disk space as temporary memory space, it is much slower than using real memory. And using a disk on a slow external connection such as USB will be even slower. You calculation may never finish! I suggest: 1) Getting as much real memory as possible. It is pretty cheap right now. 2) Checking your calculations to see if you can reduce the amount of memory used. Depending on what it is that is eating up all the memory, the participants in this group may be able to help you with (2). Gareth P.S. I note also that you didn't tell us how much real memory you have. If you don't have much, so that your calculation starts using hard disk space immediately, it might turn out that with real memory, your calculation does not take as long as you thought... > For long calculations, sometimes a message appears, telling the program > is out of disk space. The kernel shuts down. > > I searched the archives for the list, and found a number of postings on > this issue, but none of them solved my problem. > > I have 1.7 G of free space in my internal hard disk, but also have 22 G > free in my Buslink USB external hard drive. I would like to use this > space for the calculations. > > In Windows98 (control panel, system, performance, advanced, virtual > memory) there is an option to use this space, but it seems like its > either internal disk or external disk. I didn't dare to change it to > the external disk, because I received a scary message from W98 (you may > not be able to restart your computer). > > If I change the settings, will I be able to restart the PC? Is there a > way to use both disks succesively? Is there a way to use the external > one, but without restarting the computer? Is it possible to do this > directly from Mathematica? ==== Why does Mod[3.5,0.1] gives 0.1? However, 3.5 - 0.1 Quotient[3.5,0.1] gives 0 -Souvik ==== I have a problem with DigitQ and letterQ I would like for a string to yeild True when run with DigitQ if the the string looks like this: {1,2} and false if it looks like this: Right now both strings return False because of { , }. So, if there were anyway to include the charecters {, }, and , into the DigitQ 0-9 list temperarelly that would work, but I am sure there is Charles ==== Charles Does Apply[And, Map[DigitQ, list]] do what you want ? Mark Westwood > > I have a problem with DigitQ and letterQ I would like for a string to > yeild True when run with DigitQ if the the string looks like this: > {1,2} > and false if it looks like this: > Right now both strings return False because of { , }. So, if there > were anyway to include the charecters {, }, and , into the > DigitQ 0-9 list temperarelly that would work, but I am sure there is > Charles ==== I have been having difficulty using the distribution packages. In a package I created, I can't get the CDF function to evaluate, and I can't figure out the problem. Below I have included a very simple (and useless) package I created that runs in to the same problem. I want to use the numerical value of the CDF for a normal distribution. When I call TestFunction, this is the output: Global`glibb`Private`CDF[Global`glibb`Private`NormalDistribution[0, 1], -1] Global`glibb`Private`CDF[Global`glibb`Private`NormalDistribution[0., 1.], -1.] Calls to CDF return similar outputs in my useful packages. The package I am currently working with was originally written for Mathematica 2.0, and I am trying to update it to work with 4.0. I was told that all the functions were tested thoroughly in the 2.0 implementation and worked fine. TEST PACKAGE: file glibb.m ------------------------------------------------------------ BeginPackage[`glibb`, {Statistics`ContinuousDistributions`} ] glibb::usage = glibb is a test package. TestFunction::usage = TestFunction[]. Begin[`Private`] TestFunction[] := Module[{alpha,alpha2}, alpha = CDF[NormalDistribution[0,1], -1]; Print[alpha]; alpha2 = N[CDF[NormalDistribution[0,1],-1]]; Print[alpha2]; ]; End[ ] EndPackage[ ] ------------------------------------------------------------- Aaron ==== Here's a start: pairs = {{1, 1}, {2, 4}, {3, 9},{4,16}} ClearAll[f, g] g[{a_, b_}] := (f[a] = b) g /@ pairs ?? f That defines f only at the points in your list of ordered pairs. If you want to identify a polynomial (or other) fit, you could use Fit, if you have in mind what the functional form might be. Unfortunately, it might not do what you expect! You can also use Interpolation to define f on the range of values you have. expr1 = Fit[pairs, {1, x}, x] expr3 = Fit[pairs, {1, x, x^2}, x] expr4 = Fit[pairs, {1, x, x^2, x^3}, x] expr5 = Fit[pairs, {1, x, x^2, x^3, x^4}, x] expr6 = Interpolation[pairs] Plot[Evaluate[# - x^2], {x, 1, 3}] & /@ {expr1, expr2, expr3, expr4, expr5, expr6[x]}; Treat -----Original Message----- ==== You're getting the error because you're trying to set StringDrop (of an argument) equal to something. The name of a variable is a Symbol, not a string, so you need to change the result of StringDrop into a Symbol, and then set that symbol equal to the result of Import. If you don't want the files deleted, for heaven's sake take DeleteFile out of the command! Scan[(name = Symbol@StringDrop[#, -4]; Evaluate@name =.; Evaluate[name] = Import[#, Text]) &, FileNameList] (I was testing using Text files.) Treat -----Original Message----- Bettina ==== >Is there a possibility that Mathematica gives me a function to given >pairs of values? >In other words: I have several pairs like {1, 2}, {2, 4}, {3, 9}. And I >what like to know the corresponding function (what is in this example >obviously f[x]=x^2). You have to give it a model to which to fit the data. Needs[Statistics`NonlinearFit`]; data = {{1,1},{2,4},{3,9}}; model = a*x^2+b*x+c; NonlinearFit[data, model, x, {a,b,c}]//Chop 1.*x^2 Bob Hanlon Chantilly, VA USA ==== >Why does Mod[3.5, 0.1] gives 0.1? > >However, >3.5 - 0.1 Quotient[3.5, 0.1] gives 0 Lack of precision because you used machine numbers. Mod[3.5, 0.1] 0.1 Mod[35/10, 1/10] 0 Mod[Rationalize[3.5], 0.1] 0. Mod[3.5, Rationalize[0.1]] 0. Bob Hanlon Chantilly, VA USA ==== expr = {1,2}; And @@ (DigitQ /@ (ToString /@ (ToExpression@expr))) True That works if all the strings you'll apply it to are in that list format. If not, then something like this works... expr1 = {1,2,; expr2 = {1,2,m; f[expr_] := (Intersection[#1, Characters[01234567890,{}]] == Union[#1] & )[Characters[expr]] f[expr1] f[expr2] True False Treat -----Original Message----- DigitQ 0-9 list temperarelly that would work, but I am sure there is Charles ==== As a follow up to David's example: Some students seem to think that lim n->0 (1+(1/n))n = 1. Their reasoning is this: When n->0, then 1+(1/n) -> 1. Now compute lim n->0 1 n = 1. This reasoning is just too simplistic. You have to deal with both of the n's in the expression (1+(1/n))n at the same time -- i.e., the y both go to infinity simultaneously; you can't figure that one goes to infinity and then the other goes to infinity. In fact, if you let the other one go to infinity first, you'd get a different answer: lim n->0 (1+0.0000001)n = 0. So evidently the answer lies somewhere between 1 and 0. Easy methods do not work on this problem. The correct answer is a number that is near 2.718. (It's an important constant, known to mathematicians as e = aprrox. 2.718281828...) There's no way you could get that by an easy method. Jonathan Rockmann mtheory@msn.com ----- Original Message ----- In other words, if f(x) approaches 1 and g(x) increases without bound, f(x)^g(x) need not approach 1. Consider the limit of (1+1/x)^x as x increases without bound, for example. David ==== The default setting for FractionBox seems to be to have fonts smaller than the rest of the fonts in the cell. How can I globally set the fonts to be the same in a FractionBox as the default font size for the cell (which I know how to set but cannot figure out what to do with FractionBox). I do not want to manually change each specific character on account of there being too many and also I have the default cell font size for print out different from working and wrapping a Stylebox[ , fontSize-> ] around a character seems to lock the fontsize and therefore messes up the way it looks when printed. thanks Mike ==== , I don't think there is a direct analog but it is easy to make up something that is equivalent. The following will return True for all Symbols that are not x or y. test1 := MatchQ[#1, _Symbol] && !MatchQ[#1, x | y] & test1 /@ {1, Sin[x], x, y, z} {False, False, False, False, True} David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Sender: steve@smc.vnet.net Approved: Steven M. Christensen , Moderator ==== Is there some easy way of changing a certain character in a NumberedEquation cell without doing it manually? eg. Where ever D (in italics) appears in an equation it is replaced by D (bold, no italics). thanks Mike ==== Aaron, When I add the line <Is there a possibility that Mathematica gives me a function to given >pairs of values? In other words: I have several pairs like {1, 2}, {2, >4}, {3, 9}. And I what like to know the corresponding function (what >is in this example obviously f[x]=x^2). There are infinitely many possible functions that can generate the particular list in your example. Specifically f[x]:={x, x^2 +(x-1)(x-2)(x-3)g[x]} for any g[x] will work. For Mathematica to determine a specific function it would be necessary to make assumptions about g[x]. Any assumptions made are certain to be wrong for some problem. If you know the relationship between the numbers is expressed by a polynomial, then you could use InterpolatingPolynomial In[1]:=InterpolatingPolynomial[Table[{n, n^2}, {n, 3}], x] // Simplify Out[1]=x^2 ==== OK! I found I could add this statement after BeginPackage, rather than adding the other two contexts: PrependTo[$ContextPath, #] & /@ {Statistics`Common`DistributionsCommon`, Statistics`NormalDistribution`} But, of course, it really should be BeginPackage[glibb`, {Statistics`Common`DistributionsCommon`, Statistics`NormalDistribution`}] To find out where a set of functions are really coming from, you can load the packages you THINK they're in and then find out where they really are, like this: < Is there a possibility that Mathematica gives me a function to given > pairs of values? > In other words: I have several pairs like {1, 2}, {2, 4}, {3, 9}. And I > what like to know the corresponding function (what is in this example > obviously f[x]=x^2). TIA > Sven Is that really obvious? How about: In[7]:= Rationalize[Fit[{{1, 2}, {2, 4}, {3, 9}}, {x, x^2, x^3}, {x}]] Out[7]= 3*x - (3*x^2)/2 + x^3/2 In[8]:= % /. {{x -> 1}, {x -> 2}, {x -> 3}} Out[8]= {2, 4, 9} Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ ==== No there isn't one. In fact the only sensible cases in which you might wish to use a And for patterns seem to be the cases where either all patterns arise from pure functions by means of _? (PatternTest) or where at most one pattern does not arise in that way. In the first case it is clearly simpler to use ordinary && as in: In[13]:= Cases[Range[10], _?(PrimeQ[#1] && #1 > 3 & )] Out[13]= {5, 7} the other case is when you mix a true pattern and a pattern test. e.g: IIn[14]:= Cases[{0,1,1.5,2},_Integer?(#>1&)] Out[14]= {2} I can't think of any way you could try to combine two patterns that do not arise from pure functions, so I don't think such an And would be very useful. A Not for patterns might be perhaps somewhat useful, but it can always be constructed by means of the MatchQ predicate: In[15]:= Cases[{0,1,1.5,2},_?(!MatchQ[#,_Integer]&)] Out[15]= {1.5} Dear members, There is an equivalent of Or (||) to be used with patterns: Alternative > (|). I couldn't find an equivalent for And (&&) and Not (!). I don't > know if they don't exist, or it is just that I can`t find them. > > Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ ==== I think the Help Browser is only approximately correct on this point. Although it says: Mod[m, n] is equivalent to m - n Quotient[m, n] this is only really always true for exact numbers. Thus in your case: In[21]:= Mod[Rationalize[3.5],Rationalize[0.1]] Out[21]= 0 and same for In[22]:= Rationalize[3.5]-Rationalize[0.1 ]Quotient[Rationalize[3.5],Rationalize[0.1]] Out[22]= 0 For inexact numbers this relationship holds almost everywhere. I suspect this is due to the fact that arithmetic in Mathematica is in fact binary. Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ Why does Mod[3.5,0.1] gives 0.1? However, > 3.5 - 0.1 Quotient[3.5,0.1] gives 0 > -Souvik ==== Is there a publicly available Mathematica 3.0 notebook that implements the Primes is in P? http://www.msnbc.com/news/792126.asp ==== Anybody can help me? I have any program in Mathematica 3.0, I am changing to Mathematica 4.0, but I have problem in this point, with NDSolve in this equation !(* RowBox[{ RowBox[{EXERUIDO, =, RowBox[{NDSolve, [, RowBox[{ RowBox[{{, RowBox[{ RowBox[{ RowBox[{ SuperscriptBox[y, [Prime], MultilineFunction->None], [, x, ]}], ==, ((coefac[x] ((1 - alfaam/alfaem)) + alfaam etas)/(y[x] /. sinalfinal))}], ,, (y[0] == 0)}], }}], ,, y, ,, ({x, 0, Z})}], ]}]}], ;}]) NDSolve::ndnum: Encountered non-numerical value for a derivative at !(x) == !(0.`). NDSolve::ndnum: Encountered non-numerical value for a derivative at !(x) == !(0.`). In Mathematica 3.0 resolve this equation without problem. I dont know what can I do to resolve this problem. S.8ergio Milo ==== Good luck with a function like 1 + Sin[x], which has infinitely many roots but never changes sign! Or Sin[1/x], which has infinitely many roots converging on 0, but no limit for the function at 0. Or... still worse... 1 + Sin[1/x], which has BOTH problems. -----Original Message----- In[2]:= points = Cases[g, Line[x_] -> x, Infinity][[1]]; We make a list of the signs of the y values: In[3]:= signs = Sign /@ Transpose[Cases[g, Line[x_] -> x, Infinity][[ 1]]][[2]]; We find the points where the sign changes: In[4]:= positions = Position[Rest[signs]*Rest[RotateRight[signs]], -1] Out[4]= {{27}, {51}, {74}, {101}, {126}, {149}, {177}, {200}, {226}, {252}} We make a list of starting points for FindRoot: In[5]:= starts = First[Transpose[Extract[points, positions]]] Out[5]= {2.7825096162536145, 6.080185995733974, 8.787418231655966, 12.198138489619575, 15.464841498197309, 18.61672099859868, 21.92859710988888, 24.46767425065356, 27.840417480532142, 31.139545383515845} We find the roots: In[6]:= (FindRoot[Sin[x] == 0, {x, #1}, WorkingPrecision -> 20] & ) /@ starts Out[6]= {{x -> 3.141592653589793238462643383255068`20}, {x -> 6.283185307179586476925286766538051`20}, {x -> 9.424777960769379715387930149825109`20}, {x -> 12.566370614359172953850573533079026`20}, {x -> 15.707963267948966192313216916378673`20}, {x -> 18.849555921538759430775860299681079`20}, {x -> 21.991148575128552669238503682979946`20}, {x -> 25.132741228718345907701147066183302`20}, {x -> 28.274333882308139146163790449476032`20}, {x -> 31.415926535897932384626433832775678`20}} This question has been asked frequently so you can find various approaches, including this one, in the archives. Of course there is no guarantee. For very complex functions you may well miss some roots. The situation can become a lot more complicated if your equation has multiple roots. Andrzej Can Mathematica find (localize) ALL roots of non-polynomial equation eq[x]==0 on a given segment x in [a,b], a,b=Real?? (for example Sin[x]==0, for 0.1 ==== > I have a problem with DigitQ and letterQ I would like for a string to > yeild True when run with DigitQ if the the string looks like this: > {1,2} > and false if it looks like this: > Right now both strings return False because of { , }. So, if there > were anyway to include the charecters {, }, and , into the > DigitQ 0-9 list temperarelly that would work, but I am sure there is > Charles > Try this Dresser[string_String]:= Module[{x},x=StringReplace[string, ->]; If[Or[StringTake[x,1]!=(,StringTake[x,-1]!=)],Return[False]]; Apply[And, NumberQ[#]&/@ToExpression[{<>StringDrop[StringDrop[x,1],-1]<>}]]] This function trims blanks. It will do a bit more than you require -- return True for (#,#,#,...#). However you can easily make the fix to limit it to two. Additionally, you can quickly modify the code to get the numbers back. The setup will also let you easily modify it to integers, positive integers, Numerics, etc. Richard Palmer ==== I would like to plot this function : 1 n(e)=______________ Exp[b(e-mu)]+1 and get a graphic like that, with the letters n(e) ^ | | 1| ____________ | | | | |_______________ _____________________ e mu / how can i do it, i specified SetAttributes{b,constant} etc ... but it don't work please help me, i use mathematica 4 ==== Hail physics-friend! The Tick command enables you to label ticks on axes. Here: Module[ { mu = .1, b = 100 }, Plot[1/(1 + Exp[-b (mu - e)]) , {e, 0, 2 mu} , Ticks -> {{{mu, mu}}, Range[0, 1, .2]} , AxesLabel -> {e, n(e)} ] ] Your ascii picture looks nice too! Note there are no axis-arrows provided with above plot, look for them in some recent message in this group. Bye, Borut > I would like to plot this function : > 1 > n(e)=______________ > Exp[b(e-mu)]+1 and get a graphic like that, with the letters n(e) > ^ > | > | > 1| ____________ > | > | > | | > |_______________ _____________________ e > mu / how can i do it, i specified > SetAttributes{b,constant} etc ... but it don't work please help me, i use mathematica 4 ==== Here's a similar solution that averages points on either side of sign changes, to get better initial starts for FindRoot: g = Plot[Sin[x], {x, 0.1, 10.1*Pi}, DisplayFunction -> Identity]; points = First@Cases[g, Line[x_] -> x, Infinity]; signs = Sign /@ points[[All, 2]]; positions = Union[#, # + 1] &@Flatten@Position[Rest[signs*RotateRight@signs], -1] starts = 1/2Plus @@@ Partition[points[[positions, 1]], 2] x /. (FindRoot[Sin[x] == 0, {x, #1}] &) /@ starts {27, 28, 51, 52, 74, 75, 101, 102, 126, 127, 149, 150, 177, 178, 200, 201, 226, 227, 252, 253} {3.09198, 6.26091, 9.13801, 12.5265, 15.7722, 18.9688, 22.0933, 24.8161, 28.1494, 31.4348} {3.14159, 6.28319, 9.42478, 12.5664, 15.708, 18.8496, 21.9911, 25.1327, 28.2743, 31.4159} Treat -----Original Message----- In[2]:= points = Cases[g, Line[x_] -> x, Infinity][[1]]; We make a list of the signs of the y values: In[3]:= signs = Sign /@ Transpose[Cases[g, Line[x_] -> x, Infinity][[ 1]]][[2]]; We find the points where the sign changes: In[4]:= positions = Position[Rest[signs]*Rest[RotateRight[signs]], -1] Out[4]= {{27}, {51}, {74}, {101}, {126}, {149}, {177}, {200}, {226}, {252}} We make a list of starting points for FindRoot: In[5]:= starts = First[Transpose[Extract[points, positions]]] Out[5]= {2.7825096162536145, 6.080185995733974, 8.787418231655966, 12.198138489619575, 15.464841498197309, 18.61672099859868, 21.92859710988888, 24.46767425065356, 27.840417480532142, 31.139545383515845} We find the roots: In[6]:= (FindRoot[Sin[x] == 0, {x, #1}, WorkingPrecision -> 20] & ) /@ starts Out[6]= {{x -> 3.141592653589793238462643383255068`20}, {x -> 6.283185307179586476925286766538051`20}, {x -> 9.424777960769379715387930149825109`20}, {x -> 12.566370614359172953850573533079026`20}, {x -> 15.707963267948966192313216916378673`20}, {x -> 18.849555921538759430775860299681079`20}, {x -> 21.991148575128552669238503682979946`20}, {x -> 25.132741228718345907701147066183302`20}, {x -> 28.274333882308139146163790449476032`20}, {x -> 31.415926535897932384626433832775678`20}} This question has been asked frequently so you can find various approaches, including this one, in the archives. Of course there is no guarantee. For very complex functions you may well miss some roots. The situation can become a lot more complicated if your equation has multiple roots. Andrzej Can Mathematica find (localize) ALL roots of non-polynomial equation eq[x]==0 on a given segment x in [a,b], a,b=Real?? (for example Sin[x]==0, for 0.1 ==== Perhaps it's worth recalling that probably the simplest method seems to be the one posted some time ago by Adam Strzebonski In[1]:= f[x_] = Normal[Sin[10.1*Pi*x] + O[x]^100]; In[2]:= 10.1*Pi*Select[x /. NSolve[f[x] == 0, x], Im[#1] == 0 && 0.1/(Pi*10.1) <= #1 <= 1 & ] Out[2]= {31.41492328081239, 28.274379350873716, 25.132740219910605, 21.991148587034512, 18.84955591555759, 15.707963269122267, 12.56637061424962, 9.424777960775808, 6.283185307178523, 3.141592653590188} The problem is of course that it is difficult to know how long a Taylor series to take, whehter one has found all the roots and how accurate the answers are, although with careful analysis this may be a useful approach. Andrzej Kozlowski > Here's a similar solution that averages points on either side of sign > changes, to get better initial starts for FindRoot: g = Plot[Sin[x], {x, 0.1, 10.1*Pi}, DisplayFunction -> Identity]; > points = First@Cases[g, Line[x_] -> x, Infinity]; > signs = Sign /@ points[[All, 2]]; > positions = > Union[#, # + 1] &@Flatten@Position[Rest[signs*RotateRight@signs], > -1] > starts = 1/2Plus @@@ Partition[points[[positions, 1]], 2] > x /. (FindRoot[Sin[x] == 0, {x, #1}] &) /@ starts {27, 28, 51, 52, 74, 75, 101, 102, 126, 127, 149, 150, > 177, 178, 200, 201, 226, 227, 252, 253} {3.09198, 6.26091, 9.13801, 12.5265, 15.7722, 18.9688, 22.0933, 24.8161, > 28.1494, 31.4348} {3.14159, 6.28319, 9.42478, 12.5664, 15.708, 18.8496, 21.9911, 25.1327, > 28.2743, 31.4159} Treat -----Original Message----- > Sent: Friday, August 09, 2002 4:18 AM In your example, yes. Here is one way (adapted from a slightly different problem in Stan Wagon's Mathematica in Action) We make use of Mathematica's ability to plot graphs: > In[1]:= > g = Plot[Sin[x], {x, 0.1, 10.1*Pi}, DisplayFunction - Identity]; We make a list of all the coordinates of the points represented on the > graph. In[2]:= > points = Cases[g, Line[x_] -> x, Infinity][[1]]; We make a list of the signs of the y values: In[3]:= > signs = Sign /@ Transpose[Cases[g, Line[x_] -> x, Infinity][[ > 1]]][[2]]; We find the points where the sign changes: In[4]:= > positions = Position[Rest[signs]*Rest[RotateRight[signs]], > -1] Out[4]= > {{27}, {51}, {74}, {101}, {126}, {149}, {177}, {200}, {226}, > {252}} We make a list of starting points for FindRoot: In[5]:= > starts = First[Transpose[Extract[points, positions]]] Out[5]= > {2.7825096162536145, 6.080185995733974, 8.787418231655966, > 12.198138489619575, 15.464841498197309, 18.61672099859868, > 21.92859710988888, 24.46767425065356, 27.840417480532142, > 31.139545383515845} > We find the roots: In[6]:= > (FindRoot[Sin[x] == 0, {x, #1}, WorkingPrecision - 20] & ) /@ starts Out[6]= > {{x -> 3.141592653589793238462643383255068`20}, > {x -> 6.283185307179586476925286766538051`20}, > {x -> 9.424777960769379715387930149825109`20}, > {x -> 12.566370614359172953850573533079026`20}, > {x -> 15.707963267948966192313216916378673`20}, > {x -> 18.849555921538759430775860299681079`20}, > {x -> 21.991148575128552669238503682979946`20}, > {x -> 25.132741228718345907701147066183302`20}, > {x -> 28.274333882308139146163790449476032`20}, > {x -> 31.415926535897932384626433832775678`20}} > This question has been asked frequently so you can find various > approaches, including this one, in the archives. Of course there is no > guarantee. For very complex functions you may well miss some roots. The > situation can become a lot more complicated if your equation has > multiple roots. Andrzej > Can Mathematica find (localize) ALL roots of non-polynomial equation > eq[x]==0 > on a given segment x in [a,b], a,b=Real?? > (for example Sin[x]==0, for 0.1 Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ ==== Better yet, avoid unnecessary contortions: f[x_] = Normal[Sin[x] + O[x]^100]; Plot[f[x] - Sin[x], {x, 0.1, 10Pi}, PlotRange -> All]; Select[x /. NSolve[f[x] == 0, x], Im[#1] == 0 && 0.1 ? #1 ? 10.1Pi &] {3.14159, 6.28319, 9.42478, 12.5664, 15.708, 18.8496, 21.9911, 25.1327, 28.2744, 31.4156} The Plot should tell us whether we have enough terms in the Series. Treat -----Original Message----- Out[2]= {31.41492328081239, 28.274379350873716, 25.132740219910605, 21.991148587034512, 18.84955591555759, 15.707963269122267, 12.56637061424962, 9.424777960775808, 6.283185307178523, 3.141592653590188} The problem is of course that it is difficult to know how long a Taylor series to take, whehter one has found all the roots and how accurate the answers are, although with careful analysis this may be a useful approach. Andrzej Kozlowski > Here's a similar solution that averages points on either side of sign > changes, to get better initial starts for FindRoot: g = Plot[Sin[x], {x, 0.1, 10.1*Pi}, DisplayFunction -> Identity]; > points = First@Cases[g, Line[x_] -> x, Infinity]; > signs = Sign /@ points[[All, 2]]; > positions = > Union[#, # + 1] &@Flatten@Position[Rest[signs*RotateRight@signs], > -1] > starts = 1/2Plus @@@ Partition[points[[positions, 1]], 2] > x /. (FindRoot[Sin[x] == 0, {x, #1}] &) /@ starts {27, 28, 51, 52, 74, 75, 101, 102, 126, 127, 149, 150, > 177, 178, 200, 201, 226, 227, 252, 253} {3.09198, 6.26091, 9.13801, 12.5265, 15.7722, 18.9688, 22.0933, 24.8161, > 28.1494, 31.4348} {3.14159, 6.28319, 9.42478, 12.5664, 15.708, 18.8496, 21.9911, 25.1327, > 28.2743, 31.4159} Treat -----Original Message----- > Sent: Friday, August 09, 2002 4:18 AM In your example, yes. Here is one way (adapted from a slightly different problem in Stan Wagon's Mathematica in Action) We make use of Mathematica's ability to plot graphs: > In[1]:= > g = Plot[Sin[x], {x, 0.1, 10.1*Pi}, DisplayFunction - Identity]; We make a list of all the coordinates of the points represented on the > graph. In[2]:= > points = Cases[g, Line[x_] -> x, Infinity][[1]]; We make a list of the signs of the y values: In[3]:= > signs = Sign /@ Transpose[Cases[g, Line[x_] -> x, Infinity][[ > 1]]][[2]]; We find the points where the sign changes: In[4]:= > positions = Position[Rest[signs]*Rest[RotateRight[signs]], > -1] Out[4]= > {{27}, {51}, {74}, {101}, {126}, {149}, {177}, {200}, {226}, > {252}} We make a list of starting points for FindRoot: In[5]:= > starts = First[Transpose[Extract[points, positions]]] Out[5]= > {2.7825096162536145, 6.080185995733974, 8.787418231655966, > 12.198138489619575, 15.464841498197309, 18.61672099859868, > 21.92859710988888, 24.46767425065356, 27.840417480532142, > 31.139545383515845} > We find the roots: In[6]:= > (FindRoot[Sin[x] == 0, {x, #1}, WorkingPrecision - 20] & ) /@ starts Out[6]= > {{x -> 3.141592653589793238462643383255068`20}, > {x -> 6.283185307179586476925286766538051`20}, > {x -> 9.424777960769379715387930149825109`20}, > {x -> 12.566370614359172953850573533079026`20}, > {x -> 15.707963267948966192313216916378673`20}, > {x -> 18.849555921538759430775860299681079`20}, > {x -> 21.991148575128552669238503682979946`20}, > {x -> 25.132741228718345907701147066183302`20}, > {x -> 28.274333882308139146163790449476032`20}, > {x -> 31.415926535897932384626433832775678`20}} > This question has been asked frequently so you can find various > approaches, including this one, in the archives. Of course there is no > guarantee. For very complex functions you may well miss some roots. The > situation can become a lot more complicated if your equation has > multiple roots. Andrzej > Can Mathematica find (localize) ALL roots of non-polynomial equation > eq[x]==0 > on a given segment x in [a,b], a,b=Real?? > (for example Sin[x]==0, for 0.1 Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ ==== hi, I wanted to know if anybody has tried simulating DSSS.. or tracking code DSSS ...any spread spectrum simulation on mathematica. please let me know if any pointers are available on the net. thanks __________________________________________________ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com ==== Dear friends I wish to build a function to obtain from a list (i.e.:) list = {a1, a2, a3, a4}; and output like this: {{f[a2, a1, a2]}, {f[a3, a1, a2], f[a3, a2, a3]}, {f[a4, a1, a2], f[a4, a2, a3], f[a4, a3, a4]}} This following function work fine function1[tau1_] := Table[Table[ f[Extract[tau1, j + 1], Extract[tau1, i], Extract[tau1, i + 1]], {i, 1, Length[tau1] - Length[tau1] + j}], {j, 1, Length[tau1] - 1}] function1[list] // TableForm but I think is not so eleghant. I will appreciate any help to build a more effecient and eleghant solution Guillermo Sanchez ==== > I have solved the problem with the fonts. It required modifying the Format > Type Styles at the end of the style sheet. > > So my only remaining question now is, are there any known problems associated > with modifying these fonts to Arial, or sharing problems if I save a notebook > in Arial then pass it on to someone who uses the default style sheet? The answer to your question depends on two criteria: 1) Does the notebook you're sharing contain a private copy of your modified style sheet, or is the notebook configured to use a shared version of your modified style sheet? If the notebook contains a private copy, then the front end on the recipients machine will attempt to use the font settings as you specified. If not, then the notebook will use the shared default style sheet on his or her system, which means your font settings will not be used. 2) If the answer to (1) was private copy, then the next question is whether Arial is installed on the end user's system. Bear in mind that Arial started out as a Microsoft-specific TrueType font that was supposed to provide a sans-serifed font akin to Helvetica. There is a possibility that Mac users might not have this font available on their system. The same is especially true for Unix users, whose X servers may not support TrueType fonts or whose system administrators have not installed Arial and configured the X server to use it. -- ==== Dave's answer also works in patterns Cases[{1, Sin[x], x, y, z}, _?(MatchQ[#, _Symbol] && !MatchQ[#, x | y]&)] {z} Bob Hanlon Chantilly, VA USA >I don't think there is a direct analog but it is easy to make up something >that is equivalent. The following will return True for all Symbols that >are not x or y. > >test1 := MatchQ[#1, _Symbol] && !MatchQ[#1, x | y] & > >test1 /@ {1, Sin[x], x, y, z} >{False, False, False, False, True} > >David Park >djmp@earthlink.net >http://home.earthlink.net/~djmp/ >Dear members, > >There is an equivalent of Or (||) to be used with patterns: Alternative >(|). I couldn't find an equivalent for And (&&) and Not (!). I don't >know if they don't exist, or it is just that I can`t find them. > > ==== > Does anyone know how to change the default (ASCII?) Input font which is > used by Mathematica on every Input line to something easier for me to > read like, Arial? > > After getting some excellent advice on working with style sheets, I have > been able to configure the front end substantially but am still unable > to change what is, however universal, still a difficult font for me to > read. Front end style sheets include prototypes for Mathematica format types like StandardForm and InputForm. You will find these settings near the bottom of the style sheet notebook. If a cell style is configured to use a format type, then the settings in the format type protoptype cell will override the settings in the cell style itself. For example, suppose you change the FontFamily option value in Input to Arial. By default, the Input style uses the StandardForm format type. The prototype for StandardForm includes the FontFamily option with its value set to Courier. To ensure that Arial is used, you need to change the FontFamily option in the StandardForm prototype cell. Bear in mind that this will cause all cell styles, such as Output, that use StandardForm to inherit this font as well. Another caveat for you is that some format types (InputForm and OutputForm, for example), assume a monospaced font is being used to display text. It is probably not a good idea to use Arial for these format types. Choose a monospaced sans serifed font like Lucida Console instead. -- ==== SM> In Mathematica 3.0 resolve this equation without problem. Sure not. Mathematica 3.0 returns exactly the same warning messages as Mathematica 4.0 does. Mathematica got stymied because to get to a sensible output you must 1) use, in NDSolve, not {x, 0, Z} but something like {x, 0, 1} so Mathematica's algorithms could know over which range they must work and calculate the stepsize(s) required 2) define coefac[x], alfaam, alfaem, etas, sinalfinal in terms of constants and/or functions of x and/or y[x] to get Mathematica the opportunity to plunge into numeric values How could you recognize your own bug? Just pay attention to those ominous words non-numerical value ;-) In fact, you asked Mathematica kinda to find the numeric value of the expression x without defining x. You cannot do it, Mathematica cannot do it, nobody can do it. Best wishes, Vladimir =============================================================== Vladimir Bondarenko Mathematical Director Symbolic Testing Group Web : http://www.CAS-testing.org/ http://www.beautyriot.com/ (teamwork) http://www.ohaha.com/ (teamwork) Voice: (380)-652-447325 Mail : 76 Zalesskaya Str, Apt 29, Simferopol, Crimea, Ukraine P.S. Only the owners of www.maplesoft.com domain name can access this site I will keep the site open from August 11 till August 21, 2002. VB ==== , Ted Ersek has a package on MathSource called Rootsearch that is pretty decent at finding roots. Here is how it works on your examples. << Enhancements`Rootsearch` RootSearch[Sin[x] + 1 == 0, {x, -30, 30}] {{x -> -26.7035}, {x -> -20.4204}, {x -> -14.1372}, {x -> -7.85398}, {x -> -1.5708}, {x -> 4.71239}, {x -> 10.9956}, {x -> 17.2788}, {x -> 23.5619}, {x -> 29.8451}} The last example is of course more difficult because there are an infinite number of roots clustered around zero. However, if we want to find the roots in a given range: roots = RootSearch[1 + Sin[1/x] == 0, {x, 0.005, 0.01}] Length[roots] {{x -> 0.00501275}, {x -> 0.00517577}, {x -> 0.00534975}, {x -> 0.00553582}, {x -> 0.00573531}, {x -> 0.00594972}, {x -> 0.00618077}, {x -> 0.0064305}, {x -> 0.00670126}, {x -> 0.00699582}, {x -> 0.00731747}, {x -> 0.00767012}, {x -> 0.00805848}, {x -> 0.00848826}, {x -> 0.00896648}, {x -> 0.00950179}} 16 1 + Sin[1/x] /. roots {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.} Plot[1 + Sin[1/x], {x, 0.005, 0.01}]; Not too bad. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ equation In your example, yes. Here is one way (adapted from a slightly different problem in Stan Wagon's Mathematica in Action) We make use of Mathematica's ability to plot graphs: In[1]:= g = Plot[Sin[x], {x, 0.1, 10.1*Pi}, DisplayFunction -> Identity]; We make a list of all the coordinates of the points represented on the graph. In[2]:= points = Cases[g, Line[x_] -> x, Infinity][[1]]; We make a list of the signs of the y values: In[3]:= signs = Sign /@ Transpose[Cases[g, Line[x_] -> x, Infinity][[ 1]]][[2]]; We find the points where the sign changes: In[4]:= positions = Position[Rest[signs]*Rest[RotateRight[signs]], -1] Out[4]= {{27}, {51}, {74}, {101}, {126}, {149}, {177}, {200}, {226}, {252}} We make a list of starting points for FindRoot: In[5]:= starts = First[Transpose[Extract[points, positions]]] Out[5]= {2.7825096162536145, 6.080185995733974, 8.787418231655966, 12.198138489619575, 15.464841498197309, 18.61672099859868, 21.92859710988888, 24.46767425065356, 27.840417480532142, 31.139545383515845} We find the roots: In[6]:= (FindRoot[Sin[x] == 0, {x, #1}, WorkingPrecision -> 20] & ) /@ starts Out[6]= {{x -> 3.141592653589793238462643383255068`20}, {x -> 6.283185307179586476925286766538051`20}, {x -> 9.424777960769379715387930149825109`20}, {x -> 12.566370614359172953850573533079026`20}, {x -> 15.707963267948966192313216916378673`20}, {x -> 18.849555921538759430775860299681079`20}, {x -> 21.991148575128552669238503682979946`20}, {x -> 25.132741228718345907701147066183302`20}, {x -> 28.274333882308139146163790449476032`20}, {x -> 31.415926535897932384626433832775678`20}} This question has been asked frequently so you can find various approaches, including this one, in the archives. Of course there is no guarantee. For very complex functions you may well miss some roots. The situation can become a lot more complicated if your equation has multiple roots. Andrzej Can Mathematica find (localize) ALL roots of non-polynomial equation eq[x]==0 on a given segment x in [a,b], a,b=Real?? (for example Sin[x]==0, for 0.1 ==== Looks like we've been reinventing the wheel, folks. The package NumericalMath`IntervalRoots` has exactly what we need. < 20] Out: Interval[{0, 1.337913459004121`*^-18}, {0.06666864225044185`, 0.06666864225044247`}, {0.9903214888289147`, 0.9903214888289159`}, {1.4814395017188728`, 1.4814395017188753`}, {1.7387361933371692`, 1.7387361933371717`}] In: First /@ List @@ % Out: {0, 0.0666686, 0.990321, 1.48144, 1.73874} --------- Selwyn Hollis ==== I think you meant Limit[(1 + 1/n)^n, n -> Infinity], which is EXACTLY e. (1 + 1/n)n // Simplify 1+n -----Original Message----- infinity and then the other goes to infinity. In fact, if you let the other one go to infinity first, you'd get a different answer: lim n->0 (1+0.0000001)n = 0. So evidently the answer lies somewhere between 1 and 0. Easy methods do not work on this problem. The correct answer is a number that is near 2.718. (It's an important constant, known to mathematicians as e = aprrox. 2.718281828...) There's no way you could get that by an easy method. Jonathan Rockmann mtheory@msn.com ----- Original Message ----- In other words, if f(x) approaches 1 and g(x) increases without bound, f(x)^g(x) need not approach 1. Consider the limit of (1+1/x)^x as x increases without bound, for example. David ==== The other one is easy too, via L'Hospital's rule: Limit[(1 + 1/n)^n, n -> Infinity] == Exp[Limit[n Log[1 + 1/n], n -> Infinity]] == Exp[Limit[D[Log[1 + 1/n], n]/D[1/n, n], n -> Infinity]] == Exp[Limit[n/(1 + n), n -> Infinity]] == Exp[1] Lim -----Original Message----- As a follow up to David's example: Some students seem to think that lim n->0 (1+(1/n))n = 1. Their reasoning is this: When n->0, then 1+(1/n) -> 1. Now compute lim n->0 1 n = 1. This reasoning is just too simplistic. You have to deal with both of the n's in the expression (1+(1/n))n at the same time -- i.e., the y both go to infinity simultaneously; you can't figure that one goes to infinity and then the other goes to infinity. In fact, if you let the other one go to infinity first, you'd get a different answer: lim n->0 (1+0.0000001)n = 0. So evidently the answer lies somewhere between 1 and 0. Easy methods do not work on this problem. The correct answer is a number that is near 2.718. (It's an important constant, known to mathematicians as e = aprrox. 2.718281828...) There's no way you could get that by an easy method. Jonathan Rockmann mtheory@msn.com ----- Original Message ----- In other words, if f(x) approaches 1 and g(x) increases without bound, f(x)^g(x) need not approach 1. Consider the limit of (1+1/x)^x as x increases without bound, for example. David ==== MathGroup, I don't know why all of my symbols disappeared when I copied and pasted to the last post I submitted. My last post makes no sense. I bet you now I'm going to get a flood of comments about this. Sorry. It should say: A lot of people think that Lim n->00 (1+(1/n))^n 1. Their reasoning is this: When n->00, then 1+(1/n)->1. Now compute lim n->00 1^n =1. Of course, this reasoning is too simple. You have to deal with both of the n's in the expression (1+(1/n))^n at the same time -- i.e., they both go to infinity simutaneously: you can't figure that one goes to infinity and then the other goes to infinity. And in fact, if you let the other one go to infinity first, you'd get a different answer: lim n->00 (1+.0000001)^n=00. So evidently the answer lies somewhere between 1 and 00. That doesn't tell us much; my point here is that easy methods do not work on this problem. The correct answer is a number that is near 2.718281828 ... i.e. the constant e. There's no way you could get that by an easy method. Jonathan mtheory@msn.com ----- Original Message ----- 0. So evidently the answer lies somewhere between 1 and 0. Easy methods do not work on this problem. The correct answer is a number that is near 2.718. (It's an important constant, known to mathematicians as e = aprrox. 2.718281828...) There's no way you could get that by an easy method. Jonathan Rockmann mtheory@msn.com ----- Original Message ----- In other words, if f(x) approaches 1 and g(x) increases without bound, f(x)^g(x) need not approach 1. Consider the limit of (1+1/x)^x as x increases without bound, for example. David ==== No problems getting a bmp image into mathematica using import and assigning a name like g to it. Once the image is in (a displacement/deformation image created by Cosmos/Works in SolidWorks) I need to be able to generate some kind of table of (x,y,z) or (r, theta, phi) coordinates of the graph, and then interpolate the data into a harmonic function (In particular Bessel functions due to the nature of the geometry of the object being studied)...I am using Mathematica 4 and get lost...Been able to generate a Raster list, however whenever I try to manipulate this data I get errors, so obviously generating a raster is not the correct procedure...HELP!!! Jerry Mahabub ==== when trying to build (after first install) or rebuild the help index my system (Win XP) always hangs e.g. the build seems not to come to an end. In the task manager i see mathematica.exe consuming 99% of available processor time and using more and more memory. What can i do to get this index file built correctly ? Please help. ==== You have to somehow specify the values of your constants (unless you want to go to a 3D graphic). One possibility would be as follows In[1]:= n[e_,b_,mu_]:=1/(Exp[b(e-mu)]+1); In[2]:= Plot[n[e, b, mu] /. {b -> 1, mu -> 1}, {e, 0, 10}, AxesLabel -> {e, n(e)}, Epilog -> {Line[{{1, 0}, {1, n[1, 1, 1]}}], Text[mu, {0.91, -0.02}]}]; Tomas Garza Mexico City ----- Original Message ----- > ^ > | > | > 1| ____________ > | > | > | | > |_______________ _____________________ e > mu / how can i do it, i specified > SetAttributes{b,constant} etc ... but it don't work please help me, i use mathematica 4 ==== In a message dated 8/11/02 6:39:20 AM, remi.dumasNOSPAM@club-internet.fr >I would like to plot this function : > 1 >n(e)=______________ > Exp[b(e-mu)]+1 > >and get a graphic like that, with the letters > >n(e) > ^ > | > | >1| ____________ > | > | > | | > |_______________ _____________________ e > mu > / > >how can i do it, i specified >SetAttributes{b,constant} etc ... but it don't work > >please help me, i use mathematica 4 Needs[Graphics`Legend`]; Needs[Graphics`Arrow`]; 1/(Exp[b(e-mu)]+1); Rewrite the expression as 1/(Exp[b*mu(e/mu-1)]+1); % == %% // Simplify True In order to Plot the normalized function you must provide one or more specific values for the product b*mu With[{btm =4, edmMax = 3}, Plot[1/(Exp[btm(edm-1)]+1), {edm,0,edmMax}, AxesLabel-> {ToString[TraditionalForm[e/mu]], n(e}}, PlotStyle -> Hue[2/3], Epilog -> { Arrow[{.9*edmMax,0}, {1.07*edmMax,0}, HeadCenter->.25], Arrow[{0,.9}, {0,1.1}, HeadCenter->.25]}, PlotRange -> {{0,1.07*edmMax},{0,1.1}}]]; For multiple values With[{btmMin = -1,btmMax =4,edmMax = 3,n = 6}, Plot[Evaluate[ Table[1/(Exp[btm(edm-1)]+1), {btm,btmMin, btmMax, (btmMax-btmMin)/(n-1)}]], {edm,0,edmMax}, AxesLabel-> {ToString[TraditionalForm[e/mu]], n(e}}, PlotStyle -> Table[Hue[(btm-btmMin)/(btmMax-btmMin+3)], {btm,btmMin,btmMax, (btmMax-btmMin)/(n-1)}], PlotLegend-> Table[btm, {btm,btmMin,btmMax, (btmMax-btmMin)/(n-1)}], LegendPosition->{.85,-.35}, LegendLabel->b*mu =, Epilog -> { Arrow[{.9*edmMax,0}, {1.07*edmMax,0}, HeadCenter->.25], Arrow[{0,.9}, {0,1.1}, HeadCenter->.25]}, PlotRange -> {{0,1.07*edmMax},{0,1.1}}, ImageSize -> 400]]; Just for laughs : With[{btmMin = -4,btmMax =4,edmMax = 2,n = 600}, Plot[Evaluate[ Table[1/(Exp[btm(edm-1)]+1), {btm,btmMin, btmMax, (btmMax-btmMin)/(n-1)}]], {edm,0,edmMax}, AxesLabel-> {ToString[TraditionalForm[e/mu]], n(e}}, PlotStyle -> Table[Hue[(btm-btmMin)/(btmMax-btmMin+3)], {btm,btmMin,btmMax, (btmMax-btmMin)/(n-1)}], Epilog -> { Arrow[{.9*edmMax,0}, {1.07*edmMax,0}, HeadCenter->.25], Arrow[{0,.9}, {0,1.1}, HeadCenter->.25]}, PlotRange -> {{0,1.07*edmMax},{0,1.1}}, ImageSize -> 400]]; Bob Hanlon Chantilly, VA USA ==== Have you tried the option inspector? You have there the possibility to change the font for a cell, a notebook or any selection: Format | OptionInspector | FormattingOptions | FontOptions. BTW, I tried Arial, but I found it more difficult to read.... Tomas Garza Mexico City ----- Original Message ----- > Jonathan > mtheory@msn.com ==== Assuming that you are using StandardForm for input, you'll probably want to change that form's font family. Edit the style sheet (I suggesting importing a private copy), then scroll down the sheet to FormatTypeStyles. Select the Standard Form cell and change the font to whatever you want. All StandardForm cells in your notebook will change. Hope this helps. Tom Burton ==== In terms of Mathematica this can be expressed as the difference between the following: In[1]:= Limit[Limit[(1 + y/n)^m, n -> Infinity], m -> Infinity] Out[1]= 1 In[2]:= Limit[(1 + y/Abs[x])^Abs[x], x -> Infinity] Out[2]= E^(I*Im[y] + Re[y]) The latter can of course be made equal to any number, real or complex except 0. So the whole original confusion relates to the meaning of 1^Infinity. If one interpreted it in the first sense (or simply as Limit[1^x,x->Infinity]) than the answer would have been 1. However, Mathematica adopts the more general approach, considering an expression involving Infinity to be Indeterminate unless all ways of representing it as a limit lead to the same answer. Of course one should not take this too strictly, for Mathematica gives: In[3]:= Infinity! Out[3]= Infinity although a pretty good case can be made for Sqrt[2Pi], see :) Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ > MathGroup, > ส > I don't know why all ofสmy symbols disappeared when I copied and pasted > toสmy last post.ส My last post makes no sense.ส I bet you now I'm going > to get a flood of comments about this.ส Sorry.ส > ส > It should say: > ส > A lot of people think that Lim n->00 (1+(1/n))^n =1.ส Their reasoning > is this:ส When n->00, then 1+(1/n)->1.ส Now compute lim n->00 1^n =1. > Of course, this reasoning is too simple.ส You have to deal with both of > the n's in the expression (1+(1/n))^n at the same time -- i.e., they > both go to infinity simutaneously: you can't figure that one goes to > infinity and then the other goes to infinity.ส And in fact, if you let > the other one go to infinity first, you'd get a different answer: lim > n->00 (1+.0000001)^n=00.ส So evidently the answer lies somewhere > between 1 and 00.ส That doesn't tell us much; my point here is that > easy methods do not work on this problem.ส The correct answer is a > number that is near 2.718281828... i.e. the constant e.ส There's no > way you could get that by an easy method. > ส > ส > Jonathan > mtheory@msn.com > ส > ส ----- Original Message ----- > Sent: Sunday, August 11, 2002 6:12 AM > ส > As a follow up to David's example: Some students seem to think that lim n->0 (1+(1/n))n = 1. Their > reasoning > is this: When n->0, then 1+(1/n) -> 1. Now compute lim n->0 1 n = 1. > This reasoning is just too simplistic. You have to deal with both of > the n's > in the expression (1+(1/n))n at the same time -- i.e., the > y both go to infinity simultaneously; you can't figure that one goes to > infinity > and then the other goes to infinity. In fact, if you let the other one > go > to infinity first, you'd get a different answer: lim n->0 > (1+0.0000001)n = > 0. So evidently the answer lies somewhere between 1 and > 0.ส Easy methods do not work on this problem. The correct answer is a number that is near 2.718. (It's an important > constant, > known to mathematicians as e = aprrox. 2.718281828...) There's no way > you > could get that by an easy method. Jonathan Rockmann > mtheory@msn.com ----- Original Message ----- > 0^[Infinity] => 0, as expected; > 0.9^[Infinity] => 0, as expected; > 2^[Infinity] => Infinity, as expected; > 1^[Infinity] => Indeterminate, unexpected. Naively expected: 1. > > For which reason(s) is 1^[Infinity] defined as Indeterminate? Presumably because, as a limit form, 1^Infinity is indeterminate. > In other words, if f(x) approaches 1 and g(x) increases without bound, > f(x)^g(x) need not approach 1. Consider the limit of (1+1/x)^x as x > increases without bound, for example. David ==== 1. If you just want a function that accurately hits your values use InterpolatingPolynomial[{yourdata}, x] 2. If you suspect that your data should nicely fit some distribution try the appropriate tests; see Statistics`HypothesisTests`. 3. If you have a smart idea about your data (e. g. your data represent temperature over time in a fermentation vessel) look for known (technical) functions that describe your type of process: You will probably find more input variables than just time. 4. Most interesting case: We know next to nothing about the real nature of the data but we want to find out in a very broad approach if the data coincide (more or less) with values of some known mathematical function. Wolfram Research gives us: http://functions.wolfram.com/ where they have 37,366 functions as of today..... It would be interesting to know if there is something like a FunctionFinder which - given some (learned) guesses may help us to get some clue about the nature of the process underlying our data by checking which phenomena these functions usually describe. Hopefully. Matthias Bode Sal. Oppenheim jr. & Cie. KGaA Koenigsberger Strasse 29 D-60487 Frankfurt am Main GERMANY Mobile: +49(0)172 6 74 95 77 Internet: http://www.oppenheim.de -----Ursprฬ.b9ngliche Nachricht----- Gesendet: Montag, 12. August 2002 09:34 An: mathgroup@smc.vnet.net Betreff: Re: Corresponding function to given values... Ok, I thank you for your help. The values {1,2},{2,4},{3,9} were only an example. And the 2 in the first pair should actually be an 1.... But this doesn't matter since you understood the problem. I also knew the problem, that I have to give something like a model for the function... Unfortunatly, I have no idea, how the function looks like. I thought, that Matematica is maybe able to compare these values with known functions (and combinings of them). But it looks like there is no way... Anyway, the real pairs of values are: {{0.5,3.45058},{1,5.3352},{1.5,6.9328},{1.8,7.306},{1.9,7.2962},{2, 7.2163},{2.5,5.8877},{3,3.7307},{3.4464,2.0000},{4,0.6928},{5,0.04575}} At first, I thougt that the function is something like the density function of the standard normal distribution... Thus, I tried the following function (and lots of modifications): (a + e*x)(2[Pi] Exp[0.5 (c*x^d + b)^2]) Unfortunatly, the result wasn't very accurate... I know, that this is not longer a problem a Mathematica, but I just wanted to let you know... Anyway, I thank you all for your help. Sven ==== The oldest algorithm for testing primes... the Sieve of Eratosthenes... is polynomial and deterministic. It's simply too slow to use, just like the one at the attachment. -----Original Message----- Sender: steve@smc.vnet.net Approved: Steven M. Christensen , Moderator ==== I just learned that K is a System` Symbol: Information[K] Context[K] I learned this due to an error message: Block[{K = 1}, Sum[j, {j, i}]] The same message can be generated by the following: K := 1 Sum[j, {j, i}] The message can be eliminated by Removing K: Remove[K] Block[{K = 1}, Sum[j, {j, i}]] K := 1 Sum[j, {j, i}] Surely, this is not intentional. --Mark. ==== The most recent entry in the archives for problems with Export are two years old. It is difficult to believe that I am the first person to try to export a figure in Adobe Illustrator format. What am I doing wrong? I am running Mathematica 4.0.1.0 under OS 9.2 on a Mac but the problem is the same on a PC. The program tmp = Plot[Sin[x], {x, 0, 2 Pi}]; Export[AIFormat.ai, tmp, AI] runs without error and creates the file named. Adobe Illustrator 10 cannot open the file. What is worse is that the program tmp = Plot[Sin[x], {x, 0, 2 Pi}]; Export[EpsFormat.eps, tmp, EPS] creates a file that crashes my system when trying to open it within Illustrator. ==== I cannot seem to work out how to extract a subset of information from an indexed variable (without generating a full list/matrix first). For example, suppose I define: b[1,3] = 3 b[2,3] = 7 b[2,4] = 5 And I then want to get the list of all DEFINED values of b[2,_], i.e., the result should be {7,5} Help appreciated! Gareth ========================================================== Dr. Gareth J. Russell Columbia University ========================================================== ==== > > I cannot seem to work out how to extract a subset of information from an > indexed variable (without generating a full list/matrix first). > > For example, suppose I define: > > b[1,3] = 3 > b[2,3] = 7 > b[2,4] = 5 > > And I then want to get the list of all DEFINED values of b[2,_], i.e., the > result should be {7,5} try DownValues[b] which gives you: {HoldPattern[b[1, 3]] :> 3, HoldPattern[b[2, 3]] :> 7, HoldPattern[b[2, 4]] :> 5} an approach using sparse matrices would be: bLst = {{1, 3} -> 3, {2, 3} -> 7, {2, 4} -> 5}; Position[bLst, {2, _} -> _] {{2}, {3}} bLst[[#1]][[1]][[2]] & /@ Position[bLst, {2, _} -> _] {7, 5} hope that helps oliver Oliver Ruebenkoenig, ==== I want to extract numerical values for the separate R, G and B channel intensities, on a pixel by pixel basis, for specific (limited) regions in color photos (JPEG, TIFF, whatever), on a Mac, preferably while I'm viewing the region I'm examining. Any readily available software to do this? Can PhotoShop Elements, GraphicConverter, or Mathematica do it? ==== http://www.wolfram.com/products/applications/digitalimage/ . Also, go to my web pages for additional resources on image processing with Mathematica. The lectures in the form of Mathematica notebooks, that accompany my course on DIP (ELE489) should be especially relevant. Bye, Mariusz =============================== Mariusz Jankowski University of Southern Maine mjkcc@usm.maine.edu http://www.usm.maine.edu/~mjkcc > I want to extract numerical values for the separate R, G and B channel > intensities, on a pixel by pixel basis, for specific (limited) regions > in color photos (JPEG, TIFF, whatever), on a Mac, preferably while I'm > viewing the region I'm examining. Any readily available software to do this? Can PhotoShop Elements, > GraphicConverter, or Mathematica do it? ==== In Mathematica, choose Color Selector... from the Input menu. That brings up the Mac Color Picker. Move your pointer anywhere on the screen and option-click. That will select the color. Now click Okay, and the RGBColor recipe will be pasted into the Mathematica front end. A similar thing works in GraphicConverter as well. Also, in OS X, instead of option-clicking, just press the option key. Hope that helps. ---- Selwyn Hollis > I want to extract numerical values for the separate R, G and B channel > intensities, on a pixel by pixel basis, for specific (limited) regions > in color photos (JPEG, TIFF, whatever), on a Mac, preferably while I'm > viewing the region I'm examining. > > Any readily available software to do this? Can PhotoShop Elements, > GraphicConverter, or Mathematica do it? ==== > Dear All: > I want to make an animation that simulate the Doppler Effect, just 2D > circles travel out one by one, and at the same time,the origin of the > wave also moves toward one direction. I have no idea to make the speed > of the wave origin and the speed of traveling wave independent.Is > sincerely bryan > This will get you started << Graphics` doppler = Table[Show[Graphics[{Table[{Red, PointSize[0.02], Point[{k/2, 0}], Yellow, Circle[{k/2, 0}, If[t < k + 1, 0, t - k - 0.5]]}, {k, 0, 20, 2}], Text[A, {0, -1}], Text[B, {10, -1}]} ], Background -> Black, Frame -> True, FrameTicks -> None, ImageSize -> 576, AspectRatio -> Automatic, PlotRange -> {{-20, 20}, {-20, 20}}], {t, 0, 20}]; Tim Brophy ==== I only wanted the algorithm out of intellectual curiousity. Jeff >The oldest algorithm for testing primes... the Sieve of Eratosthenes... >is polynomial and deterministic. It's simply too slow to use, just like >the one at the attachment. > > -----Original Message----- >Sent: Sunday, August 11, 2002 4:14 AM >Is there a publicly available Mathematica 3.0 notebook that implements >the Primes is in P? > >http://www.msnbc.com/news/792126.asp > ==== list will be down to new posts from Thursday August 15 to Monday night August 19. I will be out-of-town and unable to moderate during that time. Posts during that time will go out on Tuesday August 20. Steve Christensen Moderator ==== Infinity! == Product[k, {k, 1, Infinity}] == Infinity! == Product[k, {k, 1, Infinity}] == E^-(D[Sum[k^(-s), {k, 1, Infinity}], s] /. s -> 0) == E^-Derivative[1][Zeta][0] == Sqrt[2*Pi] In fact Mathematica can evaluate the last three equalities: In[12]:= E^(-(D[Sum[k^(-s), {k, 1, Infinity}], s] /. s -> 0)) == E^(-Derivative[1][Zeta][0]) == Sqrt[2*Pi] Out[12]= True while the first four are obvious, aren't they :) Andrzej > [Message also posted to: comp.soft-sys.math.mathematica] > In[2]:= > Limit[(1 + y/Abs[x])^Abs[x], x -> Infinity] > Out[2]= > E^(I*Im[y] + Re[y]) > The latter can of course be made equal to any number, real or complex > except 0. Even 0 is possible. Take y to be -Infinity. > So the whole original confusion relates to the meaning of > 1^Infinity. If one interpreted it in the first sense (or simply as > Limit[1^x,x->Infinity]) than the answer would have been 1. However, > Mathematica adopts the more general approach, considering an expression > involving Infinity to be Indeterminate unless all ways of representing > it as a limit lead to the same answer. Of course one should not take > this too strictly, for Mathematica gives: > In[3]:= > Infinity! > Out[3]= > Infinity This seems to be obviously correct. > although a pretty good case can be made for Sqrt[2Pi], see > :) Could you please explain how a pretty good case can be made for > Sqrt[2Pi]? I looked at the link, but could not see any way to make > a case for Infinity! being Sqrt[2Pi]. David -- > -------------------- http://NewsReader.Com/ -------------------- > Usenet Newsgroup Service Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ ==== >I wish to build a function to obtain from a list (i.e.:) > >list = {a1, a2, a3, a4}; > >and output like this: {{f[a2, a1, a2]}, >{f[a3, a1, a2], f[a3, a2, a3]}, >{f[a4, a1, a2], f[a4, a2, a3], f[a4, a3, a4]}} > >This following function work fine >function1[tau1_] := > Table[Table[ > f[Extract[tau1, j + 1], Extract[tau1, i], Extract[tau1, i + 1]], {i, 1, > Length[tau1] - Length[tau1] + j}], {j, 1, Length[tau1] - 1}] > >function1[list] // TableForm >but I think is not so eleghant. I will appreciate any help to build a > >more effecient and eleghant solution Table[f[list[[i+1]],list[[j]],list[[j+1]]],{i,Length[list]-1},{j,i}] Bob Hanlon Chantilly, VA USA ==== Selwyn, In the plot of Abs[(1-x)^(1/x^2)] that you mention, are you adjusting PlotRange to about PlotRange->{-4,5}? Jonathan mtheory@msn.com ----- Original Message ----- > You are correct. However, that last limit claim is somewhat deceptive. > Based on it, one might conclude, incorrectly, that the direction of > approach to 0 is immaterial. Note that, although > Limit[(1-x)^(1/x^2), x->0, Direction-> -1] yields 0, > Limit[(1-x)^(1/x^2), x->0, Direction-> +1] yields Infinity. > Thus, when Mathematica says that Limit[(1-x)^(1/x^2), x->0] is 0, it is > making a hidden assumption of direction of approach. Actually it seems you've discovered a bug in Limit. If we allow complex values, then Limit[(1-x)^(1/x^2), x->0, Direction-> +1] should be 0, which is evident from the graph of Abs[(1-x)^(1/x^2)]. Mathematica gives Infinity for Limit[Abs[(1-x)^(1/x^2)], x->0, Direction-> +1] as well. If we don't allow complex values, then Limit[(1-x)^(1/x^2), x->0, Direction-> +1] can't exist at all (even as Infinity or -Infinity). >>In fact, you can construct similar examples in which >1^Infinity = anything you like. > > Well, yes, as long as you don't like negative values. David Some of my favorite numbers are negative, such as (1 + x I)^(I Pi/Log[1 + x I]) = -1 Note that this has the form 1^Infinity as x->0. >1^[Infinity] => Indeterminate, unexpected. Naively expected: 1. >>For which reason(s) is 1^[Infinity] defined as Indeterminate? > ==== Guillermo, You could use something like this... function2[f_][list_] := MapThread[f @@ list[[#1]] & , {Flatten[Table[{i, j, j + 1}, {i, 2, Length[list]}, {j, 1, i - 1}], 1]}, 1] list = {a1, a2, a3, a4}; function2[f][list] {f[a2, a1, a2], f[a3, a1, a2], f[a3, a2, a3], f[a4, a1, a2], f[a4, a2, a3], f[a4, a3, a4]} David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Table[Table[ f[Extract[tau1, j + 1], Extract[tau1, i], Extract[tau1, i + 1]], {i, 1, Length[tau1] - Length[tau1] + j}], {j, 1, Length[tau1] - 1}] function1[list] // TableForm but I think is not so eleghant. I will appreciate any help to build a more effecient and eleghant solution Guillermo Sanchez ==== Is there any built-in function in Mathematica to compute inverse Laplace-Stieltjes transform (not inverse Laplace transform)? Lenin. ==== >I cannot seem to work out how to extract a subset of information from an >indexed variable (without generating a full list/matrix first). > >For example, suppose I define: > >b[1,3] = 3 >b[2,3] = 7 >b[2,4] = 5 > >And I then want to get the list of all DEFINED values of b[2,_], i.e., >the >result should be {7,5} Cases[DownValues[b], b[2, _], Infinity] Bob Hanlon Chantilly, VA USA ==== The following is possible: Assume Mathematica runs on machine A, then you can install Java (see JLink User Guide p.20) on machine B. In this way you can execute Java programs on machine B from machine A. Those programs may read data on machine B and transfer the data to machine A, automatically. Hermann Schmitt ----- Original Message ----- >?! The same applies to OpenWrite, Import, Export... >Justus no, Mathematica is (unfortunately) still not integrated enough with Java. > However, you can use a modified GetURL (originally from the JLink manual) and > write wrapper funcionts (like the NetIfiy below) around it. > I.e., you would have to put give users on your cluster > (local, and even proxied) access to an Apache server with the > filesystem where the Mathematica (or other files) live visible. E.g.: Netify[func_, url_String/;StringMatchQ[url,http:*], args___]:= > Block[{imp,tmp},tmp = GetURL[url]; imp=func[tmp,args];DeleteFile[tmp];imp ]; Netify[Get, http://www.mertig.com/mathdepot/misc/Isolate.m] > (* this is the same as calling Get[Isolate.m] if Isolate.m would be > lokal*) > (* this just displays a gif *) > (*Here the GetURL funcion: *) Needs[JLink`] > $ProxyHost=None; > $ProxyPort=8080; Options[GetURL]={ProxyHost :> $ProxyHost, > ProxyPort :> $ProxyPort}; > GetURL[url_String, opts___?OptionQ] := > JavaBlock[ > Module[{u, stream, numRead, outFile, buf, prxyHost, prxyPort}, > {prxyHost, prxyPort} = {ProxyHost, ProxyPort} /. > Flatten[{opts}] /. Options[GetURL]; > StartJava[]; > If[StringQ[prxyHost], > (* Set properties to force use of proxy. *) > SetInternetProxy[prxyHost, prxyPort] > ]; > u = JavaNew[java.net.URL, url]; > (* This is where the error will show up if the URL is not valid. > A Java exception will be thrown during openStream, which > causes the method to return $Failed. > *) > stream = u@openStream[]; > If[stream === $Failed, Return[$Failed]]; > buf = JavaNew[[B, 5000]; (* 5000 is an arbitrary buffer size *) > outFile = OpenTemporary[DOSTextFormat->False]; > While[(numRead = stream@read[buf]) > 0, #]& > /@ Take[Val[buf], numRead]]] > ]; > stream@close[]; > Close[outFile] (* Close returns the filename *) > ] > ] You can find other useful applications of GetURL at > http://www.mertig.com/neu/HTMLLinks/index_5.html One could even think of Netifying complete complex Mathematica packages and > applications. > Kind of ASP (application service provider). > Now, if someone pays me I'll set such a system up for them ... (of course > paying attention to license issues etc.; maybe the normal Mathematica license > should just fade out and in the near .Net-like webservice futer > there should be only webMathematica licenses anymore). > Rolf Mertig Mertig Consulting > http://www.mertig.com > ==== >Since we're working alot across networks we wonder if it is possible > cluster where we've Mathematica installed and another Unix machine at > another domain (provided the permissions are set). I.e., is it > possible by calling OpenRead[...] with the appropriate options to open >a file on another domain machine for reading ? Perhaps by using pipes >?! The same applies to OpenWrite, Import, Export... >Justus no, Mathematica is (unfortunately) still not integrated enough with Java. However, you can use a modified GetURL (originally from the JLink manual) and write wrapper funcionts (like the NetIfiy below) around it. I.e., you would have to put give users on your cluster (local, and even proxied) access to an Apache server with the filesystem where the Mathematica (or other files) live visible. E.g.: Netify[func_, url_String/;StringMatchQ[url,http:*], args___]:= Block[{imp,tmp},tmp = GetURL[url]; imp=func[tmp,args];DeleteFile[tmp];imp ]; Netify[Get, http://www.mertig.com/mathdepot/misc/Isolate.m] (* this is the same as calling Get[Isolate.m] if Isolate.m would be lokal*) (* this just displays a gif *) (*Here the GetURL funcion: *) Needs[JLink`] $ProxyHost=None; $ProxyPort=8080; Options[GetURL]={ProxyHost :> $ProxyHost, ProxyPort :> $ProxyPort}; GetURL[url_String, opts___?OptionQ] := JavaBlock[ Module[{u, stream, numRead, outFile, buf, prxyHost, prxyPort}, {prxyHost, prxyPort} = {ProxyHost, ProxyPort} /. Flatten[{opts}] /. Options[GetURL]; StartJava[]; If[StringQ[prxyHost], (* Set properties to force use of proxy. *) SetInternetProxy[prxyHost, prxyPort] ]; u = JavaNew[java.net.URL, url]; (* This is where the error will show up if the URL is not valid. A Java exception will be thrown during openStream, which causes the method to return $Failed. *) stream = u@openStream[]; If[stream === $Failed, Return[$Failed]]; buf = JavaNew[[B, 5000]; (* 5000 is an arbitrary buffer size *) outFile = OpenTemporary[DOSTextFormat->False]; While[(numRead = stream@read[buf]) > 0, /@ Take[Val[buf], numRead]]] ]; stream@close[]; Close[outFile] (* Close returns the filename *) ] ] You can find other useful applications of GetURL at http://www.mertig.com/neu/HTMLLinks/index_5.html One could even think of Netifying complete complex Mathematica packages and applications. Kind of ASP (application service provider). Now, if someone pays me I'll set such a system up for them ... (of course paying attention to license issues etc.; maybe the normal Mathematica license should just fade out and in the near .Net-like webservice futer there should be only webMathematica licenses anymore). Rolf Mertig Mertig Consulting http://www.mertig.com ==== Try (DownValues@b)[[All, 2]] Treat -----Original Message----- the result should be {7,5} Help appreciated! Gareth ========================================================== Dr. Gareth J. Russell Columbia University ========================================================== ==== What makes you think log(n)^(log log(n)) isn't dominated by a polynomial? Actually, it is, and the Sieve of Eratosthenes is polynomial just like I said. For instance, n^k dominates, for ANY k>0 (including 1): f[n_] := Log[n]^Log[Log[n]] Plot[{f[n]/Sqrt[n]}, {n, 1, 100000}] logF[n_] := Log[Log[n]]^2 Limit[logF[n]/Log[n], n -> Infinity] In my initial testing, the Sieve is far faster than the new algorithm, too. FAR faster. -----Original Message----- Actually that's not true. The Sieve of Eratosthenes has complexity log(n)^(log log(n)). The algorithm below is the first deterministic primality test known to be polynomial. Unfortunately, it still appears to be not practical. David > -----Original Message----- Is there a publicly available Mathematica 3.0 notebook that implements > the Primes is in P? http://www.msnbc.com/news/792126.asp ==== I've been using Mathematica for a while, but only recently for image processing. Suppose I have the following 2D intensity arrays: r={{a1,b1},{c1,d1}}; g={{a2,b2},{c2,d2}}; b={{a3,b3},{c3,d3}}; Now I'd like to combine them to produce a color image. color=Table[{r[[i,j]],g[[i,j]],b[[i,j]]},{i,2},{j,2}] This returns {{{a1, a2, a3}, {b1, b2, b3}}, {{c1, c2, c3}, {d1, d2, d3}}} which can be viewed as a color image with Graphics[Raster[color,ColorFunction->RGBColor]]//Show When the 2D arrays are large, combining them to form the color tensor as above is very time consuming. Surely there is a more efficient, clever way to combine them than my use of Table, right? Many thanks, Kevin Gross PS Any comments pro/con from users of the Digital Image Processing package are also welcome. ==== Kevin, in version 4.2 you can get approx a factor of 2 improvement by using Transpose[Transpose/@{r,g,b},{3,2,1}] This is currently the fastest method. However, if you are using an earlier version of Mathematica, the code above will unpack the data and therefore run slowly and eat up over 6 times more memory. In that case compile your code and you will also get close to a factor of 2 improvement. As an example, here is the code used in the DIP package versions 1.0 and 1.1: cplanarInt = Compile[{{x,_Integer,3}}, With[{d = Rest[Dimensions[x]}, Table[ x[[All, i, j]], {i, d[[1]]}, {j, d[[2]]}]]] and check your code to see if it is unpacking your data using either Developer`PackedArrayQ or ByteCount at intermediate steps in your calculations. -- =============================== Mariusz Jankowski University of Southern Maine mjkcc@usm.maine.edu 207-780-5580 .. I've been using Mathematica for a while, but only recently for image > processing. Suppose I have the following 2D intensity arrays: r={{a1,b1},{c1,d1}}; > g={{a2,b2},{c2,d2}}; > b={{a3,b3},{c3,d3}}; Now I'd like to combine them to produce a color image. color=Table[{r[[i,j]],g[[i,j]],b[[i,j]]},{i,2},{j,2}] This returns {{{a1, a2, a3}, {b1, b2, b3}}, {{c1, c2, c3}, {d1, d2, d3}}} which can be viewed as a color image with Graphics[Raster[color,ColorFunction->RGBColor]]//Show When the 2D arrays are large, combining them to form the color tensor as > above is very time consuming. Surely there is a more efficient, clever > way to combine them than my use of Table, right? Many thanks, Kevin Gross PS Any comments pro/con from users of the Digital Image Processing > package are also welcome. > ==== Something like this? Partition[Transpose[Flatten/@{r, g, b}], 2] -- > I've been using Mathematica for a while, but only recently for image > processing. Suppose I have the following 2D intensity arrays: > > r={{a1,b1},{c1,d1}}; > g={{a2,b2},{c2,d2}}; > b={{a3,b3},{c3,d3}}; > > Now I'd like to combine them to produce a color image. > > color=Table[{r[[i,j]],g[[i,j]],b[[i,j]]},{i,2},{j,2}] > > This returns {{{a1, a2, a3}, {b1, b2, b3}}, {{c1, c2, c3}, {d1, d2, d3}}} > > which can be viewed as a color image with > > Graphics[Raster[color,ColorFunction->RGBColor]]//Show > > When the 2D arrays are large, combining them to form the color tensor as > above is very time consuming. Surely there is a more efficient, clever > way to combine them than my use of Table, right? > > Many thanks, > > Kevin Gross > > PS Any comments pro/con from users of the Digital Image Processing > package are also welcome. > ==== > > The oldest algorithm for testing primes... the Sieve of Eratosthenes... > is polynomial and deterministic. It's simply too slow to use, just like > the one at the attachment. > > -----Original Message----- > > Is there a publicly available Mathematica 3.0 notebook that implements > the Primes is in P? > > http://www.msnbc.com/news/792126.asp The sieve method is not polynomial in the size of the number. Polynomial in the number, yes, but exponential in the size (logarithm) of the number. The algorithm recently making waves appears not to be practical as yet. conjecture of the authors, would possibly be viable as it would bring the suspected complexity exponent from 6 to 3. I imagine we will either hear of such improvements, or, at the least, get new pseudoprime algorithms, based on such variants of this new deterministic algorithm. Daniel Lichtblau Wolfram Research ==== By the way, Mathematica gets the following limit wrong: f[n_] := Log[n]^Log[Log[n]] Limit[f[n]/n, n -> Infinity] Infinity That limit is zero. For the Sieve to be polynomial, we only need the sequence to be BOUNDED (for some power of n in the denominator). Treat -----Original Message----- In my initial testing, the Sieve is far faster than the new algorithm, too. FAR faster. -----Original Message----- Actually that's not true. The Sieve of Eratosthenes has complexity log(n)^(log log(n)). The algorithm below is the first deterministic primality test known to be polynomial. Unfortunately, it still appears to be not practical. David > -----Original Message----- Is there a publicly available Mathematica 3.0 notebook that implements > the Primes is in P? http://www.msnbc.com/news/792126.asp ==== Oops! I couldn't reproduce that error. Here's a more complete proof that Log[n]^Log[Log[n]] is bounded by n, and the limit comes out right (0). f[n_] := Log[n]^Log[Log[n]] Plot[{f[n]/n}, {n, 1, 100000}] logF[n_] := Log[Log[n]]^2 Limit[Log[x]/Sqrt[x], x -> Infinity] Limit[Log[x]^2/x, x -> Infinity] Limit[Log[Log[n]]^2/Log[n], n -> Infinity] Limit[Exp[logF[n]]/n, n -> Infinity] Simplify[Exp[logF[n]] - f[n]] Limit[f[n]/n, n -> Infinity] -----Original Message----- What makes you think log(n)^(log log(n)) isn't dominated by a polynomial? Actually, it is, and the Sieve of Eratosthenes is polynomial just like I said. For instance, n^k dominates, for ANY k>0 (including 1): f[n_] := Log[n]^Log[Log[n]] Plot[{f[n]/Sqrt[n]}, {n, 1, 100000}] logF[n_] := Log[Log[n]]^2 Limit[logF[n]/Log[n], n -> Infinity] In my initial testing, the Sieve is far faster than the new algorithm, too. FAR faster. -----Original Message----- Actually that's not true. The Sieve of Eratosthenes has complexity log(n)^(log log(n)). The algorithm below is the first deterministic primality test known to be polynomial. Unfortunately, it still appears to be not practical. David > -----Original Message----- Is there a publicly available Mathematica 3.0 notebook that implements > the Primes is in P? http://www.msnbc.com/news/792126.asp ==== >>The sieve method is not polynomial in the size of the number. Polynomial in the number, yes, but exponential in the size (logarithm) of the number. Point taken, but polynomial complexity is often overrated anyway. I've had students tell me a problem can't be solved, simply because the algorithm is exponential. The Simplex algorithm for linear programs is exponential worst-case, but very fast in practice. Meanwhile, it is reputed that the FIRST polynomial time algorithm began with a prohibitive fixed setup cost: Let there be light. Treat -----Original Message----- > -----Original Message----- > > Is there a publicly available Mathematica 3.0 notebook that implements > the Primes is in P? > > http://www.msnbc.com/news/792126.asp The sieve method is not polynomial in the size of the number. Polynomial in the number, yes, but exponential in the size (logarithm) of the number. The algorithm recently making waves appears not to be practical as yet. conjecture of the authors, would possibly be viable as it would bring the suspected complexity exponent from 6 to 3. I imagine we will either hear of such improvements, or, at the least, get new pseudoprime algorithms, based on such variants of this new deterministic algorithm. Daniel Lichtblau Wolfram Research ==== How do I interpret the shading of the ListDensityPlot function? If I use something like: ListDensityPlot[Table[Sin[x]^2+Tan[y],{x,0,2*Pi},{y,0,2*Pi}]] 1. How can I interpret the shading with the z height of the function? Such an interpretation is easier if I use somthing like Plot3D which also labels the z (height) axis. 2. What if in my plot, i want to label demarcate my axes in multiples of Pi/2, such as 0, Pi/2, Pi, 3*Pi/2 and so on, rather than the conventional integer markings on the axes? == Muhammad Sabieh Anwar Oxford ==== Group, My original version of MathLink for Excel (MLX.xla) was for Excel 97, and It worked fine. Then I upgraded the package to Excel 2000 by unloading the macro from the Wolfram site. It continued working perfectly on my old environment (Windows 98 + Mathematica 4.1). But I recently upgraded to Mathematica 4.2 under Windows 2000; and when trying to load the macro (MLX.xla) for Excel2000, I got (in Excel 2000) the following message: This workbook contains a type of macro (Microsoft Excel version 4.0 macro) that cannot be disable nor signed. Therefore, this workbook cannot be opened under high security level. Does any one have any experience on this? Emilio Martin-Serrano ==== I have Mathematica 4.0, and would like to know how to use it to compute the bifurcation points of the simple logistic map. James rjmilazzo@aol.com ==== Well, this depends on the meaning of polynomial time. The running time of the Sieve of Eratosthenes is Sqt[n], but time complexity in the case of prime testing is always expressed in terms of log[n], so the sieve is considered exponential. I think the fastest deterministic test is the Rabin-Miller which is (I am not quite sure of that) Log[n]^2, but it depends on the unproved Generalized Riemann Hypothesis. Agrawal, Kayal and Saxena give a Log[n]^12 algorithm, but they also give a complete proof of its correctness. I have not read their paper but assuming that it is correct, the algorithm is certainly much faster than the sieve. On the other hand the GRH is most probably true... > The oldest algorithm for testing primes... the Sieve of Eratosthenes... > is polynomial and deterministic. It's simply too slow to use, just like > the one at the attachment. -----Original Message----- > Is there a publicly available Mathematica 3.0 notebook that implements > the Primes is in P? http://www.msnbc.com/news/792126.asp > ==== I have an onyx 3200 running irix 6.5.16 with 7.3 compiler versions 7.3 as soon as the math program is invoked it comes out with a segmentation fault. a file command on the core produced says that its a 'IRIX N32 core dump of mathkernel' any solutions please... shibily ==== Hallo, i have a function with 14 Parameters. For any combination i want to get a grafik. But i get the message that out of central memory. How can i solve this. Perhaps you can help me. I hope, you can understand me. My english is not so good. Frank ==== Check out http://www.calc101.com Jeff ----- Original Message ----- > (read backwards). Any thoughts, suggestions, sarcasms? Jonathan > mtheory@msn.com ==== Team, I'm considering writing, to the extent that it is even possible or helpful, a package which does step-by-step integration. Some possible packages that might inspire an approach to such include step-by-step differentiation (read backwards). Any thoughts, suggestions, sarcasms? Jonathan mtheory@msn.com ==== Dear group I use HTMLSave.m to build up to date project about forthcomming large collection of notebooks (book). I have one main notebook (content.nb) from which I made links to others: chap1.nb, chap2.nb, etc. Unfortunatelly not all chaps are written yet, so each time adding a one I need to generate entire collection of html's again due to unique name convention scheme of HTMLSave. At the moment (1/3 of entire project) it takes about 3 hours on my PC. I wonder if there is a way to interupt the convertion process (say at the last ready notebook), then DumpSave[ ] the Mathematica state. After preparing one more notebook just put interaption point further, etc.... Is this possible at all? The most unclear problem to me is how to stop HTMLSave and then resume the job. Also what will happen with opened files, because DumpSave reports about them. Sincerely, Arturas Acus ==== Transpose[{r, g, b}, {3, 1, 2}] Treat -----Original Message----- This returns {{{a1, a2, a3}, {b1, b2, b3}}, {{c1, c2, c3}, {d1, d2, d3}}} which can be viewed as a color image with Graphics[Raster[color,ColorFunction->RGBColor]]//Show When the 2D arrays are large, combining them to form the color tensor as above is very time consuming. Surely there is a more efficient, clever way to combine them than my use of Table, right? Many thanks, Kevin Gross PS Any comments pro/con from users of the Digital Image Processing package are also welcome. ==== >I've been using Mathematica for a while, but only recently for image >processing. Suppose I have the following 2D intensity arrays: > >r={{a1,b1},{c1,d1}}; >g={{a2,b2},{c2,d2}}; >b={{a3,b3},{c3,d3}}; > >Now I'd like to combine them to produce a color image. > >color=Table[{r[[i,j]],g[[i,j]],b[[i,j]]},{i,2},{j,2}] > >This returns {{{a1, a2, a3}, {b1, b2, b3}}, {{c1, c2, c3}, {d1, d2, d3}}} > >which can be viewed as a color image with > >Graphics[Raster[color,ColorFunction->RGBColor]]//Show > >When the 2D arrays are large, combining them to form the color tensor as > >above is very time consuming. Surely there is a more efficient, clever > >way to combine them than my use of Table, right? Transpose /@ Transpose[{r, g, b}] Bob Hanlon Chantilly, VA USA ==== I've been using Mathematica for a while, but only recently for image > processing. Suppose I have the following 2D intensity arrays: r={{a1,b1},{c1,d1}}; > g={{a2,b2},{c2,d2}}; > b={{a3,b3},{c3,d3}}; Now I'd like to combine them to produce a color image. color=Table[{r[[i,j]],g[[i,j]],b[[i,j]]},{i,2},{j,2}] This returns {{{a1, a2, a3}, {b1, b2, b3}}, {{c1, c2, c3}, {d1, d2, d3}}} which can be viewed as a color image with Graphics[Raster[color,ColorFunction->RGBColor]]//Show When the 2D arrays are large, combining them to form the color tensor as > above is very time consuming. Surely there is a more efficient, clever > way to combine them than my use of Table, right? Many thanks, Kevin Gross PS Any comments pro/con from users of the Digital Image Processing > package are also welcome. > I'm not a user of the Digital Image Processing package but I got the following results combining 3 1000x1000 arrays on a 1GHz Mac with version 4.2: In[5]:= n=1000; {r,g,b}=Table[Table[Random[Integer],{n},{n}],{3}]; In[3]:= Timing[Table[{r[[i,j]],g[[i,j]],b[[i,j]]},{i,Length[r]},{j,Length[r [[1]]]}];] Timing[Partition[Transpose[{Flatten[r],Flatten[g],Flatten[b]}],n];] Out[3]= {3.11 Second,Null} Out[4]= {0.2 Second,Null} With n=10000 I run out of memory however. Ssezi ==== I was much too simple minded in my assessments of all the algorithms mentioned below .I should have known it's not as simple as it seemed but after all its only a hobby:). The complexity of the Sieve of Erasthoteness is well known to be O(n) (this is stated, for example, in Knuth, The Art of Computer Programming, vol 3, p. 617). The Miller-Rabin algorithm has complexity O(log(n)^5) (not log(n)^2), assuming the GRH is true. (It is also deterministic). The Agrawal, Kayal and Saxenaalgorithm has a proven complexity of O(log(n)^12) and a conjectured running time of O(log(n)^6). The the sieve is certainly not even a contender. However, as for practical implementation, it seems to me that Miller-Rabin is clearly preferable. If the GRH is true it is faster than the new one. And if you find it running slow ... well that's even better ... Andrzej > Well, this depends on the meaning of polynomial time. The running time > of the Sieve of Eratosthenes is Sqt[n], but time complexity in the case > of prime testing is always expressed in terms of log[n], so the sieve is > considered exponential. I think the fastest deterministic test is the > Rabin-Miller which is (I am not quite sure of that) Log[n]^2, but it > depends on the unproved Generalized Riemann Hypothesis. Agrawal, Kayal > and Saxena give a Log[n]^12 algorithm, but they also give a complete > proof of its correctness. I have not read their paper but assuming that > it is correct, the algorithm is certainly much faster than the sieve. On > the other hand the GRH is most probably true... > The oldest algorithm for testing primes... the Sieve of Eratosthenes... > is polynomial and deterministic. It's simply too slow to use, just > like > the one at the attachment. > > -----Original Message----- > Is there a publicly available Mathematica 3.0 notebook that implements > the Primes is in P? > http://www.msnbc.com/news/792126.asp ==== Somehow I have managed to do something in my preferences whereby when using characters from the basic typesetting pallette I end up with, for example, [Beta], instead of the symbol beta. How do I get my symbols and other fancy symbols back? Yas ==== Transpose[Flatten/@{r,g,b}] should be faster. Johannes > > I've been using Mathematica for a while, but only recently for image > processing. Suppose I have the following 2D intensity arrays: > > r={{a1,b1},{c1,d1}}; > g={{a2,b2},{c2,d2}}; > b={{a3,b3},{c3,d3}}; > > Now I'd like to combine them to produce a color image. > > color=Table[{r[[i,j]],g[[i,j]],b[[i,j]]},{i,2},{j,2}] > > This returns {{{a1, a2, a3}, {b1, b2, b3}}, {{c1, c2, c3}, {d1, d2, d3}}} > > which can be viewed as a color image with > > Graphics[Raster[color,ColorFunction->RGBColor]]//Show > > When the 2D arrays are large, combining them to form the color tensor as > above is very time consuming. Surely there is a more efficient, clever > way to combine them than my use of Table, right? > > Many thanks, > > Kevin Gross > > PS Any comments pro/con from users of the Digital Image Processing > package are also welcome. > ==== of implementation they had in mind. I slapped it together quickly. The first step of the algorithm, for instance, says something like, If n is of the form a^b for b>1, then return COMPOSITE. Well, I looped through b from 2 to Log[2,n], calculated root=IntegerPart[n^(1/b)] for each, and checked whether Mod[n,root]==0. There is undoubtedly a more efficient method, and I haven't studied the paper at length to see if they describe one. Possibly my larger mistake has to do with taking (x-a)^r. I need to check binomial coefficients one at a time instead, to avoid calculating the ones I don't need. So... I don't have a good implementation. Still, my implementation took 17 seconds on my 2.2GHz machine to check odd numbers up to only 70. It needs to be a thousand times that fast to compete with the Sieve of Eratosthenes. (But maybe my implementation IS that bad!) Also... despite all the smarter algorithms today, the Sieve is still a great (perhaps necessary) component of a real strategy to identify primes. The Great Internet Mersenne Prime Search, for instance, uses a modified Sieve. I don't know the details but, at the very least, software using idle cycles on my machine doesn't have to worry about numbers that have already been checked elsewhere. Treat -----Original Message----- conjectured running time of O(log(n)^6). The the sieve is certainly not even a contender. However, as for practical implementation, it seems to me that Miller-Rabin is clearly preferable. If the GRH is true it is faster than the new one. And if you find it running slow ... well that's even better ... Andrzej > Well, this depends on the meaning of polynomial time. The running time > of the Sieve of Eratosthenes is Sqt[n], but time complexity in the case > of prime testing is always expressed in terms of log[n], so the sieve is > considered exponential. I think the fastest deterministic test is the > Rabin-Miller which is (I am not quite sure of that) Log[n]^2, but it > depends on the unproved Generalized Riemann Hypothesis. Agrawal, Kayal > and Saxena give a Log[n]^12 algorithm, but they also give a complete > proof of its correctness. I have not read their paper but assuming that > it is correct, the algorithm is certainly much faster than the sieve. On > the other hand the GRH is most probably true... > The oldest algorithm for testing primes... the Sieve of Eratosthenes... > is polynomial and deterministic. It's simply too slow to use, just > like > the one at the attachment. > > -----Original Message----- > Is there a publicly available Mathematica 3.0 notebook that implements > the Primes is in P? > http://www.msnbc.com/news/792126.asp > > Andrzej Kozlowski Toyama International University JAPAN ==== I'm trying to solve the following sum: Sum[ p^(n-k) (1-p)^k Binomial[n, k] * (1+ n -2 k) / (1+n-k), {k, 0, Ceiling[n/2]} ] Pls, if anyone knows if that sum has a simple solution, I'll be pleasant for a hint how to find it. Constantine. P.S. The Mathematica produces the following output for this sum: n 1 1 + n Out[1]= p ((-) (-1 + 2 p) - p 1 Ceiling[n/2] > ((-1 + -) (-1 + p) Gamma[1 + n] p n > ((1 + n) Gamma[n - Ceiling[-]] 2 n n -1 + p > Hypergeometric2F1[1, -n + Ceiling[-], 2 + Ceiling[-], ------] - 2 2 p n > 2 Gamma[1 + n - Ceiling[-]] 2 n n -1 + p > Hypergeometric2F1[1, 1 - n + Ceiling[-], 2 + Ceiling[-], ------]) 2 2 p n n > ) / (p Gamma[n - Ceiling[-]] Gamma[1 + n - Ceiling[-]] 2 2 n > Gamma[2 + Ceiling[-]])) 2 Constantine Elster Computer Science Dept. Technion I.I.T. Office: Taub 411 ==== Below I slightly modify a problem Gareth Russell had. I modified it to avoid confusion on how to generalize the solution to a different example. ------ suppose we have: b[1,3] = 3; b[0,6] = 6; b[5678, 3] = 7; b[5678, 4] = 5; Then how can we get a list of what (b) can return when the first argument is (5678). In this example we want to get {7,5}. The solution is to use the following: In[5]:= posn=Position[DownValues[b], b[5678,_] ]; Extract[DownValues[b], {First[#],2}& /@ posn ] Out[6]= {7,5} -------- Let myself or the mathgroup know if you have trouble understanding {First[#],2}& /@ posn -------- The solution above works because the definitions for (b) are stored in DownValues[b]. You can see the definitions if you evaluate the following. In[7]:= DownValues[b] -------- Ted Ersek download Mathematica Tips & Tricks from: http://www.verbeia.com/mathematica/tips/Tricks.html ==== Selwyn Hollis replied to the answers on the above subject with: Looks like we've been reinventing the wheel, folks. The package NumericalMath`IntervalRoots` has exactly what we need ..... ---------- Well that isn't entirely true. The above package only works if the equation can be evaluated using Mathematica's interval arithmetic which does not support the evaluation of special functions (BesselJ, Beta, Zeta, ....). --------- Besides that after Interval[{2, 5}] is substituted for each occurrence of (x) in an expression we get the largest possible interval that can result if each instance of Interval[{2, 5}] were an independent value between 2 and 5. This sort of interval arithmetic can be helpful in some situations, but more often one wants to treat each occurrence of Interval[{2,5}] as the same value in the given interval. And I expect this will prevent the functions in the (NumericalMath`IntervalRoots`) package from converging in some cases. For an example of where Mathematica's interval arithmetic gives misleading results consider the following: In[1]:= Clear[x]; poly[x_]=ChebyshevT[12,x]; poly[Interval[{-1,1}]] Out[3]= Interval[{-9799,9801}] We get a very large interval above even though it's well known that -1 <= ChebyshevT[n, x] <= 1 ( for -1 I want to extract numerical values for the separate R, G and B channel > intensities, on a pixel by pixel basis, for specific (limited) regions > in color photos (JPEG, TIFF, whatever), on a Mac, preferably while I'm > viewing the region I'm examining. > Any readily available software to do this? Can Mathematica do it? > In Mathematica, choose Color Selector... from the Input menu. That > brings up the Mac Color Picker. Move your pointer anywhere on the screen > and option-click. That will select the color. Now click Okay, and the > RGBColor recipe will be pasted into the Mathematica front end. > > A similar thing works in GraphicConverter as well. Wow -- interesting -- it does work! I originally thought I'd have to get a JPEG image, say, into Mathematica using Import[], then Show[] it, to do this; and that does work, although Mathematica gets unhappy at importing JPEGs of any size, and is very slow at Show[]ing them. But Mathematica (on a Mac) will actually do this with an image displayed on screen using other graphics programs as well. A bit tedious -- you have to jump back and forth between Mathematica and the image, and re-open Color Selector from the menu for each sample. But, you can select and read off the color in any of multiple formats besides RGB. Sure would be nice if you could automate this in some fashion -- but I guess that's what the Mathematica Digital Image Processing package does. Damned if I can find any mention of this in the Mathematica Book or the online documentation. ==== >when trying to build (after first install) or rebuild the help index >my system (Win XP) always hangs e.g. the build seems not to come to an >end. In the task manager i see mathematica.exe consuming 99% of >available processor time and using more and more memory. > >What can i do to get this index file built correctly ? Please help. > Your preferences may be corrupted. It might help to try the following: http://support.wolfram.com/mathematica/interface/customize/corruptpreference scache.html http://support.wolfram.com/mathematica/interface/customize/corruptpreference sfile.html -Dale ==== >The default setting for FractionBox seems to be to have fonts smaller than >the rest of the fonts in the cell. How can I globally set the fonts to be >the same in a FractionBox as the default font size for the cell (which I >know how to set but cannot figure out what to do with FractionBox). > >I do not want to manually change each specific character on account of there >being too many and also I have the default cell font size for print out >different from working and wrapping a Stylebox[ , fontSize-> ] around a >character seems to lock the fontsize and therefore messes up the way it >looks when printed. > >thanks > >Mike This is controlled by an option called ScriptSizeMulitpliers. If you set it to 1 at the global level, then you'll get the behavior you want. -------------------------------------------------------------- Omega Consulting The final answer to your Mathematica needs Spend less time searching and more time finding. http://www.wz.com/internet/Mathematica.html ==== > >I've been using Mathematica for a while, but only recently for image >processing. Suppose I have the following 2D intensity arrays: > >r={{a1,b1},{c1,d1}}; >g={{a2,b2},{c2,d2}}; >b={{a3,b3},{c3,d3}}; > >Now I'd like to combine them to produce a color image. > >color=Table[{r[[i,j]],g[[i,j]],b[[i,j]]},{i,2},{j,2}] > >This returns {{{a1, a2, a3}, {b1, b2, b3}}, {{c1, c2, c3}, {d1, d2, d3}}} > >which can be viewed as a color image with > >Graphics[Raster[color,ColorFunction->RGBColor]]//Show > >When the 2D arrays are large, combining them to form the color tensor as >above is very time consuming. Surely there is a more efficient, clever >way to combine them than my use of Table, right? >PS Any comments pro/con from users of the Digital Image Processing >package are also welcome. In[]:= Transpose[{r,g,b},{3,1,2}] Out[]= {{{a1,a2,a3},{b1,b2,b3}},{{c1,c2,c3},{d1,d2,d3}}} -------------------------------------------------------------- Omega Consulting The final answer to your Mathematica needs Spend less time searching and more time finding. http://www.wz.com/internet/Mathematica.html ==== I want to make an animation that simulate the Doppler Effect, just 2D circles travel out one by one, and at the same time,the origin of the wave also moves toward one direction. I have no idea to make the speed of the wave origin and the speed of traveling wave independent.Is sincerely bryan ==== My saying Mathematica being uneffective in simulations and all was not meant precisely as said, explaining is needed, tough I won't delve in it now. For the sake of simulating Dopplet efect, i.e. building an animation, just follow my previous example : Module[ { x2 = 10, dx = .5, mach = 1.5 }, Show[ Graphics[ { Table[Circle[{i, 0}, 1/mach (# - i)], {i, 0, #, dx}] } ] , PlotRange -> {{-x2, x2}, {-x2, x2}} , AspectRatio -> Automatic ] & /@ Range[0, x2, dx] ] Hope that helps anyway, Borut > Dear All: > I want to make an animation that simulate the Doppler Effect, just 2D > circles travel out one by one, and at the same time,the origin of the > wave also moves toward one direction. I have no idea to make the speed > of the wave origin and the speed of traveling wave independent.Is > sincerely bryan > ==== I'm writing a Mathematica document and I want to include a table of contents, however, I'm struggling to get the page numbers to aligned on the right margin. Can anyone help? Dugmore Biyana ==== No flickering at all on my Powerbook G4. -- Asghar Bhatti > > The line below is from the 'Extra Examples' in the help browser for the > BitAnd function. > On my computer the resulting graphic flickers rapidly. > Do others have the same results, and does anyone have an explanation for the > flickering? > I suspect this is demonstrating a limitation of my monitor/graphics card. > > In[1] := > ListDensityPlot[Table[Sign[BitAnd[x,y]],{x,127},{y,127}]]; ==== Oliver, I think the closest you will get to the feature in vi is NotebookAutoSave->True. You can get to this via Preferences->NotebookOptions->FileOptions Yas I am looking for a feature in the mathematica front end editor that behaves > like e.g vi in case of an OS crash: vi offers the option to recover the currently edited file at the time of > the crash. So additionaly to your last saved version you can recover the > latest changes that you incoperated and have not saved so far. Is there a > similar feature in the mathematica front end, and how would I activate > this? Simply using save is irritating since at times I wish to rearrange greater > pieces of code without saving the change until the code does what it is > supposed to. thanks for any help and hints, > Oliver Ruebenkoenig, > ==== Hallo, can do all the calculations within one software. Now I'm looking for a package which helps to draw circuit diagrams without using the very basic drawing primitives. Is there a small package (shareware or freeware, nothing commercially available) with symbols of resistors, capacitors, FET and bipolar transistors as well as voltage and currentsources? I want to avoid drawing my schematics with OrCAD capture and import them as graphics into my notebook. I also want to demonstrate the capabilities of Mathematica as a universal system for doing calculations and make them ready for publish. Oliver Friedrich ==== Christopher, i = 6; If you set up the definition... f[i_] = i^2 36 ...Mathematica immediately evaluates the right hand side and i has a value of 6. I am not certain why the designers choose to ignore that i_ is a pattern variable on the lhs. So if you subsequently evaluate f[x] you obtain 36. Not what must people want! This is a regular source of confusion. The method that works is to use a delayed set (:= instead of =). Clear[f] f[i_] := i^2 Then f[x] x^2 But since i still has a value f[i] 36 David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ together. Any help would be greatly appreciated. -chris ==== In Mathematica 4.2, Help says in part ...Limit therefore makes no > explicit assumptions about symbolic functions. Same for the Package > NLimit. Therefore, I think we're out of luck here. You can't make assumptions in Limit. There are not enough general methods for such a mechanism to be really useful. > As an newbe observation, the only option for Limit (For Mathematica 4.2) > is Direction. However, if you type ??Limit, there is another Option > listed that appears not to be documented. That option is Analytic. I > thought maybe this would solve this type of problem, but it does not. I > do not know for sure what this option does. Anyone else?? This is meant for the situations when you use a custom defined function. For example: In[21]:= Limit[f[Sin[x]/x], x -> 0] Out[21]= Limit[f[Sin[x]/x], x -> 0] but In[22]:= Limit[f[Sin[x]/x], x -> 0, Analytic -> True] Out[22]= f[1] Information[Limit, LongForm -> True] > Limit[expr, x->x0] finds the limiting value of > expr when x approaches x0... Attributes[Limit] = {Listable, Protected} Options[Limit] = {Analytic -> False, Direction -> Automatic} As a possible workaround, would substituting many values for a work? > Here is what I am thinking... v = Table[Random[Real, {0, 2*Pi}], {100}]; Union[(Limit[Sin[#1*x]/(#1*x), x -> Infinity] & ) /@ v] I get all zero's like you predicted for many values of a. > {0} If you try Integers, then I get an Indeterminate because the limit > does not like a being 0. v = Table[Random[Integer, {-4, 4}], {10}]; Union[(Limit[Sin[#1*x]/(#1*x), x -> Infinity] & ) /@ v] > {0, Indeterminate} Actually the problem is that the function Sin[z]/z is singular at Infinity. Thus: In[26]:= Limit[Sin[z]/z, z -> Infinity, Direction -> -1] Out[26]= 0 In[27]:= Limit[Sin[z]/z, z -> Infinity, Direction -> -I] Out[27]= Infinity In other words the limit depends on the direction. So when you consider Limit[Sin[a z]/(a z), z -> Infinity] it is not clear in which direction the limit is being taken. This depends on whether a is real or not (as Treat already pointed this out in his message),and of course there is the special case a==0. Since Limit does nto allow assumptions to be entered if you know that you will be dealing with such cases frequently one approach is to redefine limit: Unprotect[Limit]; In[28]:= Limit[Sin[a_*x_]/(a_*x_), x_ -> Infinity] /; Im[a] == 0 && a != 0 = 0; Limit[Sin[a_*x_]/(a_*x_), x_ -> Infinity] /; Re[a] == 0 && a != 0 = Infinity; In[30]:= Protect[Limit]; Now you need to enter assumptions about a's or b's, e.g.: In[31]:= a/:Im[a]=0; In[32]:= a/:(a.89ลส0)=True; this says a is a non-zero real. Limit will now return the expected answer: In[33]:= Limit[Sin[a*x]/(a*x), x -> Infinity] Out[33]= 0 similarly for the case when b is non zero and imaginary we will get: In[34]:= b /: Re[b] = 0; In[35]:= b /: b != 0 = True; In[36]:= Limit[Sin[b*x]/(b*x), x -> Infinity] Out[12]= Infinity If you are sure you are going to onl be dealing with non-zero real numbers you can redefine Limit to return always 0 in such cases, which may make it simpler to deal with a large number of them in one go. Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ -- > Dana > Windows XP & Mathematica 4.1 > = = = = = = = = = = = = = = = = = > Sorry for 'refreshing' this message but does anyone know if I can > define the assumption below. > I don't want to write specific assumptions for each term in Limit > since I have many different variables and forms of a. Is it possible > to generalise the assumption? > it would really help me (and I really don't want to have to buy any > additional maths software). > I am also interesting in the solution of how to make an asumption > in Mathematica. I can't find any method in Mathematica. If anybody > you all .. > I know that this should be 0 but why can't I get mathematica to > think likewise. > In[4]:= Limit[Sin[a*x]/(a*x),x->Infinity] > Sin[a x] > Out[4]= Limit[--------, x -> Infinity] > a x > Is the problem a? How can I specify the properties of or > assumptions that may be made about a? > ==== I want to convert a sequence of graphic images (Graphics) created in Mathematica to a QuickTime movie using the Save Selection as QuickTime or Convert to QuickTime menu commands in Mathematica, and play them as a slide show. The images start out as EPS vector graphics in Mathematica; 'd like to get full screen display and sharp rendering of type and lines. 1) What's the aspect ratio (AspectRatio) and image size (ImageSize) for a QuickTime movie? ( Can this be changed?) 2) What Compression (Animation, Graphics, TIFF. etc) should I use in the QuickTime conversion to get sharp rendering of type and lines in a magnified image of the graphics? (Is there any vector image format available in the QuickTime Player?) 3) Is there any way to get rid of the surrounding Movie Player frame and play a movie full screen? ==== > I want to convert a sequence of graphic images (Graphics) created in > Mathematica to a QuickTime movie using the Save Selection as QuickTime > or Convert to QuickTime menu commands in Mathematica, and play them as > a slide show. > > The images start out as EPS vector graphics in Mathematica; 'd like to > get full screen display and sharp rendering of type and lines. Alas, QuickTime is for raster animation only. You are thinking of something like Flash or Scalable Vector Format, which are not supported by Mathematica. (It would be nice if they were!) > 1) What's the aspect ratio (AspectRatio) and image size (ImageSize) for > a QuickTime movie? ( Can this be changed?) As far as I can tell, Mathematica saves the frames exactly as displayed in the Front End. So if you want higher resolution, you should make the images bigger to begin with. > 2) What Compression (Animation, Graphics, TIFF. etc) should I use in > the QuickTime conversion to get sharp rendering of type and lines in a > magnified image of the graphics? (Is there any vector image format > available in the QuickTime Player?) The compression options are all raster-based, so none will give you what you are after (see above). Given that, the Animation option seems fine for this kind of thing. > 3) Is there any way to get rid of the surrounding Movie Player frame > and play a movie full screen? Yes, by upgrading to QuickTime Pro, which is about $30 or so from Apple, or by using one of the many alternative movie players out there. Note that as you will be scaling up a raster image, it will be blocky/blurry at large sizes unless you start with a very high-resolution series of images. An alternative approach is to save the images as separate image files with names like image1, image2, etc. You can then generate a movie from the image list, again, using QuickTime Pro or a shareware solution. I'm not sure, but you may be able to specify a vector format (such as EPS) or a hybrid (such as PICT) for the images, and still have this read into a movie. The images will still be converted to raster as the movie is made, but you should be able to specify the output resolution as an option in QuickTime Pro, and have it scale nicely to that size. Hope this helps! ==== Put a newline after each equation, but put them all in a single inline cell. -----Original Message----- Mike, Two ways 1) Start an inline cell in your text cell (menu>Edit>Expression Input>Start Inline Cell) Type in your equations with the alignment marker (Esc am Esc) in after each equal sign. Close the inline cell (menu>Edit>Expression Input>End Inline Cell). Select the text cell (or the inline cell, though this is a delicate operation, do it by repeatedly double clicking in it}. Use menu> Format>Text Alignment>On Alignment Marker. -- you will find that all single letters are now italic - you can select individual letters and change this - alternatively you can select the inline cell and use the option inspector (menu>Format>Option Inspector) to set SingleLetterItalics->False) -- you can put existing text in an inline cell by selcting it and using menu>Edit>Expression Input>Start Inline Cell, but you may have to adjust the line breaks after this. 2) use a grid box with a column for the equal sign and set the column alignments appropriately - but this maay give problems if you want text to run over columns. -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay@haystack.demon.co.uk Voice: +44 (0)116 271 4198 ==== Mathgroupies: hoping one of you can help with the following: I've got a Mathematica question from one of the students working on Macintosh OS-X support. He's trying to run the kernel on one OS-X machine and display on another, but he can't get it to work. Do you know much about how this is done? Both machines will run it standalone ok, but when he tries to launch a remote kernel, it basically just exits immediately. Running top on both machines indicates that it briefly starts and then dies. If you have any ideas at all, we'd really appreciate it. I thought that if anyone here might know, it would be you. -- -- -- -- -- -- -- -- -- -- -- -- Daniel Reeves http://ai.eecs.umich.edu/people/dreeves/ In this house we obey the laws of thermodynamics! -- Homer Simpson ==== > -----Original Message----- > Sent: Friday, August 02, 2002 8:43 AM > If we want to contract two tensor arrays S and T in > Mathematica we can write > S.T. We could also use the Inner product. This will contract > the last level > of S with the first level of T. > > I would like to know how to contract more than one pair of > levels. Suppose S > and T are 3rd order tensors and I want to contract the last > two levels of S > with the first two levels of T. How can I do that? > > Or suppose I wanted to contract all three levels. For example with... > > Smat = Array[S, {3, 3, 3}] > Tmat = Array[T, {3, 3, 3}] > > I would like to obtain the answer... > > Smat Transpose[Tmat, {3, 2, 1}] > Plus @@ Flatten[%] > > but by a more general method. That is, I would like to > contract any number > of adjacent levels in two tensors. > David Park > djmp@earthlink.net > http://home.earthlink.net/~djmp/ Dear David, just to pass an idea (I haven't got the time to test it extensively, esp. not for performance). (1) define a tensor product TensorProduct[s_, t_] := Outer[List, s].List[t] This just maps S_a,b,c,... x T_u,v,w,... --> S_a,b,c,... T_u,v,w,... i.e. the result is one tensor. (2) define a function do contractions on (muliple) indices of a tensor Contract[tt_, inxs : {_, _} ..] := Nest[Tr[#, Plus, 2] &, Transpose[tt, Block[{x = Range[TensorRank[tt]]}, x[[Join[inxs, Delete[x, List /@ Join[inxs]]]]] = x; x] ], Length[{inxs}]] Now you man do different things: a = Array[A, {2, 3, 3, 2}]; Contract[a, {2, 3}] % // Dimensions Contract[a, {1, 4}] % // Dimensions Contract[a, {2, 3}, {1, 4}] Contract[a, {1, 4}, {2, 3}] Sum[Sum[a[[i, j, j, i]], {j, 3}], {i, 2}] s=Array[S,{2,2,3}] t=Array[T,{3,2,2}] r=s.t Dimensions[r] Contract[TensorProduct[s, t], {3, 4}] == r Contract[TensorProduct[s, t], {3, 4}, {1, 6}] % // Dimensions Needless to say that for production purposes tests for compatible tensor Dimensions have to be made prior. Also doing the trivial Transpose has to be avoided (on performance reasons). Perhaps for better performance you may mix this idea here with a application of Dot (to avoid TensorProduct and one nesting layer of Tr), but this makes more complicated coding (I haven't got the time to make it). The function to define the transpose prescription list is somewhat awkward, perhaps you will find something better. Anyways, I hope this is of some help. Yours, Hartmut ==== The resulting graphic shows immediately on my display and, no, no flickering at all. In[1]:= ListDensityPlot[Table[Sign[BitAnd[x,y]],{x,127},{y,127}]];//Timing Out[3]= {0.16 Second,Null} Probably, as you surmise, there is something with your monitor and/or graphics card. Tomas Garza Mexico City ----- Original Message ----- > I suspect this is demonstrating a limitation of my monitor/graphics card. In[1] := > ListDensityPlot[Table[Sign[BitAnd[x,y]],{x,127},{y,127}]]; ==== ListDensityPlot has a default option Mesh->True. Since the mesh is drawn after the density plot itself, the rendering makes the graphic flicker and finally turn black with the default ImageSize. Try with a much bigger ImageSize, or with Mesh->False. I tried ImageSize->4096,Mesh->True : perfect, but huge ... and Mesh->False : usual size image, expected graphics. > > The line below is from the 'Extra Examples' in the help browser for the > BitAnd function. > On my computer the resulting graphic flickers rapidly. > Do others have the same results, and does anyone have an explanation for the > flickering? > I suspect this is demonstrating a limitation of my monitor/graphics card. > > In[1] := > ListDensityPlot[Table[Sign[BitAnd[x,y]],{x,127},{y,127}]]; ----- > Ted Ersek > ==== For an entire table? You can change these and other Font options for a single cell, for a notebook or for any selection. Use Format | Option Inspector | Formatting Options | Font Options. Tomas Garza Mexico City ----- Original Message ----- Sender: steve@smc.vnet.net Approved: Steven M. Christensen , Moderator ==== To change an existing table, select the table and change the fonts using the Format menu. To change the way a table is generated, wrap the progenitor in StylePrint, as in StylePrint[TableForm[Array[f,{3,4}]], FontFamily->Braggadocio, FontColor->Hue[0]] Tom Burton ==== >I am glad that some discussion of this is being generated. > >In general I disagree with your recommendation. If palettes and StyleSheets >go along with a package, why not put them in ConfigurationFrontEndPalettes >and ConfigurationFrontEndStyleSheets, which seem to be the places made for >them? Then they automatically appear in the menu listings. (And you as a >package writer would also know where to expect to find them.) This is true for packages in the Applications directory as well, as long as you put the files in the correct location inside the package. The advantage to this layout, instead of what you propose, is that all files are stored under the same directory tree. You can zip/tar/hqx a package and send it off to someone. They just unpack it drop it in to their copy of Mathematica. >I am not certain if I completely understand your approach and would >appreciate further explanation. If you have a set of packages, stylesheets, >palettes and documentation, where precisely would you put them? At the top >level of the Applications directory? Or would you put them in a subdirectory >within the Applications folder? If they are in a subdirectory, will >Mathematica automatically find them? What if you want to call them from >another subdirectory in the Applications folder? What about having several >documentation folders for different packages? Can you have two >DocumentationEnglish folders in one directory? I don't think so. Suppose >you provide a package with documentation and I supply a package with >documentation. Is the user supposed to merge the BrowserCatergories files >together? Would he know how to do it? All of these are possible. Mathematica has a drop-in system as long as you understand the layout scheme (which is a bit complicated, but worth understanding). The trick is that each package gets its own directory. Avoiding the conflicts you describe above. All these properties are set by options, so let's look at an option: In[3]:= pp=PalettePath/.Options[$FrontEnd, PalettePath]; Let's just look at one value, the others are similar. In[5]:= pp[[6]] Out[5]= FrontEnd`FileName[{$TopDirectory,AddOns,Applications,_,FrontEnd,Palettes}, CharacterEncoding[Rule]WindowsANSI] This says look in $TopDirectory/AddOns/Applications for directories of any name. Then in those directories look for a FrontEnd/Palettes directory with *.nb files. If any of these files exist, when the front end is started, then it will be included in the Palettes menu. Similar things are done for StyleSheetPath and AddOnHelpPath (for documentation). There are also other more exotic paths like ConfigurationPath and SpellingDictionariesPath, but these are largely unused. So when I write a package it looks like this: MyPackageName/ MyPackages.m (Actual packages) init.m (Stub package. Loaded by <In providing software to a user, I think it is a great advantage if the user >does not have to specify or alter any paths. That may be simple for you, but >it is a major hurdle to many users. If one puts the various objects in the >places that WRI provided for them, it is never neccessary to specify paths. I completely agree. I can't count the number of headaches I've had with Mathematica packages that ask you to first do this and then do that. If people knew about (i.e if it was well-documented) and used the default directories, it would save us all a bunch of headaches. >(Perhaps you want some commands in your package to automatically open a >palette. If the palette has been placed in ConfigurationFrontEndPalettes, >you as the programmer can automatically write the path to open it. The user >shouldn't have to worry about it. And he could also open the palette from >the menu.) There are a couple of way to do this. 1) The default NotebookPath option (which controls NotebookOpen) includes all the directories in the default PalettePath. So you can do NotebookOpen[MyPalette.nb] 2) Or you could actually search the $Path fns = FileNames[ ToFileName[{MyPackage, FrontEnd, Palettes}, MyPalette.nb], $Path ]; If[fns=!={}, NotebookOpen[First[fns]]] Sometimes I prefer the later in case the user installed in a non-standard location. >I don't claim to be the greatest expert on this subject. I would be glad to >learn more. But, so far, all the arguments I have heard for putting packages >somewhere other than an ExtraPackages subfolder have been unconvincing to >me. > >David Park >djmp@earthlink.net >http://home.earthlink.net/~djmp/ >ExtraPackages is a fine place to put packages if your package consists >solely of *.m files. > >However, in general I would recommend the Applications directory. The front >end has its own sets of paths (for finding palettes, stylesheets, and >documentation). With the default settings, the front end looks in the >Applications and Autoload directories, not the ExtraPackages directory. -------------------------------------------------------------- >Omega Consulting >The final answer to your Mathematica needs > >Spend less time searching and more time finding. >http://www.wz.com/internet/Mathematica.html -------------------------------------------------------------- Omega Consulting The final answer to your Mathematica needs Spend less time searching and more time finding. http://www.wz.com/internet/Mathematica.html Reply-To: ==== There's nothing to prevent Limit from converting the condition a>=0 into the change of variables a=Exp@Re@b and computing the limit (no matter what limit function or asymptote we're looking at), if Limit were made assumption-aware. That's only one example, but I think most conditions we'd be interested in can be handled similarly. -----Original Message----- > As an newbe observation, the only option for Limit (For Mathematica 4. 2) > is Direction. However, if you type ??Limit, there is another Option > listed that appears not to be documented. That option is Analytic. I > thought maybe this would solve this type of problem, but it does not. I > do not know for sure what this option does. Anyone else?? This is meant for the situations when you use a custom defined function. For example: In[21]:= Limit[f[Sin[x]/x], x -> 0] Out[21]= Limit[f[Sin[x]/x], x -> 0] but In[22]:= Limit[f[Sin[x]/x], x -> 0, Analytic -> True] Out[22]= f[1] Information[Limit, LongForm -> True] > Limit[expr, x->x0] finds the limiting value of > expr when x approaches x0... Attributes[Limit] = {Listable, Protected} Options[Limit] = {Analytic -> False, Direction -> Automatic} As a possible workaround, would substituting many values for a work? > Here is what I am thinking... v = Table[Random[Real, {0, 2*Pi}], {100}]; Union[(Limit[Sin[#1*x]/(#1*x), x -> Infinity] & ) /@ v] I get all zero's like you predicted for many values of a. > {0} If you try Integers, then I get an Indeterminate because the limit > does not like a being 0. v = Table[Random[Integer, {-4, 4}], {10}]; Union[(Limit[Sin[#1*x]/(#1*x), x -> Infinity] & ) /@ v] > {0, Indeterminate} Actually the problem is that the function Sin[z]/z is singular at Infinity. Thus: In[26]:= Limit[Sin[z]/z, z -> Infinity, Direction -> -1] Out[26]= 0 In[27]:= Limit[Sin[z]/z, z -> Infinity, Direction -> -I] Out[27]= Infinity In other words the limit depends on the direction. So when you consider Limit[Sin[a z]/(a z), z -> Infinity] it is not clear in which direction the limit is being taken. This depends on whether a is real or not (as Treat already pointed this out in his message),and of course there is the special case a==0. Since Limit does nto allow assumptions to be entered if you know that you will be dealing with such cases frequently one approach is to redefine limit: Unprotect[Limit]; In[28]:= Limit[Sin[a_*x_]/(a_*x_), x_ -> Infinity] /; Im[a] == 0 && a != 0 = 0; Limit[Sin[a_*x_]/(a_*x_), x_ -> Infinity] /; Re[a] == 0 && a != 0 = Infinity; In[30]:= Protect[Limit]; Now you need to enter assumptions about a's or b's, e.g.: In[31]:= a/:Im[a]=0; In[32]:= a/:(a$B!b(B0)=True; this says a is a non-zero real. Limit will now return the expected answer: In[33]:= Limit[Sin[a*x]/(a*x), x -> Infinity] Out[33]= 0 similarly for the case when b is non zero and imaginary we will get: In[34]:= b /: Re[b] = 0; In[35]:= b /: b != 0 = True; In[36]:= Limit[Sin[b*x]/(b*x), x -> Infinity] Out[12]= Infinity If you are sure you are going to onl be dealing with non-zero real numbers you can redefine Limit to return always 0 in such cases, which may make it simpler to deal with a large number of them in one go. Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ -- > Dana > Windows XP & Mathematica 4.1 > = = = = = = = = = = = = = = = = = > Sorry for 'refreshing' this message but does anyone know if I can > define the assumption below. > I don't want to write specific assumptions for each term in Limit > since I have many different variables and forms of a. Is it possible > to generalise the assumption? > it would really help me (and I really don't want to have to buy any > additional maths software). > I am also interesting in the solution of how to make an asumption > in Mathematica. I can't find any method in Mathematica. If anybody > you all .. > I know that this should be 0 but why can't I get mathematica to > think likewise. > In[4]:= Limit[Sin[a*x]/(a*x),x->Infinity] > Sin[a x] > Out[4]= Limit[--------, x -> Infinity] > a x > Is the problem a? How can I specify the properties of or > assumptions that may be made about a? > ==== I've been using math type in word and wondering how far I can go attempting similar in mathematica. I know that equations can be numbered and updated automatically with the numberedEquation cell style. I was wondering if it was possible to reference an equation number from another cell in a text cell and have it updated automatically if and when the equation number changes? eg: (numbered equation cell somewhere in the notebook) 1+1=2 (6) (text cell somewhere else in the notebook) == Yes, I do it all the time. Here is how it works: 1) Click on the bracket on the right for the equation. Then do either (Ctl-J) or pulldown Find -> Add/Remove Cell Tags give the equation a name, e.g. Cauchy-Goursat Theorem 2) Now, in the text type ( or however you want to indicate the equation 3) Pulldown: Input -> Create Automatic Numbering Object ... 4) Select Cauchy-Goursat Theorem or whatever, make sure that the counter type corresponds to the equation or plot or whatever the numbered object is. I have a paragraph style called Numbered Equation. Click. 5) Type a closing ) and there you are. 6) Now try adding another equation before the referenced one. You will see that the text reference and the original equation numbers are automatically updated. All of this works fine until you have lots of references. This is especially cumbersome for me since I give names to Numbered Equations, Sections, Subsections, ... In a long document it can be irritating to try to find the reference. In Windows the reference Tags are alphabetized, but not in need to choose the counter type, I would have thought this would be automatically associated with the reference name, but there it is. And while I have the soap box, it would be nice to see all or at least a lot of the Tags rather than the little bitty scroll window which shows me about 5% of the Tags in one of my documents. Anyway, even though it is cumbersome for long documents, it is workable. Kevin ----- Original Message ----- > eg: > (numbered equation cell somewhere in the notebook) > 1+1=2 (6) (text cell somewhere else in the notebook) > blah blah blah eq. (6) blah blah blah... thanks Mike ==== It is true that Mathematica could automatically replace parameters which are positive by E^Re[a] or E^Abs[a], and make a few more replacements of this kind (though it is not necessarily clear which one would be the most helpful one in a given situation) but that would do no more than you can do by making such substitutions by hand. It would thus be only of cosmetic use (it may save you a typing a few characters, although even then I am not sure that Assumptions-> ...{a>0} is that much improvement on /.a->E^(Re[b])) but they would not help you to solve a single problem you can't do now. A serious assumptions mechanism would be able to take an assumption and derive from it the consequences significant for the convergence of a limit, in other words make deductions and size estimations the way one does when working with serious limit problems (e.g. using bounds on the coefficients in the Taylor series ). Compare the assumptions mechanism in Integrate and in Simplify. The first works largely like what you are suggesting, in other words you have to know what assumptions are relevant (no deduction), they must be just in the right form, and may be ignored even if they are relevant. The other let's you enter the actual conditions and let's Mathematica itself make the necessary deductions. Also the original post said: > I don't want to write specific assumptions for each term in Limit > since I have many different variables and forms of a. The only wat to do this is to temporarily re-define Limit for the particular problem at hand. Andrzej Kozlowski > There's nothing to prevent Limit from converting the condition a>=0 into > the change of variables a=Exp@Re@b and computing the limit (no matter > what limit function or asymptote we're looking at), if Limit were made > assumption-aware. That's only one example, but I think most > conditions we'd be interested in can be handled similarly. -----Original Message----- > Sent: Friday, August 02, 2002 8:30 AM > In Mathematica 4.2, Help says in part ...Limit therefore makes no > explicit assumptions about symbolic functions. Same for the Package > NLimit. Therefore, I think we're out of luck here. You can't make assumptions in Limit. There are not enough general > methods for such a mechanism to be really useful. > As an newbe observation, the only option for Limit (For Mathematica 4. > 2) > is Direction. However, if you type ??Limit, there is another Option > listed that appears not to be documented. That option is Analytic. > I > thought maybe this would solve this type of problem, but it does not. > I > do not know for sure what this option does. Anyone else?? This is meant for the situations when you use a custom defined function. For example: In[21]:= > Limit[f[Sin[x]/x], x -> 0] Out[21]= > Limit[f[Sin[x]/x], x -> 0] but In[22]:= > Limit[f[Sin[x]/x], x -> 0, Analytic -> True] Out[22]= > f[1] > Information[Limit, LongForm -> True] > Limit[expr, x->x0] finds the limiting value of > expr when x approaches x0... > Attributes[Limit] = {Listable, Protected} > Options[Limit] = {Analytic -> False, Direction -> Automatic} > As a possible workaround, would substituting many values for a work? > Here is what I am thinking... > v = Table[Random[Real, {0, 2*Pi}], {100}]; > Union[(Limit[Sin[#1*x]/(#1*x), x -> Infinity] & ) /@ v] > I get all zero's like you predicted for many values of a. > {0} > If you try Integers, then I get an Indeterminate because the limit > does not like a being 0. > v = Table[Random[Integer, {-4, 4}], {10}]; > Union[(Limit[Sin[#1*x]/(#1*x), x -> Infinity] & ) /@ v] > {0, Indeterminate} Actually the problem is that the function Sin[z]/z is singular at > Infinity. Thus: In[26]:= > Limit[Sin[z]/z, z -> Infinity, Direction -> -1] Out[26]= > 0 In[27]:= > Limit[Sin[z]/z, z -> Infinity, Direction -> -I] Out[27]= > Infinity In other words the limit depends on the direction. So when you consider Limit[Sin[a z]/(a z), z -> Infinity] it is not clear in which direction the limit is being taken. This > depends on whether a is real or not (as Treat already pointed this out in his message),and of course there is the special case a==0. Since Limit does nto allow assumptions to be entered if you know that > you will be dealing with such cases frequently one approach is to > redefine limit: Unprotect[Limit]; In[28]:= > Limit[Sin[a_*x_]/(a_*x_), x_ -> Infinity] /; > Im[a] == 0 && a != 0 = 0; > Limit[Sin[a_*x_]/(a_*x_), x_ -> Infinity] /; > Re[a] == 0 && a != 0 = Infinity; In[30]:= > Protect[Limit]; > Now you need to enter assumptions about a's or b's, e.g.: In[31]:= > a/:Im[a]=0; In[32]:= > a/:(a.89ลส0)=True; this says a is a non-zero real. Limit will now return the expected > answer: In[33]:= > Limit[Sin[a*x]/(a*x), x -> Infinity] Out[33]= > 0 similarly for the case when b is non zero and imaginary we will get: In[34]:= > b /: Re[b] = 0; In[35]:= > b /: b != 0 = True; > In[36]:= > Limit[Sin[b*x]/(b*x), x -> Infinity] Out[12]= > Infinity If you are sure you are going to onl be dealing with non-zero real > numbers you can redefine Limit to return always 0 in such cases, which > may make it simpler to deal with a large number of them in one go. > -- > Dana > Windows XP & Mathematica 4.1 > = = = = = = = = = = = = = = = = = > Sorry for 'refreshing' this message but does anyone know if I can > define the assumption below. > I don't want to write specific assumptions for each term in Limit > since I have many different variables and forms of a. Is it possible > to generalise the assumption? > it would really help me (and I really don't want to have to buy any > additional maths software). > I am also interesting in the solution of how to make an asumption > in Mathematica. I can't find any method in Mathematica. If anybody > you all .. > I know that this should be 0 but why can't I get mathematica to > think likewise. > In[4]:= Limit[Sin[a*x]/(a*x),x->Infinity] > Sin[a x] > Out[4]= Limit[--------, x -> Infinity] > a x > Is the problem a? How can I specify the properties of or > assumptions that may be made about a? > ==== package I have that has a style sheet and a palette. It worked as advertised and I agree that your method is a perfectly reasonable and good method. So, now I would say that there are two good methods. They differ mainly in where users would prefer to store various file types. Let me outline them along with their advantages and disadvantages, which are relatively minor and a matter of taste. (I have a question about using zip files that somewhat affects the advantages and disadvantages.) 1) Gather all the package material together in one folder, which is placed in the Applications folder. Create subfolders FrontEndPalettes, FrontEndStyleSheets and EnglishDocumentation for those items if they exist. The advantage is that all the package material is in one place. The disadvantage is that you have packages, palettes and style sheets scattered all over. 2) Put the package and documentation in a folder in the ExtraPackages directory. Put any palettes in ConfigurationFrontEndPalettes. Put any style sheets in ConfigurationFrontEndStyleSheets. The advantage is that you have all your third party packages in one place, all your style sheets in one place and all your palettes in one place. The disadvantage is that the user must move the palettes and style sheets to the stanard directories. Now, I would like to ask you how I can send a package, style sheets, palettes and documentation to a user. I am working in Windows 98 and have the WinZip program. As far as I understand (and I did ask the WinZip people about it) it is not possible to include a file structure in a .zip file. You can make self-extracting zip files (which I don't know how to do) but I understood that only people working under Windows can use them. So at present, in my major package, I tell people how to set up the file structure in ExtraPackages. I put all the documentation files in one .zip file and all the package files plus the palette in a second .zip file. They have to copy them out into the correct folders. How can I send the files in a folder structure? If I can't do that, the first method loses a little of its appeal. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ >package writer would also know where to expect to find them.) This is true for packages in the Applications directory as well, as long as you put the files in the correct location inside the package. The advantage to this layout, instead of what you propose, is that all files are stored under the same directory tree. You can zip/tar/hqx a package and send it off to someone. They just unpack it drop it in to their copy of Mathematica. >I am not certain if I completely understand your approach and would >appreciate further explanation. If you have a set of packages, stylesheets, >palettes and documentation, where precisely would you put them? At the top >level of the Applications directory? Or would you put them in a subdirectory >within the Applications folder? If they are in a subdirectory, will >Mathematica automatically find them? What if you want to call them from >another subdirectory in the Applications folder? What about having several >documentation folders for different packages? Can you have two >DocumentationEnglish folders in one directory? I don't think so. Suppose >you provide a package with documentation and I supply a package with >documentation. Is the user supposed to merge the BrowserCatergories files >together? Would he know how to do it? All of these are possible. Mathematica has a drop-in system as long as you understand the layout scheme (which is a bit complicated, but worth understanding). The trick is that each package gets its own directory. Avoiding the conflicts you describe above. All these properties are set by options, so let's look at an option: In[3]:= pp=PalettePath/.Options[$FrontEnd, PalettePath]; Let's just look at one value, the others are similar. In[5]:= pp[[6]] Out[5]= FrontEnd`FileName[{$TopDirectory,AddOns,Applications,_,FrontEnd,Palettes}, CharacterEncoding[Rule]WindowsANSI] This says look in $TopDirectory/AddOns/Applications for directories of any name. Then in those directories look for a FrontEnd/Palettes directory with *.nb files. If any of these files exist, when the front end is started, then it will be included in the Palettes menu. Similar things are done for StyleSheetPath and AddOnHelpPath (for documentation). There are also other more exotic paths like ConfigurationPath and SpellingDictionariesPath, but these are largely unused. So when I write a package it looks like this: MyPackageName/ MyPackages.m (Actual packages) init.m (Stub package. Loaded by <In providing software to a user, I think it is a great advantage if the user >does not have to specify or alter any paths. That may be simple for you, but >it is a major hurdle to many users. If one puts the various objects in the >places that WRI provided for them, it is never neccessary to specify paths. I completely agree. I can't count the number of headaches I've had with Mathematica packages that ask you to first do this and then do that. If people knew about (i.e if it was well-documented) and used the default directories, it would save us all a bunch of headaches. >(Perhaps you want some commands in your package to automatically open a >palette. If the palette has been placed in ConfigurationFrontEndPalettes, >you as the programmer can automatically write the path to open it. The user >shouldn't have to worry about it. And he could also open the palette from >the menu.) There are a couple of way to do this. 1) The default NotebookPath option (which controls NotebookOpen) includes all the directories in the default PalettePath. So you can do NotebookOpen[MyPalette.nb] 2) Or you could actually search the $Path fns = FileNames[ ToFileName[{MyPackage, FrontEnd, Palettes}, MyPalette.nb], $Path ]; If[fns=!={}, NotebookOpen[First[fns]]] Sometimes I prefer the later in case the user installed in a non-standard location. >I don't claim to be the greatest expert on this subject. I would be glad to >learn more. But, so far, all the arguments I have heard for putting packages >somewhere other than an ExtraPackages subfolder have been unconvincing to >me. > >David Park >djmp@earthlink.net >http://home.earthlink.net/~djmp/ > >ExtraPackages is a fine place to put packages if your package consists >solely of *.m files. > >However, in general I would recommend the Applications directory. The front >end has its own sets of paths (for finding palettes, stylesheets, and >documentation). With the default settings, the front end looks in the >Applications and Autoload directories, not the ExtraPackages directory. -------------------------------------------------------------- >Omega Consulting >The final answer to your Mathematica needs > >Spend less time searching and more time finding. >http://www.wz.com/internet/Mathematica.html -------------------------------------------------------------- ==== Andrzej makes sense in a way, but I have a few problems: (1) Since Limit[Sin[z]/z, z -> Infinity] evaluates to zero, Limit is obviously making an assumption about z, and hence it's capable of making assumptions. In this case, it's making an assumption we have no control of, which can't be ideal. Also note this assumption isn't DOCUMENTED. (2) If a = Exp@Re@b;Limit[Sin[a z]/(a z), z -> Infinity] evaluates to zero, Limit apparently knows that Exp@Re@b is >0 or, at least, non-zero and real, and it uses that information in computing the limit, does it not? How does it do that, if assumptions can't be handled in the inner workings? (3) a=1+Re@b;Limit[Sin[a z]/(a z),z->Infinity] evaluates to zero, but a = Re@b;Limit[Sin[a z]/(a z), z -> Infinity] is NOT evaluated. In both cases, a==0 for b on a vertical line in the complex plane, but Limit ignores that problem in case and not the other. (4) ClearAll[a, F];Limit[F[z, a], z -> 0] evaluates to F[0,y] but ClearAll[a, F];F[z_, a_] := Sin[a z]/(a z);Limit[F[z, a], z -> Infinity] is unevaluated. In the first case, Limit has made an unwarranted assumption about F. In short, Limit can and does make assumptions; we simply can't control them. If Andrzej's point is that algebraic software still can't do all the work for us, that's obviously true. If he's saying Limit is doing all it can reasonably be expected to do, I don't think so. (Witness these anomalies in Limit's behavior.) -----Original Message----- a single problem you can't do now. A serious assumptions mechanism would be able to take an assumption and derive from it the consequences significant for the convergence of a limit, in other words make deductions and size estimations the way one does when working with serious limit problems (e.g. using bounds on the coefficients in the Taylor series ). Compare the assumptions mechanism in Integrate and in Simplify. The first works largely like what you are suggesting, in other words you have to know what assumptions are relevant (no deduction), they must be just in the right form, and may be ignored even if they are relevant. The other let's you enter the actual conditions and let's Mathematica itself make the necessary deductions. Also the original post said: > I don't want to write specific assumptions for each term in Limit > since I have many different variables and forms of a. The only wat to do this is to temporarily re-define Limit for the particular problem at hand. Andrzej Kozlowski > There's nothing to prevent Limit from converting the condition a>=0 into > the change of variables a=Exp@Re@b and computing the limit (no matter > what limit function or asymptote we're looking at), if Limit were made > assumption-aware. That's only one example, but I think most > conditions we'd be interested in can be handled similarly. -----Original Message----- > Sent: Friday, August 02, 2002 8:30 AM > In Mathematica 4.2, Help says in part ...Limit therefore makes no > explicit assumptions about symbolic functions. Same for the Package > NLimit. Therefore, I think we're out of luck here. You can't make assumptions in Limit. There are not enough general > methods for such a mechanism to be really useful. > As an newbe observation, the only option for Limit (For Mathematica 4. > 2) > is Direction. However, if you type ??Limit, there is another Option > listed that appears not to be documented. That option is Analytic. > I > thought maybe this would solve this type of problem, but it does not. > I > do not know for sure what this option does. Anyone else?? This is meant for the situations when you use a custom defined function. For example: In[21]:= > Limit[f[Sin[x]/x], x -> 0] Out[21]= > Limit[f[Sin[x]/x], x -> 0] but In[22]:= > Limit[f[Sin[x]/x], x -> 0, Analytic -> True] Out[22]= > f[1] > Information[Limit, LongForm -> True] > Limit[expr, x->x0] finds the limiting value of > expr when x approaches x0... > Attributes[Limit] = {Listable, Protected} > Options[Limit] = {Analytic -> False, Direction -> Automatic} > As a possible workaround, would substituting many values for a work? > Here is what I am thinking... > v = Table[Random[Real, {0, 2*Pi}], {100}]; > Union[(Limit[Sin[#1*x]/(#1*x), x -> Infinity] & ) /@ v] > I get all zero's like you predicted for many values of a. > {0} > If you try Integers, then I get an Indeterminate because the limit > does not like a being 0. > v = Table[Random[Integer, {-4, 4}], {10}]; > Union[(Limit[Sin[#1*x]/(#1*x), x -> Infinity] & ) /@ v] > {0, Indeterminate} Actually the problem is that the function Sin[z]/z is singular at > Infinity. Thus: In[26]:= > Limit[Sin[z]/z, z -> Infinity, Direction -> -1] Out[26]= > 0 In[27]:= > Limit[Sin[z]/z, z -> Infinity, Direction -> -I] Out[27]= > Infinity In other words the limit depends on the direction. So when you consider Limit[Sin[a z]/(a z), z -> Infinity] it is not clear in which direction the limit is being taken. This > depends on whether a is real or not (as Treat already pointed this out in his message),and of course there is the special case a==0. Since Limit does nto allow assumptions to be entered if you know that > you will be dealing with such cases frequently one approach is to > redefine limit: Unprotect[Limit]; In[28]:= > Limit[Sin[a_*x_]/(a_*x_), x_ -> Infinity] /; > Im[a] == 0 && a != 0 = 0; > Limit[Sin[a_*x_]/(a_*x_), x_ -> Infinity] /; > Re[a] == 0 && a != 0 = Infinity; In[30]:= > Protect[Limit]; > Now you need to enter assumptions about a's or b's, e.g.: In[31]:= > a/:Im[a]=0; In[32]:= > a/:(a$B!b(B0)=True; this says a is a non-zero real. Limit will now return the expected > answer: In[33]:= > Limit[Sin[a*x]/(a*x), x -> Infinity] Out[33]= > 0 similarly for the case when b is non zero and imaginary we will get: In[34]:= > b /: Re[b] = 0; In[35]:= > b /: b != 0 = True; > In[36]:= > Limit[Sin[b*x]/(b*x), x -> Infinity] Out[12]= > Infinity If you are sure you are going to onl be dealing with non-zero real > numbers you can redefine Limit to return always 0 in such cases, which > may make it simpler to deal with a large number of them in one go. > -- > Dana > Windows XP & Mathematica 4.1 > = = = = = = = = = = = = = = = = = > Sorry for 'refreshing' this message but does anyone know if I can > define the assumption below. > I don't want to write specific assumptions for each term in Limit > since I have many different variables and forms of a. Is it possible > to generalise the assumption? > it would really help me (and I really don't want to have to buy any > additional maths software). > I am also interesting in the solution of how to make an asumption > in Mathematica. I can't find any method in Mathematica. If anybody > you all .. > I know that this should be 0 but why can't I get mathematica to > think likewise. > In[4]:= Limit[Sin[a*x]/(a*x),x->Infinity] > Sin[a x] > Out[4]= Limit[--------, x -> Infinity] > a x > Is the problem a? How can I specify the properties of or > assumptions that may be made about a? > ==== It seemed strange that no one mentioned pattern matching construct of _?. Count[{1,1,1,0,0,1,0,1,0,0,1,0,0}, _?((t=#==0&&i==1;i=#;t)&)] ==> 4 If different tests are needed on the same data set, it'd be advised to make test functions such as f[x_]:=(t=x==0&&i==1;i=x;t) and run Count[w,_?f]. The reason why {___,1,0,___} doesn't work is because patterns are matched elementwise. DH ==== >Is there a way to produce text that rotates with a graphic in Mathematica? >I can only imagine of producing a 2-D text graphic, then displaying it in a >rectangle in 3D, and rotating the result. This works only as long as you >stay in front of (on the picture side) of the rectangle. > >Any ideas? Use hershey fonts package from mathsource. The accompanying example illustrates text rotation and projection onto 3d planes. The use of hershey fonts is the only way to get rotated text effect on Mac frontends, for those in needs of such feature. DH Reply-To: ==== Hagihara, Well... that method is more than ten times slower than any other method suggested, almost 300 times slower than the fastest. Here are timings (in seconds) for 13 methods on a list of 2 million entries. Your method is last in the list: {1.297, 0.578, 0.547, 0.203, 0.047, 0.125, 0.11, 0.546, 0.516, 0.672, 0.078, 0.047, 13.906} -----Original Message----- The reason why {___,1,0,___} doesn't work is because patterns are matched elementwise. DH Reply-To: ==== Depending on what Zip utility you're using, yes, you can save the file structure. I can do this with PowerDesk, and I used to do it with PKZIP and LHARC. You'd use relative paths to save the DrawGraphics directory, for instance, which (if I'm understanding the instructions below) would contain FrontEndPalettes, FrontEndStyleSheets and EnglishDocumentation. Then you'd unzip that file into the Applications folder. When you unzip, there's again an option... to keep or discard paths. You'd keep them, of course. -----Original Message----- where users would prefer to store various file types. Let me outline them along with their advantages and disadvantages, which are relatively minor and a matter of taste. (I have a question about using zip files that somewhat affects the advantages and disadvantages.) 1) Gather all the package material together in one folder, which is placed in the Applications folder. Create subfolders FrontEndPalettes, FrontEndStyleSheets and EnglishDocumentation for those items if they exist. The advantage is that all the package material is in one place. The disadvantage is that you have packages, palettes and style sheets scattered all over. 2) Put the package and documentation in a folder in the ExtraPackages directory. Put any palettes in ConfigurationFrontEndPalettes. Put any style sheets in ConfigurationFrontEndStyleSheets. The advantage is that you have all your third party packages in one place, all your style sheets in one place and all your palettes in one place. The disadvantage is that the user must move the palettes and style sheets to the stanard directories. Now, I would like to ask you how I can send a package, style sheets, palettes and documentation to a user. I am working in Windows 98 and have the WinZip program. As far as I understand (and I did ask the WinZip people about it) it is not possible to include a file structure in a .zip file. You can make self-extracting zip files (which I don't know how to do) but I understood that only people working under Windows can use them. So at present, in my major package, I tell people how to set up the file structure in ExtraPackages. I put all the documentation files in one .zip file and all the package files plus the palette in a second .zip file. They have to copy them out into the correct folders. How can I send the files in a folder structure? If I can't do that, the first method loses a little of its appeal. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ for >them? Then they automatically appear in the menu listings. (And you as a >package writer would also know where to expect to find them.) This is true for packages in the Applications directory as well, as long as you put the files in the correct location inside the package. The advantage to this layout, instead of what you propose, is that all files are stored under the same directory tree. You can zip/tar/hqx a package and send it off to someone. They just unpack it drop it in to their copy of Mathematica. >I am not certain if I completely understand your approach and would >appreciate further explanation. If you have a set of packages, stylesheets, >palettes and documentation, where precisely would you put them? At the top >level of the Applications directory? Or would you put them in a subdirectory >within the Applications folder? If they are in a subdirectory, will >Mathematica automatically find them? What if you want to call them from >another subdirectory in the Applications folder? What about having several >documentation folders for different packages? Can you have two >DocumentationEnglish folders in one directory? I don't think so. Suppose >you provide a package with documentation and I supply a package with >documentation. Is the user supposed to merge the BrowserCatergories files >together? Would he know how to do it? All of these are possible. Mathematica has a drop-in system as long as you understand the layout scheme (which is a bit complicated, but worth understanding). The trick is that each package gets its own directory. Avoiding the conflicts you describe above. All these properties are set by options, so let's look at an option: In[3]:= pp=PalettePath/.Options[$FrontEnd, PalettePath]; Let's just look at one value, the others are similar. In[5]:= pp[[6]] Out[5]= FrontEnd`FileName[{$TopDirectory,AddOns,Applications,_,FrontEnd,Palettes }, CharacterEncoding[Rule]WindowsANSI] This says look in $TopDirectory/AddOns/Applications for directories of any name. Then in those directories look for a FrontEnd/Palettes directory with *.nb files. If any of these files exist, when the front end is started, then it will be included in the Palettes menu. Similar things are done for StyleSheetPath and AddOnHelpPath (for documentation). There are also other more exotic paths like ConfigurationPath and SpellingDictionariesPath, but these are largely unused. So when I write a package it looks like this: MyPackageName/ MyPackages.m (Actual packages) init.m (Stub package. Loaded by <In providing software to a user, I think it is a great advantage if the user >does not have to specify or alter any paths. That may be simple for you, but >it is a major hurdle to many users. If one puts the various objects in the >places that WRI provided for them, it is never neccessary to specify paths. I completely agree. I can't count the number of headaches I've had with Mathematica packages that ask you to first do this and then do that. If people knew about (i.e if it was well-documented) and used the default directories, it would save us all a bunch of headaches. >(Perhaps you want some commands in your package to automatically open a >palette. If the palette has been placed in ConfigurationFrontEndPalettes, >you as the programmer can automatically write the path to open it. The user >shouldn't have to worry about it. And he could also open the palette from >the menu.) There are a couple of way to do this. 1) The default NotebookPath option (which controls NotebookOpen) includes all the directories in the default PalettePath. So you can do NotebookOpen[MyPalette.nb] 2) Or you could actually search the $Path fns = FileNames[ ToFileName[{MyPackage, FrontEnd, Palettes}, MyPalette.nb], $Path ]; If[fns=!={}, NotebookOpen[First[fns]]] Sometimes I prefer the later in case the user installed in a non-standard location. >I don't claim to be the greatest expert on this subject. I would be glad to >learn more. But, so far, all the arguments I have heard for putting packages >somewhere other than an ExtraPackages subfolder have been unconvincing to >me. > >David Park >djmp@earthlink.net >http://home.earthlink.net/~djmp/ > >ExtraPackages is a fine place to put packages if your package consists >solely of *.m files. > >However, in general I would recommend the Applications directory. The front >end has its own sets of paths (for finding palettes, stylesheets, and >documentation). With the default settings, the front end looks in the >Applications and Autoload directories, not the ExtraPackages directory. -------------------------------------------------------------- >Omega Consulting >The final answer to your Mathematica needs > >Spend less time searching and more time finding. >http://www.wz.com/internet/Mathematica.html -------------------------------------------------------------- ==== This problem has bothered me for years. In elementary calculus we change integration variables. For 1d this is straightforward. For 2d we make use of the cross product to determine transformed areas. For 3d we use the dot-cross product to represent a cube of volume. So far so good. Now when we have more than 3 we use the Jacobian determinant which is on obvious extension to the 3d case. I have never seen a proof of the multidimensional case. Can someone point me to a reference? Kevin ==== Kevin, It comes down to a fact about determinants, whose proof can be found in any intermediate-level linear algebra text: volume(L(R)) = |det L|* volume(R) Use that with R = dV and L = the linearization of the integrand, i.e. the Jacobian. By the way, a wonderful reference is ``Linear Algebra Done Right by Sheldon Axler (Springer). See also ``Advanced Calculus of Several Variables by C.H. Edwards (Dover). ---- Selwyn Hollis slhollis@mac.com > This problem has bothered me for years. In elementary calculus we change > integration variables. For 1d this is straightforward. For 2d we make use of > the cross product to determine transformed areas. For 3d we use the > dot-cross product to represent a cube of volume. So far so good. Now when > we have more than 3 we use the Jacobian determinant which is on obvious > extension to the 3d case. I have never seen a proof of the multidimensional > case. Can someone point me to a reference? ==== > Over the years I've never had any success printing notebooks to PDF when > using acrobat. The documents never look like they do in the notebook due > apparently to several screwy font substitutions. I've never figured out how > to correct this. Mike: I had the same problem with Acrobat until I started selecting Embed All Fonts when I printed to a pdf. Since then I've had lots of students read documents on various systems without a problem. I'm using Acorbat with Mac OS 9.0.4. Ive been doing the same with OS X too, but not for long; so I can't say for sure that it works as well. Ken Levasseur UMass Lowell ==== Over the years I've never had any success printing notebooks to PDF when using acrobat. The documents never look like they do in the notebook due apparently to several screwy font substitutions. I've never figured out how to correct this. I'm wondering if it is possible to save a whole notebook as a postscript file. Some of the archived material in mathsource is postscript. If this is possible i wanted to see what the resulting file looks like in Ghostview and then maybe save as PDF from Ghostview. thanks Mike ==== There is an undocumented assumption in limit, which has already been discussed in this list , which is that Limit[Sin[z]/z, z -> Infinity] is actually Limit[Sin[z]/z, z -> Infinity,Direction->-1] If you do not know that you might find the following surprising (at least I did): Limit[Tan[x], x -> Pi/2] -Infinity This assumption is in fact controllable with the Direction function. As for (2), of course you are right, Limit does in a way know quite a lot of things. But the point is that there is no systematic way of incorporating the sort of assumptions the user might enter into a Limit computation. In other words, if you enter just the assumptions that Limit needs for your case they might be used, but slightly different ones, may not. In fact, I do not deny that you can introduce a simple assumptions mechanism, what I doubt is that it can do much more than you can already do by means of various substitutions of the kind you used in this problem. Your point (3) actually is a good illustration of the kind of thing that is likely to go wrong in a primitive assumption mechanism, by which I mean one that is based on trying to match some known patterns rather than using a general algorithm. The problem with syntactic pattern matching is that semantically (i.e. mathematically) equivalent expressions will usually not match the same pattern, and it is normally not possible to write out all possible patterns that amount to the same mathematical condition. The conditions a=1+Re[b] and a=Re[b] contain exactly the same mathematical information about a, but they are different as patterns. Different outputs in these cases seem to indicate that no general algorithm but only some kind of pattern matching is being used. So I think this example rather supports my position. Point (4) is simply a bug, which was pointed out by Jack Goldberg recently on this list. I certainly am not saying Limit is perfect, in fact I think its has very limited use. In my opinion it is only useful for dealing with singular cases where you need to consider Direction. In all other situations it is much better to use Series. I also doubt that adding an assumptions mechanism to Limit would make much difference. Fixing all the remaining bugs would do more. Andrzej Kozlowski > Andrzej makes sense in a way, but I have a few problems: (1) Since Limit[Sin[z]/z, z -> Infinity] evaluates to zero, Limit is > obviously making an assumption about z, and hence it's capable of making > assumptions. In this case, it's making an assumption we have no control > of, which can't be ideal. Also note this assumption isn't DOCUMENTED. (2) If a = Exp@Re@b;Limit[Sin[a z]/(a z), z -> Infinity] evaluates to > zero, Limit apparently knows that Exp@Re@b is >0 or, at least, > non-zero and real, and it uses that information in computing the limit, > does it not? How does it do that, if assumptions can't be handled in > the inner workings? (3) a=1+Re@b;Limit[Sin[a z]/(a z),z->Infinity] evaluates to zero, but a > = Re@b;Limit[Sin[a z]/(a z), z -> Infinity] is NOT evaluated. In both > cases, a==0 for b on a vertical line in the complex plane, but Limit > ignores that problem in case and not the other. (4) ClearAll[a, F];Limit[F[z, a], z -> 0] evaluates to F[0,y] but > ClearAll[a, F];F[z_, a_] := Sin[a z]/(a z);Limit[F[z, a], z -> Infinity] > is unevaluated. In the first case, Limit has made an unwarranted > assumption about F. In short, Limit can and does make assumptions; we simply can't control > them. If Andrzej's point is that algebraic software still can't do all the > work for us, that's obviously true. If he's saying Limit is doing all > it can reasonably be expected to do, I don't think so. (Witness these > anomalies in Limit's behavior.) -----Original Message----- > Sent: Friday, August 02, 2002 5:31 PM It is true that Mathematica could automatically replace parameters > which are positive by E^Re[a] or E^Abs[a], and make a few more > replacements of this kind (though it is not necessarily clear which one > would be the most helpful one in a given situation) but that would do no more than you can do by making such substitutions by hand. It would thus be only of cosmetic use (it may save you a typing a few characters, > although even then I am not sure that Assumptions-> ...{a>0} is that > much improvement on /.a->E^(Re[b])) but they would not help you to solve a single problem you can't do now. A serious assumptions mechanism > would be able to take an assumption and derive from it the consequences > significant for the convergence of a limit, in other words make > deductions and size estimations the way one does when working with > serious limit problems (e.g. using bounds on the coefficients in the > Taylor series ). Compare the assumptions mechanism in Integrate and in Simplify. The first works largely like what you are suggesting, in other words you have to know what assumptions are relevant (no deduction), > they must be just in the right form, and may be ignored even if they are relevant. The other let's you enter the actual conditions and let's > Mathematica itself make the necessary deductions. Also the original post said: > I don't want to write specific assumptions for each term in Limit > since I have many different variables and forms of a. The only wat to do this is to temporarily re-define Limit for the > particular problem at hand. Andrzej Kozlowski > There's nothing to prevent Limit from converting the condition a>=0 > into > the change of variables a=Exp@Re@b and computing the limit (no matter > what limit function or asymptote we're looking at), if Limit were made > assumption-aware. That's only one example, but I think most > conditions we'd be interested in can be handled similarly. > > -----Original Message----- > Sent: Friday, August 02, 2002 8:30 AM > In Mathematica 4.2, Help says in part ...Limit therefore makes no > explicit assumptions about symbolic functions. Same for the Package > NLimit. Therefore, I think we're out of luck here. > You can't make assumptions in Limit. There are not enough general > methods for such a mechanism to be really useful. > As an newbe observation, the only option for Limit (For Mathematica > 4. > 2) > is Direction. However, if you type ??Limit, there is another > Option > listed that appears not to be documented. That option is Analytic. > I > thought maybe this would solve this type of problem, but it does not. > I > do not know for sure what this option does. Anyone else?? > This is meant for the situations when you use a custom defined > function. > For example: > In[21]:= > Limit[f[Sin[x]/x], x -> 0] > Out[21]= > Limit[f[Sin[x]/x], x -> 0] > but > In[22]:= > Limit[f[Sin[x]/x], x -> 0, Analytic -> True] > Out[22]= > f[1] > Information[Limit, LongForm -> True] > Limit[expr, x->x0] finds the limiting value of > expr when x approaches x0... > Attributes[Limit] = {Listable, Protected} > Options[Limit] = {Analytic -> False, Direction -> Automatic} > As a possible workaround, would substituting many values for a > work? > Here is what I am thinking... > v = Table[Random[Real, {0, 2*Pi}], {100}]; > Union[(Limit[Sin[#1*x]/(#1*x), x -> Infinity] & ) /@ v] > I get all zero's like you predicted for many values of a. > {0} > If you try Integers, then I get an Indeterminate because the > limit > does not like a being 0. > v = Table[Random[Integer, {-4, 4}], {10}]; > Union[(Limit[Sin[#1*x]/(#1*x), x -> Infinity] & ) /@ v] > {0, Indeterminate} > Actually the problem is that the function Sin[z]/z is singular at > Infinity. Thus: > In[26]:= > Limit[Sin[z]/z, z -> Infinity, Direction -> -1] > Out[26]= > 0 > In[27]:= > Limit[Sin[z]/z, z -> Infinity, Direction -> -I] > Out[27]= > Infinity > In other words the limit depends on the direction. So when you > consider > Limit[Sin[a z]/(a z), z -> Infinity] > it is not clear in which direction the limit is being taken. This > depends on whether a is real or not (as Treat already pointed > this > out in his message),and of course there is the special case a==0. > Since Limit does nto allow assumptions to be entered if you know that > you will be dealing with such cases frequently one approach is to > redefine limit: > Unprotect[Limit]; > In[28]:= > Limit[Sin[a_*x_]/(a_*x_), x_ -> Infinity] /; > Im[a] == 0 && a != 0 = 0; > Limit[Sin[a_*x_]/(a_*x_), x_ -> Infinity] /; > Re[a] == 0 && a != 0 = Infinity; > In[30]:= > Protect[Limit]; > Now you need to enter assumptions about a's or b's, e.g.: > In[31]:= > a/:Im[a]=0; > In[32]:= > a/:(a.89ลส0)=True; > this says a is a non-zero real. Limit will now return the expected > answer: > In[33]:= > Limit[Sin[a*x]/(a*x), x -> Infinity] > Out[33]= > 0 > similarly for the case when b is non zero and imaginary we will get: > In[34]:= > b /: Re[b] = 0; > In[35]:= > b /: b != 0 = True; > In[36]:= > Limit[Sin[b*x]/(b*x), x -> Infinity] > Out[12]= > Infinity > If you are sure you are going to onl be dealing with non-zero real > numbers you can redefine Limit to return always 0 in such cases, which > may make it simpler to deal with a large number of them in one go. > > -- > Dana > Windows XP & Mathematica 4.1 > = = = = = = = = = = = = = = = = = > Sorry for 'refreshing' this message but does anyone know if I can > define the assumption below. > I don't want to write specific assumptions for each term in Limit > since I have many different variables and forms of a. Is it possible > to generalise the assumption? > it would really help me (and I really don't want to have to buy any > additional maths software). > I am also interesting in the solution of how to make an > asumption > in Mathematica. I can't find any method in Mathematica. If anybody > you all .. > I know that this should be 0 but why can't I get mathematica to > think likewise. > In[4]:= Limit[Sin[a*x]/(a*x),x->Infinity] > Sin[a x] > Out[4]= Limit[--------, x -> Infinity] > a x > Is the problem a? How can I specify the properties of or > assumptions that may be made about a? ==== Where does one get PowerDesk? Does it work with Windows 98? One of the problems that has to be faced is: Can all users unzip the file in the proper way? Almost everyone can unzip files. How many can unzip them when they have special features. If I am going to make a package available, I want it available in a format that EVERYBODY can use. What is the best way to do that? David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ ==== > > When I executed my program in mathematica 4.1, I had a problem with the > PseudoInverse. The error massage is : > PseudoInverse:: cfail, Algorithm faild to converge > Perhaps, the problem is that the matrix is singular. Can you give some > suggestions to solve this problem? Or is there some function of Mathematica > useful for this? > > El Mnafeg Ouafa > Doctorat Student > Ecole Polythechnique Montreal > Montreal Canada It sounds like a failure in the underlying SingularValues computation. This happens, though rarely, when working with machine arithmetic. You might try it at higher precision (you can use SetPrecision for this) to see if it converges then. It will, however, be alot slower. If your matrix did not have machine numbers then post it or send it and I can have a closer look. Daniel Lichtblau Wolfram Research ==== When I executed my program in mathematica 4.1, I had a problem with the PseudoInverse. The error massage is : PseudoInverse:: cfail, Algorithm faild to converge Perhaps, the problem is that the matrix is singular. Can you give some suggestions to solve this problem? Or is there some function of Mathematica useful for this? El Mnafeg Ouafa Doctorat Student Ecole Polythechnique Montreal Montreal Canada ==== >I'm wondering if it is possible to save a whole notebook as a >postscript file. Some of the archived material in mathsource is >postscript. If this is possible i wanted to see what the resulting >file looks like in Ghostview and then maybe save as PDF from >Ghostview. Yes, it is possible to save a notebook as postscript and convert it to PDF using GhostView. Details of how to save a notebook file to postscript can be found on the Mathsource site. Look at item 0211-598. There is one other issue you will need to address. A standard installation of GhostView will not include the fonts Mathematica uses. You will need to copy the needed fonts to an appropriate directory. Details on doing this can be found in the documentation for GhostView. ==== I am still relatively new to Mathematica so please take this into account in reacting to this perhaps simple question. Namely, suppose I have written some code in a given notebook, saved it, and then exited in and closed Matheamtica.Later I restart Mathematica and open the same notebook. Am I supposed to take some particular step before continuing my work? To be concrete, suppose I have a Do loop with some parameter p that previously I had set at p = 10 and now (in restarting) I want to return to the Do loop and replace the 10 with another number, and then evaluate the cell, e.g., to display a bar chart for a list determined by the new value. My experience, as limited as it is, is that this doesn't work unless I go up to the top of that notebook and re-evaluate all the cells leading up to the Do loop. Yet, it is doubtful that this is what experienced Mathematica users do -- so what steps should one take in order to have total continuity from day 1 to day 2, say, in developing and evaluating code in a given notebook? Tom ==== Is there any way to swap x and y axis in Plot command?? I tried something like fja := Display[$Display, #,ImageRotated->True] & Plot[Sin[t], {t, 0, 3Pi/2}, DisplayFunction :> fja] but it doesn't work. Help!! Note: I prefer avoiding ListPlot, if possible... ==== > Over the years I've never had any success printing notebooks to PDF when > using acrobat. The documents never look like they do in the notebook due > apparently to several screwy font substitutions. I've never figured out how > to correct this. > > I'm wondering if it is possible to save a whole notebook as a postscript > file. Some of the archived material in mathsource is postscript. If this is > possible i wanted to see what the resulting file looks like in Ghostview and > then maybe save as PDF from Ghostview. You can do this under Windows and MacOS by installing a PostScript printer driver, choosing this printer as your target from Mathematica, and then specify that the driver write its ouput to a file rather than a printer port. You can download the generic PostScript driver directly from Adobe's website: http://www.adobe.com/support/downloads/main.html#Printer The X Window version of Mathematica emits PostScript when printing, so it suffices just to click on the print dialog radio button that directs its output to a file. -- ==== Can Mathematica find a non-recursive function equivalent to a given recursive function? ==== After giving this matter a little more thought I have convinced myself that I now know the right way functions like Limit ought to work. The idea is illustrated by the following re-definition of Limit to deal with the case that started this thread: In[1]:= Unprotect[Limit]; Limit[Sin[a_*x_]/(a_*x_), x_ -> Infinity] := If[Im[a] == 0 && a != 0, 0, If[Re[a] == 0 && a != 0, Infinity, Limit[Sin[a*x]/(a*x), x -> Infinity]]]; Protect[Limit]; Observe that with this re-definition we can now use Simplify with assumptions: In[4]:= Simplify[Limit[Sin[a*x]/(a*x), x -> Infinity], a > 0] Out[4]= 0 In[5]:= Simplify[Limit[Sin[a*x]/(a*x), x -> Infinity], a < 0] Out[5]= 0 In[6]:= Simplify[Limit[Sin[a*x]/(a*x), x -> Infinity], Re[a] == 0 && Im[a] != 0] Out[6]= Infinity Moreover, if we know nothing about a we get: In[7]:= Limit[Sin[a*x]/(a*x), x -> Infinity] Out[7]= If[Im[a] == 0 && a != 0, 0, If[Re[a] == 0 && a != 0, Infinity, Limit[Sin[a*x]/(a*x), x -> Infinity]]] This has the advantage of telling us immediately what assumptions Mathematica needs to return an answer to this problem. The point is that this way we already know that there is no use entering other assumptions unless they imply the conditions given by If. Andrzej Kozlowski > In Mathematica 4.2, Help says in part ...Limit therefore makes no > explicit assumptions about symbolic functions. Same for the Package > NLimit. Therefore, I think we're out of luck here. You can't make assumptions in Limit. There are not enough general > methods for such a mechanism to be really useful. > As an newbe observation, the only option for Limit (For Mathematica > 4.2) > is Direction. However, if you type ??Limit, there is another Option > listed that appears not to be documented. That option is Analytic. I > thought maybe this would solve this type of problem, but it does not. I > do not know for sure what this option does. Anyone else?? This is meant for the situations when you use a custom defined > function. For example: In[21]:= > Limit[f[Sin[x]/x], x -> 0] Out[21]= > Limit[f[Sin[x]/x], x -> 0] but In[22]:= > Limit[f[Sin[x]/x], x -> 0, Analytic -> True] Out[22]= > f[1] > Information[Limit, LongForm -> True] > Limit[expr, x->x0] finds the limiting value of > expr when x approaches x0... > Attributes[Limit] = {Listable, Protected} > Options[Limit] = {Analytic -> False, Direction -> Automatic} > As a possible workaround, would substituting many values for a work? > Here is what I am thinking... > v = Table[Random[Real, {0, 2*Pi}], {100}]; > Union[(Limit[Sin[#1*x]/(#1*x), x -> Infinity] & ) /@ v] > I get all zero's like you predicted for many values of a. > {0} > If you try Integers, then I get an Indeterminate because the limit > does not like a being 0. > v = Table[Random[Integer, {-4, 4}], {10}]; > Union[(Limit[Sin[#1*x]/(#1*x), x -> Infinity] & ) /@ v] > {0, Indeterminate} Actually the problem is that the function Sin[z]/z is singular at > Infinity. Thus: In[26]:= > Limit[Sin[z]/z, z -> Infinity, Direction -> -1] Out[26]= > 0 In[27]:= > Limit[Sin[z]/z, z -> Infinity, Direction -> -I] Out[27]= > Infinity In other words the limit depends on the direction. So when you consider Limit[Sin[a z]/(a z), z -> Infinity] it is not clear in which direction the limit is being taken. This > depends on whether a is real or not (as Treat already pointed > this out in his message),and of course there is the special case a==0. Since Limit does nto allow assumptions to be entered if you know that > you will be dealing with such cases frequently one approach is to > redefine limit: Unprotect[Limit]; In[28]:= > Limit[Sin[a_*x_]/(a_*x_), x_ -> Infinity] /; > Im[a] == 0 && a != 0 = 0; > Limit[Sin[a_*x_]/(a_*x_), x_ -> Infinity] /; > Re[a] == 0 && a != 0 = Infinity; In[30]:= > Protect[Limit]; > Now you need to enter assumptions about a's or b's, e.g.: In[31]:= > a/:Im[a]=0; In[32]:= > a/:(a.89ลส0)=True; this says a is a non-zero real. Limit will now return the expected > answer: In[33]:= > Limit[Sin[a*x]/(a*x), x -> Infinity] Out[33]= > 0 similarly for the case when b is non zero and imaginary we will get: In[34]:= > b /: Re[b] = 0; In[35]:= > b /: b != 0 = True; > In[36]:= > Limit[Sin[b*x]/(b*x), x -> Infinity] Out[12]= > Infinity If you are sure you are going to onl be dealing with non-zero real > numbers you can redefine Limit to return always 0 in such cases, which > may make it simpler to deal with a large number of them in one go. > -- > Dana > Windows XP & Mathematica 4.1 > = = = = = = = = = = = = = = = = = > Sorry for 'refreshing' this message but does anyone know if I can > define the assumption below. > I don't want to write specific assumptions for each term in Limit > since I have many different variables and forms of a. Is it possible > to generalise the assumption? > it would really help me (and I really don't want to have to buy any > additional maths software). > I am also interesting in the solution of how to make an asumption > in Mathematica. I can't find any method in Mathematica. If anybody > you all .. > I know that this should be 0 but why can't I get mathematica to > think likewise. > In[4]:= Limit[Sin[a*x]/(a*x),x->Infinity] > Sin[a x] > Out[4]= Limit[--------, x -> Infinity] > a x > Is the problem a? How can I specify the properties of or > assumptions that may be made about a? > ==== You should be able to find this in every book which deals with integration on manifolds. The first one I looked at is Michael Spivak's short and elegant undergraduate text Calculus on manifold(1965 edition) which has the proof on page 67. Andrzej Kozlowski > This problem has bothered me for years. In elementary calculus we change > integration variables. For 1d this is straightforward. For 2d we make > use of > the cross product to determine transformed areas. For 3d we use the > dot-cross product to represent a cube of volume. So far so good. Now > when > we have more than 3 we use the Jacobian determinant which is on > obvious > extension to the 3d case. I have never seen a proof of the > multidimensional > case. Can someone point me to a reference? > Kevin > ==== >Can Mathematica find a non-recursive function equivalent to a given >recursive function? >Anyone who knows, please, please, please, reply... Look at the on-line documentation for the standard add-on package DiscreteMath`RSolve` Bob Hanlon Chantilly, VA USA ==== >Is there any way to swap x and y axis in Plot command?? > >I tried something like > >fja := Display[$Display, #,ImageRotated->True] & >Plot[Sin[t], {t, 0, 3Pi/2}, DisplayFunction :> fja] > >but it doesn't work. > >Help!! > >Note: I prefer avoiding ListPlot, if possible... Module[{plt = Plot[Sin[x], {x, 0, 2 Pi}, DisplayFunction -> Identity]}, Show[plt /. {x_?NumericQ, y_?NumericQ} -> {y, x}, AspectRatio-> 1/(AspectRatio /. AbsoluteOptions[plt]), ImageSize -> 178, DisplayFunction -> $DisplayFunction]]; Bob Hanlon Chantilly, VA USA ==== Dear Chrisopher, here is a simple rough and dirty way to set up functions that use dummy variables. As an example, I set up functions which simulate Sum[...]. The simplest, but inefficient strategy is to use substitution: sumsim0[f_,{dum_Symbol,lo_Integer,up_Integer}]:= Block[{i},Plus@@Table[f/.dum->i,{i,lo,up}]] Evaluation can be increased considerably, if you generate a local Function object using Evaluate, since then the slow pattern substitution can be avoided: sumsim[f_,{dum_Symbol,lo_Integer,up_Integer}]:= Block[{i,ff}, ff=Function[{i},Evaluate[f/.dum->i]]; Plus@@Table[ff[i],{i,lo,up}]] Example: sumsim[f[a,{b,c},d],{a,0,2}] returns f[0,{b,c},d]+f[1,{b,c},d]+f[2,{b,c},d] This is only a rough and dirty implemenation, since it does not account for how f is defined. For example, if the definition of f were f[a,b_]:=(a+b)^2 sumsim[f[a,b],{a,0,2}] would replace 'a' subsequently by 0,1,2 and produce b^2 + (1+b)^2 + (2+b)^2, which is not correct, since there appears no Blank (_) after a in the definition of f and f should be returned unevaluated if its firs argument is not 'a'. You could account for this by using the tests in the following version more sophisticated of the program: SetAttributes[sumsim,HoldFirst] sumsim[f_,{dum_Symbol,lo_Integer,up_Integer}]:= Module[{i,ff,argli=Apply[List,Unevaluated[f]], h=Head[Unevaluated[f]]}, If[TrueQ[Apply[h,argli/.dum->i]==f], ff=Function[{i},Evaluate[f/.dum->i]]; Plus@@Table[ff[i],{i,lo,up}], Plus@@Table[Apply[h,argli/.dum->i],{i,lo,up}]]] Johannes Johannes > > How do I set up a function that behaves like the Mathematica function Sum vis-a-vis > its treatment of dummy variables? For example I can define i=6 and then > enter > > Sum[f[i],{i,1,n}] > > and mathematica will not make the substitution i->6 even though the output > generally still involves the dummy variable i. I figure this has something > to do with Modules, Blocks, and Holds but I'm not sure how to put it all > together. Any help would be greatly appreciated. -chris > <><><><><><><><><><><><><><><><><><> Johannes Ludsteck Institut fuer Volkswirtschaftslehre Lehrstuhl Prof. Dr. Moeller Universitaet Regensburg Universitaetsstrasse 31 93053 Regensburg ==== Constantine: Look at the Standard Add-On package RSolve. It's one of the DiscreteMath packages. Best, Harvey Harvey P. Dale University Professor of Philanthropy and the Law Director, National Center on Philanthropy and the Law New York University School of Law Room 206A 110 West 3rd Street New York, N.Y. 10012-1074 -----Original Message----- ________________________________________________________________________ service. For more information on a proactive anti-virus service working around the clock, around the globe, visit http://www.messagelabs.com ________________________________________________________________________ ==== This is a repost of a question I asked last week. Apparently, I wasn't clear about my problem. I have written a function that is similar to the Mathematica function Sum in that the user needs to use dummy indicies in order to CALL the function. That is, one enters, mysum[f[i,j,k,...],{i,mini,maxi},{j,minj,maxj},{k,mink,maxk},...] The function works the way I want it to except that I must be certain that the dummy variables i, j, k, etc... are not already defined in the Global context. In other words, because I have not done anything special in defining the function, Mathematica will substitute in any Global values that exist for i, j, k, before using the arguments of mysum in a computation. I would rather be able to use dummy indicies without making sure that they are not already defined. The Mathematica function Sum behaves this way. How do I write a function like that? I figure this has something to do with setting attributes for mysum but I haven't been able to work out all the details. Any help would be much appreciated. thanks in advance -ciao -chris ==== Mihajlo, Try... ParametricPlot[{Sin[t], t}, {t, 0, 3Pi/2}, AspectRatio -> 2]; David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Sender: steve@smc.vnet.net Approved: Steven M. Christensen , Moderator ==== Tom, Basically, if you want to open a notebook and evaluate some cell in the notebook, then every cell that loads a package, creates or contributes to a definition or calculates a quantity used by that cell must be evaluated first. No other cells need to be evaluated. So this raises the question of how to organize a notebook that will be easy to come back to, or easy for others to look at. This is how I do it. It is not the only way, and it may not be the best way, but it works for me. First, learn how to use Cell grouping (Sections, Subsections, Subsubsections), and how to open and close Cell groups. Stay with the default AutomaticGrouping. It has a few minor weak points but basically everybody knows how it works and it does the job. I put all of the initialization statements at the top of the notebook. These are generally Needs statements to load any needed packages. You might also want statements to turn off the spelling warning messages. If there are a lot of general initialization statements I put them into a Section called Initialization. I make these cells Initialization cells. When you first save the notebook, Mathematica will ask if you want to create an AutoSavePackage. Answer No. The next time you load the notebook and try to evaluate ANY Input cell, Mathematica will automatically ask if you want to evaluate the initialization cells. Answer Yes. I then create a Section called Routines. It is initially empty. However, as I work on the material I often find that I have to develop little routines that do various subcalculations. Once I have such a routine perfected (sic!) I move it to the Routines Section and make it an Initialization cell. (It is also a good practice to write usage statements for these routines. Later, it will help you and others understand what the routines do and how to use them. Also, if you create a collection of nifty routines, you are not far from turning them into a package.) Suppose I am working on some topic, say Topic1. I will create a Topic1 Section and then try to work it out. Often my first attempts don't work very well, so I will change the Section head to Topic1 - First Try, copy it and try again. When I get it worked out, I will delete all of the initial attempts, and move any routines I developed to the Routines Section. You can then turn the remaining Topic1 Section into a nice exposition section where you actually do the calculation you want in a clear and clean manner. If you come back to the notebook later, you can go directly to the Topic1 section and start evaluating the first cell. All of the Initialization cells needed will automatically be evaluated. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ the Do loop and replace the 10 with another number, and then evaluate the cell, e.g., to display a bar chart for a list determined by the new value. My experience, as limited as it is, is that this doesn't work unless I go up to the top of that notebook and re-evaluate all the cells leading up to the Do loop. Yet, it is doubtful that this is what experienced Mathematica users do -- so what steps should one take in order to have total continuity from day 1 to day 2, say, in developing and evaluating code in a given notebook? Tom Reply-To: ==== >>Can Mathematica find a non-recursive function equivalent to a given recursive function? Sometimes. Look for recurrence relations in Help. In general, it requires thought, and that's YOUR job, not Mathematica's. See below for hints. Look up Recursive functions in help and read the section on functions that remember their values. Note two important points, in addition to what it says there: 1) You're trading space for time. If the values you're saving take up a LOT of space and/or you're saving a LOT of values, that can become a problem. 2) If you compute, for instance, F[2000] and F is recursive (with or without saving values) you'll run into $RecursionLimit. The simple fix is to make sure you compute things from bottom up rather than top down. If the first thing you need is F[2000], compute the others first like this: Last[F/@Range[2000]] You can also use a non-recursive definition like the following (for the Fibonacci example). If you want the n-th term of the Fibonacci series, do something like this: nxt[{a_, b_}] := {b, a + b} fib[n_] := Last[Nest[nxt, {0, 1}, n - 1]] fib[7] fib /@ Range[10] 13 {1, 1, 2, 3, 5, 8, 13, 21, 34, 55} This method is best if you won't need again the values you've already computed; if you will, save values as explained in Help. Treat -----Original Message----- ==== In the help pages I found how to find a non recursive function equivalent to a function that has one argument. More precisly I'm looking for a general non-recursive formula for the following recursive function (has 2 arguments): S[0,0] = 1 S[k_,m_] := Which [ k < 0, 0, m < 0, 0, True, p*S[k-1,m] + (1-p)*S[k,m-1]] I'll be very pleasant if anyone can help or give a hint in how to find the equivalent non-recursive function. Constantine. Constantine Elster Computer Science Dept. Technion I.I.T. Office: Taub 411 ----- Original Message ----- > that remember their values. Note two important points, in addition to > what it says there: 1) You're trading space for time. If the values you're saving take up > a LOT of space and/or you're saving a LOT of values, that can become a > problem. 2) If you compute, for instance, F[2000] and F is recursive (with or > without saving values) you'll run into $RecursionLimit. The simple fix > is to make sure you compute things from bottom up rather than top down. > If the first thing you need is F[2000], compute the others first like > this: Last[F/@Range[2000]] You can also use a non-recursive definition like the following (for the > Fibonacci example). If you want the n-th term of the Fibonacci series, > do something like this: nxt[{a_, b_}] := {b, a + b} > fib[n_] := Last[Nest[nxt, {0, 1}, n - 1]] > fib[7] > fib /@ Range[10] 13 > {1, 1, 2, 3, 5, 8, 13, 21, 34, 55} This method is best if you won't need again the values you've already > computed; if you will, save values as explained in Help. Treat -----Original Message----- > Sent: Sunday, August 04, 2002 5:01 AM Can Mathematica find a non-recursive function equivalent to a given > recursive function? > Anyone who knows, please, please, please, reply... > Constantine Elster > Computer Science Dept. > Technion I.I.T. > Office: Taub 411 ==== >Is there any way to swap x and y axis in Plot command?? >I tried something like >fja := Display[$Display, #,ImageRotated->True] & Plot[Sin[t], {t, 0, >3Pi/2}, DisplayFunction :> fja] >but it doesn't work. You might try ParametricPlot. Your example above could be done as ParametricPlot[{Sin[t],t},{t, 0, 3Pi/2}] ==== I have been using Mathematica for basic stuff so far and find myself lost on how to acheive the following: I need to extract the last numerical value of 'a' in Solve ( without the 'a ->'), so I can use it elsewhere, without having to type it in. Here is what Solve[Sin[a]==0.4717 * Sin[(Pi/3)-a],a]; Last[a /. %] The problem is that the value in '%' is not the output of Solve, but the whatever operation came before that! Any help on how to extract the last numerical from solve will be greatly appreciated. Kaustubh __________________________________________________ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com ==== Is this the sort of thing you are looking for: g = Plot[Sin[t], {t, 0, 3Pi/2}] Show[g /. x_Line :> Map[Reverse, x, {2}]] ?? Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ > Is there any way to swap x and y axis in Plot command?? I tried something like fja := Display[$Display, #,ImageRotated->True] & > Plot[Sin[t], {t, 0, 3Pi/2}, DisplayFunction :> fja] but it doesn't work. Help!! Note: I prefer avoiding ListPlot, if possible... >