Actually, we already have enough to make a Mathematica server. Have some sliders on an HTML page with some Javascript to send the slider values back to an ASP.NET server and then use functionality to call Mathematica from .NET to generate the graphic and send it back to the user: reference.wolfram.com/mathematica/NETLink/guide/… Forgot we already have that.
Going down to the pool for a beer. Only phone typing for a bit.
Hello guys. I have a quick stupid question. Suppose I have an ArrayPlot and I want to show the value of a particular square while hoovering it. I've tried to use Tooltip to no avail.
@Pragabhava Since ArrayPlot is based on Raster (i.e. a singel graphics primitive), there's no quick solution. You'll have to build your own and use Rectangles for each pixel instead of a single Raster. The link above shows several ways.
@Pragabhava Happens to me all the time that I don't use the right keyword until I actually ask someone. ;-) The he points out that googling for the same words that I used in my question brings up the solution.
Nested for loops are commonly seen in pseudo-code. How is such pseudo-code usually implemented in Mathematica? Fold[f, {1, 1}, Tuples[Range[3], 2] /. {1, 1} -> Sequence[]] ?
@kirma I guess that's the confusing part. I've been using MMA for a year and the advice "do't use For, Do, ..." still trips me up. Implementing an algorithm that takes five seconds to do in procedural languages such a Java turns into a two full day's of work :S
@Pickett My interpretation of the license agreement says that you could make a webpage with some sliders whose values are sent to your computer, which has a process that asks the kernel for a graphic, which it sends back to the user. You couldn't expose an input box that allows users to enter arbitrary expressions though. It has to be limited access, and the kernel requests have to come from a process on the same machine.
@Pickett the loop vs. functional thing, is due to performance in Mathematica. Loops are slower in M since it is not optimized for it. In Julia for example, loops are actually encouraged, and are the fastest way to do this. And I agree with you, many applied numerical algorithms are more naturally expressed using loops. You can't find nature.
@Nasser I think both inefficiency of loops in Mathematica and "loops being natural" in numerical algorithms are sort of artefacts of limited resources and perspective in design foundations, legacy and scarcity of computing resources in the past. I think in the long term, systems should accept description what users want them to accomplish, not explicitly how to accomplish it. And systems should find even relatively untrivial transformations to do it with relatively high efficiency.
Looping is strongly a "this is how you do it" construct, which I don't exactly love (but for living I actually write C, so I write lots of explicit loops), and Map is better. But then again, many features of functional programming, from language design and intuition to back-end implementation, cause similar dislike, and feeling of inelegance and incompleteness in me.
Yeah, I think most people that write pseudo-code are more familiar with procedural programming. I certainly think Mean/@matrix is a more natural way to find the averages of the rows of a matrix than using a loop.
"systems should accept description what users want them to accomplish"
That is what one does when writing code. It is description of what to do. Many iterative methods in linear algebra are just more natural in loops, since one must perform many operations based on positions and indexing and based on current state. See for example SOR algorithm en.wikipedia.org/wiki/Successive_over-relaxation and open numerical numerical recipes, etc...
It really depends on the algorithm. Sure, doing #^2&/@ list is better than a loop here. But we are not talking about this here. But for much more complicated algorithms.
I would want the languages be such that automatic reasoning would be easier, which would possibly take a lot of human reasoning burden away. Especially when there are heterogenous computing architectures to target.
It might be I've looked at horrible issues that creep up with pointer alias analysis (or incapability of performing it well) in C a bit too much.
@kirma I would never use C or C++ for actual production scientific or numeric programming. Fortran will be my first choice for this. I use M because it makes it much easier for me to try things and simulate things very quickly.
Often it's almost impossible coder to reason about architectural efficiency with algorithms that aren't overly vector/matrix oriented. More capable compilers and language design should bridge the gap between intuitive algorithm description and architecture-efficient implementation.
@Nasser Software I work with is non-scientific, but rather efficiency-critical. I have spent months trying to understand how and how well these software systems could be mapped for instance to COTS vectorized microarchitectures, or GPU-like targets. Or how those could be reorganized to minimize memory architecture limitations.
There's lot to be done, and there would be lot to be accomplished, but large portion of solutions are probably beyond humanly manageable explicit transformations of code.
It just makes me feel disheartened to look at a piece of human-semantically quite srtaight-forward C code, which in naive programmers' worldview looks very nice, and do a deep analysis of what's wrong with it, understand that it could probably at least triple in performance if it would be mapped efficiently to modern microarchitectures, and conclude that no current compiler could do it, and the piece of software would become almost completely unmanageable it it would be explicitly optimized.
These automatic transformations might be feasible if the goal of the software would be described in highly abstract terms; not how to do it, but what to accomplish.
@acl Procedural can be pretty problematic even when compiled. Almost nothing of the mental CPU model most people have in their heads doesn't hold in real life. At least regarding efficiency.
Of course usually Compile improves performance, if the problem doesn't map trivially to optimized performance primitives of Mathematica in the first place. :)
@kirma All I'm saying is that if you have an algorithm which is procedural and want to implement it in mathematica, and have it be reasonably fast, you can either a) spend some time and effort to express it in the "right" way (and often you need a lot of knowledge that's not in the docs to do that), or b) just write it with Do loops and the like and wrap a Compile around it (often, this also requires knowledge that is not easy to come by, but usually less than case (a) for me)
@acl True. My rant escalated out of context. I'm mostly feeling sort of weltschmerz for gap between programmer and hardware in general. Probably one could more down to earth. :)
I just deployed my first demo in the cloud. But will not given the URL to any because it will cost me cloud tokens to use it. I love this new technology.
@Nasser I don't think it's particularly strange that they charge you for hosting something for you (and running calculations). I have to pay if I have a passive site hosted somewhere as well.
@Nasser It is not really comparable to the demonstrations site.
@Nasser Yes, that's true. I misunderstood your original message and it was too late too delete. I thought you meant you needed credits to get the URL at all. I have about 400 credits left.
@Pickett you have 400, and I have more than you now. Can I sell you some of my cloud credits? I wonder if one is allowed to trade W-Cloud coins? Is it legal?
@Pickett You are right. My price was too high. Explorer plane is 5,000 tokens for $15 per month. So 3 token is one cent. I just do not know how these translate to actual usage. i.e. how they measure token usage. Any way, with missing Manipulator support in Cloud, it is of little use to me now. I'll stick to regular CDF and put them on my server's ISP.
Hmmh. Why FullSimplify[Solve[a GoldenRatio^b == # && b >= 0 && (a | b) \[Element] Integers, {a, b}, Reals], (a | b) \[Element] Integers] & works fine for (145 + 65 Sqrt[5])/2, but causes effectively non-abortable kernel busyloop with 1?
@Nasser The price varies depending on how you buy them. The cheapest way is to buy a million of them, which will give you 40 credits per cent. But still as I have said I agree that the price is a bit too steep. They would have to come down to Amazon EC2-levels for me to be interested.
@Pickett the problem is that one does not know how this translate to usage. The number does not matter. What if I get one billion tokens, and then each click on my demo uses one million tokens? That is why I think this whole plane makes no sense. People want to know ahead of time how much something cost. This uncertainty is what will scare people away.
@Nasser Like I've also said I have no problem with the pricing model. It is commonly used, and I have used such services before.
That was the information I used to calculate how expensive it was. Using the fact that 1 credit is 100 ms you can easily calculate that it is much more expensive than EC2, which also charges for computation time used.
@Pickett I never used such a plane. I always pay fixed monthly charges for anything. ISP, cell phone, etc... but I am not an internet guru, so I do not know. I just will not sign up for something without knowing ahead how much it will cost me.
@Nasser It's really not different from what you have now. Let's say you paid your web host $20 for web space so that you could put up your website. That will give you x gb of bandwidth. When that bandwidth runs out you'll have to pay more. With WRI's plan you pay a certain amount for x cloud credits, when that runs out you'll have to pay for more.
@Nasser I'm assuming your web host is going to charge you extra if you become the next Facebook?
@picket most ISP's given unlimited disk space. or more space that you'll ever need. I called my ISP and they said they do not charge by disk space and I can use as much as I need.
But even with this, one knows ahead of time the maximum. This is easy to know. I know the size of my demos before. so if WRI charges by disk space, then it is more clear to users how much they need.
First of all, ISPs are Internet Service Providers. You buy Internet access from them, they're usually not in the web hotel business. Most web hotels give you a lot of web space because it's cheap and they know you can't use it because you'll run out of bandwidth if people start downloading that amount of data.
@Nasser Look, the bottleneck for web hotels is bandwidth and the bottleneck for WRI is computation time. They need to charge for different things, but it's the same kind of deal.
Hosting a small website is generally very cheap, so it's easy to predict which plan you need, sure, but you'll be paying a lot more than you have to with any plan because it's so cheap for the provider.
WRI could also make it easy to pick a plan by adding a large margin so that the number of cloud credits is probably more than you'll need, but that would make it expensive because the kind of operation they run is more expensive.
@Nasser Perhaps you are under the impression that you wake up and suddenly if your demo was successful you owe WRI 9999999U$S? I doubt it works that way. Probably it just stops working if you choose not to pay more and your quota is exceeded. Right?
It actually sounds nicer to pay only if successful, if the alternative is overpaying a fixed amount just in case
@Rojo good question. I do not know the answer. Yes, that is what I was afraid of. If it will stop charging me when I run out of tokens, then this is much better, at least I know what the worst case cost.
I'm assuming it will stop working when you run out of credits. If not they would have simply billed you. No need to introduce credits in the first place.
@Nasser or just another view on the demos of the demonstrations site that doesn't require the plugin, for those demos that have been checked not to use up lots of cpu, or with timing restrictions
What is the right way to copy the code from a notebook, to cloud? now, I select a cell in a notebook in the PC, then convert to inputForm, then copy as text, then paste the code into the cloud window. But it does not like many of the annotations when displayed. Here is a screen shot:
@SjoerdC.deVries I looked for that first thing. Will keep looking. can't find it now.
@SjoerdC.deVries so you are saying, can't use the same fonts and symbols I am using on the PC? like \Beta[] etc...? This means I have to rewrite the demo!
how to change a cell property to not be open? Now the code shows up in a cell and the manipulate below it. I need to close the code cell like I do with notebook, using cell->open/close before I save it as CDF. I can't find how to do this in the cloud
may be I need to wait for the Wolfram desktop to do all these.
@Nasser Could you try setting the default font of your browser to Lucida Unicode Sans or Arial Unicode MS? They contain more symbol blocks than the default Times Roman
@Nasser If you use SaveDefinitions -> True then you won't need the code at all, isn't it?
Ok, I deployed my first demo, but I do not see the manipulate there. Only the source code above the Manipulate cell. any way, this is all too complicated for me, I'll just stick to standard CDF for now. Thanks to everyone for help.
The problem is that Mathematica, does not support annotation on function argument that tells one if the input is pass by value or by reference. This makes code maintenance very hard since one does not know now if an argument is pass by value or by reference by just looking at the signature of the function.
You can't now. can you? You'd have to go search somewhere else to see if there is a HoldAll on foo?
@Rojo but that is my point. Suppose you are reading source code. What do you do? You are looking at the source, say on a paper, or you do not have access to M. In other languages that support this, the mechanism is given as part of the signature, using IN, INOUT, OUT. So it is clear to the reader.
@acl I was (still am). But this requires more free time in a bulk than I currently have. I am waiting for the next big "window" to make some real progress with it. Don't know yet when this happens.
@acl The thing is, I intended to write a more in-depth book, covering more stuff and on more advanced level. This is a multi-dimensional problem, so to say, and a pretty hard one.
@acl Yes, and this is only a part of the problem. I want it to be useful to advanced users and experts too, but I want it to be useful also to intermediate users. I want it terse, but also clear. Etc, etc. This is actually a design problem, very similar to ones related to designing software.
@acl Function[params, body, {attr1, attr2, ...}] represents a pure function that is to be treated as having attributes for the purpose of evaluation. »
@acl Intermediate user is, in my view, someone who understands how to use functional programming, e.g. for common list manipulation tasks, and to some extent understands the performance model of Mathematica.
@Nasser I just had to prepare some figures for a paper, my prof was fussy about the details, and at the moment I am not at all happy with Mma's graphics capabilities ...
@Szabolcs I mean for programming. Not like for printing and publication. Mathematica makes it so easy to program 3D graphics and such. For printing, Tikz might be best. (Latex/tickz)
@acl Advanced user is the one who also understands, at least to some extent, the evaluation process, working with held expressions, how rules and patterns interact with evaluation, also has a really good understanding of performance and the FP layer. Basically, then one who can write decent (fast, structural) functional etc code.
@acl Not completely. Those who completely understand the performance are experts, and actually even among them very few I think can say that they understand it completely
does anyone know how I can separate the coefficients of a 2-variable polynomial in a strict way? Example: 2 x^2 + 3 y^2 + 4 x + 5 y + 6 + x y + x y^2. I just want to extract 4 as the coefficient of x, not the y and the y^2.
@Leonid Each row contains each column name. That's a lot of repetition of column names and it probably takes a lot of memory (difficult to tell because of the double-counting ByteCount sometimes does). So what is an optimal way to use Dataset? I said I thought something like <| "a" -> {1,2,...}, "b" -> {1,2....}, "c" -> {...} |> might make more sense. But we only had a few days to really play with it (since WolframCloud became public)
@Szabolcs We don't currently have an optimized representation for tabular data. It was considered more important to expose the interface. I do have reasons to believe that such more optimized representations will be added in the near future.
@acl lol
@Szabolcs The main idea is that Dataset is supposed to unify tabular and hierarchical data. Presently, I'd say it is biased towards hierarchical data, in the sense that it is more powerful when used with that. For tabular data, it does have performance disadvantages you mentioned. I think they will be addressed in the near future.
anyone? "does anyone know how I can separate the coefficients of a 2-variable polynomial in a strict way? Example: 2 x^2 + 3 y^2 + 4 x + 5 y + 6 + x y + x y^2. I just want to extract 4 as the coefficient of x, not the y and the y^2."
that works like a charm, though could I generalize it so that I can select any variations of h and k, like in this: 2 x + h^2 x + Sin[k] x + Exp[h/k] + y x, x