Xah Programing Blog

On programing, languages, functional programing, Unicode, keyboard, hacker culture, ….

adaptive sampling, in plotting math curve

math plot adaptive sampling 2016-05-01
math plot adaptive sampling

been working on this in past week.

given a function, you want to plot it. The more points you use, the smoother the plot. But, points are wasted if the curve is fairly straight. So, you want adaptive sampling. You want to add points only when the bend is sharp.

If you use Mathematica, adaptive sampling is builtin in its Plot function. Likely, the algorithm is used in any quality 2D plot software.

But, for plotting complex plane, or 3D curves, it may not have adaptive sampling.

I had to implement it (in 2006) when doing a complex function plotter. see Stereographic Projection and Geometric Transformation on the Plane

note that, when you project a curve from a plane onto a sphere, if you don't have adaptive sampling, your sphere is going to look like a polygon ball, or not looking like a sphere at all. Because, on the plane, two neighboring points may be very close, but when mapped to the sphere, they may become wide apart. For example, you take a rope and wrap it on a big ball. The 2 endpoints doesn't show anything about the curve of the rope.

on the question of too many programing libraries

in the past 5 years, there seems to be a exponential growth of programing language libraries.

this can especially be seen in JavaScript land.

this is different from say 1990s, where, there is usually widely accepted “the best” lib for X.

today, there are so many, that usually a programer never heard of.

so, the question to me is, what to do about it?

i'm the type that tend to know it all, alway keeping a eye on all things. But that has been impossible now, or even, impractical and meaningless.

i want to think about this, as to have some kinda conclusion or closure on the situation.

if i do nothing, then, libs will just grow without my awareness. This been the case for many years already. It can be likened to not knowning all latest movies, or all latest comic books published, or Japan comics books published in Japan, or say TV shows published in China, or not keeping up with gaming community, new games, etc. There are, thousands, millions, of them, things, you don't know. When you were a teen, you might know all the best new video games, or hot movies, or comics books, but not now, because you haven't been following it, no longer interested, or no time.

so, what's the deal with programing language libraries? well, today, not just lib grows exponentially, but also languages, and now programing paradigms.

〔➤see Proliferation of Computing Languages

for example, few years ago, node.js popularized event based programing. Now, reactive programing seems to be hot. There are language and libraries doing it. And, the idea of Persistent Data Structure seems also getting popular. First popularized by clojure, now Facebook immutable lib for JavaScript.

in the end, i don't think there's much one can do, or should do. Do you know all the movies published in India? In programing, even in the 1990s, not everyone knows about all fields of programing, such as operating systems, database, game programing, networking, scientific programing, etc.

but if you are a philosopher, a observer, then, you might still try to follow, keep in the know and analyze trends and have opinions about where are we going. In some sense, the task now is harder, and more exciting, than compared to 1990s.

actually, the phenomenon of exponential growth, is happening not just in programing libs, but every day things too. Everyday things, trends, inventions, practices, behaviors, i think they are all growing. (for example, think of cell phone, payment methods, dating practice) In this regard, am thinking, humanity has entered a era, sometimes depicted in dystopia scifi, where you have massive diverse groups and things each one odd to another.

i think, the speed and number of new things springing up, is faster than the speed they can be digested or merged with some universal status quo. So, you end up with lots regional phenomenon.

ok. So far so good. But, how does this compare to the era before? say, before the internet, or before industrialization?

before the internet, communication tech isn't as strong, so, first of all, new things may be happening around the world, just that you don't know about them. (the internet made us known things we never know before, such as sexual practices, and all sorts of others things, e.g. we can see and discuss on reddit now.) before the internet, even old things we don't know, such as different cultures. For example, to know what Chinese do, you have to be a academic, or go to library to dig book and look at a handful of pictures, or have lived in china. But now, you can know what chinese do daily, or watch their daily lives if you want to. (for example, twitter, facebook.)

