Archive for July, 2005

.NET spreading

Sunday, July 31st, 2005

More sites must be moving to .NET because I’m starting to see .NET stack dumps when visiting web sites. Today’s occurrence was the second in the week for me. I don’t remember the first site, but this one appeared to be from the New York Times, but it was actually from http://www.sportsnetwork.com which apparently supplies some of the sports content. Below is the message, with some suggestions for turning on debug more removed.

I don’t remember seeing Java servlet stack dumps on production web sites, but that could be selective memory…

The stack dump is not very big, but when I viewed the html source, it showed a more complete stack dump in a comment.

Server Error in ‘/Merge’ Application.


Your transaction (process ID #329) was deadlocked with another process and has been chosen as the deadlock victim. Rerun your transaction.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Your transaction (process ID #329) was deadlocked with another process and has been chosen as the deadlock victim. Rerun your transaction.

Stack Trace:

[SqlException: Your transaction (process ID #329) was deadlocked
 with another process and has been chosen as the deadlock victim.
Rerun your transaction.]
   System.Data.SqlClient.SqlDataReader.Read() +176
   ASP.scoreboard_aspx.Page_Load(Object Source, EventArgs E) +17232
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +750


Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

Orange Daylilies = Summer

Wednesday, July 27th, 2005

Orange DaylilyI like daylilies, and it’s partly because of the name which is descriptive and counter-descriptive at the same time. Presumably, the name is because each bloom lasts for a day before it shrivels up and falls away. However, a group of daylilies can bloom all summer because there are at least some flowers open at any given time. In the photo, you can see several blooms-in-waiting even in this small stand.

XBoard and GNU4J

Friday, July 22nd, 2005

After I got the Java port of the GNU Chess engine working last month, I mentioned converting XBoard to Java to provide a GUI for the engine. These days I’m investigating using Jin as a GUI. Jin is a Java client app for Internet chess servers. The architecture is pluggable with plug-ins for FICS and ICC. My plan is to make a plug-in for local engines, perhaps pretending to be other players on the network to play against.

Before doing any of that though, I realized I could run XBoard on my Mac within X11 and let it talk to chessbox_gnu4j via the command line like it talks to other engines. Putting the jar file in the same directory as XBoard, the command to launch XBoard and have it use the Java engine is:

./xboard -fcp "java -cp chessbox_gnu4j.jar org.chessbox.gnu4j.Main"

Playing this way uncovered a couple of bugs, which I have fixed. Taking back a move and starting a new game didn’t work. I’ve updated the download at chessbox.org to version 1.02.

Graphical Prime Factorization

Wednesday, July 20th, 2005

Every so often I like to waste a lot of time trying to solve some practically impossible math problem, like finding a simple proof to Fermat’s Last Theorem or proving Goldbach’s Conjecture. These days I’m trying to find a quick way to factor numbers by using graphs to gain insights. (Unlike the other problems, solving this one would put me in an interesting dilemma about how to publish the solution.)

Remainder by X

Trial division is the most basic technique for factoring numbers. You just go through candidate factors, dividing each one into the number to be factored and getting a yes/no for each candidate. My thought was to look at the result of the division (not just yes/no) and use that to decide how far to skip ahead for selecting the next candidate. The first graph shows trial divisions of the number 3341287, which is the product of two primes, 2087 and 1601. The candidate factors start at the square root of n and increase along the horizontal axis. The remainders are on the vertical axis.

You can definitely see patterns in the remainders, and it turns out the points lie on “concentric” quadratic curves. The equations for the curves are all of the form: x^2 – m*x + n, for some integer m. We can factor the quadratic into (x-a)(x-b) where n=ab and m=a+b, but that doesn’t help since n=ab is what we’re trying to solve in the first place. However, since each curve covers multiple points, we can reduce our work by iterating over m and solving each quadratic instead of iterating over each x. Unfortunately successive curves cover fewer and fewer factors, and soon it doesn’t help at all.

We might also try to solve the general quadratic. Using the quadratic formula we end up with something of the format k^2-n under the radical (where 2k=m), which means all we have to do is find a k that makes the square root an integer, or in other words an integer solution to k^2 – n = p^2, or k^2 – p^2 = n, or (k-p)(k+p) = n, but then we’re back where we started trying to factor n.

Remainder by X

The second graph is the same as the first, but with a wider domain of x. Other interesting quadratics start to appear. In all graphs the red line represents y=x.

The technique of using the quadratics to skip candidates is basically the same as Fermat’s factorization method, except with a graphically inspired derivation. Fermat started where I ended, noticing that any odd number could be written as (k-p)(k+p) and then trying to find solutions by starting k at the square root of n and checking if each k^2 – n is a perfect square.

Remainder by X

The last graph shows the remainders for the x values corresponding to the Fermat trial divisors. I think each “Fermat point” represents a quadratic curve from above, using the point with the maximum remainder (or 0 remainder). The green line is at y=n/x, and I’m not sure why all the non-trivial Fermat remainders are above it.

So iterating through quadratics is really the same as Fermat’s method, and we haven’t gained anything, but what about the patterns in the Fermat remainders themselves? Looks like there are some quadratics there as well and maybe we can use the same idea to reduce the number of Fermat points we examine. I’ve found that the quadratics are generally of the form x^2 – a/b * x + n/b, where b has been a small integer in my tests. I haven’t gone much further — there needs to be a way of iterating through these quadratics with confidence of convering all the candidate factors. Then again, even if only most of the candidates are covered, there’s some chance of finding a factor quicker.

At best, any attempt to use those quadratics will surely also be duplicating optimizations that have already be made to Fermat’s method. For instance, there is a method of re-centering the search by multiplying n by some number to offset the problem of diminishing returns once you get far from the “center”, and that sounds a lot like using the quadratics that have another center point.

Mountain Week-end

Monday, July 18th, 2005

Bald Mountain

In an effort to keep up with the Jones’s, Bonnie and I went to the NC mountains for the week-end. The photo is of Bald Mountain, I think. It’s one of the mountains around Lake Lure. I got to use my kayak for the first time since my Dad took it up to their house there, but most of the time was spent racing him with Gran Turismo. He won most of the time.

High-Low at Durham Sectional

Monday, July 11th, 2005

Mom and I played every session of the recent Durham bridge sectional. Friday and Saturday we had an amazing run of finishing first overall for all four sessions. Well, “overall” for the 0-200 players, that is. That included a 70+% session on Saturday morning, which is pretty rare — 60% is often good enough to win. We collected about 9.5 masterpoints, which is almost as many as I’ve won all year before this.

Most of the competition wasn’t too strong, of course, but there was one quite good team that kept finishing second to us. They got their revenge on Sunday by handily winning the Sunday Swiss teams event, where you need a team of four players to compete. We drafted my friends Rob and Brad who are good players if a little rusty. They did fine, but Mom and I couldn’t get in sync for too many hands, and we ended up in last place out of 10 teams (except for the two teams that bailed out early).

The event was well-attended and stretched the resources of the organizers, but they were up to the challenge. For some sessions, they even had tables set up in the hallways. The location was the basement of Northgate Mall in Durham — a place I never knew existed. There’s nothing about the basement on the mall map except for a mention in the directory of the location “Office Area”, which includes a few service businesses.

Hyco Lake

Thursday, July 7th, 2005

Beth driving boatBonnie and I went out to Hyco Lake with Beth and Scott last week-end. Much better than owning a boat is having friends who own a boat. The weather cooperated nicely for a nice tour of the lake and swim.

Neither I nor anyone I have talked to since had heard of Hyco Lake. Apparently it’s a somewhat of a secret (don’t tell anyone). It’s a very large private lake about a hour north of RTP near the Virginia border and is owned by the power company there. The lake was built for cooling the coal-burning power plant, and as a side-effect the water was pleasantly warm for swimming.