idlebox (page 1 of 1 2 3 4 5 6)

The QuadClip AlgorithmFinding Roots of Polynomials by Clipping - Report and Implementation from my Lab Course in Numerical Mathematics

Posted on 2012-03-20 22:29 by Timo at Permlink with Comments. Tags: maths university c++

This semester I had the pleasure to take part in a lab exercise course supervised by Prof. Thomas Linß at the FernUniversity of Hagen. The objective was to comprehend, implement and evaluate a particular recent advancement in the field of numerical mathematics. My topic was finding the roots of a polynomial by clipping in Bézier representation using two new methods, one devised by Michael Bartoň and Bert Jüttler [1], the other extended from the first by Ligang Liu, Lei Zhang, Binbin Lin and Guojin Wang [2].

My implementation of this topic was done for the lab course in C++ and contains many in themselves interesting sub-algorithms, which are combined into the clipping algorithms for finding roots. These sub-algorithms may prove useful for other purposes, which is the main reason for publishing this website. Among these are:

For the lab course I wrote two documents, both in German: one is an abstract Kurzfassung.pdf (1 page), which is translated into English below, and the other a short report Ausarbeitung.pdf (6 pages). The report contains a short description of the algorithms together with execution and convergence speed measurements, which verify the original authors experiments. For presenting the lab work I created these Slides.pdf, which however are not self-explanatory due to my minimum-text presentation style.

The implementation is a single file C++ program, which can optionally output LaTeX code for debugging purposes. The code can easily be compiled on any Linux machine, and probably also using other tool chains. It requires the GNU mpfr library for arbitrary precision floating-point numbers to enable high precision calculations (this library is also available for Visual C++). You can download the clipper.zip (23 KB) and view the corresponding doxygen HTML documentation.

The program can output LaTeX code documenting each individual steps of the computation while it is running, this method yields extremely detailed execution protocols for each input. For demonstration purposes the code contains nine different sets of examples, called demo1 through demo9. Among these demos six, seven and eight are speed test demos, which can be run without debugging overhead to measure the algorithms' run time. Results of these speed tests are documented in the short report above. The detailed execution protocols of the eight demos can downloaded below:

Abstract (Translation of Kurzfassung)

Fast computation of the roots of a polynomial is the basis for many more complex applications. Classical algorithms for this problem are for example bisection and the Newton-Raphson method, where the latter is quadratically convergent on single roots, but only linear convergent on double roots. In 2007, Bartoň und Jüttler [1] presented a new method, which is based on degree reduction and can find all roots of a polynomial within a given search interval. Like other numerical algorithms it is based on nested intervals enclosing the root and the new method exhibits a convergent rate of 3 for single roots and 3/2 for double roots. The method's scheme was continued in 2009 by Liu et al. [2] and their enhanced algorithm features convergent rate 4 for single roots, 2 for double roots and 4/3 for triple roots.

Both methods are based on approximating a polynomial of degree n given in Bernstein-Bézier representation by two polynomials of second or third degree, which bound the original polynomial from above and below. The roots of the polynomials of smaller degree can be found directly using the quadratic or Cardano's formulas and these roots yield smaller intervals which are recursively searched. The algorithms are iterated until a desired precision is reached and by branching into disjoint search interals, all roots of the polynomial can be found.

The convergent rates of the sequence of nested intervals is guaranteed by selecting the best-possible approximating polynomials of second or third degree. These can be calculated efficiently using a method developed by Jüttler, which is based on an explicit formula for the dual basis of the Bernstein polynomials. This method allows direct calculation of quadratic or cubic polynomials with smallest error distance to the target polynomial regarding the L_2 norm. In the end, the degree reduction operation is a simple matrix multiplication.

[1] Bartoň, M. and Jüttler, B. "Computing roots of polynomials by quadratic clipping", Computer Aided Geometric Design 24.3, (2007) p. 125-141. DOI: 10.1016/j.cagd.2007.01.003

[2] Liu, L., Zhang, L., Lin, B., Wang, G. "Fast approach for computing roots of polynomials using cubic clipping", Computer Aided Geometric Design 26.5, (2009), p. 524-599. DOI: 10.1016/j.cagd.2009.02.003


Drawing of PG(2,3)Vervollständigung meiner Seminararbeit in Diskreter Mathematik

