« first day (134 days earlier)      last day (4351 days later) » 

8:26 AM
14
Q: Pattern issues weird warning

RojoTake for example head[b_[PatternSequence[_, _]]] := 9 I know this example serves no purpose as is. It also happens in useful examples such as head[b_[_, arg : PatternSequence[_, _]]] := {arg, b} The definition is made propely, but it issues the message Pattern::patvar: First element in...

 
 
2 hours later…
10:09 AM
I was wandering: can we or should we merge into ?
has more instances, but the term covers a more broad domain while is more focused on styles and their storing in stylesheets. Keeping both might be redundant, but I can also see why is still in existence as it covers a more specific area.
 
acl
10:24 AM
@IstvánZachar I think it makes sense to keep as a separate tag. it's a somewhat obscure area of mathematica (at least for me and, apparently, for many others too). one would ask different questions about stylesheets than about eg "how do I display equations"
 
I wouldn't merge them. 'formatting' contains 'stylesheet', but 'stylesheet' contains clear additional information, so it's valuable.
I'd only merge in cases where two tags are either synonyms, or one of them is so exceedingly rare that it's not worth keeping. THis is not the case for 'stylesheet'.
 
Ok, in the meantime I got to this conclusion too. Both are valid, and different in some sense. So I now try to make the tag descriptions a bit more diverged, please feel free to correct my modifications.
 
11:09 AM
Have any of you ever constructed a Kalman filter in Mathematica (or know about someone who did)?
 
12:41 PM
KalmanEstimator[ss,{w,v}]
constructs the Kalman estimator for the StateSpaceModel object ss with process and measurement noise covariance matrices w and v.
 
12:53 PM
What I really need is an implementation which is transparent. The built-in KalmanEstimator is a black box.
 
1:41 PM
Aren't Kalman filters always a mysterious black box?
 
2:17 PM
This isn't helpful, but sorry I couldn't resist :(
Opacity[KalmanEstimator[ss,{w,v}] ,0.01]
 
lol
Victory! I have written the longest-running FullSimplify[] in the world
What do I win?
 
A patience badge ?
 
haha
Or a dunce cap. We'll see
 
In the spirit of SE I vote you get the badge :)
 
that would be fun to explain to everybody who saw it :)
 
F'x
2:26 PM
@ColinK congrats for running a decent, stable OS on your computer
 
Nonsense. My OS is made of tinker-toys and sadness
Actually if I did run this on our linux machine I'd have access to more CPU cores, that might be helpful. Does FullSimplify[] parallelize well?
 
R.M
@ColinK FullSimplify tries every damn thing known to it
13
A: What is the difference between a few simplification techniques?

R.MThe primary difference between Refine and the two *Simplify functions is that Refine only evaluates the expression according to the assumptions given. It might so happen to be the simplest form when evaluated, but it does not check to see if it is indeed the simplest possible form. You should use...

You might want to control it, else you'll be disappointed after 2 days
 
Yeah I know. I'm sort of abusing it to achieve a particular goal
I've got this complexity function that you'll probably laugh at
although TimeConstrained is probably a good idea
 
2:45 PM
@RM The guy teaching us Mathematica when I was an undergraduate was dead set against FullSimplify. He made us use things like Together and Expand to simplify our expression.
 
R.M
@Heike Yeah, I found that out the hard way about a year ago — FullSimplify took nearly a day to return what Simplify did in 2 seconds. Now I use it only if everything else has been a dead end
 
@RM You actually waited a day for FullSimplify to finish? You're more patient than me.
 
I'm willing to wait through a lunch break but I'll probably go a different way if this takes longer than that
because A) I'm lazy and B) I can at least do other stuff while I let mathematica chug away at the algebra for me
I've got enough cores... I can still Matlab while Mathematica works :)
 
I was just thinking about that!
 
2:55 PM
So what do those of us who use interpreted languages say ?!??!?!
 
FullSimplifying?
doesn't have the same ring to it though
 
Depends who your boss is
I'd just say compiling
 
@image_doctor "The pictures are still rendering..."
 
