A35 === Hi,Export[img.gif,{graph1,graph2,..},??Look in the additional information part of the Online documentation ofExport[] Jens ==== =Dear group, I have m balls shared in n box. What is the probability that one box has r o more balls?If m = 4, n=3 and r = 2 the solution will be (?): In[1] := Needs[DiscreteMath`Combinatorica`]In[2] := list = Compositions[4,3];In[3] := (Count[list,2,2]+Count[list,2,3]+Count[list,2,4])/(3 Length[list])The question is that this way works only when m and n are small , but for values sush as m=20, n=11 and r=5 the computer is out of memory. Any idea?GuillermoSanchez---------------------------------------- -----This message was sent using Endymion MailMan. ==== =HiHow can I tell Mathematica to pull a particular factor out of an expression.For example in this expression:{(a - 2*wone*Sin[a*t])/4, (a - 2*wone*Sin[a*t])/4, (a + 2*wone*Sin[a*t])/4,(a + 2*wone*Sin[a*t])/4, (-a - 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/4, (-a - 2*Sqrt[a^2 +wone^2*Sin[a*t]^2])/4, (-a + 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/4, (-a + 2*Sqrt[a^2 +wone^2*Sin[a*t]^2])/4}I would like to bring the a out to the front of the expression, evenoutside the matrix.How can I ask Mathematica to do this, and how can I stop the a justßoating back into the main expression?YoursChris RodgersSt John's Collegehttp://rodgers.org.uk/Reply-To: kuska@informatik.uni-leipzig.de ==== =Hi,something like:13];NotebookPut[nb] Jens ==== =John,There is a nice trick for this. It works on every operating system and all versions of Mathematica from at least 4.0 onward (and probably earlier). It uses the undocumented function System`Private`FindFile, but if that ever goes away we'll have to add something to take its place because J/Link uses this exact technique to find its application resources.Put a line like this in your .m file: thisPackageDirectory = DirectoryName[System`Private`FindFile[$Input]]The variable thisPackageDirectory will get the directory name in which the .m file resides no matter how the user reads the package, e.g.: < Mathematica1 ... Math4 <-> Mathematica4 aremostly unchanged but the Math5 font has the gothic, the double struckand the caligraphic alphabet inside. Now Mathematica5 hold thecaligraphiccharacters, Mathematica6 the ghotic characters and Mathematica7 thedouble struck characters. And so your trick work for greek lettersbut not for ghotic, double struck and some of the caligraphicletters. Jens> Dear MathGroupers,> Mathematica 4.2 comes with seven font families, compared with five in the> previous version. I am wondering if anyone knows how compatible these fonts> are.> The reason I ask is that I have a large number of graphics exported from> Mathematica 4.1 under Mac OS 9, which now need to be incorporated into a> (pdf)LaTeX document under Mac OS X. TeXShop/teTeX under Mac OS X chokes> badly on the OS9 versions of the old font sets, but if I edit my LaTeX .map> file to tell pdfLaTeX to embed Mathematica1.pfa instead of Math1(.pfa),> everything seems to work. Ditto for Mathematica2/Math2. So I'm getting rhos> and thetas where I should be getting rhos and thetas. This is a relief, but> I'm wondering whether this trick will work in general for Mathematica> graphics generated under from previous versions. What's in the new fonts> that's not in the old fonts? The documentation just says New characters for> double struck, script, and Gothic numbers, the planets, and musical notes.> Does this mean that Math[Bold,Mono][1-5] = Mathematica[Bold,Mono][1-5]?> Luci EllisReply-To: kuska@informatik.uni-leipzig.de ==== =look at the online-help for Graphics[] ! What is listed first ??The following graphics primitives can be used:....andThe following graphics directives can be used:What else can be done ? Should the text color red ?and ßashing ? Jens> So today I'm doing some graphics. Oh: there are _options_ and _directives_.> So I try to find out what are all the graphics primatives?> When you look in the index of the 1500 page book, or type Graphics Primatives> in the on-line Help, you don't find it. You have to look under Graphics or> Graphics3D. In the book, it's in the appendix.> And the entry in the appendix is not quite complete:> It says Graphics[primatives, options] represents a two-dimensional graphical> image.> It should say returns a graphis object The reason is that the appendix is> the place for the complete and formal description of the functions and all> their arguments and returns. No longer the place for chatty-teachy.> (represents is chatty-teachy)> To understand the system, I need to be able to trace the sequence> Line[...] is a graphics _primative_> Graphics[ ... graphics primatives ....] is a graphics _object_> Show [... graphics object...] puts a picture on the screen.> I don't know if this sounds dumb on my part, but I do know that I have just> wasted a bunch of time on this, and that having to go back and forth just to> find out the type of the return of a function (to use old fashioned> nomenclature) .... which people knew thirty years ago was part of documenting a> system .... seems pretty dumb on the part of Mathematica.> Dave GolberReply-To: kuska@informatik.uni-leipzig.de ==== => What this example shows is that the description> Graphics[primatives,options] represents ...> is inconsistent. The first written argument primatives must be an actual> single argument. If you want to submit several graphics primatives, you must> combine them into a List.If there are multiple elemts allowed the documentation would writeGraphics[primitive1,primitive2,...,options]as to see in the documetation for Union[]> On the other hand, the second written argument may be multiple actual> arguments, or may be a List.> The documentation is inconsistent.> I see no explanation of this any part of the Appendix. And it's particularly> disappointing because systems were able to document these sorts of things> decades ago.> Sorting this kind of thing out takes hours. Every time I do something slightly> new with Mathematica, I find I spend a lot of time because of sloppy> documentation.Hmm, sloppy documentation ? realy ? My Windows XP came with a 12 pagesbooklet*that* is a sloppy documentation ! The book should be splitted into3 or 4 parts and it is to heavy to read it in a bathtub but it isnot sloppy.> I'd really like to hear Mathematica personnel report on (1) Do they agree there> is an error here, and (2) When do they expect to have corrections available.> And by the way: another thing that needs to be corrected in the documentation> of Graphics is how graphics directives get used . The header line is:> Graphics[primatives,options]> Unfortunately, a graphics directive is neither a primative or an option. And> sure enough, when we read a little farther on, we see The following graphics> primatives can be used This is vague. Used how? Remember that the appendix> the Appendix.)> (The fact that the body can say nothing better than the vague statement that> directives can be used is of course a result of the fact that the form> Graphics[primatives,options] does not allow directives.)There is a much harder inconsistence in Mathematicas Graphic[], thegraphics directives should be options to the primitives and notstandalonefunctions, i.e.,Line[{{0,0},{1,1}}, Color->RGBColor[1,0,0]]instead of{RGBColor[1,0,0],Line[{{0,0},{1,1}}]}May be that you save a lot of time when you readhttp://www.amazon.com/exec/obidos/ASIN/0387940472/qid= 1038213121/sr=2-1/ref=sr_2_1/002-6128995-6365638andhttp:// www.math.ubc.ca/people/faculty/cass/graphics/text/www/ index.html Jens ==== =This will take you pretty close:FullSimplify[ComplexExpand[ d*Pi + I*d*(Log[M] - 2*Log[(-I)*Sqrt[(M*r)/d] + Sqrt[M - (M*r)/d]]), TargetFunctions -> {Re, Im}], M > 0 && 0 < r < d]d*(Pi + 2*ArcTan[Sqrt[M - (M*r)/d], -Sqrt[(M*r)/d]])Still, there appears to be something missing among the rules FullSimplify is applying.It seems related to the following behaviour, that certianly suggests a bug:FullSimplify[ArcTan[x, y], {x > 0, y < 0}]ArcTan[x, y]FullSimplify[ArcTan[2*x, 2*y], {x > 0, y < 0}]ArcTan[y/x]>> I'm trying to simplify (M, r, d are positive reals with r d*Pi + I*d*(Log[M] - 2*Log[(-I)*Sqrt[(M*r)/d] + Sqrt[M - (M*r)/d]])>> to>> 2*d*ArcCos[Sqrt[r/d]]>> I've tried applying>> FullSimplify[#,M>0 && 0> and>> ExpToTrig>> but Mathematica won't get rid of the Log and the I and give me the > ArcCos.>> Does anyone know which Mathematica functions to apply to my expression > to> give me the simplification I want?>>>>Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ ==== =Dear Borut,The problem is that Mathematica does not export proprietary fonts. The solution depends on which Mathematica version you use.If you use Mathematica 4.0 or 4.1, you can download paul hinton's emmathfnt tool which manages inclusion of the fonts or you can configure ghostscript so that it puts Mathematica fonts into the graphics files.If you use 4.2.0, give it up, since font export isn't possible any more for the unexperienced user. This is because the emmathfnt tool does not work with the newfont naming scheme. And neither the emmathfnt tool nor hinton who explained me the issues involved in a friendly and clear reply and referred me to the wolfram support team. Now I am waiting about one week for an answer from support@wolfram.com.If you are an experienced user (with a c compiler available), try to adapt the source code of emmathfnt and recompile it. I tried to do this but I failed, since I don't understand the font naming scheme and other details.If you use version 4.2.1, you can configure font export in the preferences dialog (or give it as an option).[Wolfram research seems to have realized *finally* that eps font export is an important feature demanded by many users. It is surprising that this process lasted some years, since EPS font export questions were a FAQ in MathGroup.] If you have premier service, simply obtain the updatedversion. Johannes Ludsteck> As I am generating Mathematica images for inserting them into TeX, problems> occur, like> f(t) seen as fHtL on EPS image in GSView, FontFamily->Trebuchet MS (or> Helvetica) not taken into account, ...> Can you direct me to any relevant material on the internet, book about ways> to tackle this problems?> Borut Levart> <><><><><><><><><><><><><><><><><><>Johannes LudsteckInstitut fuer VolkswirtschaftslehreLehrstuhl Prof. Dr. MoellerUniversitaet RegensburgUniversitaetsstrasse 3193053 Regensburg ==== =>> 1. If I want to print out the elements of S which have order 15, do I > use a> nested If or Do loop?I think here by print out you mean just make a printable list of the elements? In that case you do not need any loops or nested Ifs. Mathematica's programming language is quite different form most others. It's more like Lisp and Prolog than any more usual ones (you can also program in that style, called imperative, but doing so in Mathematica is inefficient). So here is how to make a list of elements which have order 15.S = Flatten[Outer[List, Range[0, 89], Range[0, 35]], 1];mult[{a_, b_}, {c_, d_}] := {Mod[a + c, 90], Mod[b + d, 36]}ord[p_] := Length[NestWhileList[mult[p, #1] & , p, #1 != {0, 0} & ]]orders = Map[ord,S];So now S is the list of elements and orders a list of orders. You can get all elements of order 15 with:Extract[S,Position[orders,15]]{{6,0},{6,12},{6,24},{12,0 },{12,12},{12,24},{18,12},{18, 24},{24,0},{24,12},{24,24},{36,12},{36, 24},{42,0},{42,12},{42,24},{48,0},{48,12},{48,24},{54,12},{54 , 24},{66,0},{66,12},{66,24},{72,12},{72,24},{78,0},{78,12},{78 , 24},{84,0},{84,12},{84,24}}>> 2. I have just ordered the Mathematica Link to EXCEL package. I will > use it> able to> find a way to get all of the output of the table to print on > Mathematica. I> have tried page wrap of various sorts. Is there a way?I think here by print out you mean print out on a printer? This sounds like a problem with your particular operating system which I most likely cannot solve. I use Mathematica on Mac OS X and a PostScript printer any have never had any problems with printing. If you really have a printing problem you should describe precisely the hardware and the operating system you are using and someone will probably be able to help you.If on the other hand you are referring to printing out a table on the screen: just use the command TableForm to format your output as a table. It takes various options that can make it look nicer. But I think you were referring to real printing.Andrzej> Andrzej,> Two questions:>> 1. If I want to print out the elements of S which have order 15, do I > use a> nested If or Do loop?>> 2. I have just ordered the Mathematica Link to EXCEL package. I will > use it> able to> find a way to get all of the output of the table to print on > Mathematica. I> have tried page wrap of various sorts. Is there a way?>> much> more fun.>> Diana> Mathematica groupies,>> I just got my copy of Mathematica tonight. I understand permutations >> of> S_5>> and A_5, etc., but I am having a little difficulty figuring out how to>> calculate the order of elements of Z_90 and Z_36, and the order of> elements>> of the external direct product of Z_90 (+) Z_36.>> I am wanting to calculate the number of cyclic subgroups of order 15 >> in> Z_90>> (+) Z_36 with Mathematica.>> Z_90 is the additive group {0, 1, 2, 3, ..., 89}. Z_36 is the additive> group>> {0, 1, 2, 3, ..., 36}.>> So, elements of Z_90 (+) Z_36 would be 2-tuples of the form: (a, b), >> where> a>> is an element of Z_90, and b is an element of Z_36. If you add (a, b) >> to>> itself 15 times, you will get {0, 0}. Note that the operation of >> adding> the>> first component of the 2-tuple is modulo 90, and the operation of >> adding> the>> second component of the 2-tuple is modulo 36.>> Can someone help?>> Diana M.>>>>Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ ==== =Not a function call but a pattern with Head tree. Actually pretty basic Mathematica programming. Look up the Mathematica book under Head etc. Oh, by the way, one more thing. Knowing too much about other programming languages is actually a bit of a handicap as far as Mathematica is concerned, unless they are Lisp and Prolog (and even then you have to be pretty careful for things tend to be not quite what they seem...)Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> I found this:> rightTree[tree[_, _, right_]] := right>> in Dr. Mç.94ç[Times]der's Computer Science with Mathematica. I understand the > spirit of> the statement, but it looks rather strange to me. Is there a way of> describing, in a language such as English, exactly what this definition> means? The part that I find confusing is the inclusion of what looks > like a> function call in the parameter list. This simply defies my sense of > how> programming languages work. That doesn't mean it's a bad thing. It > just> means that I don't feel comfortable with the syntax.>> Is there somewhere in the Mathematica Book , or Help which discusses > such> arcana?>> -- > STH> Hatton's Law:> There is only One inviolable Law.>> ==== =With Mathematica 4.1 (and previous versions, I'm pretty sure), I would oftendisplay a graphics image in a notebook, grab it with the mouse and enlargeit to a size often larger than the notebook window or even my screen. Itwas possible to scroll the window to the right to see parts of the graphicat high magnification.This is no longer possible with 4.2. Parts of the image that fall outsidethe width of the notebook window are not displayed and you cannot scrollright to see them. Thus there is a limit when the notebook window ismaximised to take the whole screen width.I suspected that the ImageRegion option had something to do with this andtried changing it in the Option Inspector but to no avail.Does anyone know how to get around this annoying problem?John Jowett ==== => I found this:> rightTree[tree[_, _, right_]] := right> in Dr. Mí¡.89[Hyphen]åder's Computer Science with Mathematica. I understand the spirit of> the statement, but it looks rather strange to me. Is there a way of> describing, in a language such as English, exactly what this definition> means? The part that I find confusing is the inclusion of what looks like a> function call in the parameter list. This simply defies my sense of how> programming languages work. That doesn't mean it's a bad thing. It just> means that I don't feel comfortable with the syntax.> Is there somewhere in the Mathematica Book , or Help which discusses such> arcana?How about rightTree returns the third element of a three-element expressionheaded by Ôtree'?Think Lisp (I date myself :-). Lower your mental wall between functions anddata. Everything is an expression [The Mathematica Book section 2.1.1]. Inthe example above, rightTree resembles a function, and tree resembles astructure, but these apparent roles could (in principle) reverse elsewhere.If tree also evaluates as a function, then the expression above would stillwork if rightTree has the HoldAll or HoldFirst attribute.Tom Burton ==== =Steve,The header tree is not a function call but a wrapper for three objects. Isthe following code as much of a mystery?pick3rdOnListOf3[List[_, _, third_]]:= thirdDavid Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/means that I don't feel comfortable with the syntax.Is there somewhere in the Mathematica Book , or Help which discusses sucharcana?--STHHatton's Law:There is only One inviolable Law. ==== =1. ConsiderIn[1]:=Function[y,Module[{x=1},y+x]][x]Module[{x=1},# +x]&[x]Out[1]=1+xOut[2]=2The first example always works as a function returning its argument plusone (unless we pass it Ôunallowed' argument x$); the second exampledoesn't.I think the unnamed Slot parameters should internally be treated thisway:In[3]:=Function[slot1,Module[{x=1},slot1+x]][x]Out[3] =1+xThis works consistently for any arguments passed to the function,doesn't interfere with the Module local variables and gives the sameresults as thedefinition using named parameters.2. ConsiderIn[4]:=x=1;Function[x,Evaluate@x]Module[{x=2}, Function[x,Evaluate@x]]x=.Out[5]=Function[x,1]Out[6]=Function [x,1]The reason why the second example works this way is that Function makesthe global x variable local, not the Module's x$n.This means we can't define functions that depend on Module's localvariables unless we use some special tricks.Wouldn't it be better if Function made Module's variables local insteadso thatModule[{x}, Function[x,fx]]becameModule[{x}, Function[x$n,fx]]?This behaviour would be useful in conjunction with the modificationdiscussed below. The same goes for Rule and Set inside Module.3. ConsiderIn[8]:=y=x;Function[x,Evaluate[2x+y]]y=.Module[{y=x}, Function[x,Evaluate[2x+y]]]Out[9]=Function[x,3 x]Out[11]=Function[x$,x+2 x$]problem is that it makes the task of creating functions inside Modulesmuch more complicated;if we want to do something like Unapply[fx, x], there is a simplesolution Evaluate[fx/.x->#]& but it doesn't work for fx=#+x&.Is it possible to change the evaluation rules so that inFunction[x,Evaluate[fx]] fx is evaluated outside the Function scope?Then the result is passed to the Function; in the second example aboveit would work as follows:Evaluate[2x+y]->3x->Function[x,3x],or, in the case of x being local to the Module,Evaluate[2x$n+y]->3x$n->Function[x$n,3x$n].The same goes for the right-hand side of Rule and Set.Maxim Rytin ==== => I found this:> rightTree[tree[_, _, right_]] := right>> in Dr. Mç.94ç[Times]der's Computer Science with Mathematica. I understand the > spirit of> the statement, but it looks rather strange to me. Is there a way of> describing, in a language such as English, exactly what this definition> means? The part that I find confusing is the inclusion of what looks > like a> function call in the parameter list. This simply defies my sense of > how> programming languages work. That doesn't mean it's a bad thing. It > just> means that I don't feel comfortable with the syntax.>It's best to forget about function calls, think about expression evaluation. What I mean is Mathematica operates using a read-eval-print loop similarly to LISP (again, it really helps to have some exposure to LISP and Prolog when dealing with programming issues in Mathematica). So you enter an expression, Mathematica reads it, then passes it off to be evaluated then finally prints the resulting expression. Function call implies all sorts of arcana about putting references or copies of arguments on a call stack, jumping to a subroutine, restoring the call stack etc. that really isn't a factor in Mathematica. What does this have to do with the above expression?First let's get rid of the infix notation rightTree[tree[_,_,right_]]:=right is equivalent to SetDelayed[rightTree[tree[_,_,right_]],right] when the evaluator sees the SetDelayed it means means create a rule associating the DownValue of the first argument (held) with the second (also held). Since all the arguments are held there is no more evaluation.That's pretty simple, the real magic happens when you evaluate the expression rightTree[(some expression with head tree and three arguments, let's call it t for now)]. The evaluator searches the rule list of rightTree for the most specific match, since t has head tree (and assuming no more specific rule has been written) that's the rule that transforms the expression. That rule says that the third argument of the expression tree[_,_,_] is to be called right and that is the value of the expression rightTree[tree[_,_,right_]]. So the expression represented by the pattern right_ is passed to the evaluator. If that expression has no transformation rules associated with it then evaluation stops and that value is returned.This isn't really a question of syntax (since the LISP syntax looks something like (defun rightTree (tree) (car (nthcdr 2 tree))), I've omitted the type checking) it's a question of semantics. Incidentally I believe the Prolog syntax actually looks a lot more like the Mathematica, it's been a while since I dealt with Prolog but I think rightTree isisaTree(Node) :- atom(Node)isaTree([Left,Node,Right]) :- isatree(Left),atom(Node),isatree(Right).rightTree(tree) :- isaTree(tree),Right.This version has the type checking but a real Prolog programmer would probably use guards.> Is there somewhere in the Mathematica Book , or Help which discusses > such> arcana?> This is all explained in section 2.5.4 of the Mathematica book. The key is to understand that at the most basic level all Mathematica does is take expressions, match them to rules (as expressed by patterns), apply the transformation and repeat the above process until no more transformations can be done.Ssezi ==== =Steven,Mathematica may look like it uses functions but it is actually to do withthe action of replacement rules on expressions.Thus, rightTree[tree[_, _, right_]] := right( or for that matter rightTree[tree[_, _, r_]] := r)means: Store a rule so that when during the evaluation process an expression of the form rightTree[tree[_, _, x_]] is found, it is replaced by xThe rule is stored in DownValues[rightTree] DownValues[rightTree] {HoldPattern[rightTree[tree[_,_,right_]]]:>right}The evaluation process is described in Appendix 4 (A.4) of the Book.--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198> I found this:> rightTree[tree[_, _, right_]] := right>> in Dr. Míóder's Computer Science with Mathematica. I understand thespirit of> the statement, but it looks rather strange to me. Is there a way of> describing, in a language such as English, exactly what this definition> means? The part that I find confusing is the inclusion of what looks likea> function call in the parameter list. This simply defies my sense of how> programming languages work. That doesn't mean it's a bad thing. It just> means that I don't feel comfortable with the syntax.>> Is there somewhere in the Mathematica Book , or Help which discusses such> arcana?>> --> STH> Hatton's Law:> There is only One inviolable Law.>>Reply-To: kuska@informatik.uni-leipzig.de ==== =this mean: if someone wish the right branch of a tree[]it does not matter what is in the left branch of thetree or in the tree's node. Jens> I found this:> rightTree[tree[_, _, right_]] := right> in Dr. Míóder's Computer Science with Mathematica. I understand the spirit of> the statement, but it looks rather strange to me. Is there a way of> describing, in a language such as English, exactly what this definition> means? The part that I find confusing is the inclusion of what looks like a> function call in the parameter list. This simply defies my sense of how> programming languages work. That doesn't mean it's a bad thing. It just> means that I don't feel comfortable with the syntax.> Is there somewhere in the Mathematica Book , or Help which discusses such> arcana?> --> STH> Hatton's Law:> There is only One inviolable Law. ==== => I think, when Mathematica was created, OO was not yet existent in> programming languages.You could easily learn about the history of OO. Simula (1967), Smalltalk,the variety of very sophisticated lisp OO systems: ßavors, LOOPS, CLOS,all predate Mathematica.Wolfram claims Mathematica unifies various programming paradigms,and if you don't look too closely, it does have many resemblances.However, much of it is really implemented on top of pattern matchingand a kind of fixed-point evaluation. Thus details like scope, vital infunctional programming, were wrong initially (Block), and repaired so they arebetter (Module) but still not quite right.You also misunderstand the nature of language implementation anddesign. Mathematica or Java or Lisp.. are designed for various reasons.Any of them can be implemented by an interpreter or via compilation.Or both. If you mean Mathematica is interactive, sure. But thatdoes not mean it must be interpreted. In fact there is a compiler usedby numerical evaluation in plotting and a few other spots.I think that it would be useful for you to learn about programming languagesinstead of believing that all you need to know about programming languagesis that subset that appears in Mathematica or Java. There are many many textbookson the subject of programming languages. I suggest you find The Art of theMeta Object Protocol by Bobrow and Kiczales, if you wish to understand thevarieties of OO possible.RJF I am astonished about the OO-like features, which are> built into Mathematica despite of this. Into older languages OO must be> built after they were created, and this is also done.> In my opinion it is not the main criterion, that a program runs fast in that> programming language. If this was the case you should program in assembler> language. The fact, that Mathematica is an interpreted language shows, that> other considerations were prominent, when the language was designed.> Compiled languages are faster.> The main criterion is in my opion is, that the program can be created easily> and yet more important, that it can be easily understood and modified> afterwards.> I think, Mathematica is well suited, to integrate an OO-System.> Hermann Schmitt.> ----- Original Message ----->>Well, it simply means that I do not agree with some of the things you>>seem to think, that's all. Basically it amounts to the fact that>>Mathematica was not meant to be used as an OO-langauge by Wolfram and>>was deliberately not constructed in this way, unlike those languages>>that are designed from ground up to be OO. So when you write in>>OO-style you are simply dressing-up Mathematica language in a foreign>>paradigm and usually end up with less efficient code. Unlike what you>>seem to think, I think there is a big difference between built-in>>abilities and those added by users, and it shows itself in performance.>>In fact being aware of this difference is the most important factor in>>efficient Mathematica programming. This distinguishes Mathematica from>>most other languages.>>I don't really want to enter into any arguments which after all are>>only a matter of opinion, but I would propose the following>>objective test of good OO package in Mathematica. The test is that>>a proficient user cannot write easily a more efficient and equivalent>>code without the package. So far I have not seen any OOP in>>Mathematica that does anything in a way that I cannot do equally or>>(usually) more efficiently myself without it. Unless an OOP package can>>satisfy this requirement it will be used only by users who learned>>their programming on other languages and have not adapted their style>>to Mathematica.>>By the way, I have a good reason to believe that Wolfram will introduce>>some OOP into Mathematica, that will actually enhance rather than>>reduce performance. I will then think of it as real OOP rather than>>pseudo-OOP.>>Andrzej Kozlowski>>>>>what do you mean with pseudo-OOP?>Hermann Schmitt>----- Original Message ----->To: >Sent: Tuesday, November 05, 2002 11:00 AM>>>>>Various have people have sent interesting examples of OO programming>>in>>Mathematica, as a proof that it can be done. However, let me clarify>>one possible confusion: I for one have never doubted that it can be>>done. (In fact I have occasionally tried it myself). The more>>doubtful>>issue is is it worth doing?, or is it really the best way to>>program>>in Mathematica?. I can imagine that OOP may be useful for dealing>>with large structures and there may be (as I have been told) some>>performance advantages in introducing some OOP into Mathemaitca. But>>none the examples I have seen here seems to me to gain much from>>pseudo-OOP, which is in fact also the trouble with Maeder's package. I>>have seen a couple fairly large project written using it (one is the>>Object-Oriented Graph Theory in Chapter III of Grey's Mastering>>Mathematica), but all of them can be programmed with no more effort>>using the natural Mathematica functional-pattern based style.>>>>Andrzej Kozlowski>>>>>>>Andrzej Kozlowski>>Yokohama, Japan>>http://www.mimuw.edu.pl/~akoz/>>http:// platon.c.u-tokyo.ac.jp/andrzej/> In-reply-To: <200211250656.BAA14527@smc.vnet.net> ==== =D> What does it mean when I submit a differential equation, and the sameD> equation appears as the output?Mathematica cannot find the answer.D> I have tried this equation:D> DSolve[y'[x] == (-x^2 + 2 y[x]^(-3))/(2 x y[x] - 3 x^2), y[x], x]D> Is it too complicated for the program?In the version you tried, yes.Please note that y'[x] = dy/dx = 1/(dx/dy)= 1/x'[y](This trick only works with the first derivative, don't jump to a conclusionthat y''[x] = 1/x''[y], that's totally wrong - by the way, why? ;-)(* DSolve[y'[x] == (-x^2 + 2 y[x]^(-3))/(2 x y[x] - 3 x^2),y[x], x] *) In[1] := DSolve[x'[y] == (-x[y]^2 + 2 y^(-3))/(2 x[y] y - 3 x[y]^2), x[y], y] Out[1] = {{x[y] -> y/3 - (2^(1/3)*y^4)/(3*(-27*y^4 - 2*y^9 + 27*y^6*C[1] + Sqrt[-4*y^18 + (-27*y^4 - 2*y^9 + 27*y^6*C[1])^2])^(1/3)) - (-27*y^4 - 2*y^9 + 27*y^6*C[1] + Sqrt[-4*y^18 + (-27*y^4 - 2*y^9 + 27*y^6*C[1])^2])^(1/3)/(3*2^(1/3)*y^2)}, {x[y] -> y/3 + ((1 + I*Sqrt[3])*y^4)/(3*2^(2/3)*(-27*y^4 - 2*y^9 + 27*y^6*C[1] + Sqrt[-4*y^18 + (-27*y^4 - 2*y^9 + 27*y^6*C[1])^2])^(1/3)) + ((1 - I*Sqrt[3])*(-27*y^4 - 2*y^9 + 27*y^6*C[1] + Sqrt[-4*y^18 + (-27*y^4 - 2*y^9 + 27*y^6*C[1])^2])^(1/3))/(6*2^(1/3)*y^2)}, {x[y] -> y/3 + ((1 - I*Sqrt[3])*y^4)/(3*2^(2/3)*(-27*y^4 - 2*y^9 + 27*y^6*C[1] + Sqrt[-4*y^18 + (-27*y^4 - 2*y^9 + 27*y^6*C[1])^2])^(1/3)) + ((1 + I*Sqrt[3])*(-27*y^4 - 2*y^9 + 27*y^6*C[1] + Sqrt[-4*y^18 + (-27*y^4 - 2*y^9 + 27*y^6*C[1])^2])^(1/3))/(6*2^(1/3)*y^2)}}That is you have 3 implicit equations connecting x and y. Your ODE is solved.Best wishes,Vladimir BondarenkoMathematical and Production DirectorSymbolic Testing GroupMail : 76 Zalesskaya Str, Simferopol, Crimea, Ukraine ==== => What does it mean when I submit a differential equation, and the same> equation appears as the output?> I have tried this equation:> DSolve[y'[x] == (-x^2 + 2 y[x]^(-3))/(2 x y[x] - 3 x^2), y[x], x]> Is it too complicated for the program?Yes, in general, if Mathematica returns input unprocessed without comment,you may conclude that Mathematica cannot process it, for whatever reason.(Sometimes Mathematica is not sure why, so better to say nothing. In thiscase, perhaps a hint would be nice.) This differential equation, though notcomplicated, is strongly nonlinear. Few such DE's admit analyticalsolutions. Try NDSolve.Tom Burton ==== => As I am generating Mathematica images for inserting them into TeX, problems> occur, like> f(t) seen as fHtL on EPS image in GSView, FontFamily->Trebuchet MS (or> Helvetica) not taken into account, ...> Can you direct me to any relevant material on the internet, book about ways> to tackle this problems?Note to Wolfram:As messages about this particular gotcha keep appearing and reappearing time after time after time (from me among others), perhaps it's time to implement a more long-term solution to this whole Operator Substitution hassle than just repeatedly replying to these newsgroup messages.It may be too late to change the default setting on the Operator Substitution option -- although my view would be that if a user explicitly specifies FontFamily->xxx, the user has stated what she wants, and Operator Substitution should definitely be automatically turned off. In addition:1) Add at least a brief notation on this issue in the Help messages for TextStyle and other places, so useres will at least learn of the Operator Substitution problem and have a pointer to look for more detailed info.2) *Much* upgraded documentation within the Help system of the (presently very mysterious) PrivateFont and OperatorSubstitution optionsPower tends to corrupt. Absolute power corrupts absolutely. Lord Acton (1834-1902)Dependence on advertising tends to corrupt. Total dependence on advertising corrupts totally. (today's equivalent) Reply-To: kuska@informatik.uni-leipzig.de ==== =look into the$TopDirectory/SystemFiles/IncludeFiles/TeX/texmf/doc/ wolframdirectory and read the msymdoc.pdf it include the instructions tomake the Mathematica fonts work with TeX/Ghostscript .. Jens> As I am generating Mathematica images for inserting them into TeX, problems> occur, like> f(t) seen as fHtL on EPS image in GSView, FontFamily->Trebuchet MS (or> Helvetica) not taken into account, ...> Can you direct me to any relevant material on the internet, book about ways> to tackle this problems?> Borut Levart ==== =In response to David Park :> 1) [How to] Save and restore the default options.> saveListPlotOptions = Options[ListPlot];> SetOptions[ListPlot, Sequence @@ saveListPlotOptions]; That's useful -- and it makes the point that in a situation like this you have to use the Sequence command in front of the list of options. But, I'm still surprised there's no way in Mathematic to, in essence, reset the kernel to its initial default startup state -- to, in essence, reload the kernel from disk or, in essence, *really* Remove everything that's happened since the most recent startup. There used to be the CleanSlate package to do something akin to this, but it wasn't actually all that clean, and I don't know if it's still around.> 2) Within Mathematica and a single plot you can use the TextStyle option.> TextStyle -> {FontFamily -> Helvetica, FontSize -> 12,> FontWeight -> Bold}];> or for a whole notebook> $TextStyle -> {FontFamily -> Helvetica, FontSize -> 12, FontWeight ->> Bold} But neither of these solves the turn off Operator Substitution problem, do they? -- and that's the aspect that I'm after.> 3)Use the AxesFront option from the FilledPlot package.> I have always maintained that AxesFront should be a general Graphics option> and not buried in the FilledPlot package. I'd agree with that!Power tends to corrupt. Absolute power corrupts absolutely. Lord Acton (1834-1902)Dependence on advertising tends to corrupt. Total dependence on advertising corrupts totally. (today's equivalent) ==== =I have a Mathematica program that uses DatabaseAccess package toretrieve large amount of data from Sybase database. DatabaseAccess isavailable for Windows only since it uses odbc. Now, I wanted to runaccess. At the end of this message I'll insert the code that emulatesDataSourceEvaluate and OpenDataSource from DatabaseAccess but usesjdbc. The implementation is simple and straightforward. The problem isthe code works MUCH slower than the equivalent odbc-based one on NT. Iretrieve A LOT of data so this is really annoying. So I have twoquestions:1. Is it one of the Mathematica functions that make it slow (theconversion of the result of the sql query into Mathematica table) oris it some fundamental java-related problem (JLink, jdbc etc)?2. How can I make it run faster?AlexanderInstallJava[];AddToClassPath[ jconn2.jar, jdbc2_0-stdext.jar];LoadJavaClass[java.sql.Types]; LoadJavaClass[java.util.Calendar];Clear[GetColumn];GetColumn[ i_, type_, rs_] := Switch[type, Types`CHAR,rs@getString[i], Types`DOUBLE,rs@getDouble[i], Types`INTEGER,rs@getInt[i], Types`VARCHAR,rs@getString[i], Types`TIMESTAMP,JavaBlock[ ToString[cal@get[Calendar`MONTH] + 1]<>/<> ToString[cal@get[Calendar`DATE]]<>/<> ToString[cal@get[Calendar`YEAR]]] ], Types`NUMERIC,rs@getInt[i]]ClearAll[DataSourceEvaluate]; DataSourceEvaluate[conn_,sql_String] := JavaBlock[ Module[{st = conn@createStatement[],rs,md, types,res}, res = If [st@execute[sql], rs = st@getResultSet[]; md = rs@getMetaData[]; types = Array[md@getColumnType[#]&,{md@getColumnCount[]}]; Rest[ NestWhileList[ Array[GetColumn[#,types[[#]], rs] &,{Length@types}] &, 1, rs@next[] &]], {}]; st@close[]; res]]Clear[OpenDataSource];OpenDataSource[database_String, user_String,password_String] := Module[{driver = JavaNew[com.sybase.jdbc2.jdbc.SybDriver], dbUrl = jdbc:sybase:Tds:<>$DBServer<>:<>$DBPort<>/<>database, prop = JavaNew[java.util.Properties]}, prop@setProperty[user,user]; prop@setProperty[password,password]; driver@connect[dbUrl,prop]]; ==== =I argued over the more appropriate definition of (or algorithm for) theinverse cotangent function with someone, based on what math we have learned.(A) arccot x = Pi/2 - arctan x(B) arccot x = arctan 1/xMy calculus book used the definition A when it talked about the derivativesof inverse trig functions. I think it said that definition B is also used insome situations, but I don't have the book now.It's obvious why my calculus book and most calculus study guides found onthe Internet use the definition A--arccot would be continuous on its domain,and the complementary angle relationship is preserved. But Mathematica usesdefinition B, or a definition closer to B. Seehttp://mathworld.wolfram.com/InverseCotangent.htmlSo, is there any merit of definition B, besides convenience? Should wesacrifice the continuity of inverse cotangent just to satisfy the simplex-reciprocal relationship?And this pagehttp://mathworld.wolfram.com/ InverseTrigonometricFunctions.htmlsays the domain (my math teacher would say range) of ArcCot is (0, Pi/2)or (-Pi, -Pi/2). Where does that come from? It's not even consistent withthe graph on Wolfram's own inverse cotangent page! The range for ArcCsclisted there is strange too. Also, Wolfram doesn't say that arccot is notdifferentiable because of discontinuity at x=0 when it lists the firstderivative of ArcCot[z], while definition B would require that. Is itsomething in more advanced mathematics that I don't know yet?When I argued over the two definitions few weeks ago, my opinion was thatdefinition B was acceptable, or even should be authoritative, becauseWolfram and possibly other systems use it. But after my opponent pointed out thatinconsistency, I didn't know what to say. Still, I believe there is a reasonwhy definition B not only survived but also is used in these authoritativeYaohan Chen ==== = > As I am generating Mathematica images for inserting them into > TeX, problems> occur, like> f(t) seen as fHtL on EPS image in GSView, > FontFamily->Trebuchet MS (or> Helvetica) not taken into account, ...> Can you direct me to any relevant material on the internet, > book about ways> to tackle this problems?This happens because the application you're inserting the graphic in dosen'tunderstand where to find the particular font that Mathematica uses to renderthe characters ( & ) (& more besides ...).emmathfnt for this purpose.It's explained in reasonable detail athttp://support.wolfram.com/mathematica/graphics/export/ includefonts.htmlwhere you can find a link to the above program. Dave. ==== ======================================= Dr. David Annetts EM Modelling Analyst Australia David.Annetts@csiro.au ==== ==================================== ==== =====> I have the following data of the following form.> {123-456-7899, John Smith,2223334444}> How can I convert this to > {123,456,7899, John,Smith,222,333,4444}> and then to> {1234567899johnsmith00000)> 1. The - are removed> 2. John Smith is concerted to lower case> 3. The space between John and Smith is removed (ie john and smith is > concatenated)> 4. 123454567899johnsmith is padded right so the the total number of > characters is 24.> John> Did you have a look at operations on strings in the book (chapter 2.7.2 in version 4)?StringJoin, StringTake, StringReplace should get you going.eg (should do most of the work):StringReplace[abcdabcdaabcabcd, {abc -> Y, d -> XXX}]YXXXYXXXaYYXXXHope that helps.Marc-- Marc Heusserremove the obvious CHEERS and MERCIAL... from the reply addressReply-To: selwynh@earthlink.net ==== =John,Here's one approach. I'm assuming that you're starting out with strings.data1 = {123-456-7899, John Smith, 2223334444};{l1, l2, l3} = Characters /@ data1;data2 = Flatten[{ StringJoin[DeleteCases[#1,-]]&/@ Partition[l1, 4], StringJoin[#1]&@ l2[[Range@@ Prepend[Flatten[Position[l2, ]]-1, 1]]], StringJoin[#1]&@ l2[[Range@@ Append[Flatten[Position[l2, ]]+1, Length[l2]]]], StringJoin[#1]&/@ {l3[[{1,2,3}]], l3[[{4,5,6}]], l3[[{7,8,9,10}]]}}] {123, 456, 7899, John, Smith, 222, 333, 4444}data3 = StringJoin[data3 = StringJoin[data2[[Range[1,5]]]], StringJoin[Table[0, {24 - Length[Characters[data3]]}]]] 1234567899JohnSmith00000---Selwyn Hollis>I have the following data of the following form.>>{123-456-7899, John Smith,2223334444}>>How can I convert this to >{123,456,7899, John,Smith,222,333,4444}>and then to>>{1234567899johnsmith00000)>>1. The - are removed>2. John Smith is concerted to lower case>3. The space between John and Smith is removed (ie john and smith is >concatenated)>4. 123454567899johnsmith is padded right so the the total number of >characters is 24.>John>> ==== =John,Here is a long journey to your forms - I am assuming that we start with {123-456-7899,John Smith,2223334444}and I show input forms to distinguish strings. (fm1=MapAt[ StringReplace[ StringTake[ {2,-2}], ->]&, StringReplace[{123-456-7899,John Smith,2223334444},{ -->,, ->,}], {-1}])//InputForm{123,456,7899, John,Smith, 222,333,4444}(fm2=StringJoin@@ PadRight[ Characters[StringJoin@@StringReplace[ToLowerCase/@Drop[fm1,-1 ],,->]],24, 0])//InputForm1234567899johnsmith00000--Allan---------------- -----Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198>> I have the following data of the following form.>> {123-456-7899, John Smith,2223334444}>> How can I convert this to> {123,456,7899, John,Smith,222,333,4444}> and then to>> {1234567899johnsmith00000)>> 1. The - are removed> 2. John Smith is concerted to lower case> 3. The space between John and Smith is removed (ie john and smith is> concatenated)> 4. 123454567899johnsmith is padded right so the the total number of> characters is 24.> John> ==== =>> I have the following data of the following form.>> {123-456-7899, John Smith,2223334444}>> How can I convert this to> {123,456,7899, John,Smith,222,333,4444}> and then to>> {1234567899johnsmith00000)>> 1. The - are removed> 2. John Smith is concerted to lower case> 3. The space between John and Smith is removed (ie john and smith is> concatenated)> 4. 123454567899johnsmith is padded right so the the total number of> characters is 24.> John>>G'day John,robust.Some notes and function foobar[file_String] follows;1. Import the file as Word(s), not String2. Replace the hyphen first to avoid confusion with minus3. WRT l3 in foobar, first step takes 222333444 and inserts a comma andspace in the 4th and 7th positions. Second step takes the remainingelements and makes a list. Then convert to string and then to expression.The space after the comma just got inserted as one character I think andyou can't do much with that.4. WRT to l4, get rid of the last three entries in the expression and addthe zeroes, convert to string and replace the unwanted characters withwanted characters.In[1]:=foobar[file_String] := Module[{l1, l2, l3, l4}, l1 = ReadList[file, Word, RecordSeparators -> {,}]; l2 = StringReplace[l1, {- -> ,}]; l3 = {Drop[l2, -1], StringInsert[Last[l2], , , {4, 7}]} // ToString//ToExpression // Flatten; l4 = StringReplace[{Drop[l3, -3], {0, 0, 0, 0, 0}} // Flatten // ToString, {, -> , -> , J -> j, S -> s}] ]In[2]:=foobar[~/Desktop/data.txt]Out[2]={ 1234567899johnsmith00000}YasReply-To: kuska@informatik.uni-leipzig.de ==== =tryIn[]:=expr = d*Pi + I*d*(Log[M] - 2*Log[(-I)*Sqrt[(M*r)/d] + Sqrt[M -(M*r)/d]]);In[]:=expr1=expr /. a_.*M + b_*M :> M*(a + b) /. Sqrt[M*a_] :> Sqrt[M]*Sqrt[a] /. a_.Log[b_] + c_.*Log[d_] :> Log[b^a*d^c] /. Sqrt[M]*a_ + Sqrt[M]*b_ :> Sqrt[M]*(a + b) /. Log[a_^b_] :> b*Log[a] /. Log[-I*a_ + b_] :> Log[-I*(a + I*b)] /. Log[a_*b_Plus] :> Log[a] + Log[b]//ExpandOut[]=(-2*I)*d*Log[Sqrt[r/d] + I*Sqrt[1 - r/d]]In[]:=FullSimplify[expr1, Element[{r, d}, Reals] && r < d] Out[]=2*d*ArcSin[Sqrt[1 - r/d]]ups... Jens> I'm trying to simplify (M, r, d are positive reals with r d*Pi + I*d*(Log[M] - 2*Log[(-I)*Sqrt[(M*r)/d] + Sqrt[M - (M*r)/d]])> to> 2*d*ArcCos[Sqrt[r/d]]> I've tried applying> FullSimplify[#,M>0 && 0 and> ExpToTrig> but Mathematica won't get rid of the Log and the I and give me the ArcCos.> Does anyone know which Mathematica functions to apply to my expression to> give me the simplification I want?> ==== =According to the default complexity measure ArcTan[y/x]is not simpler than ArcTan[x, y].In[1]:= LeafCount /@ {ArcTan[x, y], ArcTan[y/x]}Out[1]= {3, 6}One can use ComplexityFunction to specify that two-argumentArcTan should be replaced whenever possible.In[2]:= f=1000 Count[#, ArcTan[_, _], {0, Infinity}]+LeafCount[#]&;In[3]:= FullSimplify[ArcTan[x, y], {x > 0, y < 0}, ComplexityFunction->f] yOut[3]= ArcTan[-] xWith this ComplexityFunction we get a somewhat better resultfor the original problem, though still not the desired form.In[4]:= FullSimplify[ComplexExpand[ d*Pi + I*d*(Log[M] - 2*Log[(-I)*Sqrt[(M*r)/d] + Sqrt[M - (M*r)/d]]), TargetFunctions -> {Re, Im}], M > 0 && 0 < r < d, ComplexityFunction->f] 1Out[4]= d (Pi - 2 ArcTan[------------]) d Sqrt[-1 + -] rAdam StrzebonskiWolfram Research> This will take you pretty close:> FullSimplify[ComplexExpand[> d*Pi + I*d*(Log[M] - 2*Log[(-I)*Sqrt[(M*r)/d] +> Sqrt[M - (M*r)/d]]), TargetFunctions -> {Re, Im}],> M > 0 && 0 < r < d]> d*(Pi + 2*ArcTan[Sqrt[M - (M*r)/d], -Sqrt[(M*r)/d]])> Still, there appears to be something missing among the rules > FullSimplify is applying.> It seems related to the following behaviour, that certianly suggests a bug:> FullSimplify[ArcTan[x, y], {x > 0, y < 0}]> ArcTan[x, y]> FullSimplify[ArcTan[2*x, 2*y], {x > 0, y < 0}]> ArcTan[y/x]>> I'm trying to simplify (M, r, d are positive reals with r> d*Pi + I*d*(Log[M] - 2*Log[(-I)*Sqrt[(M*r)/d] + Sqrt[M - (M*r)/d]])>> to>> 2*d*ArcCos[Sqrt[r/d]]>> I've tried applying>> FullSimplify[#,M>0 && 0> and>> ExpToTrig>> but Mathematica won't get rid of the Log and the I and give me the >> ArcCos.>> Does anyone know which Mathematica functions to apply to my expression to>> give me the simplification I want?>>>>>>> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/> ==== =Dave we have, e = d*Pi + I*d*(Log[M] - 2*Log[(-I)*Sqrt[(M*r)/d] + Sqrt[M - (M*r)/d]]); e2 = ComplexExpand[e, TargetFunctions -> {Re, Im}]; e3 = Simplify[e2, M > 0 && 0 < r < d] d*(Pi + 2*ArcTan[Sqrt[M - (M*r)/d], -Sqrt[(M*r)/d]]) e4 = Simplify[e3, M > 0 && 0 < r < d, ComplexityFunction -> (Count[#1, M, Infinity] & )] d*(Pi - 2*ArcTan[Sqrt[r]/Sqrt[d - r]])Here I have to be interactive:a = ArcTan[Sqrt[r]/Sqrt[d - r]] is in (0, Pi/2),.So b = Pi - 2a is in (0,Pi).Consequently b/2 is ArcCos[Cos[b/2]].That is FullSimplify[Cos[(Pi - 2*ArcTan[Sqrt[r]/Sqrt[d - r]])/2], 0 < r < d] 1/Sqrt[d/r]--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198>> I'm trying to simplify (M, r, d are positive reals with r d*Pi + I*d*(Log[M] - 2*Log[(-I)*Sqrt[(M*r)/d] + Sqrt[M - (M*r)/d]])>> to>> 2*d*ArcCos[Sqrt[r/d]]>> I've tried applying>> FullSimplify[#,M>0 && 0> and>> ExpToTrig>> but Mathematica won't get rid of the Log and the I and give me the ArcCos.>> Does anyone know which Mathematica functions to apply to my expression to> give me the simplification I want?>> ==== =>> I'm trying to simplify (M, r, d are positive reals with r d*Pi + I*d*(Log[M] - 2*Log[(-I)*Sqrt[(M*r)/d] + Sqrt[M - (M*r)/d]])>> to>> 2*d*ArcCos[Sqrt[r/d]]>> I've tried applying>> FullSimplify[#,M>0 && 0> and>> ExpToTrig>> but Mathematica won't get rid of the Log and the I and give me the > ArcCos.>> Does anyone know which Mathematica functions to apply to my expression > to> give me the simplification I want?>>I can't get the form you want butFullSimplify[ComplexExpand[d*Pi + I*d*(Log[M] - 2*Log[(-I)*Sqrt[(M*r)/d] + Sqrt[M - (M*r)/d]])],{M>0&&r>0&&d>0&&r I want to evaluate the integral:>> f[u_] = Integrate[E^x/Cos[x], {x, 0, u},> Assumptions -> {x [Element] Reals, u < Pi/2}]> (1 - I)*E^((1 + I)*u)*Hypergeometric2F1[> 1/2 - I/2, 1, 3/2 - I/2, -E^(2*I*u)] +> (1/2)*((-I)*PolyGamma[0, 1/4 - I/4] +> I*PolyGamma[0, 3/4 - I/4])>> so far so good. This integral should be real-valued, at least in the> Range 0<=u And that is my problem. How can I get a real result> with no imaginary I's. Neither FunctionExpand or FullSimplify did it.If you mean that you want the result expressed without the imaginary Iappearing anywhere in it, please realize that such might be impossible.Whether it's impossible in this particular case or not, I don't know.Think, for example, of expressing the real roots of a cubic polynomialin terms of nothing more sophisticated than radicals. In the so-called_casus irreducibilis_, it is well known that, even though the roots arereal, they must, in general, be expressed using the imaginary I. Yourintegral result might be similar, requiring complex numbers for itsexpression in Mathematica, despite the fact that it is real.David-- -------------------- http://NewsReader.Com/ --------------------Usenet Newsgroup Service New Rate! $9.95/Month 50GB ==== => I want to evaluate the integral:> f[u_] = Integrate[E^x/Cos[x], {x, 0, u},> Assumptions -> {x [Element] Reals, u < Pi/2}]> (1 - I)*E^((1 + I)*u)*Hypergeometric2F1[> 1/2 - I/2, 1, 3/2 - I/2, -E^(2*I*u)] +> (1/2)*((-I)*PolyGamma[0, 1/4 - I/4] +> I*PolyGamma[0, 3/4 - I/4])> so far so good. This integral should be real-valued, at least in the> Range 0<=u with no imaginary I's. Neither FunctionExpand or FullSimplify did it.As far as I can see the imaginary parts of the numerical evaluation of the above expression are numerical artifacts. They are around <10^(-15). So you should use Chop[f[u]] to suppress these numerical uncertainties.-- Hendrik van Hees Fakult.8at f.9fr Physik http://theory.gsi.de/~vanhees/ D-33615 Bielefeld