Posted on 2011-08-31 20:12 by Timo at Permlink with Comments. Tags: maths university

Heute habe ich meine Seminararbeit in Diskreter Mathematik an der FernUni Hagen vervollständigt. Ich möchte mich bei Prof. Hochstättler bedanken für die erfahrene Leitung und planvolle Einführung in die interessanten Gebiete der Design Theorie und endlicher Geometrien. Die Arbeit ist auf deutsch und unter folgendem Link downloadbar.

Download PDF: Seminararbeit-Singer-Differenzenmengen.pdf (2,8 MB)

Zusammenfassung

Die Entwicklung von Differenzenmengen in der Design Theorie begann 1938 mit einer algebraischen Untersuchung endlicher projektiver Geometrien von James Singer. Nach Einführung der wichtigsten Grundbegriffe der Design Theorie und projektiver Geometrien werden in dieser Ausarbeitung die beiden Resultate von Singer entwickelt. Die Existenz einer Kollineation mit Periode frac{n^{d+1}-1}{n-1} führt zur Definition von Differenzenmengen und beide Ergebnisse liefern elegante Konstruktionsverfahren für PG(d,p^k).


Small drawing of a B+ treeUpdate Release of STX B+ Tree 0.8.6

Posted on 2011-05-18 12:44 by Timo at Permlink with Comments. Tags: c++ stx-btree

After four years I have decided to release an updated version 0.8.6 of the STX B+ Tree C++ Template Classes package. The updated release contains all patches that have accumulated in my inbox over the years. So yes, please send me patches for this project, it is not in vain! Below the highlights on the changes in this release:

I also reran the speed test done back in 2007 on my new hardware and compared the results with the old data. Due to the larger L2 cache sizes in my new Intel Core i7, the B-tree speed-up first starts to show at about 100,000 integer items, rather than 16,000 items with my older Pentium 4. This might also have something to do with the new CPU using 64-bit pointers and thus requiring larger nodes for child references. Read the complete speed test here.

result plot from new speedtest

The updated source code package is available for download from this webpage.


Yet Another Release of digup 0.6.40 - A Digest Updating Tool

Posted on 2011-01-31 20:25 by Timo at Permlink with Comments. Tags: c++

This is yet another release entry of digup. This time, however, it is a major release with lots of new improvements and some old fixes:

For more information and the new version see the digup web page.


Bugfix Release: digup 0.6.30 - A Digest Updating Tool

Posted on 2010-10-03 16:12 by Timo at Permlink with Comments. Tags: c++

Fixed another severe bug in the digup tool: on the amd64 architecture the tool crashed when writing the digest file, thanks goes to Daniel D. for reporting and fixing this bug.

The bug was caused by the variable arguments lists va_list used twice in the fprintfcrc() function. Apparently, on the amd64 platform va_start() and va_end() must be called twice even when passed the list to vsprintf().

For more information and the new version see the digup web page.


Bugfix Release: digup 0.6.27 - A Digest Updating Tool

Posted on 2010-08-20 23:05 by Timo at Permlink with Comments. Tags: c++

Fixed a two bugs in the digup tool: added large file support when compiling the program and fixed a string allocation bug.

This new version enables large file support by using long long variables for size. Furthermore, a string allocation bug was fixed which occured when using -t and -f command line parameters.

For more information and the new version see the digup web page.


Bugfix Release: stx-execpipe 0.7.1 - STX Execution Pipe C++ Library

Posted on 2010-07-30 17:13 by Timo at Permlink with Comments. Tags: c++

Fixed a small bug in the stx-execpipe library: add large file support when compiling the library.

This bug switches on the large file support functions. Without this fix a pipeline reading or writing files >2GB will not function properly. The fix is to #define _FILE_OFFSET_BITS 64 when compiling the library's code.

For more information and the source code see the stx-execpipe web page.


Execution pipe with exec() bubblesPublished stx-execpipe 0.7.0 - STX Execution Pipe C++ Library

Posted on 2010-07-18 23:31 by Timo at Permlink with Comments. Tags: c++

The STX C++ library series has been extended today with a new installation: the STX Execution Pipe library, in short STX ExecPipe. It is the solution to an issue that I encountered in writing a small backup application. This backup tool collects some file to backup and then calls tar and xz followed by ncftpput.

