Carl Love

Carl Love

27187 Reputation

25 Badges

11 years, 341 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are Posts that have been published by Carl Love

What's up with Mapleprimes's timing today? Every time I click on a Post or Question, the main post loads at the normal speed (which is slow to start with), and then it takes a full minute for the Answers or Replies (or lack thereof) to load. This has been consistent for every Post or Question that I've read today. Is anyone else experiencing this?

There has been a spate of Questions posted in the past week about computing eigenvalues. Invariably, the Questioners have computed some eigenvalues by applying fsolve to a characteristic polynomial obtained from a floating-point matrix via LinearAlgebra:-Determinant. They are then surprised when various tests show that these eigenvalues are not correct. In the following worksheet, I show that the eigenvalues computed by the fsolve@Determinant method (when applied to a floating-point matrix) are 100% garbage for dense matrices larger than about Digits x Digits. The reason for this is that computing the determinant introduces too much round-off error into the coefficients of the characteristic polynomial. The best way to compute the eigenvalues is to use LinearAlgebra:-Eigenvalues or LinearAlgebra:-Eigenvectors. Furthermore, very accurate results can be obtained without increasing Digits.

 

The correct and incorrect ways to compute floating-point eigenvalues

Carl Love 2016-Jan-18

restart:

Digits:= 15:

macro(LA= LinearAlgebra):

n:= 2^5:  #Try also 2^3 and 2^4.

A:= LA:-RandomMatrix(n):

A is an exact matrix of integers; Af is its floating-point counterpart.

Af:= Matrix(A, datatype= float[8]):

P:= LA:-CharacteristicPolynomial(A, x):

P is the exact characteristic polynomial with integer coefficients; Pf is the floating-point characteristic polynomial computed by the determinant method.

Pf:= LA:-Determinant(Af - LA:-DiagonalMatrix([x$n])):

RP:= [fsolve(P, complex)]:

RP is the list of floating-point eigenvalues computed from the exact polynomial; RPf is the list of eigenvalues computed from Pf.

RPf:= [fsolve(Pf, complex)]:

RootPlot:= (R::list(complexcons))->
     plot(
          [Re,Im]~(R), style= point, symbol= cross, symbolsize= 24,
          axes= box, color= red, labels= [Re,Im], args[2..]
     )
:

RootPlot(RP);

RootPlot(RPf);

We see that the eigenvalues computed from the determinant are completely garbage. The characteristic polynomial might as well have been x^n - a^n for some positive real number a > 1.

 

Ef is the eigenvalues computed from the floating-point matrix Af using the Eigenvalues command.

Ef:= convert(LA:-Eigenvalues(Af), list):

RootPlot(Ef, color= blue);

We see that this eigenvalue plot is visually indistinguishable from that produced from the exact polynomial. This is even more obvious if I plot them together:

plots:-display([RootPlot(Ef, color= blue), RootPlot(RP)]);

Indeed, we can compare the two lists of  eigenvalues and show that the maximum difference is exceedingly small.

 

The following procedure is a novel way of sorting a list of complex numbers so that it can be compared to another list of almost-equal complex numbers.

RootSort:= (R::list(complexcons))-> sort(R, key= abs*map2(`@`, signum+2, Re+Im)):


max(abs~(RootSort(RP) -~ RootSort(Ef)));

HFloat(1.3258049636636544e-12)

 

 

``

 

Download Eigenvalues.mw

Dear Bryon and Will:

Please fix MaplePrimes so that the Replies to Answers to Questions appear in chronological order under their respective Answers. Currently they appear in a somewhat random and changing order when their are several Replies. This has been a problem since the last "upgrade" to MaplePrimes.

Another persistent problem since that upgrade is that about half of the time that someone tries to attach a file, the file does not actually attach, even though the editor gives every indication that it has attached, and a hyperlink even appears in the post.

People are starting to leave MaplePrimes because of these problems.

Thank you for your attention to these matters,
Carl Love

It is a relatively recent innovation that complex-number computations can be done in the evalhf environment. When combined with plots:-densityplot, this makes escape-time fractals in the complex domain very easy to plot. This fractal is based on the Collatz problem. This Wikipedia article has a high-resolution picture of this fractal. I've switched the real and imaginary axes and reversed the direction of the real axis purely for asthetic reasons.

 

Collatz:= proc(b,a)  #Axes switched
local z:= -a+b*I, k;  #real part negated
     for k to 31 while abs(Im(z)) < 1 do
          z:= (1+4*z-(1+2*z)*cos(Pi*z))/4
     end do;
     k #escape time
end proc:

#Test evalhf'ability:

evalhf(Collatz(0,1));

32.

plotsetup(
     jpeg, plotoutput= "C:/Users/Carl/desktop/Collatz.jpg",
     plotoptions="height= 1024, width= 1024, quality= 95"
);

 

CodeTools:-Usage(
     plots:-densityplot(
          Collatz,
          -1..1, # imaginary range
          -0.5..4.5, #negative of real range
          colorstyle= HUE, grid= [1024, 1024], style= patchnogrid,
          labels= [Im,-Re], labelfont= [TIMES, BOLD, 14],
          axes= boxed,
          caption= cat("      Happy New Year ",                  

                StringTools:-FormatTime("%Y")),
          captionfont= [HELVETICA, BOLDOBLIQUE, 18]
     )
);

memory used=24.08MiB, alloc change=24.00MiB, cpu time=7.78s, real time=7.79s

 

Download Collatz_fractal.mw

There are still several bugs resulting from the MaplePrimes update last week which you may not be aware of.

  1. The list "All Recent Posts & Questions" is not in the correct order. It is ordered by the time of creation of the Post or Question. It should be ordered by the time of the most recent update to the thread. In other words, the top seven entries in "All Recent Post & Questions" should be the seven entries of "Active Conversations".
  2. Email notifications do not always contain a hyperlink to the relevant post. (I could send you some examples if you need.)
  3. In the list of Answers in a user's profile, the votes for the Answers are not shown for those Answers created after the update.
  4. There are no longer automatically generated titles for Replies for which the author fails to enter a title. This taken alone may be a good idea, but it contributes to bug (2) above. Also, it makes it impossible to send a "Contact Author" email relating to the Reply---when you click send on the email, it will be rejected, even if you tried to add a title.
1 2 3 4 5 Page 3 of 5