This will do the trick: collatz = Compile[{{n, _Integer}}, If[EvenQ[n], n/2, 3 n + 1]//Round] I think that the problem is with n/2. Although the result is guaranteed to be integer, the compiler cannot analyze the code and know it, so the output is set to Real. > Some compiled functions yield reals even if the > e input and necessary output are integers. How can I > force the output to be an integer rather than a real > in such cases? To be clear, not all compiled program > output produces reals; some compiled programs, given > integer inputs, produce integer outputs. But some do > not. An example is: > > collatz = Compile[{{n, _Integer}}, If[EvenQ[n], n/2, > 3 n + 1]] > > It produces real rather than integer output, and I'd > like to force integer output if possible. > > Thanks > > Best, > > Harvey >

0 |

5/13/2014 2:26:32 AM

I like this idea. Does the mathematical/algebraic "programming" style scale up to large problems? Are there examples? Or perhaps it doesn't strictly scale, but is better applied judiciously. It could be used to steer a code at a very high level, or conversely, used in the gaps (the Mathematica-in-the-gaps argument). Conventional programming would make up the difference. If indeed mathematical programming is not the silver-bullet paradigm, where should the conventional (though modern) programming be done? Within or without Mathematica? If within, then we've c...

Hi David, Comments are interlaced in the text below, > -----Original Message----- > From: David Bailey [mailto:dave@Remove_Thisdbailey.co.uk] > Subject: Re: EUREKA Re: Types in Mathematica, a > practical example > > Hello, > > If you want to compute with undefined array elements, why not > use subscript elements such as Subscript[a,1,2]. Hmmm, maybe... Let's see ax := {{Subscript[ax, 1, 1], Subscript[ax, 1, 2]}, {Subscript[ax, 2, 1], Subscript[ax, 2, 2]}} is not a good idea, since evaluation of ax gives an infinite loop. (There are o...

On Dec 4, 2005, at 6:16 AM, Steven T. Hatton wrote: I started this reply before seeing your conversations with Kris Carlson, he seems to have better elucidated the points I was trying to make. > On Saturday 03 December 2005 21:37, Sseziwa Mukasa wrote: > >> On Dec 3, 2005, at 6:52 PM, Steven T. Hatton wrote: >> An example of a strong and >> dynamic language is LISP, and this is one respect in which >> Mathematica >> differs from LISP. >> > > (setq f 1) > (setq g 2.2) > (setq h (+ f g)) > (print h) > =>3.2...

Log[1/E^.5] -0.5 Log[1/E^-.5] � .5 True Refine[1/E^x, 0<x<1] E^-x Or if you need to, Refine[Log[1/E^x], 0<x<1] -x Kris -------------- Original message -------------- > On Sun, 27 Nov 2005 08:24:53 +0000 (UTC), Bob Hanlon > wrote: > > >The output that you want is "unstable", i.e., Mathematica automatically > >converts it. > > > > Thanks. > > I have another question if you don't mind. > > I'm trying to just check and see if I got a whole bunch of > even-numbered study exercises r...

I forgot one thing: how to deal with your original problem. In[1]:= a=Array[Unique[a]&,{2,2}] Out[1]= {{a$17,a$18},{a$19,a$20}} In[2]:= a-x/.Flatten[Thread/@Thread[a->x]] Out[2]= {{0,0},{0,0}} Seems to me a little simpler than with the HoldForm approach. Andrzej On 17 Dec 2005, at 13:48, Andrzej Kozlowski wrote: > If you feel really want do it in this sor of way, I suggest the > following approach: > > > x=Array[Unique[x]&,{2,2}] > > > {{x$23,x$24},{x$25,x$26}} > > etc. > > I think in this way you get...

On Fri, 22 May 2009 01:50:51 -0400 (EDT), skkaul wrote: > On May 10, 5:13 am, John Fultz <jfu...@wolfram.com> wrote: > >> <install= >> directory>/SystemFiles/FrontEnd/TextResources/UnicodeFontMapping.tr >> > Besides the comments, is there any documentation on this file? In > particular, what are type V and H entries, and what font is referenced > by -2? > > Thanks, > Shiva It's not documented because it's not intended for user consumption, although being able to edit it very rarely allows working around certain issues...

To get the 'double struck small e' type esc e e esc, or click it off the palette. In any case, it is not the Latin small case e. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ From: New Guy [mailto:NewGuy@yahoo.com] On Fri, 2 Dec 2005 11:05:41 +0000 (UTC), Jean-Marc Gulliet <jeanmarc.gulliet@gmail.com> wrote: >Now, the base of the natural logarithm is written E (capital e). Beg to differ here. The BasicInput.nb palette uses the small 'e' that is kind of double-struck. Bookreader ...

You have to use the correct Mathematica syntax. E and Log instead of e and LN. You don't even have to use Simplif in this case. Log[1/E^2] -2 David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ From: New Guy [mailto:NewGuy@yahoo.com] On Sun, 27 Nov 2005 08:24:53 +0000 (UTC), Bob Hanlon <hanlonr@cox.net> wrote: >The output that you want is "unstable", i.e., Mathematica automatically >converts it. > Thanks. I have another question if you don't mind. I'm trying to just check and see if I got a whole bunch of even-nu...

On 11/27/05 at 2:40 AM, hattons@globalsymmetry.com (Steven T. Hatton) wrote: >A related question follows from this example: >In[n]:=Information[Plot3D] >Plot3D[f, {x, xmin, xmax}, {y, ymin, ymax}] generates a >three-dimensional plot of f as a function of x and y. Plot3D[{f, >s}, {x, xmin, xmax}, {y, ymin, ymax}] generates a three-dimensional >plot in which the height of the surface is specified by f, and the >shading is specified by s. >Note there is no specification of /what/ "f", "x", "xmin", "xmax", >"y&...

No, the first executable statement is a PUT SKIP; I am using a rather old version of emacs, 19.22, not that it should matter, but my guess is that emacs is interpreting the null byte as end of file. I tried this on a current version of emacs on Linux and no problem. In fact the first two statements in the program are PUT SKIP; PUT SKIP LIST ('BENCHMARK 1 - TWO AND THREE DIMENSIONAL SLOW VECTOR', ' DOT PRODUCT - VAX PL/I DEC'); so I don't see where the null byte is coming from. Maybe the skip is inserting the null byte, will have to test...

On Thu, 7 Feb 2008 04:43:57 -0500 (EST), beggars.banquet@gmail.com wrote: > On 6 f=E9v, 05:39, Carl Woll <ca...@wolfram.com> wrote: > >> Adam Weyhaupt wrote: >>> A colleague of mine has a fresh installation of Mathematica 6.0.0 on >>> a Windows XP machine. The kernel seems to be running fine (2+2=4), >>> but graphics commands generate no output (only the line " -Graphics- >>> " (no quotes) is printed to the output). If you switch to Version 5 >>> graphics the graphics work fine (but of course are not rotatable, ...

Some compiled functions yield reals even if the input and necessary output are integers. How can I force the output to be an integer rather than a real in such cases? To be clear, not all compiled program output produces reals; some compiled programs, given integer inputs, produce integer outputs. But some do not. An example is: collatz = Compile[{{n, _Integer}}, If[EvenQ[n], n/2, 3 n + 1]] It produces real rather than integer output, and I'd like to force integer output if possible. Thanks Best, Harvey ...

(Pardon the top-post. MS Outlook requires it, I think.) A recent event in the C++ community relates to this discussion tangentially. Bjarne Stroustrup and Gabriel Dos Reis (of GCC fame) just published a formal definition (formalism) of the C++ language: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1885.pdf Have a look at the follow-up document as well, http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1886.pdf, which uses the C++ formalism to specify C++ concepts. For those new to it, concepts have several uses, one being to constrain template argumen...

On 3/23/10 at 4:23 AM, hemmecke@gmail.com (hemmecke) wrote: >Does somebody know why I get different behaviour for the following >General::dupsym: The symbol Array with context A` already exists. >message? Why does that message appear at all? If A`Array exists, >then Mathematica should just use it, shouldn't it? >According to >http://reference.wolfram.com/mathematica/tutorial/Contexts.html we >have: >`name a symbol in the current context >So why is Mathematica complaining? The message is not telling you the symbol exists in the current cont...

... , or external linking . The most common reason for wanting to transform source code is to create an executable program. The name "compiler" ...

"Compile" and "compiling" redirect here. For the software company, see Compile (publisher) . For other uses, see Compilation . This article has ...

Earlier this morning, Facebook officially made their new PHP “compiler,” called HipHop, available as open source software. In the blog post by ...

jurvetson posted a photo: Sheba may be the harbinger of art in the digital age — a mathematical sculptor with digital matter. She manipulates ...

This animation explains the difference between interpreters and compilers. It is from Episode 6 of the classic 1983 television series, Bits and ...

The main contributor to the Scala compiler, Paul Phillips, has announced on GitHub that he is forking the compiler to “fix some of the innumerable ...

Given that any kind of formal truce between Apple and Adobe was essentially blown out of the water by Steve Job's very public slating of Flash ...

... to the general public this summer. Among the new features: According to Apple, Xcode 4.4 includes an editor for Collada 3D files, compiler support ...

... are announcing that they are bringing Python support to CUDA. Specifically, Continuum Analytics’ will be introducing a new Python CUDA compiler, ...

I'm not going to pretend to be a developer here, and I'll openly admit that the bulk of what IDEA 12 does is over my head. However, I do understand ...

Resources last updated: 1/26/2016 10:47:51 PM