Month: May 2020

Crashing Mathematica with HatchShading + Opacity

May 31, 2020 math and physics play , , ,

I attempted to modify a plot for an electric field solution that I had in my old Antenna-Theory notes:
\begin{equation}\label{eqn:advancedantennaProblemSet3Problem1:n}
\BE
=
j \omega
\frac{\mu_0 I_{\textrm{eo}} l}{4 \pi r} e^{-j k r}
\lr{ 1 + \cos\theta }
\lr{
-\cos\phi \thetacap
+ \sin\phi \phicap
},
\end{equation}
and discovered that you can crash Mathematica (12.1.0.0) by combining PlotStyle with Opacity and HatchShading (new in 12.1).  Here’s a stripped down version of the plot code that demonstrates the crash:

ClearAll[ rcap]
rcap = {Sin[#1] Cos[#2], Sin[#1] Sin[#2], Cos[#1]} & ;

{
ParametricPlot3D[
rcap[t, p]
, {t, 0, π}
, {p, 0, 2 π}
, PlotStyle -> { HatchShading[0.5, Black]}
]
, ParametricPlot3D[
rcap[t, p]
, {t, 0, π}
, {p, 0, 2 π}
, PlotStyle -> {Directive[Opacity[0.5`]]}
], ParametricPlot3D[
rcap[t,p]
,{t,0,π}
,{p,0,2 π}
,PlotStyle\[Rule]{Directive[Opacity[0.5`]], HatchShading[0.5, \
Black]}
]
}

The first two plots, using one, but not both of, Opacity or HatchShading work fine:

In this reproducer, the little dimple at the base has been removed, which was the reason for the Opacity.

I’ve reported the bug to Wolfram, but wonder if they are going to come back to me saying, “Well, don’t do that!”

 

EDIT: Fixed in Mathematica 12.1.1

Attack took out my godaddy hosted wordpress blog for most of a day.

May 29, 2020 Incoherent ramblings , , , , , , , ,

Guilty admission: The title of this post is click-baity, as the attack was not likely on my blog, but something colocated on the server that my blog happened to have been hosted on.  In particular, the math, physics, complaining about COBOL, rants, and other random garbage that you’ll find on this blog does not likely warrant a DOS attack.  This isn’t the story of my offending somebody enough to get DOSed, but is just the story of a painful interaction with godaddy customer support.

I used to use a wordpress hosted blog, and eventually decided that I wanted flexibility enough to pay for hosting.  I experimented a bit with amazon hosting, but the variability in price scared me off, and I ended up buying my hosting from godaddy.  I don’t remember anymore what other options I considered, nor why I ended up settling on godaddy’s “managed wordpress” offering, over any others, although low initial cost was a factor.  That hosting has generally been problem free, but their IT support, when there is trouble, has proven to be less than desirable.  Here’s that story in case anybody else is considering using godaddy for their own hosting.

Yesterday, I happened to notice that my blog was completely unresponsive.  I only noticed this because I wanted to make one small change to one of my pages.  All told, to get this resolved, I spent about 3 hrs with their IT support (1/2 last night, and the other 1/2 today).  Ironically, by the time I got to the fifth support professional, the problem resolved itself.  I am glad that I don’t run any sort of business off of this site, as the downtime was at least 16 hours.

My 1.5 hrs on the godaddy IT chat support with Parjeet, Jaspreet, and Shibin was a complete waste of time.  Parjeet (who’s name I am probably butchering, since I didn’t keep a copy of my chat log with him) managed to get the blog restarted.  However, it appears that he also disabled all the plugins at the same time without telling me.  He also didn’t identify the root cause.  Jaspreet insisted that the issue was the content I was hosting, even though that content was not an issue before yesterday.  He gave me various self help options (plugin tuning, …) despite the fact that the blog was performing abysmally even with all plugins disabled, and had been okay prior to the reboot, and despite the fact that even the admin pages were slow, which have nothing to do with the content being served for normal blog page or post content.  He also was not able to identify the root cause, and I insisted on dealing with his manager at that point.  That claimed-manager was Shibin, who was helpful seeming, but was not able to do anything, nor able to find somebody who had access to the server logs to diagnose the issue.  When I gave up for the night, he promised to email me the results of his investigation, but no such email materialized.

I was busy with work all morning, and at one point when I had a pause in my day, I thought of checking whether the response time issue had cleared up.  It had not, and the blog was still effectively down today, with 30 second response time for any page access.  Because of the complete ineffectiveness of godaddy’s 24/7 IT chat support, I opted for a half hour on hold to be able to talk with somebody directly.  With headphones available, that time on hold wasn’t a write off, since I was able to keep working the day job — but I have to say that godaddy has some of the worst “on-hold” music that I’ve ever heard!  Once I was finally off hold for the first time today, my support guy (I got today’s support guys names mixed up, and only recall that one of them was named Joshua) investigated what he could, and ended up having to pass the buck to their tier II support, because he didn’t have access to the server logs.  That put me on hold for another hour or so.  When I finally got to deal with somebody who had access to the server logs, the blog coincidentally became responsive without any intervention.  It turns out that there was an attack on one of the servers.  Either that attack, or the godaddy throttling that was instated as a response to that attack finally abated when I was on hold waiting for the tier II support.

The godadday response to an attack is pretty deficient.  If the server that your blog is running on is attacked, they throttle the performance of that server to mitigate the effectiveness of the attack.  The idea is that the attacker will eventually just give up.  That is done apparently done at the server level, and not just for the instance that is under attack.  It seems pretty dumb that godaddy doesn’t migrate the VMs that happen to be unfortunately colocated with attackee onto another physical host.  That’s not a good sign for anybody that wants a service that requires continuous uptime.

When I bought godaddy’s hosting initially, I do remember that it was one of the most cost effective options.  The godaddy hosting price went up considerably sometime after the first or second year of initial service, but I haven’t taken the time to figure out how to migrate to something else.  Perhaps amazon is worth looking at again? Basically, I’m allowing myself to be exploited financially a bit because the time cost to figure out how to migrate to other hosting is probably higher than the monetary cost of the blog hosting itself.

The support interaction that I had over the last two days might be enough of a kick in the butt that I’ll take the time to look at other hosting options, and how to do a migration.  One thing that I do recall was nice about amazon was they offered ssh access to the machine.  I only get sftp access on godaddy, which can be a pain in the butt, and is very inflexible.

You might wonder why I even bothered switching from wordpress.com hosting, which was free.  I did that to have the flexibility to install my own non-wordpress.com sanctioned plugins.  For somebody who is crazy enough to blog a lot of mathematics, that was very worthwhile, as I’ve been able to run a customized version of the Mathjax-Latex plugin, which renders very nicely, and allows me to replicate many of the latex macros that I use.  That streamlines my latex-to-wordpress conversion considerably, and has saved me many many hours.  That saving is in comparison to the time that would have been required to blog the same mathematics with the default wordpress.com latex plugin.  Recently, I also installed the Mathematica Toolbox plugin, which looks like it will allow some fun interactivity, much like the original Wolfram CDF plugin had before it became useless and eventually was no longer supported (i.e. it only worked in 32-bit browsers.)  So, I don’t think that I’m going to go back to wordpress.com hosting, but it’s definitely worth some investigation of the options.

A price increase for Geometric Algebra for Electrical Engineers

May 28, 2020 Geometric Algebra for Electrical Engineers , , , ,

As of this week (end of May 2020), I raised the price of the black and white version of my Geometric Algebra book slightly (from $12 to $14.50 USD).  I say slightly, despite the 17% price increase, because the price is still pretty low from an absolute value perspective, as the markup I’d added to the minimum price was fairly small.  This price increase was an experiment in response to a reseller (SuperBookDeals) buying copies at $12 and then reselling them at higher prices.  For some reason amazon lists the higher price reseller copies before their own kindle-direct-publishing version, so a buyer had to go out of their way to find the lowest priced version.

I wouldn’t care if resellers undercut my list price, and then got a preferential listing from amazon.  The fact that this reseller doesn’t play this game with the color version of the book, which has a much higher printing cost (I haven’t changed my price for that, and am still selling it for $40 USD), suggests to me that I’d set the price too low for the black and white version.

If you are interested in a copy of the book, but don’t like the new higher price, please note that the (color) PDF version is still available for free.

I may drop the price back to the original $12 later, but for now I’m going to charge $14.50, and am curious to see how the pricing game plays out.

Note that a temporary side effect of me having changed the price is that SuperBookDeals appears to have dropped their price of one of their listings below $12 (my original price) to clear out their stock. Amazon also appears to be offering a couple copies at the old $12 price, which now lists as a sale price.

 

Unexpected COBOL implicit operator distribution!

May 27, 2020 COBOL , , , , , , , , , , ,

Another day, another surprise from COBOL.  I was debugging a failure in a set of COBOL programs, and it seemed that the place things started going wrong was a specific IF check, which basically looked like:

The original code was triple incomprehensible, as it:

  • Was in German.
  • Was in COBOL.
  • Was generated by DELTA and was completely disgusting spaghetti code.  A map of the basic blocks would have looked like it was colored by a three year old vigorously scribbling with a crayon.

It turns out that there was a whole pile of error handling code that happened after the IF check, and I correctly guessed that there was something wrong with how our compiler handled the IF statement.

What I didn’t guess was what the actual operator precedence in this IF check was.  Initially, my C programmer trained mind looked at that IF condition, and said “what the hell is that!?”  I then guessed, incorrectly, that it meant:

if ( X != SPACES and X = ZERO)

where X is the array slice expression.  That interpretation did not explain the runtime failure, so I was hoping that I was both wrong about what it meant, but right that there was a compiler bug.

It turns out that in COBOL the implicit operator for the second part of the IF statement is  ‘NOT =’.  i.e. the NOT= distributes over the AND, so this IF actually meant:

if ( X != SPACES and X != ZERO)

In the original program, that IF condition actually makes sense.  After some reflection, I see there is some sense to this distribution, but it certainly wasn’t intuitive after programming C and C++ for 27 years. I’d argue that the root cause of the confusion is COBOL itself. A real programming language would use a temporary variable for the really long array slice expression, which would obliterate the need for counter-intuitive operator distribution requirements. Imagine something like:

  VAR X = PAYLOAD-DATA(PAYLOAD-START(TALLY): PAYLOAD-END(TALLY))

  IF (X NOT = SPACES) AND (X NOT = LOW-VALUE)
     NEXT SENTENCE ELSE GO TO CHECK-IT-DONE.

(Incidentally LOW-VALUE means binary-zero, not a ‘0’ character that has a 0xF0 value in EBCDIC).

COBOL is made especially incomprehensible since you can’t declare an in-line temporary in COBOL.  If you want one, you have to go thousands of lines up in the code to the WORKING-STORAGE section, and put a variable in there somewhere.  Such a variable is global to the whole program, and you have to search to determine it’s usage scope.  You probably also need a really long name for it because of namespace collision with all the other global variables.  Basically, you are better off not using any helper variables, unless you want to pay an explicit cost in overall code complexity.

In my test program that illustrated the compiler bug, I made other COBOL errors. I blame the fact that I was using gross GOTO ridden code like the original. Here was my program:

Because I misinterpreted the NOT= distribution, I thought this should produce:

000000001: !(not space and low-value.)
000000002: !(not space and low-value.)
000000003: !(not space and low-value.)
000000003: not space and low-value.

Once the subtle compiler bug was fixed, the actual SYSOUT from the program was:

000000001: not space and low-value.
000000001: !(not space and low-value.)
000000002: !(not space and low-value.)
000000003: !(not space and low-value.)

See how both the TRUE and FALSE basic blocks executed in my code. That didn’t occur in the original code, because it used an additional dummy EXIT paragraph to end the PERFORM range, and had a GOTO out of the first paragraph.

There is more modern COBOL syntax that can avoid this GOTO hell, but I hadn’t used it, as I kept the reproducer somewhat like the original code.

My collection of Peeter Joot physics paperbacks

May 22, 2020 math and physics play , , , , , , , ,

I ordered a copy of my old PHY456 Quantum Mechanics II notes for myself, and it arrived today!  Here it is with it’s buddies (Grad QM and QFT):

With the shipping cost from the US to Canada (because I’m now paying for amazon prime anyways) it’s actually cheaper for me to get a regular copy than to order an author proof, so this time I have no “not for resale” banding.

This little stack of Quantum notes weighs in at about 1050 pages, and makes a rather impressive pile.  There’s a lot of info there, for the bargain price of either free or about $30 USD, depending on whether you want a PDF or print copy of this set.  Of course, most people want neither, and get all their quantum mechanics through osmosis from the engineering of the microchips and electronics in their phones and computers.

I have to admit that it’s a fun ego boost to see your name in print.  In order to maximize the ego boost, you can use my strategy and do large scale vanity press, making a multiple volume set for yourself.  Here’s my whole collection, which includes the bulk of my course notes, plus my little book:

Based on the height of the stack, I’d guess this is about 3000 pages total, the product of about 10 years of study and work.

Making these all available for free to anybody in PDF form surely cripples my potential physical copy sales volume, but that doesn’t matter too much since I’ve set the price so low that I only get a token payment for each copy anyways.  Based on linear extrapolation of my sales so far, I’ll recoup my tuition costs (not counting the opportunity cost of working part time while I took the courses) after another 65 years of royalties.