lol @Heike
@ColinK Ignorance is bliss then ...
 
@JM I like your latest avatar. How was that one made?
 
3:01 PM
@Heike About a day of waiting ContourPlot3D[] to finish...
 
Wow, yeah that is cool
 
Anyway: it's a surface called a gyroid.
 
some sort of manifold with local scalar curvature giving the colormap?
 
@ColinK Nah, I don't have that kind of stamina. I just Perlin'd it up for the colors.
 
3:04 PM
"Perlin, for all your noise issues."
 
yeah I read about this Perlin noise. Some of it looks like f^{-\alpha} noise, but the algorithm sounds much more complicated
and some of it looks nothing like fractal noise
 
@ColinK Effectively interpolated Brownian motion, yes.
 
oh. well thatsa a much more concise explanation than wikipedia
Even when you say it twice :)
 
Are there some advantages to Perlin noise ?
 
I get the impression that it's both flexible and computationally efficient
 
3:08 PM
Those of you who have not signed any NDA, what is your no.1 wish for v9?
 
An interruptable FrontEnd
 
A one-line function that efficiently does exactly the thing I'm working on right now.
and cookies
 
time series
profiler, without having to buy workbench
@JM is there a public code snippet for Perlin Noise ?
 
A decent debugger would be nice as well
 
@image_doctor One in the docs and one by Heike somewhere on this site
 
3:13 PM
@Szabolcs thanks
 
@image_doctor I use a Perlin noise generator here
 
@Heike thank you
@heike I enjoyed that question
 
@image_doctor Thanks, me too.
 
R.M
@Heike yeah, actually I did. It was for a paper and I had to show my complicated X was equivalent to someone else's simple Y. In the end, a PowerExpand before Simplify was all I needed
 
@ColinK Nah, that was due to my connection being crappy...
 
3:22 PM
@JM Doesn't look like the same as this:
 
@image_doctor It's pretty nice, but there is now simplex noise (which is what I used for my Gravatar).
@Szabolcs Yes, I used RegionFunction to restrict the surface to what's within a sphere.
 
@jm thanks, I'll read a little on that as well
 
(I'll post my simplex noise routine when I've ironed out all the kinks.)
 
@JM Am I right in thinking that Simplex noise is basically Perlin noise with triangular elements?
 
@Heike Yes, you're interpolating across the corners of a randomly-oriented simplex to produce the noise function.
Classical Perlin noise interpolates across a (hyper)cube.
 
3:32 PM
@JM Your's doesn't quite look the same as mine. Did you take the equations from Wikipedia (the sin-cos thing?)
 
@Szabolcs Cos[x] Sin[y] + Cos[y] Sin[z] + Cos[z] Sin[x] == 0 is the equation I used.
 
It would be an interesting game to look at a surface and try to guess the equation.
 
R.M
guess the equation ;)
 
Here's the non-stylized version of the gyroid in my Gravatar: ContourPlot3D[Cos[x] Sin[y] + Cos[y] Sin[z] + Cos[z] Sin[x] == 0, {x, -9, 9}, {y, -9, 9}, {z, -9, 9}, Axes -> None, Boxed -> False, Mesh -> False, PlotPoints -> 75, RegionFunction -> Function[{x, y, z}, x^2 + y^2 + z^2 < 81]]
@RM You know that old Indian story about the blind men and an elephant? :)
 
lol @RM
 
3:39 PM
@RM It's simple: $U = 0$ what $U$ depends on is up to someone else to figure out. :)
 
Easy, it's the Heaviside Elephant Function, implemented in Mathematica as UnitElephant[]
2
 
@ColinK Exactly.
Heaviside is oddly appropriate in this case ... :P
 
I was going to go with Heaviside or Bessel :)
 
@ColinK No way, Bessel is too oscillatory...
 
Or, Euler. never hurts to use Euler.
 
3:42 PM
You probably need to trun(c)(k)ate something as well
2
 
If I apply a smoothing function to uniform noise... will I get something approximating Perlin noise?
 
Rimshot[]
 
