Prev: JLink NaN Support
Next: SyntaxInformation Question
From: Nasser M. Abbasi on 5 Jul 2010 06:02 FYI, When I typed the following: ----------------------------- Clear[z] c = 1 + I; p = -9 + 3*I; t = 3.3; d = 1 - Exp[t*p]/z; expr1 = c/TraditionalForm@d; expr2 = c/d; (expr1 - expr2) /. z -> 1 -------------------------------- I was expecting to get ZERO, as I do when I do not use TraditionalForm, but instead got: (-0.9999999999999455 - 0.9999999999998298*I) + (1 + I)/ 1.0000000000001124` + 5.779350816615805`*^-14 I Then I read in the help for TraditionalForm "Output from TraditionalForm cannot necessarily be given as unique and unambiguous input to Mathematica" And the above seems to explain this result. Too bad, because I wanted to use TraditionalForm inside an expression to format parts of it using a function which requires this wrapper. My lesson of the day: do not use TraditionalForm inside expressions. --Nasser
From: AES on 5 Jul 2010 21:14 In article <i0saj2$eno$1(a)smc.vnet.net>, "Nasser M. Abbasi" <nma(a)12000.org> wrote: > > My lesson of the day: do not use TraditionalForm inside expressions. > Another example of what some of us call a "gotcha". To its credit, Wolfram gives a kind of semi-explicit warning about this particular gotcha as the first item in the "More Information" cell that comes right after the initial short command summary in the "ref/TraditionalForm" Help window. But: 1) Your wording is a lot more terse, and will be much clearer and more helpful for novice users, than Wolfram's. 2) And, this More Information cell is, for some reason, closed by default when the ref/TraditionalForm window is opened. I can get from a notebook cell to a ref/Xxxx Help window (and back) purely by keyboard commands on my extended Mac keyboard -- but I don't know how to then open the More Information cells except by going to the mouse and futzing with it. Seems to me the default for the More Information cells ought to be that they're open when any ref/Xxxx window is opened. Any way to set that default for all ref/Xxxx (and similar) windows? (And while we're at it, any keyboard way to open _all_ the subsequent closed section-heading cells in a ref/Xxxx window at once, so that powerful Find or Search capabilities could be used in some of these very lengthy Help windows?)
From: Andrzej Kozlowski on 6 Jul 2010 05:03 This information is very misleading because what you have observed has nothing in particular to do with TraditionalForm. To see that, replace TrditionalForm with InputForm or StandardForm and see what happens. All these "forms" are meant only for the purpose of formatting and should not be used inside computations as they are not stripped of after evaluation (as, for example, Unevaluted is). E.g: 1 + InputForm[1] 1+1 FullForm[%] Plus[1,InputForm[1]] vs 1 + Unevaluated[1] 2 Andrzej Kozlowski On 5 Jul 2010, at 19:02, Nasser M. Abbasi wrote: > > FYI, > > When I typed the following: > > ----------------------------- > Clear[z] > c = 1 + I; p = -9 + 3*I; t = 3.3; > d = 1 - Exp[t*p]/z; > > expr1 = c/TraditionalForm@d; > expr2 = c/d; > > (expr1 - expr2) /. z -> 1 > -------------------------------- > > I was expecting to get ZERO, as I do when I do not use TraditionalForm, > but instead got: > > (-0.9999999999999455 - 0.9999999999998298*I) + (1 + I)/ > 1.0000000000001124` + 5.779350816615805`*^-14 I > > Then I read in the help for TraditionalForm > > "Output from TraditionalForm cannot necessarily be given as unique and > unambiguous input to Mathematica" > > And the above seems to explain this result. Too bad, because I wanted to > use TraditionalForm inside an expression to format parts of it using a > function which requires this wrapper. > > My lesson of the day: do not use TraditionalForm inside expressions. > > --Nasser > >
From: AES on 7 Jul 2010 07:41 In article <i0urh5$6l9$1(a)smc.vnet.net>, Andrzej Kozlowski <akozlowski(a)gmail.com> wrote: > 1 + Unevaluated[1] > > 2 Fascinating. I'd call this one more classic Mathematica gotcha, and one more example of fairly poor quality of Mathematica documentation -- or at least of the very arcane character of Mathematica for "ordinary users", once you get to any depth within it. Help Browser says: Unevaluated[expr] represents the unevaluated form of expr when it appears as the argument to a function. So, what does Unevaluated[expr] do when it is NOT the argument to a function? (The previous statement I'd say clearly implies that there are times when Unevaluated[expr] does appear as an arg to function, and therefore times when it does not -- and both need to be defined.) So, if Unevaluated[expr] is entered all by itself in a cell, is it then "the argument to a function"? If the cell contains 1 + Unevaluated[expr] as above, does that make the Unevaluated[expr] an argument to a function -- or not? (I can see arguing that above queries either way -- and digging further down into the Help Browser examples is not very helpful.) How would one find out from Mathematica documentation what "argument to a function" means, precisely? Is there any significance to "argument to" rather than the (I think) more common usage "argument of"? Is Unevaluated[expr] used in a syntactically acceptable way _always_ the argument to a function?
From: David Bailey on 7 Jul 2010 07:42
On 06/07/10 10:03, Andrzej Kozlowski wrote: > This information is very misleading because what you have observed has > nothing in particular to do with TraditionalForm. To see that, replace > TrditionalForm with InputForm or StandardForm and see what happens. > All these "forms" are meant only for the purpose of formatting and > should not be used inside computations as they are not stripped of after > evaluation (as, for example, Unevaluted is). > > E.g: > > 1 + InputForm[1] > > 1+1 > > FullForm[%] > > Plus[1,InputForm[1]] > > vs > > 1 + Unevaluated[1] > > 2 > > Andrzej Kozlowski > > I have always thought WRI could usefully change the wording that appears in the documentation of all these wrapper functions: "InputForm acts as a "wrapper", which affects display, but not evaluation." Of course, they DO affect evaluation! David Bailey http://www.dbaileyconsultancy.co.uk |