« first day (1834 days earlier)      last day (2647 days later) » 

8:40 AM
I came across another weird pattern matching behaviour:
a*b*c*d /. a*b -> 1
Out[554]= c d

a*b*c*d /. c*d -> 1
Out[555]= a b

a*b*c*d /. a*b -> 1 /. c*d -> 1
Out[556]= 1

a*b*c*d /. a*b | c*d -> 1
Out[557]= a b c d
Anyone have a clue why it no longer matches once I use Alternatives? Am I missing something obvious or is this worth a question on main?
 
9:07 AM
@MartinEnder Well, as I see it, the first two examples are the special case here that should not match.
And the reason they do match seems to be to make the language usable.
Consider this:
Hold[(a*b) (c*d)] /. a*b | c*d -> 1
 
Hm, so Mathematica stops picking out individual factors from larger products once they are inside Alternatives?
 
@MartinEnder If you have a*b*c*d /. a*b -> 1 then Mathematica is picking out the a and b although the general structure does not match.
@MartinEnder This behavior is connected to the Flat attribute.
Try
g[a, b, c, d] /. g[a, b] -> 1
and then
SetAttributes[g, Flat]
and the replacement above again.
@MartinEnder So what seems to happen is that Alternative prevents that all combinations are tried because basically a structure g[a,b,c,d] could come from all kinds of combinations with nested g
g[g[a, b], g[g[g[c]], d]] /. g[a, b] -> 1
 
I'm aware that the first two examples work because of the flat attribute, but that doesn't explain to me why Alternatives prevents Mathematica from attempting the same matches.
 
@MartinEnder I see no obvious reason why Alternative does this and the documentation does not give any clues about it.
 
9:22 AM
the only related thing I'm seeing on main is mathematica.stackexchange.com/q/105472/2305
actually, that question is outdated. the first example there does work in 11.0.0
left a comment
 
9:39 AM
posted a new question
I think even if that doesn't result in a satisfactory reason or workaround, it's good to have this documented somewhere.
 
9:52 AM
@MartinEnder Have you seen this?
5
Q: Why rule does not work if Flat attribute?

Suzan CiocThe following works: In[39]:= ClearAttributes[M, Flat]; Replace[M[F1[a]], M[x_F1] | M[x_F2] -> x] Replace[M[F2[a]], M[x_F1] | M[x_F2] -> x] Replace[M[F3[a]], M[x_F1] | M[x_F2] -> x] Out[40]= F1[a] Out[41]= F2[a] Out[42]= M[F3[a]] the following does not In[34]:= ClearAttributes[M, Flat]; Se...

 
huh that's even weirder
 
It's only remotely related but it seems there are other issues as well.
 
10:47 AM
Adding Flat to Alternatives does it: Unprotect[Alternatives]; SetAttributes[Alternatives, Flat];
SetAttributes[g, Flat]; g[a, b, c, d] //. (g[a, b ] | g[c, d]) -> 1 gives g[1,1]. So the question is why Alternatives is not Flat.
 
wow, nice find (and that's a good question indeed)
 
11:51 AM
@R.M. I've always used latexmk for compilation, I believe it's included in TexLive. It takes care of any needed re-compilations automatically. I've also used it successfully with .tex files that make external commands to sed and awk. But mostly I just run pdflatex (latexmk figures out how many times it needs to run in order to get references and bibtex entries)
 
12:10 PM
@BenNiehoff The biggest drawback of LaTeX in scientific writing is currently, that I'm in a dilemma. To write good English as a non-native speaker, I need to use an excellent grammar-checker, but such systems need to see plain text. This doesn't work if you have small formulas or even things like latex abbreviations in the text.
So I could write the text in a different system and add it to LaTeX later with all the cite, emph, etc commands which is annoying.
Or I write TeX first and check the text after compilation which is annoying too.
 
@halirutan I did start using Grammarly after you recommended it, but its suggestions aren't always correct. It likes to suggest too many commas (when the sentence would be fine either with or without that comma) and sometimes its suggestions are plainly wrong. It is true that when it makes a mistake, it often because of sentences that are too complicated.
 
@halirutan Your grammar sounds native to me, you probably don't need to worry as much as you think you do. My opinion (as someone who also does scientific writing and uses loads of formulas!) is that one should stick to simpler grammatical constructions anyway, and focus on writing in a way that flows more like speech. The end goal is to explain what you've done (as opposed to encode it, which is a style of writing I see a lot of)
 
> one should stick to simpler grammatical constructions anyway
precisely
 
@Szabolcs Yes, you still need to think. What I really like is that it points me to suspicious places and that I can double click on a word to get synonyms.
 
@halirutan I agree that spell checking LaTeX is a pain. I have practically given up on it. I know you don't have a perfect solution, but what is the best you could find? TeXStudio with LanguageTool?
 
12:19 PM
@Szabolcs Yes. Because TeXStudio does "precompile" the text. So it extracts e.g. \emph{word} so that LanguageTool isn't confused.
 
TeXStudio seems to do decent spellchecking. I have no idea if it does grammar checking, but I've never seen a grammar checker that gives sensible results
 
@BenNiehoff You can turn on LanguageTool with TS
 
@BenNiehoff Unfortunately there are lots of academics who are not satisfied until they managed to make their sentences convoluted and hard to understand. Or at least replace even everyday word with a synonym that I need to look up in the dictionary. I hate this.
OK, download TeXStudio ... :)
 
@Szabolcs If you use the binary, then it doesn't work with the latest LT. You need LT 3.5 because from then on they switched to JSON.
 
