Friday, September 10, 2021

How You Should View Images with the Public Library's Read-In-Browser App

I'm thinking it is powered by Overdrive (why they're getting worse with each year is beyond me).

Here's what you do :

  1. Get your mouse over the image (no clicking yet) and wait for the "Zoom image" tooltip to show.
  2. Now, click and HOLD, don't just click and release as that'll navigate!
  3. Once it's gone into image view mode, you can use your scroll wheel to get more detail by zooming in.

Like?

The app seems to be so buggy that this doesn't always work :(

Thursday, September 09, 2021

BellingCat : Holding the World Accountable

Data mining exposes spikes in communication among perpetrators in Russia's military establishment ahead of key events, like the Navalny poisoning. These are the detectives making sure the world knows about Russia's crimes against humanity.

https://www.economist.com/podcasts/2021/08/10/how-open-source-intelligence-is-disrupting-statecraft

https://www.bellingcat.com/

Watch the lovely Alice Himsworth (Senior Legal Counsel @ Google) chat the founder Elliot Higgins : https://www.youtube.com/watch?v=rqsfOz9fdmQ

Buy the book (don't worry, I get nothing :) : https://www.amazon.com/We-Are-Bellingcat-Global-Sleuths/dp/1635577306


Monday, August 09, 2021

Is there Such a Thing as WSL Terminal?

I love the thing, but, wanting it today for a new PC, couldn't find it.

What I did find, M$ has made the WSL installation much simpler - just a simple command in powershell.

So, where do you find "WSL terminal" which beats the crappy thing they call "bash" :

https://github.com/mintty/wsltty

It's wsltty, or mintty.

Enjoy.

Thursday, July 08, 2021

Great Accomplishments of Mathematica You Might Not Know About

Mathematica is often thought of as a sophisticated calculator, graphing program, or teaching tool. But in mathematics and theoretical physics it has also served as something closer to a laboratory: a place where researchers can experiment numerically, manipulate exact symbolic expressions, visualize complicated systems, spot unexpected patterns, formulate conjectures, and sometimes discover results that would have been extremely difficult to find by hand.

It is worth making one distinction. Not every example below was discovered exclusively with Mathematica. Some involved Maple, PARI/GP, custom programs, or specialized software. But all illustrate the style of experimental mathematics that Mathematica helped make practical:

compute → recognize a pattern → conjecture → prove.

1. Discovering remarkable formulas for π

One of the most famous examples of experimental mathematics is the 1995 Bailey–Borwein–Plouffe formula:

π = Σk=0∞ 16−k [4/(8k+1) − 2/(8k+4) − 1/(8k+5) − 1/(8k+6)].

Its extraordinary consequence is that one can calculate a hexadecimal digit of π far out in its expansion without first calculating all the preceding digits. High-precision computation and integer-relation algorithms such as PSLQ were crucial to discovering formulas of this kind.

This illustrates a striking modern technique: calculate a constant to hundreds of digits, ask the computer whether those digits conceal a simple relation involving known constants, and then attempt to prove the resulting conjecture.

2. A mysterious harmonic-number identity

As an undergraduate, Enrico Au-Yeung numerically investigated the series

Σn=1∞ Hn2/n2

and conjectured that it equaled

17π4/360.

Jonathan Borwein initially suspected that the agreement was accidental. Using high-precision numerical integration with systems including Mathematica and Maple, the identity was checked to many more digits. It was correct and helped stimulate further work on what are now called Euler sums.

This is an especially clean example of a computer turning a weak numerical hint into a sufficiently convincing conjecture to justify looking for a proof.

3. New identities involving the Riemann zeta function

Researchers have used hundreds of digits of numerical precision together with integer-relation algorithms to discover unexpected formulas involving values such as ζ(3), ζ(5), and related sums.

Some discoveries generalized the remarkable series that appear in Apéry's proof that ζ(3) is irrational. Instead of starting with an elegant identity and checking it on a computer, researchers sometimes began with a mysterious decimal number and let computation suggest the exact expression hiding behind it.

4. Unexpected links between particle physics and knots

Very complicated Feynman-diagram calculations in quantum field theory produced numerical constants whose structure was initially obscure. High-precision computation and integer-relation searches helped reveal connections among Feynman diagrams, multiple zeta values, and knot theory.

That is a remarkable conceptual jump: an integral describing particle interactions can contain mathematical structure associated with knots.

5. Exact formulas hidden inside statistical-physics integrals

Researchers including David Bailey, Jonathan and Peter Borwein, and Richard Crandall evaluated complicated integrals from statistical physics to hundreds of digits.

Numbers that looked like arbitrary decimals turned out to have exact forms involving familiar mathematical objects such as zeta values and Dirichlet L-functions. Computation also exposed unexpected recurrence relations, some of which were later proved.

6. Mathematica in black-hole and gravitational-wave physics

Mathematica has become an important tool in general relativity. Packages such as xAct and components of the Black Hole Perturbation Toolkit manipulate curvature tensors, metric perturbations, Kerr and Schwarzschild geometries, self-force calculations, and gravitational-wave equations.

Some modern calculations first determine quantities around black holes numerically to extremely high precision. Integer-relation methods can then reconstruct exact analytic coefficients involving constants such as π, logarithms, and zeta values.

In these problems the symbolic expressions can become so large that computer algebra is no longer merely convenient. It becomes an essential part of doing the physics.

7. Feynman-diagram calculations that would be impractical by hand

The Mathematica package FeynCalc has long been used for symbolic quantum-field-theory calculations. It can manipulate Dirac matrices, Lorentz tensors, loop integrals, color algebra, and enormous expressions generated by Feynman diagrams.

A researcher can preserve exact symbolic structure while performing thousands or millions of algebraic manipulations that would be extraordinarily error-prone by hand.

8. Modeling gravitational-wave detectors

Mathematica has also been used in the engineering behind gravitational-wave observatories. Symbolic models of the complicated multi-stage pendulum suspensions used in LIGO were developed with Mathematica and converted into forms suitable for further control-system simulation.

This is an important reminder that Mathematica's contribution is not limited to pure mathematics. Its combination of symbolic equations, numerical simulation, and programmable notebooks makes it useful for real physical systems as well.

9. Rule 30: complexity arising from an almost trivial rule

Stephen Wolfram's experiments with cellular automata revealed that extraordinarily simple rules can produce behavior that looks effectively random.

Rule 30 is one of the most striking examples. Starting from a single black cell and repeatedly applying a tiny local rule produces an intricate, partly random-looking structure.

This discovery predates Mathematica itself, but the desire to explore large spaces of simple computational systems helped motivate Wolfram to build the software that eventually became Mathematica.

10. Rule 110: a tiny rule capable of universal computation

Another elementary cellular automaton, Rule 110, produces persistent structures that collide and interact in complicated ways.

Wolfram conjectured that it could support universal computation, and Matthew Cook later proved that it could. Thus one of only 256 elementary binary nearest-neighbor cellular automata is powerful enough, with suitable initial conditions, to emulate arbitrary computation.

It is difficult to imagine anyone guessing such a property merely by staring at the rule table. Large-scale computational experimentation made the hidden complexity visible.

11. The Borwein integrals: when a computer pattern suddenly fails

Experimental mathematics can also expose the danger of trusting patterns too readily.

A famous sequence of sinc-function integrals produces exactly π/2 again and again as more factors are added. The natural conjecture is that the pattern continues forever.

Then, after several cases, the next integral differs from π/2 by an extraordinarily tiny amount—only around 10−11.

With ordinary numerical precision the answer may still appear to be exactly π/2. Only careful high-precision computation reveals that the beautiful pattern has finally broken.

What Mathematica really changed

The most important contribution of Mathematica is therefore not simply that it can evaluate a difficult integral or solve an equation faster than a human.

It allows mathematical work to proceed in a continuous cycle:

formulate symbolically → calculate exactly → experiment numerically → visualize → notice a pattern → conjecture → verify → prove

In traditional mathematics, computation often came after the creative insight. In experimental mathematics, computation can participate in producing the insight itself.

That may ultimately be one of Mathematica's most important accomplishments: helping turn the computer from a machine that merely carries out mathematics into a tool with which mathematicians and physicists can discover mathematics.

Thursday, February 25, 2021

Never Again : Use Windows to Copy a Large File

Does it happen only to me? You do the good old drag and drop thing and you get a dialog telling you the percent completion. Problem is, with a large file, when it hangs, even if things are going on okay without you knowing it, you're mostly hosed. You kill the copy and then go to that directory and see most of the file has been copied, but you'd never guess. A waste of effort anyway.

What's better? Some form of linux - like the WSL - but, even Git bash might be your friend here. Why? Because because GiT and Windows are best friends ever since you know what. So, you can right click on the source folder in File Explorer, and say "Git bash here" and open up a terminal in that folder - not having to guess what to use to get there in unix - seriously, how would you know it needs to be //tsclient/C/Users/whatever?

When? You downloaded a large file onto one PC but now you want it on another one and don't have a USB stick large enough to get the entire season of House there.. So, you use Remote Desktop Connection into the destination PC, and, in that PC, you now find your folder and say Git bash here and then copy to /c/Users/<name>/wherever... and that's much more reliable - so much smoother when you stay command-line.

Monday, January 04, 2021

How Should You Judge Code Quality

Dimension Weight Description
Functionality High Does it correctly store data as JSON? Handles the core requirement?
Error Handling High Gracefully handles invalid JSON, file errors, type mismatches
Code Quality Medium Clean, readable, follows Python conventions (PEP 8)
Flexibility Medium Adaptable to different use cases, configurable parameters
Performance Medium Efficient memory usage, appropriate for the task scope
Documentation Medium Clear docstrings, helpful comments, self-documenting code
Security Medium Safe file operations, input validation, no obvious vulnerabilities
Maintainability Medium Easy to modify, extend, or debug
Line Efficiency Low Makes good use of the line(s) constraint
Best Practices Low Follows Python idioms, proper imports, context managers

Thursday, October 29, 2020

Add Line Numbers to a Text File

 You want

line 1

line 2

line 3

..

to become

1. line 1

2. line 2

3. line 3

...

My way : pipe through perl -p -e 's/^/$.. /;'

nl -ba and cat -n both give a large number of spaces before the line number. Don't know how to prevent that..

Tuesday, October 20, 2020

The Best Book Review in the World

https://www.amazon.com/Programming-Kotlin-Expressive-Performant-Applications/dp/1680506358

Reviewed in the United States on October 6, 2020
Pros: The broad organization of the book, in terms of order of chapters, headings and subheadings, is good. The summary at the end of each chapter is concise.
Cons:
1. The body text tends to be repetitious, The code examples are trivial and silly, and sometimes exemplars of lousy code. A poster child for the latter is the functional-programming recipe for testing whether a number is primreame. The author's code tries to divide the number by every number from two up to the number itself. In reality, for a non-trivially large number, you only need to divide by numbers up to the approximate rounded-up square root of the number to be tested - a recipe that Eratosthenes figured out 2 millennia ago.

Another instance of a bad example: he defines his own Complex class using Pairs - of *integers* for the real and imaginary parts. (They should be decimal or floating point numbers.)

2. The author has an unhealthy obsession about the supposed evils of read-write variables (declared with var). Traditional languages have them for a good reason: you can't keep cloning large collections (arrays, lists, maps, etc.) each time you decide to modify a collection by adding or removing an element. Kotlin itself has a family of classes prefixed with the name Mutable (e.g., MutableList) which, it turns out, can be declared with val - they permit modifications to the contents while not allowing replacement of the entire collection with another. (The fact that you get some safety by declaring mutable collections with val is not mentioned in the book: you have to go to the online Kotlin documentation.)

3. Some chapters are superficial placeholders that will take you from beginner to -- beginner. For example, chapter 20 on Kotlin programming on the android platform is a joke.

4. The book gives every impression of being a rush job, with more thought being given to the jokes in the text (which are sometimes decent, but often labored) than to the examples and detailed exploration of this excellent language, to which this book does a disservice.

5. The author repeatedly emphasizes conciseness (you don't have to type semicolons and sprain your right pinky - wow!), but mere conciseness without clarity (which is important for long-term code maintainability) is worthless. The old days where show-off C programmers tried to squeeze in as much semantics into a single statement, combining multiple assignments separated by commas, and increment/decrement operators are over - opaque code gets programmers fired today Kotlin allows a reasonable degree of conciseness, but I expect that, at some point, when enough experience with the language has accumulated, a style guide will be written that identifies the optimum balance between conciseness and clarity.

In summary, the author does a quick survey of Kotlin, but I have to wonder if he's ever written serious, production-quality code for a living.

Friday, October 02, 2020

Get the Length of Each Line : Something unix wc Can't Do

Replace each line with the character count :

perl -p -e 's/^(.+)$/sprintf("%d",length($1))/e;'

Prefix each line with character count :

perl -p -e 's/^(.+)$/sprintf("%d:$1",length($1))/e;'