@image_doctor That would be what the CG guys call "value noise".
@rcollyer Or even Gauss.
 
@JM True, but they're still publishing Euler's collected works. The man was a machine.
 
@rcollyer Of note was that he produced a good portion of those after he went blind...
 
3:45 PM
@JM I did not know that. I was impressed before ... Sort of like Beethoven being deaf.
 
I can imagine that helping actually
 
probably it is similar with Hawking
 
@rcollyer Beethoven is an apt analog. :) (I never thought of it that way before, I must confess.)
 
J.S. Bach became blind as well
 
Easier to think about complex geometry when you're less connected to the concrete 3-D world. also less distraction. You cna just stay with one line of thinkking without being pulled away by what you're seeing
 
3:47 PM
"there is no spoon"
 
Some forms of meditation are done with the eyes closed for exactly that reason.
@Heike only forks.
 
@heike but I have concrete proof of the existence of sporks
 
@image_doctor they're mutations from the pure fork stock.
 
@image_doctor Speaking of sporks... I laughed at that Wall-E scene where he was having trouble classifying the spork for his collection.
 
3:58 PM
@rcollyer it is the sort of thing that abounds when everyone starts bio-hacking :)
@JM oh for a soft classifier
 
Oh dear, I'm reminded of that Batman thing again... :o
 
4:28 PM
Hello all.
 
Hi!
 
Okay, so not being a proper physicist, I've never studied tensor calculus to know what the proper notation is, but here I am having to describe it in my thesis. Does anyone know how to express the partial trace Map[Tr, tensor, {2, ArrayDepth[tensor] - 1}] in more conventional notation?
 
CHM
5:02 PM
Easy one here if anybody's interested!
 
@OleksandrR shame TraditionalForm@HoldForm@Map[Tr, tensor, {2, ArrayDepth[tensor] - 1}] doesn't work
[also, hi all]
 
5:17 PM
@EliLansey Hi!
 
 
1 hour later…
6:37 PM
@Szabolcs: Woah, awesome.
You guys weren't kidding about FullSimplify[]
 
@ColinK See RM's link below, it's from there.
 
yeah I saw that immediately after I said that to you
awesome
So if the main difference between Simplify[] and FullSimplify[] is that the latter uses special functions, that means that if Simplify[] doesn't find a simpler form than the input, anything FullSimplify[] does find will necessarily include a special function, correct?
 
@ColinK no because there can be certain values of special functions that are expressible without requiring the general form. So you can have a transformation using special functions which then gets re-simplified.
 
@ColinK FullSimplify uses a larger set of transformations while searching for a simpler form. I'm not sure if it's only about special functions or also some trafos for triginometric ones
 
6:44 PM
Oh, I see
ty
 
@OleksandrR I'm afraid I didn't learn a notation for that either.
 
@Szabolcs it seems to be something quite unusual. http://en.wikipedia.org/wiki/Abstract_index_notation helps with the Tr_xy notation used there, but I have no idea if this is standard.
 
I need to generate something that could be intuitively described as a "small rotation". It has to be small, i.e. when applied to a point on the unit sphere, it shouldn't displace it by a lot. It has to be random, i.e. applying it lots of times repeatedly to a point on the unit sphere should generate a set of points with uniform distribution on the sphere.
 
I never really used tensors much, but I did get a physics degree. The most common notation I've seen for the trace is just Tr()
 
Is a rotation by a small angle around a randomly chosen axis the best solution?
 