ok, but do new things happen as much in say 1990s as now? I think in general no. Today, the tech is vibrant that new things happen far more often.

now thinking about before industrialization, i think the above is confirmed. Without technology, things don't change much.


Unicode: Math Symbols ∑ ∞ ∫ π ∈ ℝ²

starting a dedicated keyboard blog. See

Xah keyboard Blog

Subscribe there. I'll not duplicate keyboard stuff here. Thanks.

a dedicated keyboard blog allows me to freely post any keyboard related stuff quickly without dithering.

had a clarity, about designing my JavaScript svg library.

JavaScript Language Design: Dot Notation be Namespace or Object System

sigil for my φvariable ξnames

fret about whether i should continue using funky sigil for my variable names. As in:

xd.drawCircle = function (φcontainer, φcenter, φr, φstyle) {
    var ξcir = document.createElementNS("http://www.w3.org/2000/svg", "circle");
    ξcir.setAttribute("cx", φcenter[0]);
    ξcir.setAttribute("cy", φcenter[1]);
    ξcir.setAttribute("r", φr);

    if (φstyle !== undefined) { ( ξcir.setAttribute("style", φstyle)); };

    if ( φcontainer === undefined ) {
        return ξcir;
    } else {
        return φcontainer.appendChild (ξcir);

the problem, is people. Other people.

you see, it's like the many english spelling reform. It is sound and good, except, the masses, idiots, will not have it, and is doom'd to failure.

the reason i want to do it is here: Sigil for Function Parameter Names and Programing Style: Variable Naming: English Words Considered Harmful.

but i thought about it more due to the my dilemma of continuing the practice, in JavaScript or any lang other than emacs lisp. I took a walk, talking to myself, for 30 min. Here's some more insights.

the essential good of it, is that it embeds semantic info into syntax. That is, you can tell if a variable is a function parameter, or local variable, or not global, just by its name.

This is in general called sigil. (most popularized by perl, followed by ruby.)

there are other examples of widely accepted practice of embedding semantic info in syntax. For example, in Java and python, class names starts with capital letters. This is a strong convention, everyone follows. It is important, because, classes, variable, methods, have very different semantics. Being able to tell by a glance saves you time or error.

also read, if you are inclined:

but i think am going to stop this geek char sigil practice. My emacs lisp code base are full of it, it's hopeless. For lisp, i probably should push on my way, as lisp is weird already and lisp people are weird. But for my JavaScript code, which there isn't much, am thinking of stopping this φsigil ξthing, while the night is young!

the problem, is that whenever it is exposed and seen by other people, it's a problem. You'll need to do explanations, and you'll win yourself a weirdo badge. And, other consequences. For example, the jslint won't accept names that start with Unicode char.

unless, i keep my code to myself only. Imagine, i, am the greatest coder, couldn't care less what other coder do or say. I just churning out my own code that rules the world. Well, it hasn't happened yet.

Google Plus https://plus.google.com/+XahLee/posts/Ei5eKe8T49i

Ontology of Postfix Notation, Method Chaining, and Unix Pipe

24 hours clock, 00 start at top or bottom?

Uno 24 hours watch
Uno 24 - One Hand Men's Watch by Botta-Design. amazon

24 hours watches are superior, because, the needle points as a fraction of day. And, you can tell just by a glance, how much daylight is left, or how much a day is left.

roughly, half of the circle is daylight.

in designing a 24 hours clock, there's the question of whether the 0 clock should start at top or bottom.

the advantage of starting at top is that, it's just normal for 0 to start at top, as in our typical clock.

the advantage of starting it bottom is that, now, the daylight will roughly correspond to the upper half of the circle. This is somewhat natural because we associate light as above us.

if you look at existing 24-hour watches, see amazon at 24 hours watches, most has 00 at bottom. But for 24-hour clocks, most has 00 at top.

i'm making a JavaScript version, see JavaScript: 24 Hour Clock

new language, Kotlin, from JetBrains. Runs on Java Virtual Machine. Similar to Java, but designed to improve java.

Proliferation of Computing Languages

The Complexity of Java's Access Specifiers (oldbie, new home)

Clojure's Ring, Compojure, hiccup, perfect doc!

Clojure's Ring, Compojure, hiccup's docs are SUPERB! all by the same guy. Clear, concrete, + example! a rarity in industry.

by the way, the code are written by the same guy too. The guy is James Reeves, aka @weavejester. github at https://github.com/weavejester

see also Clojure: Essential Libs for Web App

HTTP Protocol Tutorial (new)

Python: GET Webpage Content

Perl: GET Web Page Content (on its own page)

Clojure: Essential Libs for Web App

Mac, press 【Fn+】 for page down. It actually sends the same signal as ⇟ Page ▽ key.


nice doc = auto code

i imagine one day lang are so well doc'd that coding is simply read the doc and type functions you need together, once! and done.

Functional Notation vs Operator, Ultimate Superiority

suddenly, am thinking of the ultimate answer to the question of superiority of functional notation vs operator notation once for all

this is because, when i read, John Baez's post here

Zamolodchikov Tetrahedron Equation By John Baez. @ http://blogs.ams.org/visualinsight/2016/03/15/zamolodchikov-tetrahedron-equation/〕 (also here, more chatty at: https://plus.google.com/117663015413546257905/posts/QCrdfbbMYhZ )

the article title is daunting, and it immediately talks about 4D space and monoidal category and morphism.

but, actually just ignore those jargons. look at the image of braids. It says:

In other words, we can slide a crossing of two strands under a third strand. In topology this is called the third Reidemeister move, one of three basic ways of changing a picture of a knot without changing the topology of the knot.

now that's the beauty of math. Because, all those equations and symbols, are used only, and necessarily, to capture this simple concepts in a precise and efficient way. In the case here, is braids and movements.

but i digress.

what i personally got a omg moment at this point, is that, notice how he said in the Google Plus post:

My blog article explains it, with pictures. But in simple terms, the idea is this. When you think of the commutative law

xy = yx

as a process rather than an equation,

There! “consider communicative law as a process!

Now, that got me thinking. Because, i have thought about this myself. See:

the Nature of Associative Property of Algebra

in which, i realized the nature of associative law, and in general, the kinda nature of context these laws arise. So, i was thinking now, if thinking of it as a process would give me some more enlightenment.

but immediately, the associative law (a⊕b)⊕c == a⊕(b⊕c) don't have a analogous way as a process to turn it into a braid. You just get 3 staight lines.

i need to think about this some other time. Now I need to do something else.

wait, but back to the title. Why is it some ultimate solution of functional notation vs operator?

you need to read this first: What's Function, What's Operator?

because, notation, and syntax, is my obsession. And, basically, i am suddently prompted at this point to think about whether perhaps there's a way so that one of the notation can be eliminated without picking up disadvantages.

my immediate thought is that, perhaps functional notation can be dropped. Certainly not the other way around, because pure functional notation is too cumbersome (lisp is good example. you can't write math, in lisp). So, perhaps, somehow, operator notation is supreme… well but one immediate problem is that in general operators can only be for binary function. That is, 2 args, on the left and right sides. But, actually we could have match-fix notation. (see match-fix explained here Concepts & Confusions of {Prefix, Infix, Postfix, Fully Nested} Notations) But the issue with match fix is that, then we have to have a way to still use function names. That is, we can't device thousands type of brackets. So, in order to still have names, then have XML or lisp-like things… but oh, we back. Ok. Stopping here now.

List of Keylogging Software

Python: Class and Object (updated. made it passable. Never worked with python object. New, learned about python supporting multi-inheritance, and the diamond problem.)

TCP/IP Tutorial for Beginner (updated)

“set value to variable” vs “set variable to value”

which is correct? “set value to variable” vs “set variable to value”

as native speaker, you'd say the first.

Assign a value to a variable is correct. Alternatively, you could say assign a variable a value.

Compare assign and give:

Give a value to a variable vs. give a variable a value

〔from http://english.stackexchange.com/questions/51343/assign-a-variable-to-a-value-or-the-other-way-round

But, there's problem.

when we have x = 4, it's natural that we say give x a value. Or simply, set x to 4, corresponding naturally to x = 4.

The Sad Story of OAuth 2.0 and Open Standards, IETF

Sessions, and Token Based Auth

been a long time i've worked on web app. That's a review about sessions.

exposition on the ridiculousness of Sun Microsystem's official tutorial on java interface, now moved to here: Official Java Tutorial on Interface, the Inanity

What's Interface in Java? new. Now, simple tutorial.

Clojure's Popularity, A Tango with Java

Java Tutorial: Collection, Map. This is especially for Clojure coders who don't know Java. Because clojure doc constantly mention Java stuff.

Iterator, Enumerator, Abstraction Went Wrong

Why Clojure is Dense

clojure Rich Hickey a stateful transducer 2014-09-17
A Stateful Transducer. 〔image source https://github.com/matthiasn/talk-transcripts/blob/master/Hickey_Rich/Transducers/00.36.36.jpg

Why Clojure is Dense

Artificial Neural Network is Nasty

Marbel Machine, Mechanical Music Box. any programer must see this.

Clojure Leiningen Tutorial (major rewrite)

Clojure: Function Chaining (major rewrite)

Clojure: Destructure Binding (major rewrite)

clojure's binding form is powerful, but with lots of sugar syntax.

clojure the language is fond of sugar syntaxes. It's like, a situation when one is enamored with icons in user interface. Gradually, you have more and more beautiful icons instead of text/menu, and it's all patently obvious to you what they mean. But to outsiders, it's completely incomprehensible. See for example Clojure: Magic Characters ' \ @ ^ # ` ~ .

in Wolfram Language, Mathematica, there's also lots of syntax, but you can press a button in editor to see the StandardForm. Not so in Clojure. Some of them are special form, some are macro, some of them reader macro, same are just by design (namespace, java access syntax, etc).

See also Formal Definition of Systematic Grammar, and On Constructed Languages, Computer Languages, and Their Grammar Complexity

How Java Package Works. Java: Package Tutorial (major rewrite)

OCAML's Official Tutorial Blatantly Suck

Homotopy Type Theory

Linux: Move File to Trash by Command

Formal Definition of Systematic Grammar

1 xah's edu corner extempore. on what's computation of types?

2 the computation of types, and what's the nature of numerical computation? string computation? symbolic computation?

3 in haskell, ocaml, they have type inference. And it seems, computation of types can become a thing of itself.

4 as primary goal, as in some math proof system.

5 now, what's “computation of types”? what's its nature?

6 of language i know of, perl python ruby JavaScript elisp clojure java golang, only last 2 has types.

7 golang has type inference, but i think nothing close to haskell/ocaml in proof world.

8 so, what exactly is computation of types? if it exist? what's its nature?

9 to understand that, we look at something we know. For example, there's numerical computation, string computation, symbolic computation.

10 numerical computation is like 2+5, or find earth position, matrix, statistics, calculus, civil engineering, physics simulation, …

11 strings computation, or text processing, we also familiar. Any grep, regex, find/replace, report, extraction. We do everyday.

11.5 search engines, in large part, is string computation, text processing.

12 symbolic computation, typically derivative, integration, symbolic solution to equations. e.g. Wolfram Language Mathematica.

13 ok, we intuitively/practically understand numerical, string, symbolic computation. But, how can we explain them in terms of computation?

14 let's look at algorithms. there's algorithm for sort, for implement regex, for solving equation, traveling salesman problem.

14.5 what is THEIR difference? how to characterize their difference?

15 seems, they are simply different “problems”, or “problem domains”.

16 now, what does “problem” mean here? how can we explain it in terms of “computation”?

17 looks like we now need to look into the meaning of “computation”.

18 computation, most of the time have a goal. Human activated computation. e.g. we compute to solve a problem, or a do something, a goal.

19 as opposed to, nature's computation. As in, which rain drop on window will fall first.

19.5 Or, any thing in universe is computation of physical forces or perhaps some quantum. The churning of the universe.

20 so, human activated computation, come with a goal, or problem, to begin with.

21 now, problems comes in many forms, kinds. Math questions, academic questions, but also tasks, counting, processing, sorting.

22 so,if computation is using some machinary to automate some process… but still,how does this explain string/numerical/symbolic computation?

23 seems the question of string/numerical/symbolic computation is similar to asking what's diff of different algorithms, or problems.

24 e.g. what's the diff between, say, problems of algebraic geometry, vs diff equations, vs linear programing? or combinatorics problem?

25 so far, i don't have good answer. So, on the question of nature of the computation of types… i have no answer.

26 maybe you have an answer. suggest away.

for now, enjoy the most beautiful melody in history. Schubert Impromptu in G Flat 📺 http://xahmusic.org/piano/schubert_impromptu_G_flat.html

Unicode: Hand Gesture 👍 👎 👌 👊 ✌ 🖕 ✋ ☛

Unicode 7 New Chars

Wolfram Language Slow?

On Constructed Languages, Computer Languages, and Their Grammar Complexity

Why Does Struct Datatype Encroach Namespace?

Download Free Unicode Fonts

The Jargon Automata in Finite State Automata

Python Tutorial now has navigation panel on the side.

Unicode Search ☯ ☭ ⚡ → ∑ ♀ ♂ ♥ 😄. now there's nav panel on the left side for each page.

Unicode Character in Variable/Function Names

minor update.

Lisp notation isn't “prefix”

math notation prefix infix postfix matchfix
math notation: prefix infix postfix matchfix

Concepts & Confusions of {Prefix, Infix, Postfix, Fully Nested} Notations

naming, terminalogy, are critical, because misnomer creates perpetual misunderstanding. Jargons of Software Industry

Formal logic's Chinese roots. Chinese, The Logicians or School of Names (名家)

Linux: LXDE/OpenBox, Disable Mouse Scroll Wheel Shade Window

City Hunter keyboard

a very strange keyboard, but seems real.

City Hunter keyboard 00008
keyboard from 〈City Hunter 3〉 episode 9.

more screenshots, see City Hunter Keyboard

the term “ambiguous grammar” is a misnomer. Grammar of comp lang are never ambiguous. It should be called multi-parse-tree grammar

Linux: Disable Ubuntu New/Overlay Scrollbar

Regular Grammar, Lexical Grammar, Systematic Syntax, Uniform Syntax

for a decade, i wanted a term to describe certain syntax that's regular, such as a idealized lisp, XML, or Wolfram Language syntax.

I've used “regular grammar” & “lexical grammar”, but that's wrong. Perhaps systematic syntax or uniform syntax.

the Common Lispers, at times claim lisp syntax is simple by the idiotic phrase “no syntax”, at other times says lisp syntax can't described by grammar because of lisp reader. LOL

Jargons of Software Industry (updated.)

What is Closure in a Programing Language? (updated)

Python Doc Links All Dead

unix “grep” name, came from qed/ed editor command g/re/p meaning “Global search for Regular Expression and Print matching lines”

Linux: How to Set Mouse Speed

Linux: How to Swap Mouse Buttons (updated)


Steam controller gamepad angled view
Steam Controller. amazon

Valve Steam Controller. New device, novel design.

Why is Array Access Constant Time

What's Ontology of Programing Language?

CM Storm QuickFire Rapid-i keyboard. New from Cooler Master. Features a lighting effect with 32-bit ARM processor for effects

Past Articles by Date