@Szabolcs bleh, I hate that...the only thing worse are the ones who think they need to have a mathematical notation for everything, and that math written in words isn't real
 
12:23 PM
 
it's newer or equal!
 
@Szabolcs It seems to work with latest version of LT. Just download and unzip the package and in TS use Options -> Language Checking and point the LT Path to the languagetool-server.jar
 
12:41 PM
Can someone point me to the question about creating graphical representations for own arbitrary expression e.g. how to recreate what e.g. Interpolation or LinearModelFit do with their output?
I couldn't find it with help of the site search
 
34
Q: How to create a dynamic expanding DisplayForm's styled like the ones in v10?

M.R.The display forms for objects like ClassifierFunction are nice clickable summary boxes I like this, and now I'm trying to create my a custom version of this for my functions, so I dissected the code in the output cell and trimmed it down to this: CellPrint@ Cell[BoxData[ Interpret...

 
1:04 PM
Should (136098) be closed as a duplicate of (135952)? I can close it myself, but I'd rather not act unilaterally. rcollyer thinks it's the same bug, but didn't cast a close vote. Maybe didn't think of it, but it's left me in some doubt.
 
1:32 PM
One of these questions again... how do I compute (analytically or numerically) minumum distance of two points on an algebraic surface, along the surface?
 
@kirma That could be very tricky indeed, considering that the points are not necessarily connected by a geodesic
 
@BenNiehoff Yep... maybe I can avoid the whole question in many cases though.
 
1:50 PM
@kirma what do you have to start with? Just the two points? Do you have some curve that connects them, even if it isn't minimal length?
 
@BenNiehoff Just the points, but I guess at least one could find numerically some path between them by moving a point along the surface using NDSolve of a point with velocity always being projection of direction of destination point to the surface normal. Well, this wouldn't work if the projection is a zero vector.
 
@kirma have you looked at anything here: google.be/…
 
I suspect such a path might sometimes not be topologically straightened to the minimal distance curve, though...
 
@BenNiehoff Sometimes, when you read a paper, you get the sinking feeling that they actually don't want you to implement their results. So, not unlike patents... ;P
 
@J.M. haha, yes. This goes back to the earlier discussion about writing styles
From scanning the paper in the first link, it looks like the best generic option is to first put a mesh on your surface, then use graph theory algorithms to get a decent initial guess; then use Newton-Raphson and the geodesic equation to refine until you get the shortest path
 
2:04 PM
In general... more I think of my problem (intelligent discretization of constructive solids geometry of algebraic surfaces), more it makes me think trying to find distances along the surface is an unnecessarily complex approach. And actually, even that most things beyond some sort of augmented marching cubes algorithm is not worth the effort.
I'm really somewhat disappointed of the fact Mma doesn't really have any serious attempt on discretizing semialgebraic sets better than essentially running marching cubes over them...
 
I think when your needs are highly specialized, Mathematica tends not to have anything built-in that meets them
 
Mma has nice building blocks for doing stuff on semialgebraic sets built in, but not applied into geometric regions...
 
@BenNiehoff Haven't seen the link, but are you referring to that paper in PNAS by any chance?
I had looked through that and the papers referring to it for this, but implementing the eikonal equation had me beat.
 
Unfortunately Google just links directly to a PDF, so I have no idea what journal the paper may have ended up in
 
BTW, is there an (easy or "obvious") method to perform surface discretization on Mma so that mean distance between discretized and algebraic surfaces would be minimized, instead of maintaining discretized points on the surface?
 
2:17 PM
but it looks like many algorithms are ready available by doing a fairly straightforward search
@kirma I'm confused what that criterion would mean. Can't you minimize the "mean distance" just by putting all of the discrete points on the surface?
 
let's simplify the question into a 2D circle. You can draw a triangle inside it with all vertices on the circle, but if you want to minimize average distance from the circle to the triangle (not just vertices but also edges), you want your triangle to be larger.
 
That may be a very expensive operation for generic surfaces, since you'll be asking to minimize a continuous integral
but there are probably algorithms that use points at both the vertices and the centroids of the faces, and then use some sort of weighted minimization between the two
but this is not something I know much about
 
I'm trying to intentionally limit myself to algebraic surfaces, but I'm not sure if things are that much easier with them.
 
there are approximation methods for surfaces that are similar to Simpson's parabola rule, but they are way more complicated, and I'm afraid I don't even remember the name of the book where I saw them
 
Also, not too fancy discretization. More like having a result from marching cubes, and then adjusting vertices along gradient of the surface field.
 
 
4 hours later…
6:14 PM
One of those recent additions that make certain visualizations much easier: density plots (and also contour plots) over implicit surfaces...
Somewhat confusingly called SliceDensityPlot3D...
 
 
2 hours later…
8:20 PM
@kirma - yeah, it only really looks like slices when you use the built in string options for the surface, like "CenterPlanes" or "XStackedPlanes"
 
9:19 PM
@JasonB Yep. I think naming hides functionalities which are much more general than the name suggests...
 
10:09 PM
Quick question: if you're trying to use find root and its not finding roots that you can just visually see exist, what can you do?
 
Maybe ListSurfaceDensityPlot just sounds like you took four other functions and sandwiched their names together lol
 
:)
 
@KevinDriscoll - what if you put in the visual root as the initial guess, still won't find it?
I do like DonutPlot though
or maybe it's DoughnutPlot
 
That would be even more specific than a "slice" plot... :/
 
@jasonB yea, if I put in somehting real close to what it is visually, still nothing
just fails to converge after N iterations
 
10:54 PM
is the code reasonably short you could post it here or on pastebin and link to it?
 

« first day (1834 days earlier)      last day (2647 days later) »