6:48 PM
FWIW this comes from a Taylor expansion of a matrix-valued function I'm using for experimental error propagation:
With[{contracted = Map[Tr, D[exprs, {vars, #}], {2, #}]},
    1/#! contracted.MatrixPower[covarianceMatrix, #].Transpose[contracted]
    ] & /@ Range[order] // Total
I looked high and low for anyone that did anything like this, but it seems nobody did. Maybe it's just a bad idea? :)
 
@Szabolcs: I think small angles would work like that, but I can't think of how to be sure. Rotations are annoying because of F*@*%$ non-comutativity
 
@OleksandrR Looks like a pretty convenient and intuitive notation. I like the Einstein summation convention :)
 
@Szabolcs the most difficult aspect of that seems to be the uniform distribution after repeated application. It sounds almost like a random walk on the sphere, but of course a random walk does not produce a uniform distribution.
 
An AR(1) series could do that
 
Need to run down to the corner store before it closes, brb
 
6:55 PM
@Szabolcs The numbers would be temporally correlated but maybe that's alright for you?
 
7:06 PM
@ColinK Nope, they must be uncorrelated. The main concern is computational efficiency.
 
So you don't need a time series either then?
ie. it would be acceptable to draw repeatedly from a distribution?
 
@OleksandrR Eventually it'll be uniform because the sphere has a finite surface. Actually a small rotation around a random axis would work, but my main concern is computational efficiency. Is this the most efficient way, if I'm storing the rotations in quaternion representation?
 
Is there a reason you cant just choose your two angles from a normal distribution?
 
@ColinK Yes, that's what I need and I'm trying to figure out the most efficient way.
@ColinK What do you mean by two angles exactly?
 
@Szabolcs oh, if you're not concerned with the distribution after a small number of rotations, I guess that's okay. Not sure about how to do it based on quaternions though; I've never used them actually.
 
7:08 PM
in Matlab syntax, I'm saying: angleList=randn(2,N) where N is the number of points on the sphere you want
you were talking about points on the surface of a sphere
 
@OleksandrR It's really easy to convert between axis-angle and quaternion representation, actually.
 
any point on a unit sphere can be identified by 2 angles (although if you are comfortable with quaternions, then go for it)
 
@ColinK That was a wrong phrasing, actually. What I need is not points, but rotations, that could rotate any point. Walking a single point is easier than having a series of rotations that can be applied to any point.
@ColinK Of course, but a rotation is not fully determined by how it transforms a single point.
 
oh, ok then I don't quite get what you're after.
you want a set of rotations that, when applied sequentially, do not rotate a point by more than some limit?
or, more generally, rotate a point by some amount that is normally distributed?
 
@ColinK I simply need to efficiently generate a small random rotation. Small = when applied to any point, it won't displace it by more than a threshold. I don't need to compute the magnitude of this threshold exactly in terms of my parameters, I just need to keep it "small".
I think I'll just go with that: random axis and random small angle.
 
7:14 PM
oh. well then by that definition, your solution is fine. Numerically I can't imagine it getting much more efficient
any way you go about it you need to generate the same number of matrix entries (or quaternions in your case)
 
This is going to be optimized C++, and I suspect generating the rotations will be one of the bottleneck, so I wanted to make sure I don't waste too many cycles.
This doesn't redraw properly here on Windows: Rotate[Graphics[{}, Axes -> True], Pi/3]
brb
 
7:27 PM
back
 
I thought of a couple other ideas but now I don't think they will work
I was thinking you could make a matrix of random numbers, and then impose some (computationaly) simple limits on their values to make it a rotation matrix (or equivalent in quaternion language)
but I think applying those constraints would be just as expensive as making a random rotation in the first place
:(
 
Or formulate the rotation matrices explicitly, using small angle approximations to get rid of the transcendental functions:
smallRotationMatrix[\[Theta]_, \[Phi]_] := {
   {1 - \[Phi]^2/2, 0, \[Phi]},
   {\[Theta] \[Phi], 1 - \[Theta]^2/2, 1/2 \[Theta] (-2 + \[Phi]^2)},
   {1/2 (-2 + \[Theta]^2) \[Phi], \[Theta],
    1/4 (-2 + \[Theta]^2) (-2 + \[Phi]^2)}
   };
 
oh now that's an idea
 
(Experimental`OptimizeExpression shows that this is actually pretty minimal after CSE.)
 
although, are the trig functions in C++ particularly slow? they are all implemented as LUTs under the hood, right?
 
7:33 PM
I would think even well optimized trig functions will be slower than making the small angle approximations, which turn it into just a couple of multiplications and additions.
 
Yeah that would be my instinct as well, but I'm not so sure of it
 
Well, Experimental`OptimizeExpression gives you this:
Block[{Compile`$1, Compile`$5, Compile`$10, Compile`$8},
 Compile`$1 = \[Phi]^2; Compile`$5 = \[Theta]^2;
 Compile`$10 = -2 + Compile`$5;
 Compile`$8 = -2 + Compile`$1;
 {{1 - Compile`$1/2, 0, \[Phi]},
  {\[Theta] \[Phi], 1 - Compile`$5/2, (\[Theta] Compile`$8)/2},
  {(Compile`$10 \[Phi])/2, \[Theta], (Compile`$10 Compile`$8)/4}
  }
 ]
 
C(++) basic math functions have had a long time to be optimized. Especially if you've custom compiled your libraries. and since a LUT function needs only do 2 hash table lookups (absurdly fast) and a linear interpolation, I can imagine that somebody sufficiently smart has reduced that to a number of machine operations comparable to a division
especially if there happen to be CPU instructions for this sort of thing, which I'm sure there are these dyas
but either way it's a nitpick. I like your idea
 
Division is still comparatively expensive. :) 20 cycles or so.
The Experimental`OptimizedExpression has only 6 multiplications and 4 additions.
For the entire matrix!
 
sweet
Wow that's mighty impressive actually
 
7:42 PM
Oops, forgot the squarings. Make that 8 multiplications.
Problem with the approximations is that obviously points will eventually move off the unit sphere. For instance applying the same matrix 10,000 times with an rotation of 0.1 rad in each axis gets you a slightly distorted sphere; doing it 100,000 times gives you an obvious ellipsoid. So the angles do have to be small.
With 0.01 rad angular displacement, the sphere still looks alright after 1 million rotations. (I'm applying the same rotation to points over a whole sphere, BTW.)
 
If it becomes a problem, it would be cheap to occasionally force the point back on the sphere. say, every 1e6 iterations
 
Well, if you know where the sphere is. Perhaps these points didn't start on the unit sphere but just have to diffuse in fixed shells.
 
oh, yeah good point.
I should shut up, I'm only half paying attention and I keep saying silly things :)
 
Sorry for diappearing for a while
Something really weird is going on here:
2
Q: ShearingTransform and Dynamic

ndroock1Background: I have a geometric transformation composed of a RotationTransform, ScalingTransform and ShearingTransform, I can use dynamic constructs with rotations and scalings but this does not ( seem to ) work with the ShearingTransform. Consider the following snippet: DynamicModule[{shr, d...

 
8:00 PM
Not sure I know enough about Dynamic to be able to comment. It's not something I use often.
 
is there a straightforward way to test whether two expressions are equivalent?
== and :equiv: don't seem to be doing what I want
 
@ColinK equivalent in what sense? If you mean structurally identical, use SameQ (===)
 
oops never mind I go tit
 
Yes, SameQ tests if they're structurally the same.
 
R.M
8:39 PM
Hmm... why can't I use rule replacements on the fullform of graph objects? For example:
Graph[{a \[DirectedEdge] b, b \[DirectedEdge] c,
   a \[DirectedEdge] c}] /. DirectedEdge -> UndirectedEdge
 
@RM Because Graph doesn't have a FullForm. ANything the system print as a FullForm is a lie. Graph is atomic.
 
R.M
aaah. I now remember something about Graph and atomicity on SO. Thanks.
 
@RM Not only is it atomic, it may contain a lot of information that the "FullForm" that the system tells you doesn't show. (E.g. some properties).
I agree that this is annoying.
There are other complex atomic symbols, but at least their FullForm contains all information about them
E.g. Rational or SparseArray
 
R.M
It feels weird to me to think of a Graph as atomic (probably why I keep forgetting it)
 
@RM To make things more confusing, you can actually have a normal Mathematica expession with the head Graph in certain cases, usually when the Graph expression you typed is not a valid Graph. This is why the correct pattern for graphs is _?GraphQ and not _Graph.
Yes, it's weird. I guess it's because of performance reasons.
 

« first day (134 days earlier)      last day (4351 days later) »