However, I could not find any useful C++ library that allows convenient chaining of external programs like used in everyday shell piping. This pipe line functionality is based on the system calls fork(), exec() and pipe(), which are not easy to use correctly. After writing some ad-hoc functions to call one or two external programs, I decided to tackle this basic problem once and for all. The result is the stx-execpipe library.

Using the library a C++ program can build a sequence of external programs with command line parameters. These programs are connected by the library just like a shell pipe: stdout of the preceding stage goes into stdin of the next one. The input and output of the whole pipeline can be redirected to a plain fd, a file or saved in a std::string.

One very interesting feature of the library is to insert intermediate processing functions into a pipe line. The data can be intercepted and passed back to the parent process for manipulation or just inspection. This was necessary to calculate the SHA1 digest of a backup tarball simultaneously to uploading it.

For more information and the source code see the stx-execpipe web page.

The following small code snippet exemplifies the flexibility of the stx-execpipe solution:

stx::ExecPipe ep;

// first stage calls tar
std::vector<std::string> tarargs;
tarargs.push_back("tar");
tarargs.push_back("--create");
tarargs.push_back("--verbose");
tarargs.push_back("--no-recursion");
tarargs.push_back("/path/to/some/files");
tarargs.push_back("/path/to/more/files");
ep.add_execp(&tarargs);

// second stage compresses the tarball
ep.add_execp("xz", "-9");

// third stage intercepts data for a SHA1 digest
Sha1Function sha1tar;
ep.add_function(&sha1tar);

// fourth stage sends the tarball via FTP
std::vector<std::string> ftpargs;
ftpargs.push_back("ncftpput");
ftpargs.push_back("-c");
ftpargs.push_back("ftp.upload-to-host.net");
ftpargs.push_back("/path/to/ftpfile.tar.gz");
ep.add_execp(&ftpargs);

if (ep.run().all_return_codes_zero()) {
    std::cout << "Backup upload complete." << std::endl
}
else {
    // error processing...
}

Drawing of cbtreedb tree index structurePublished stx-cbtreedb 0.7.0 - STX Constant B-Tree Database Template Classes

Posted on 2010-04-14 13:34 by Timo at Permlink with Comments. Tags: c++

Published yet another C++ template library using a B-tree. This time the solution is a disk-based read-only key-value mapping using a "packed, sequential" B-tree as index structure.

All applications mapping a large number of constant, integral keys to string or data blobs can benefit from this library. The database structure is highly compact and contains self-verification checksums over both key and value areas.

stx-cbtreedb is a direct contender with cdb and tinycdb, which however are based on hash tables and do not retain key proximity. Compared to other full-fledged B-tree implementations like BerkeleyDB or TokyoCabinet, the stx-cbtreedb is very small, faster and the database files have much less overhead due to read-only optimizations.

For more information and the source code see the stx-cbtreedb web page.


Drawing from Double Take short storyNew LibriVox Recording: "Double Take" by Richard Wilson

Posted on 2010-02-01 17:53 by Timo at Permlink with Comments. Tags: librivox

My second LibriVox recording is finished! The basic idea behind LibriVox is to read public domain texts and to put the recordings back into the public domain. More about that on librivox.org.

As with the last recording, my personal motivation is to practice my rusty English pronunciation. By reading and rereading the texts I believe my English will become more fluent and in the end also achieve better articulation.

The second recording is "Double Take" by Richard Wilson, a science fiction short story available from Project Gutenberg. I have also made a quick LaTeX typesetted version of the Gutenberg etext for more comfortable reading and with slight corrections: doubletake_wilson_text.pdf (369 KB).

Story Summary / Teaser

Pacing through a high-speed spy adventure, young Paul Asher finds himself going around in circles -- very peculiar circles indeed!

Audio Recording - Runtime: 26:29

MP3 encoded with standard lame VBR preset (obviously better/smaller than CBR 128 kbps)

doubletake_wilson_tb_vbr.mp3 (19.1 MB)

The recording is now also available on archive.org in the LibriVox Short Science Fiction Collection 033.


Show Page: 1 2 3 4 5 6 Next >
RSS 2.0 Weblog Feed Atom 1.0 Weblog Feed Valid XHTML 1.1 Valid CSS (2.1)