Tips for golfing in APL

Question: I started one code golf challenge recently and it seems like the winner is GolfScript (surprise, surprise!). What's interesting is that there was another very strong competitor that had all chances to win over GolfScript. Its name is APL. I see a lot of answers written in APL here. It seems like this language is fairly efficient for code golfing, so I decide to ask for any code golfing tips you know for APL programs. Feel free to post some code examples. It is usually very interesting to see language in action.
Answer: Edit: for people reading this who don't  know APL at all but want  to take it up, Mastering Dyalog APL is a very good resource.

Evaluation is strictly right-to-left. This includes setting variables, so take advantage of it.
2+a, 1+a←1  -> 3 4
a is set to 1, 1+a evaluates to 2, a,2 evaluates to 1 2 and 2+1 2 evaluates to 3 4.

Like C, ← can be combined with a function, i.e. a +← 3. Unlike C, this is generic: foo F← bar sets foo to F bar. Somewhat unintuitively, as an expression this returns bar, not F bar.
It works with anonymous functions too:
       a←0
       a+←3 ⋄ a
 3
       a+←3 ⋄ a
 6
       a { ⍵/'!' } ←4 ⋄ a
 !!!!

You can assign to an array: A[3]←8, like you'd expect. But you can also assign multiple items at the same time: A[3 5 6]←9 1 4, or even A[3 5 6]←9, setting them all to the same item. You can, of course, add a function to the ← here too. The  function will then be applied to each element separately, as if you did F¨.

⍨ is your friend, even if he doesn't look too happy about it.

If F is dyadic, dyadic ⍨ switches the arguments: a F b <-> b F⍨ a. This comes in handy when golfing because it can save you from using braces:
(F G H x) K y      <->     y K⍨ F G H x

This does change the evaluation order, as the right hand is always evaluated before the left hand.

If F is dyadic, monadic ⍨ applies the same argument to both sides of the function:
      5⍴5
5 5 5 5 5
      ⍴⍨5
5 5 5 5 5

The argument is only evaluated once. This particularly comes in handy with outer products, i.e. to compare each value in an array with the other values in the same array, you can use ∘.=⍨ instead of having to do x∘.=x←(whatever).

If F is monadic, ⍨ does nothing, but it does separate the function from the argument. So it can still save you braces if the function is complex:
      {⍵+3}⍣5 6
      ∇{⍵+3}
     ∇ ⍣ 5 6
      ({⍵+3}⍣5)6
21
      {⍵+3}⍣5⍨6
21

Learn the idioms! Then golf the idioms. For example:
 ((((1↑⍴X),⍴Y)↑X)^.=Y)⌿X

can be mechanically transformed into:
 X⌿⍨Y^.=⍨X↑⍨(1↑⍴X),⍴Y

and then further into:
 X⌿⍨Y^.=⍨X↑⍨(⊃⍴X),⍴Y

⊃ (first) being equivalent to 1↑ (take one) in this case. And possibly:
 X⌿⍨Y^.=⍨X↑⍨(≢X),⍴Y

≢ (tally) being equivalent to ⊃⍴ (the first element of the shape) for all but scalars.
Comment: @Fabinout: At dyalog.com you can download a free Windows version. Click "Download Zone" and then "Unregistered Download". It will nag you to register but otherwise it's fully functional and free and legal. If you're a student, you can get the normal version for free by filling out a form. If you don't live in a country where they ruin your life for pirating, well, you know what to do.
Comment: There is GNU APL.
Comment: There is also Nars2000, an open source implementation that has many more features than Dyalog (and some bugs.) Some of its features come in handy for golfing, such as the prime number functions or multisets.
Comment: @M.Alaggan: GNU APL is not very good though, especially for golfing. (It lacks proper d-fns, for one, and it certainly doesn't do trains or other fancy stuff.) If you want an open-source APL for golfing, ngn/apl is probably better. (Though that one's arguably a worse APL, as that one lacks the ∇-functions completely, but you don't use those for golfing anyway.)
Comment: +1 Excellent post. Regarding 4.3. `⊢` is better than `⍨` for separating arguments, as it works on dyadic functions too, and doesn't cause syntax errors if the function is strictly monadic.
Comment: Is there a way to get a free license beside having the raspberry pi version?
Comment: A legal way to get it, obviously.
Comment: @marinus Should it not be possible to contribute improvements to GNU APL so it kicks the same amount of arse? I have the program installed on Mac OS, how much is it lacking in terms of the language's coverage...?
Answer: Trains
A(f g h)B      ←→  (A f B)g A h B  ⍝ fork
 (f g h)B      ←→  (  f B)g   h B  ⍝ fork
A(  g h)B      ←→         g A h B  ⍝ atop
 (  g h)B      ←→         g   h B  ⍝ atop
 (A g h)       ←→  ({A} g h)       ⍝ "Agh" fork
 (f g h k)     ←→  (f (g h k))     ⍝ 4-train
 (f g h k l)   ←→  (f g (h k l))   ⍝ 5-train, etc
 (f g h k l m) ←→  (f(g h(k l m))) ⍝ groups of 3 from the right, last could be 2
  f∘g B        ←→    f g B         ⍝ "compose" operator, useful in trains
A f∘g B        ←→  A f g B

Comment: Does that mean that for the sake of future readers, we shouldn't tell Oberon how to shorten it?
Comment: No, do as you normally would on PPCG. I'll remove that line after the expression reaches (what I believe to be) its shortest. It's an easy exercise - I don't think you personally would benefit from it.
Comment: I can get it down to 16, but I'm not using any of your tips, so maybe I'm way off.
Comment: @Adám well, you are using a train :) mine was similar but longer because I didn't think of ⎕ML
Comment: Isn't it "groups of 3 from the ***right***"?
Comment: @Adám right, I don't know what I was thinking...
Answer: Use ⊥ to combine multiplication with addition
(a×b)+C  ->  a⊥b,C
(C)+a×b  ->  a⊥b,C
(a×b)-C  ->  a⊥b,-C

Assumptions:

a and b are terms that don't require further parentheses when used as a left argument
C is an expression that may need parentheses when used as a left argument
a b C evaluate to numeric scalars
Answer: Tricks for dealing with / and ⌿ in trains
When using trains you may want to use reductions f/ like sum +/ or even replicate reduction // . However, if your train has more parts to the left of the reduction you need parentheses to create an atop. Here are some tricks to save bytes.
Use 1∊ instead of monadic ∨/ or ∨⌿ on Boolean arrays
Task: Given two equal-length strings A and B, return 2 if any corresponding characters of A and B are equal, 0 otherwise. E.g. A←'abc' and B←'def' gives 0 and A←'abc' and B←'dec' gives 2.
A dfn solution may be A{2×∨/⍺=⍵}B but you want to shorten it by going tacit. A(2×∨/=)B is not going to work because the rules of train formation parse this as 2 (× ∨/ =) but you want 2 × (∨/=) .
Observe that ∨/ or ∨⌿ on a Boolean vector (∨/, or ∨⌿, for higher rank arrays) asks whether there is any 1 present, i.e. 1∊ , so we can write our train as 2×1∊= .
Note that ∊ ravels its right argument, so you cannot use it to reduce each row or column separately.
Use 1⊥ instead of monadic +/ or +⌿
Task: Given a list of lists L and an index N, return thrice the sum of the Nth list. E.g. L←(3 1 4)(2 7) and N←1 gives 24.
A dfn solution may be N{3×+/⍺⊃⍵}L but you want to shorten it by going tacit. N(3×+/⊃)L is not going to work because the rules of train formation parse this as 3(× +/ ⊃) but you want 3 × (+/⊃) .
Observe that evaluating a list of numbers in unary (base-1) is equivalent to summing the list because ∑{a, b, c, d} = a + b + c + d = (a × 1³) + (b × 1²) + (c × 1¹) + (d × 1⁰). Therefore +/a b c d is the same as 1⊥a b c d , and we can write our train as 3×1⊥⊃ .
Note that on higher-rank arguments, 1⊥ is equivalent to +⌿.
Use f.g instead of f/g with scalar and/or vector arguments
Task: Given a list L and a number N, return the range 1 thorough the number of minimum division remainder when the elements of L are divided by N. E.g. L←31 41 59 and N←7 gives 1 2 3.
A dfn solution may be N{⍳⌊/⍺|⍵}L but you want to shorten it by going tacit. N(⍳⌊/|)L is not going to work because the rules of train formation parse this as ⍳ (⌊/) | but you want ⍳ (⌊/|) .
The inner product A f.g B of scalar two functions when the arguments are scalars and/or vectors is the same as f/ A g B because both are (A[1] g B[1]) f (A[2] g B[2]) f (A[3] g B[3]) etc., so we can write our train as ⍳⌊.| .
Note that this does not work for higher-rank arrays.
Use ∊⊆ instead of / with Boolean left and simple vector right arguments
Task: Given a list L and a number N, filter the list so that only numbers greater than N remain. E.g. L←3 1 4 and N←1 gives 3 4.
A dfn solution may be N{(⍺<⍵)/⍵}L but you want to shorten it by going tacit. N(</⊢)L is not going to work because the binding rules will parse this as (</) ⊢ but you want / to be the function replicate rather than the operator reduce.
Dyadic ⊆ with a Boolean left argument partitions the right argument according to runs of 1s in the left argument, dropping elements indicated by 0s. This is almost what we want, save for the unwanted partitioning. However, we can get rid of the partitioning by applying monadic ∊. Thus {(⍺<⍵)/⍵} can become {∊(⍺<⍵)⊆⍵} and thus we can write our train as ∊<⊆⊢ .
Note that this does not work for higher-rank arrays.
Use ∊⍴¨ instead of / with non-Boolean left and simple vector right arguments
Task: Given a list L, replicate Nth item N times. E.g. L←3 1 4 gives 3 1 1 4 4 4.
A dfn solution may be {(⍳⍵)/⍵}L but you want to shorten it by going tacit. (⍳/⊢)L is not going to work because the binding rules will parse this as (⍳/) ⊢ but you want / to be the function replicate rather than the operator reduce.
Dyadic ⍴ combined with ¨ copies each element of the right argument according to the matching element in the left argument. This is almost what we want (e.g. 1 2 3⍴¨3 1 4 → (3)(1 1)(4 4 4)). Then, we can get rid of the nesting by applying monadic ∊. Thus {(⍳⍵)/⍵} can become {∊(⍳⍵)⍴¨⍵} and thus we can write our train as ∊⍳⍴¨⊢.
Note that this does not work for higher-rank arrays.
Use 0⊥ instead of ⊢/ or ⊢⌿ with numeric arguments
Task: Given a list L and a number N, multiply the N with the rightmost element of L. E.g. L←3 1 4 and N←2 gives 8.
A dfn solution may be N{⍺×⊢/⍵}L but you want to shorten it by going tacit. N(⊣×⊢/⊢)L is not going to work because the rules of train formation parse this as ⊣ (× ⊢/ ⊢) but you want ⊣ × (⊢/⊢) .
Observe that 0⊥ on a numeric array is the same as ⊢⌿ , so we can write our train as ⊣×0⊥⊢ .
Note that this selects the last major cell of higher-rank arrays.
Answer: Complex numbers
Often overlooked, they present wonderful opportunities to shorten expressions dealing with grids, mazes, fractals, or geometry.
0j1⊥¨    0j1⊥   ⍝ pair(s) of reals -> complex
11 9∘○¨  11 9○  ⍝ complex -> pair(s) of reals
|z0-z1          ⍝ distance between two points
0j1×z   0j¯1×z  ⍝ rotate by ±90° around (0,0)
0j1*⍳4          ⍝ the four cardinal directions
+z       -+z    ⍝ reflect across x or y axis
+\0,z           ⍝ sequence of steps -> path
¯2-/z           ⍝ path -> sequence of steps
0j1⊥¨n-⍳2⍴1+2×n ⍝ lattice centred on (0,0)

Answer: Indexing modulo vector length
⊃i⌽a is often shorter than the naive ⊃a[(≢a)|i] or a⊃⍨i|⍨≢a (where a is a vector and i is an integer, and ⎕io is 0)
a useful variation on this (thanks EriktheOutgolfer for pointing out) is: I↑Y⌽⍨I×X where Y is the concatenation of some length-I vectors and X is the index of the one we want to pick, for instance: 3↑'JanFeb...Dec'⌽⍨3×month
Answer: Generate A001057, A130472, and many variations
A001057 is a simple sequence of alternating integers, starting with 0, 1, -1, 2, -2, 3, -3, .... A130472 is its negation, 0, -1, 1, -2, 2, -3, 3, ....
APL has a surprisingly short way to generate nth term or first n terms:
nth term of A001057 (0-indexed)
⎕IO←1
-/⍳

Try it online!
nth term of A130472 (1-indexed)
⎕IO←0
-/⍳

Try it online!
first n terms of A001057, leading 0 removed (1, -1, 2, -2, ...)
⎕IO←1
-\⍳

Try it online!
first n terms of A130472 (0, -1, 1, -2, 2, ...)
⎕IO←0
-\⍳

Try it online!
Applying various primitive functions to these sequences can give many interesting results which are shorter than other alternatives:

1, 1, 2, 2, 3, 3, ...: With ⎕IO←1, |-\⍳n is shorter than n↑2/⍳n in explicit form
0, 1, 1, 2, 2, 3, ...: With ⎕IO←0, |-\⍳n is shorter than ⌈2÷⍨⍳n in explicit form
0, 1, 0, 2, 0, 3, ...: With any ⎕IO, |0⌊-\⍳n or -0⌊-\⍳n is shorter than any known alternatives, both tacit and explicit
0, -1, 0, -2, 0, -3, ...: With any ⎕IO, 0⌊-\⍳n
1, 0, 2, 0, 3, 0, 4, ...: With ⎕IO←1, 0⌈-\⍳n
0, 1, 1, 0 repeated: With ⎕IO←0, 2|-\⍳n
1, 1, 0, 0 repeated: With ⎕IO←1, 2|-\⍳n
Reverse odd then forward even, e.g. 7 → 5 3 1 0 2 4 6: ⍋-\⍳n with ⎕IO←0. ⎕IO←1 gives 7 → 6 4 2 1 3 5 7.
Permutation of 0 to n-1, alternating front and end, e.g. 7 → 0 6 1 5 2 4 3: n|-\⍳n with ⎕IO←0.
First n terms of A002620, 0, 1, 2, 4, 6, 9, 12, 16, 20, ...: -\-\⍳n with ⎕IO←0 (⎕IO←1 gives same sequence with leading zero removed), which is shorter than ⌊×⍨2÷⍨⍳n with ⎕IO←1.
Answer: Use ⍨
Avoid parentheses
⍨ (Commute) can save you bytes by avoiding parentheses. Whenever you have a function where the left argument needs to be parenthesised and the right argument does not, you can save a byte, e.g. (A<B)÷C → C÷⍨A<B.
Double arrays
To append a copy of an array to its end, use ,⍨A or ⍪⍨A.
Double numbers
Instead of using 2∘× to double, you can use +⍨ since it adds the argument to itself: 1+2∘× → 1++⍨.
Square numbers
Instead of using 2*⍨Y to square, you can use ×⍨Y since it multiplies the argument with itself: 2*⍨A+B → ×⍨A+B.
Random permutation
?⍨N will give you a random permutation of length N.
Self-classify
Find the indices of the first occurrence of each major cell with ⍳⍨A
Count trailing 1s in a Boolean vector
Instead of +/∧\⌽B to count how many trailing 1s there are in N you can use ⊥⍨.
Reverse composition
A f∘g B is A f g B, but if you want (g A) f B, use f⍨∘g⍨.
Reverse reduce
f/ a1 a2 a3 is a1 f (a2 f a3). If you want (a1 f a2) f a3, use f⍨/⌽.
Reverse scan
f\ A B C is
 A  (A f B)  (A f (B f C)).
f⍨/∘⌽¨,\ A B C is
 A  (A f B)  ((A f B) f C).
f⍨\⌽ A B C is
 ((A f B) f C)  (B f C)  C.
⌽f/∘⌽¨,\⌽ A B C. is
 (A f (B f C))  (B f C)  C.
Answer: Generate all nonempty subsequences
I recently discovered the expression (⊢,,¨)\ in this answer. If applied to a simple numeric or char vector, it does the following:

(⊢,,¨)/ v gives all subsequences of v which include the last item.

  (⊢,,¨)/ '1234'
→ '1' (⊢,,¨) '2' (⊢,,¨) '3' (⊢,,¨) '4'
→ '1' (⊢,,¨) '2' (⊢,,¨) '4' '34'
→ '1' (⊢,,¨) '4' '34' '24' '234'
→ '4' '34' '24' '234' '14' '134' '124' '1234'

(⊢,,¨)\ v applies (⊢,,¨)/ to each prefix of v, giving all non-empty subsequences as a list of lists of vectors.

  (⊢,,¨)\ '1234'
→ '1' ('2' '12') ('3' '23' '13' '123') ('4' '34' '24' '234' '14' '134' '124' '1234')

The result can be flattened once using ⊃,/, which gives the list of nonempty subsequences.
The order is the one imposed by the binary digits of 0..2^n-1, grouped by the last item. You can use it whenever it suffices to generate all subsequences in any order. An interesting feature is that the original vector comes last, so you can also test e.g. "the original satisfies something but any smaller subsequence doesn't" using </.
Note that the order is different from plain binary/lexicographic/shortlex order, so it is hard to use when the challenge requires specific ordering of subsequences.
A nice application of this trick is "extract all subsequences of digits of a number": ⍎⍕(⊢,,¨)\⍕n. Figuring out how it works is left as an exercise to the reader. :)

(⊢,,¨)/ can be used to generate all subsequences (including empty), with the same order as binary order:
 ¯1↓¨¨(⊢,,¨)/'1234',0
→ '' '4' '3' '34' '2' '24' '23' '234' '1' '14' '13' '134' '12' '124' '123' '1234'

It's longer than the scan version, but it fits in a train better and might be useful when the order is important.
Comment: @Jonah [Inception?](https://codegolf.stackexchange.com/questions/211350/delicate-primes/211363#comment497749_211363) :P
Comment: @Jonah Actually, if you want to *reduce* over the subsequences instead of collecting them, J works equally well without explicit boxing.
Comment: Very nice, is there a J equivalent of that subsequence trick?
Comment: Damn, hate being outgolfed by my former self.
Answer: Enumerate the characters in a string without ⍳≢
Task: Given two strings, S and T, list the indices of their concatenation. E.g. S←'abcd' and T←'xyz' gives 1 2 3 4 5 6 7.
A dfn solution may be S{⍳≢⍺,⍵}T but you want to shorten it by going tacit. ⍳≢, is not going to work because the train parsing rules will parse this as (⍳)≢(,) but you want (⍳≢),.
Dyadic ⍋ with an empty left argument grades simple character arrays according to their current order, which is the same as ⍳≢. Thus {⍳≢⍺,⍵}  can become {⍬⍋⍺,⍵} , so we can write our train as ⍬⍋, .
Note that this does not work for numeric or mixed arrays.
Comment: Wow, didn't know that was a thing.
Answer: Constant functions
=⍨ and ≠⍨ thanks to ngn.
Sometimes you just need a single value for each element of a list. While you might be tempted to use {value}¨ (it is shorter to use value⊣¨ or value⍨¨), you can get even shorter (using ⎕IO←0) for some common values:
¯1s with ⍬⍸list
0s with ⍬⍳list
1s with ⍬⍷list
Note that these only work on lists (though they may be nested). For higher-rank simple arrays, you can use the following to get all 0s and all 1s:
1s with =⍨
0s with ≠⍨
If you set ⎕ML←0, all numbers can be made into zeros (as if 0×) with:
∊
If you only need a single number, you may be able to use monadic ≡ to get 1 or 0 instead of using 1⊣ or 0⊣.
Note that Dyalog APL 18.0 added a constant operator which derives an ambivalent function that always returns the constant.
Comment: "_Sometimes you just need a single value for each element of a list._" - It may be noteworthy: when that value is the first element of the list, you can use `⊣\ `
Comment: @ngn I'd say that `⊣` and `⊢` with `/` and `⌿` merit a post of their own.
Answer: Constructing a long complex string (char vector)
Original idea from @ngn.
We can (ab)use rotation n⌽ and enlist ∊ to shorten multiple concatenations:
'(',(⍺∇r),'|',(⍺∇s),')'
  → Rotate the last ')' to front and apply 1⌽
1⌽')(',(⍺∇r),'|',(⍺∇s)  (-1 byte)
  → We don't need parens at the end
1⌽')(',(⍺∇r),'|',⍺∇s    (-3 bytes in total)
  → Remove some concats(,) to use stranding instead and enlist(∊) later
1⌽∊')('(⍺∇r)'|',⍺∇s     (-4 bytes in total)

Note that we can't remove the last concat (,) in this case; otherwise the recursive call would be screwed up.
The ∊ trick can also be used to shorten construction of numeric arrays:
0,(⍳5),0
  →
∊0(⍳5)0   (-1 byte)

Answer: ⎕FMT, the formatting function
Dyalog documentation page
In user's answer to ascii art reflection,, they used an interesting builtin called ⎕FMT to split text on a carriage return \r. I feel it has potential to save a lot of bytes in ascii-art and string challenges. It works very well with specific output/input specifications.
Converting carriage return separated input directly to a matrix
A string with carriage returns can be converted directly to the matrix using monadic ⎕FMT:
      ⎕FMT'Hello'(⎕UCS 13)'There'
 Hello
 There
      ⍴⎕FMT'Hello'(⎕UCS 13)'There'
2 7

It automatically pads the matrix with spaces, just like ↑(mix).

⎕FMT can take arrays as arguments, and can apply a format specification to each of it's elements. However, the rank of the array must not exceed 2, and the format specifier must be a proper match for the elements.
There are multiple format specifiers allowed, which give different results:
rAw     Alphanumeric format
rEw.s   Scaled format
rqFw.d  Decimal format
rqG⍞pattern⍞    Pattern
rqIw    Integer format
Tn  Absolute tabulation
Xn  Relative tabulation
⍞t⍞     Text insertion

Where:
r   is an optional repetition factor indicating that the format phrase is to be applied to r columns of Y
q   is an optional usage of qualifiers or affixtures from those described below.
w   is an integer value specifying the total field width per column of Y, including any affixtures.
s   is an integer value specifying the number of significant digits in Scaled format; s must be less than w-1
d   is an integer value specifying the number of places of decimal in Decimal format; d must be less than w.
n   is an integer value specifying a tab position relative to the notional left margin (for T-format) or relative to the last formatted position (for X-format) at which to begin the next format.
t   is any arbitrary text excluding the surrounding character pair.  Double quotes imply a single quote in the result.

This allows a lot of useful tricks like format strings, ASCII tabulation, representation of arbitrary precision floating point values, and allow you to apply them cyclically to the contents of any matrix you choose. ⎕R might be simpler to use in the case of a single line character vector, however.
These letters and their modifiers are discussed in more depth in the Documentation.
Answer: Base Conversions
The function b⊥v, where b is a numeric base and v is a vector of digit values in that base, converts the vector v into its decimal (base-10) equivalent. If you want to convert a base-10 number into base b, a naïve approach would be to try to use ⊤, but this requires figuring out (or calculating) how many digits the number would require in base b. Instead, use the Power operator ⍣ with a right operand of ¯1: (b∘⊥⍣¯1). This will invert the convert-to-decimal function to convert back to base b with exactly the minimum necessary number of digits in the base-b representation.
      2⊥1 1 0 1            ⍝ Convert the base-2 digit vector 1 1 0 1 to base-10
13
      (2∘⊥⍣¯1)13           ⍝ Convert 13 to its base-2 digit vector
1 1 0 1

Comment: Often, you don't need the `∘`:  `2(⊥⍣¯1)13`
Answer: Miscellaneous ideas
Cross-post of my own J tip, because APL and J are so closely related that the two can share many ideas.
If you're facing -⍨/, try ¯1⊥ instead
A common reason to use -⍨/ is to reverse-subtract over a length-2 axis, e.g. given a 2-element array x y, compute y-x.
If this is the case, ¯1⊥ is an equivalent expression; just like 2⊥x y computes 2x+y, ¯1⊥x y computes -x+y. While the two expressions have same length, ¯1⊥ is more likely to fit well in trains (due to being a dyadic primitive function with a left arg, vs -⍨/ being a monadic derived function).
Note that, if you apply it to longer axis, ¯1⊥ gives you more similar result to -/ (alternating sum), with negated result when the length is even.
Construct a boolean square matrix where the border is ones/zeros and the interior is the opposite
This is mainly for large fixed-size matrices, say 6 by 6.
The matrix
1 1 1 1 1 1
1 0 0 0 0 1
1 0 0 0 0 1
1 0 0 0 0 1
1 0 0 0 0 1
1 1 1 1 1 1

can be generated by ∘.∨⍨ -ing the boolean vector 1 0 0 0 0 1. The shortest known way to generate that vector is 6⍴5↑1, so we can get the matrix above in just 9 bytes:
∘.∨⍨6⍴5↑1

We can also get negation of it at no extra cost, by swapping ∨ with ⍱! (Remember that APL has NOR ⍱ and NAND ⍲; they are rarely needed, but definitely are a byte saver when we do need them.)
Answer: Repeat with intermediate results
This is originally @ngn's suggestion on an APL answer of mine.
While APL has the power operator ⍣ which can repeat a function certain number of times, it cannot collect intermediate results on its own (unlike J's ^: allowing <n or i.n right operand to do the job). Usually one would collect the intermediate results by using an auxiliary variable with modified assignment, or "hack" the left operand of ⍣ to something like (⊣/,f¨)⍣n⊂x, or naively write down the iterations like {⍵(f⍵)(f f⍵)}x.
But there is a clever way using scan ⊢∘f\. Since x ⊢∘f y ignores x and applies f to y monadically, such a scan over n copies of x (enclosed if x is non-scalar) gives the results of f applied to x 0..n-1 times:
  ⊢∘f\n⍴⊂x
→ ⊢∘f\x x x ... x
→ (x)(x ⊢∘f x)(x ⊢∘f x ⊢∘f x) ...
→ x(f x)(f f x)(f⍣3⊢x) ... (f⍣(n-1)⊢x)

This is shorter than several alternatives (assume x is a complex expression):
{⍵(f⍵)(f f⍵)}x  ⍝ way too long for 2nd or higher iterations
(⊣/,f¨)⍣n⊂x     ⍝ shorter, but still long
⊢∘f\n⍴⊂x        ⍝ shortest

Interestingly, the scan expression ties when compared to various expressions that collect only zeroth and first iterations:
{⍵(f⍵)}x  ⍝ dfn
(⊂,⊂∘f)x  ⍝ tacit
y(f y←x)  ⍝ intermediate assignment; this wins if f is a single primitive
⊢∘f\2⍴⊂x  ⍝ scan

Also note that ⊢∘f\n⍴⊂ without the right arg is also a valid train.

As of Dyalog 18.0, you can write f⍤⊢\ in place of ⊢∘f\, which may or may not save bytes depending on the structure of f. (The conversion never adds bytes, so f⍤⊢\ can be universally used.)
Comment: some times is better not be clever
Answer: When you need to encode some arbitrary data (as is common in the Kolmogorov complexity questions), it can be achieved with a string of characters from the atomic vector ⎕AV.
For example, to encode the array 256 13 16 127 128 168 192 in Dyalog APL:
⎕AV[256 13 16 127 128 168 192]      ⍝ the result is: ⍣%⍵⊣⌷∧⊤

Then to decode it:
⎕AV⍳'⍣%⍵⊣⌷∧⊤'

Adám's SBCS (single byte character set) also allows to encode some other characters (⊆⍠⍤⌸⌺⍸) as a single byte.
Comment: This, of course, only works if all your integers are 1≤n≤256 (or 0≤n≤255 with `⎕IO←0`). If all your integers are 1≤n≤26 (or 0≤n≤25 with `⎕IO←0`), you can use `⎕A` instead of `⎕AV`.
Comment: Well, I used it like this `∊(5 5 5⊤⊢)¯6+⎕AV⍳'ÏSSS9i⌶⌶⌶⌶RSÐSS'`. In this case each byte is decoded into three numbers in range 0≤k<5. So you get 45 numbers from 15 characters. But I had to use an offset -6 because I was "unlucky". (And, of course, added logic worsens the "compression rate".)
Comment: Another thing to note is that, if you're unlucky, you will get some chars like linefeed which can't be embedded in the string literal.
Comment: …Another trick here is to pick the string so that to avoid using `¨`, of course.
Answer: Encode into base b without digit limit
b⊥⍣¯1
Explanation:
  ⍣¯1 Do the inverse of...
b⊥    Decoding from base b (which is encoding to base b with no digit limit!!!)

Comment: what is digit limit?
Comment: @thejonymyster none, it's how many digits it can get
Comment: i had no idea apl normally had a digit limit for base conversion. that's insane
Comment: Because you need to specify a mixed radix there's a limit, for example `2⊤11` is `1`
Comment: Also high minus is the negative number identifier, which is different from monadic - (negation)

Tips for golfing in APL


Are Jews allowed to listen to music that is performed by non-Jew?

Question: I am machmir on only listening to music that was performed by a Jew, but i don't really understand it. Does anyone know what is the source for this? Does Matisyahu perform with only Jews?
Comment: From your question it sounded like you decided to do this yourself (hence my confusion). Why don't you ask the Rav who told you this in the first place?
Comment: I have been to many Chasunos where some of the band members were non Jews
Comment: If you don't understand it, why do you do it? I'm not being facetious, just trying to understand your thought process.
Comment: @dave because my rav said so
Answer: Here's a summary of Igrot Moshe Yoreh Deah 2:56, which says that the bottom line is that "it is forbidden to listen to non-Jewish religious music ... However, if the song is written and/or song by a non-Jew but has no religious purpose, then there is technically no prohibition."
Comment: So, I can listen to Bach Cantatas or Handel's Messiah? Or Norman Greenbaum's "Spirit in the Sky", written by a Jew claiming he'll have a place with Jesus?
Comment: @MonicaCellio I would most definitely agree regarding Messiah, esp. since it tends to be sung close to Christmas season. "Spirit in the sky" was not composed to be a religious song. I think it was just meant to be a catchy tune for rock radio listeners, which it was. I don't think they are singing this song in any church.
Comment: @DanF I would think that Handel's Messiah and Greenbaum's "Spirit in the Sky" have religious purposes.
Answer: See Igros Moshe YD 2:111 where he raises issue of church influence which relate to the players' intentions, the words, and the instruments. Jews presumably would not have suspicious (regarding idol worship) intentions.
Answer: I heard a prominent Rabbi say that it was mutar as long as the lyrics and clean and the beat will not make one do inappropriate things.  (See Rambam's comment on Avots 1:16)
Comment: How does reading Rambam's comment there make anything more clear?
Answer: In a Q&A session by R' Hershel Schachter I recently heard, he explains (I forget based on who) that artists put some of their essence into the art they make, so when you consume art, you internalize a little bit of the artist's soul. So, he advocates against listening to music composed by non-Jews.
Comment: I think the question was about music being *performed* by non-Jews. That does not automatically follow from the principle you mentioned.
Comment: @avrohom Your first sentence seems to be disagreeing with me, while your second sentence seems to be agreeing with me. In any case, the reality is that when you hear music, the emotions of both the composer and the performer are expressed therein, in different ways and to different degrees. How that should affect practice is either a Halachic question for your Rabbi, R' Schachter, and whatever sources they cite or a personal matter.
Comment: Agreed, although I suspect that he'd say that the rule is the same. I recommend that you listen to the recording to get his nuances and see if he quoted a source.
Comment: @isaac no its not the same. there's a difference between me performing beethoven on the piano and some ali ahmad or james jones doing beethoven


Burial on Yom Tov Sheni

Question: If someone passes away on the first day of Yom Tov - should the burial be done on Yom Tov Sheni? How is it done?
Answer: See here and here.
The gemara (Beitza 6a) rules that burial on yom tov sheni is permissible, and Rambam and Shulchan Aruch rule like the opinion in the gemara that even things that are not strictly necessary for burial may be done if they are in the spirit of kavod hames, since yom tov sheni is treated as a weekday with regards to burial.
However, nowadays, when we have the ability to postpone burial due to refrigeration, some poskim (notably, R' Moshe Feinstein) are of the opinion that we should be stringent and wait until after yom tov, since holding a funeral on yom tov may cause its unnecessary violation by ignorant or irreligious people
Answer: From what I've heard (need sources), the rabbis were very lenient with the second day of yomtov when it came to prompt burial; the human dignity of not leaving a corpse out decomposing had a very high value.
However, today, when the corpse can be refrigerated, I've heard the common practice is to wait until after all of yomtov before the burial.
Comment: My grandfather died on the first day of Pesach (a shabbos that year).  The funeral was on the first day chol hamoed, third day of Pesach, a Monday.

Burial on Yom Tov Sheni


How to plan a day hike

Question: Is there kind of a checklist what to consider before going on a day hike? Like which preparation should one take, things to pack (not detailed, like "food"), useful information (weather forecast e.g.) and so on.
Comment: My checklist changes depending who I'm going with, even bringing just the dog makes a difference
Comment: You might look up "ten essentials".
Comment: Just grab a canteen and go.
Comment: @ShemSeger word :)
Comment: Should the answer be in community wiki form?
Answer: It depends on your destination. In general I would think of:
Preparation

organise one or more detailed map(s) of the area to go to
check the weather forecast
organise your way to your destination and back home (in case you do not start walking at your door). This could include:

check public transport and buy tickets
check fuel of your car; rent a car; check parking options; etc. (inspired by mattnz's comment)

make sure, you have appropriate clothes, shoes and backpack (and everything else, you want to take with you)

clothes and shoes should be hiking or trail shoes and non-cotton exercise clothing (comment from Radar)

pack
charge your cell phone and check, whether it will have reception at your destination (comments from jamesqf and Peter Green)
depending on your destination: plan sight seeing stops (e.g. check opening hours of the castle you want to go in or anything)

Thinks to pack

water
food
money, ID card, emergency information
a hiking map
medication etc. (if you need any)
a fully charged cell phone
additional rain/sun/wind/cold protection (depending on the weather forecast and the area you want to go to)
maybe a pencil and a small notebook
maybe stuff to take pictures (make sure the battery is charged, the memory card empty)
the above mentioned tickets

Edited to incorporate comments
Comment: Before depending on a cell phone, it's a good idea to check whether the area you're going to actually has cell phone reception.  Even close to populated areas, trails in e.g. mountain canyons may not.
Comment: mattnz Remember that this answer to your question will be read by many people, not just you.  That's part of the point of public forums - while you are getting help, this becomes a resource for others searching for the same information.  Ignore the bits that doesn't apply to you and use the rest.  This is a good answer but I will add my own preparation checklist as well.
Comment: +1 I would also add that appropriate clothing means suitable footwear (hiking or trail shoes, not flip flops) and non-cotton exercise clothing. Way too many people have rough hikes (even day hikes) due too poorly selected clothing.
Comment: Be aware that mobile phones don't work everywhere. In some areas you might want to consider carrying an emergency locator beacon or a satphone.
Comment: Why would I need to check public transport? I have a car and can drive to the start of the hike and where I live, the public transport will not get to to most anyway.
Answer: As well as checking the weather forecast you should research the general weather conditions for the area you will be visiting, often conditions in hilly or mountainous areas can change quickly and without warning so you should be prepared for the worst possible conditions you might encounter. This also includes checking sunset times for the time of year.
It is also important to consider your route carefully, looking at gradients and terrain as well as distance. Satisfy yourself that all of your party can manage it in the time available. Ideally you should have an alternative or exit route in case you are delayed for any reason. Even on well marked paths a map and compass and at least a basic understanding of how to use them are essential, GPS etc should be considered useful additions not the sole means of navigation.
Also consider any potential hazards on or near the route such as cliffs or rivers which could be danger if you get lost and/or visibility deteriorates. Some areas may have particular hazards in the form of wildlife or be prone flooding etc etc.
Inform somebody reliable of your route and the time you expect to be back and check in with them when you return.
In many areas it is wise to take at least some preparations for an emergency overnight stay. In most cases this will not be full camping kit but might include extra food and water, some sort of emergency shelter and torches. The simple fact of being prepared can do a lot to prevent panic if you do get lost.
Have an emergency plan in case you get lost or separated. In most cases this means deciding in advance whether people will stay put once they realise they are lost or head to a prearranged meeting point.
As well as the obvious safety implications this sort of thinking ahead will tend to make a trip more relaxed and enjoyable.
Comment: +1 specifically for "Inform somebody reliable of your route and the time you expect to be back and check in with them when you return."
Answer: Some good answers here, but so far no-one has mentioned perhaps the single most important safety-factor:

Understand the reality of the hazards you are facing, and be sure you have the skills to cope with them

Depending on the area and the season, the risk factors you should be considering might include:

Weather: How challenging can it get? Do you really have the equipment and experience to cope? If need be, can you handle extreme heat, wet or cold?
Navigation: How hard is it to find the route? This can vary hugely. Even on marked trails you'll sometimes come across a baffling
junction. If need be, can you navigate the route in cloud, dark and
storm?
Emergency: If you get into trouble, how hard would it be to get help? Does your party have the experience to extract yourselves in case of illness or accident?
River Crossings: These can be lethal. Do you have the skill and judgement to keep safe?
Snow and Ice: What can you expect to encounter? You can't always see this from the valley. If you have any doubt about your ability to cope, ask locally about current conditions.
Bears and other wild animals: Do you know the local regulations? Do you know what precautions to take?

Over the years, most of the issues I've seen in the hills have stemmed from a party underestimating the route or overestimating their skills.
Sometimes this can be quite extreme: I once had to help rescue a lady who was attempting Ben Nevis in full winter conditions and a gathering blizzard while shod in high-heel shoes!
So do your homework, get a realistic idea of what you're up against, and make a realistic assessment of whether it's the right route for you and your party.
Answer: I'll second the earlier nomination of the "ten essentials" list (@Nate Eldredge).  There are two versions of this list, with the classic version of the list tracing its roots back to the 1930's.  These lists are presented convenently on REI's web site (http://www.rei.com/learn/expert-advice/ten-essentials.html), but I will reproduce them below for posterity.
One bit of wisdom often not given in association with these lists is "...and the knowledge to use them properly".  Without knowledge, these items are little more than additional pack weight.  If you are going into any sort of a remote area, get proper training in navigation, first aid, and basic survival skills.
For anything much more than a short outing at a local park, I will pack enough for an overnight including all of the items on the modern version of the list.  Understand that this would NOT be a comfortable overnight, but I would be protected from the forecast weather conditions and have sufficient food and water.  This typically weighs in at 12-14 lbs (and this is where the ultralight backpackers get to chuckle...).
Updated Ten Essential "Systems"

Navigation (map and compass)
Sun protection (sunglasses and sunscreen)
Insulation (extra clothing)
Illumination (headlamp/flashlight)
First-aid supplies
Fire (waterproof matches/lighter/candles)
Repair kit and tools
Nutrition (extra food)
Hydration (extra water)
Emergency shelter

Classic Ten Essentials

Map
Compass
Sunglasses and sunscreen
Extra clothing
Headlamp/flashlight
First-aid supplies
Firestarter
Matches
Knife
Extra food

How to plan a day hike


How does Bitcoin choose to which miner the reward will go?

Question: Let's say 100 miners with similar hashrate all try at the same time to mine the same block and finish at the same time, how will Bitcoin choose to which miner the reward will go? Is there some prority protocol?
Answer: It's all about probability. In about 10 minutes, a miner among those 100 will finally achieve to solve the proof of work for the given block before others will. So, he then will write that block on the blockchain, using it's address in the receiving address field of the coinbase transaction, thus obtaining it's reward.
what happen if they all mine the block at the same time
In that case, the blockchain would be temporary forked on the block at height X, given X the number of the block been mined at the same time by more than one miner. This won't last forever. Remember the golden rule of bitcoin: the longest chain win. Among those forks, one will definitely be resolved (again, it's all about probability at the end of the day), meaning more hashrate will be brought to it, so it will grow faster (speaking about blockheight) than the other. That one will become the current blockchain.
What happens to the other forks? Well, they're simply not valid blockchains. They contain outdated data. If forking miner continue to mine on those blockchain, they'll do at a lost, because they will get rewards on a blockchain which is not the main one
Is there some priority protocol? No, absolutely. Just probability. The more hashrate you have, the more probably you can mine the next block
how the precise time of completion is calculated (is it using the miner's computer clock as timestamp? From the bitcoin wiki

A timestamp is accepted as valid if it is greater than the median
timestamp of previous 11 blocks, and less than the network-adjusted
time + 2 hours. "Network-adjusted time" is the median of the
timestamps returned by all nodes connected to you. As a result block
timestamps are not exactly accurate, and they do not need to be. Block
times are accurate only to within an hour or two.Whenever a node connects to another node, it gets a UTC timestamp from it, and stores its offset from node-local UTC. The network-adjusted time is then the node-local UTC plus the median offset from all connected nodes.
Comment: I edited my question to ask more precisely about wht happen if they all mine the block at the same time. Is there some priorioty protocol? I also wonder how the precise time of completion is calculated (is it using the miner's computer clock as timestamp?).
Answer: Time in bitcoin isn't precise nor reliable, every peer can have their own idea of time and every peer has a view of other peers time that lead a single peer to have knowledge about time drift (adjusted time).
Any miner can mine using past or even future timestamps but there are rules that enforce blocks to be generated not too much in the past (using the median time of previous blocks) and not too much in the future (using the adjusted time from your known peers)
Having said that, mining is a race, if many mine at the same time the network will have temporary different views based on peers and their neighborhood (e.g. if you are connected directly to a miner, you'll likely get first the block from it while if you have not direct connection to a miner but one of your peers does, you'll likely get the block from that miner too, basically it's about latency between nodes)
At that point your node have a view that will put one of these mined blocks as your TIP, if you are a miner and you succeed to find the next block before others add a block on other forks, you'll likely have a chance that your view will become the valid one for the rest of the network (if other big miners don't decide to ignore your block and try to mine on their own vision, in case they found the previous block and have incentives to do so)
Well, I understand my explaination isn't probably easy to follow because there are lot of nuances behind, in any case the short ELI5 answer is: when multiple miners mine a block at the same time, the network will sort it out waiting for the longer chain to emerge from forks.
EDIT
P.S.
note that when all of them mine, all of them get the reward in their own view, because all of them think to be on the tip of the chain.
But only one of these blocks will survive because the longest chain based on these forks will become the valid one and so other miners will have to rollback their own view up to the fork point (so losing the reward they thought they won) and moving to the now-valid chain


What do 7th chords generally resolve/lead to?

Question: Particularly Major 7th chords.  I've been messing around in the key of E major and have decided to start of the bass line of this bit of experimenting with the Emaj7 chord and I'm trying to resolve to some other (more mellow) chord.  After messing around a bit, I've found a few nice ways of resolving it (Em alone seems to work alright), but I'm not really sure if I'm going about looking for the chord's resolution properly.  Is there even a proper way to resolve 7th chords?
Comment: I find that 2 7th chords both resolve to the subdominant of their root. Those would be the dominant 7th and the minor 7th. The minor/major 7th has so much tension that I don't feel it can be resolved to a triad without resolving into another 7th chord. Major 7th chords I feel resolve most to the triad that the 7th is based off of, so CM7 would resolve to C major, etc. Minor 7th chords I find to be so consonant(being the only 7th without either tritones or 6ths or both outside of inversions) that I can stay in the 7th as though I am in another key.
Answer: Some chord sequences to explore starting with Emaj7, these may help you to start to develop a vocabulary of sequences that work:
<code>Emaj7 - E6 - F#m7 - F#m+6
Emaj7 - F#m7 - G#m7 - F#m7
Emaj7 - Fdim - F#m7 - Gdim - E/G# - G#/F# - C#m/E
Emaj7 - C#m7 - Amaj7 - E/G# - A/C# - B/D# - C#/F - Fdim - F#m7
Emaj7 - Amaj7 - B - C#m - A - B/F# - E
</code>
Obviously this is not an exhaustive list, and there are many more creative sequences available. Different periods of music had different rules (formal or informal) that were followed in the chord progressions but unless you are trying to compose in a particular style there is no best practice as such, though arguably some progressions will simply sound unnatural, unusual, awkward etc and will therefore be more suited to styles such as eary/suspense music than fanfares or pop music.
Answer: Chordal 7ths like to either resolve downward to the next tone in the key, downward chromatically,  or be held as a common tone. If you want it to resolve downward to the next scale tone, to C# in this case, you could make the chords C#m(7), B9, A(M7), or F#m(7). If you wanted to keep the seventh as a common tone, D# in this case, you could use B(7), D#dim, or G#m(7).
There are more out there especially when you look at alterations, borrowed chords, and extensions, but this should you an idea where to start and what to look for.
Comment: Another common resolution is when the Maj 7 becomes a min 7, especially if the Maj 7 is short in duration. This could be something like this: EMaj, EMaj7, E7, AMaj.
Comment: @Tim, I meant that the interval of a major 7th can go to the interval of a min 7th which is what happens when you go from an E Maj 7 chord to an E7 chord. But E7 is a dominant seventh chord, not a min 7 chord.
Comment: Thank you very much ^-^!  That was exactly the kind of answer I was looking.  This is second time you've helped me out, so thanks a bunch :D!
Comment: @Alex - you seem to have missed out the min7 part in your example.
Answer: To add to Dom's answer in the case of Dominant sevenths you are also going to need to resolve the leading tone. So for instance in E Major the Dominant seventh's notes are B, D#, F#, and A. The seventh has to resolve down to the G# and the D# (Leading tone) has to resolve to a E.
There is only two chords in E major with those notes. The tonic chord and the Sub Mediant chord.
Comment: It doesn't 'have to'. It just often does. In Blues, it often doesn't...
Comment: I clearly answer theory questions out of a classical perspective.
Answer: Chords that include the tritone - in G7 that's the F and B - have a pull towards resolving the F to E and the B to C.  Hence G7 as the "dominant 7th" of C major.
Where there is no tritone, though there's always an overall pull towards "home", the tonic note/chord, it's less insistent.  You needn't think of a maj7 chord "resolving", more of where ot might move to.
If you're in E major, any E chord IS "home" harmonically speaking.  If you find Emaj7 too astringent, you could move to E6.  Or just to E, though the change in density may feel rather empty.  "Planing" can also be effective, either diatonic - Emaj7, F#m7, G#m7...  or chromatic - Emaj7, Dmaj7, Fmaj 7, Emaj7.


Can I summon an unbound Dremora after completing the conjuration ritual quest?

Question: Can the unbound dremora be summoned after the conjuration ritual is complete?
I have the sigil stone and I also completed the quest, but it won't interact with me.  Why is that so?
Comment: that specific dremora or any unbound dremora?
Answer: Yes, you can summon unbound dremora at Atronach Forge. You need your sigil stone, a daedra heart, a skull and two raw meat. Since a dremora drops daedra heart when they die, you just need one heart, lots of meat and lots of skulls to summon many dremoras. It's a good way to hone your fighting skills and collect enchanted weapons.
Answer: You can summon him again if you want, he just won't react to you. He'll fight if you have your followers attack him, and he sometimes fights other daedra. But other than that, he won't react to anything.


Error rate setting in Canu error correction

Question: I want to use Canu to correct my nanopore long read (version: MinION R9.5), but I am not quite sure how to set the correctErrorRate. Should I follow the Canu manual (Nanopore R7 2D and Nanopore R9 1D Increase the maximum allowed difference in overlaps from the default of 14.4% to 22.5% with correctedErrorRate=0.225), or you guys have a better option?
Answer: It's generally a good idea to trust the "official" suggestions. You can also adjust the error rate based on coverage according to parameter reference:

For low coverage datasets (less than 30X), we recommend increasing
  correctedErrorRate slightly, by 1% or so.
For high-coverage datasets (more than 60X), we recommend decreasing
  correctedErrorRate slighly, by 1% or so.
Raising the correctedErrorRate will increase run time. Likewise,
  decreasing correctedErrorRate will decrease run time, at the risk of
  missing overlaps and fracturing the assembly.

That being said, the sequencing quality can vary from between libraries or flow cells. The error rate is not a constant.
According to the developer (full thread):

if you want to assemble 1D data or have a bad run, it is possible you
  would need to increase the error rate. You could run with a high error
  rate (0.1) and look at the distribution of overlap error rates in the
  unitig step to look for a peak in the distribution. If you have a near
  neighbor you could also map the corrected reads to it and estimate the
  residual error that way.
Answer: There seems to be some confusion here.
For the first stage of the Canu pipeline (read correction), i think the parameter to use is rawErrorRate.
From the docs:
rawErrorRate  The allowed difference in an overlap between two uncorrected reads, expressed as fraction error. Sets corOvlErrorRate and corErrorRate. The rawErrorRate typically does not need to be modified. It might need to be increased if very early reads are being assembled. The default is 0.300 For PacBio reads, and 0.500 for Nanopore reads.
I think that correctedErrorRate is what you use at the next stages of the pipeline (trimming and assemble).


What is /dev/ttyAMA0

Question: complete newbie here. Can someone please tell me what /dev/ttyAMA0.
I read that it is the TxRx pins. But what is it? is it used to refer to the pins or their address?
is it explicitly the Rx or the tx pin?
Comment: related: [What is the difference between ttys0, ttyUSB0 and ttyAMA0 in Linux?](https://unix.stackexchange.com/questions/307390/what-is-the-difference-between-ttys0-ttyusb0-and-ttyama0-in-linux).
Answer: @Milliways had the best answer in my opinion. His answer can be found here: Link given here
ttyAMA0 can be the Tx, Rx pins for the Raspberry. But for the Raspberry Pi 3b it was used for the Bluetooth. Because of this, pins 8 & 10 were using the miniUART which is labeled ttyS0 (unless you disable the Bluetooth which has instructions in that link in the beginning of this post)
So to answer you question, it can refer to pins 8 and 10 if you disable the Bluetooth. It is both the RX and TX pins as it refers to the device it self, which contains both pins.
I hope this and the answer by Milliways helps you out.
Comment: this was hugely helpful. @Milliways gives a comprehensive answer and your answer made sense to what he was talking about. Thanks a lot. I am a complete novice to Rpi and everybit is very intimidating. However I am trying my best to get a good grasp of it. I was wondering if you could send me your mail Id, if you dont mind me contacting you directly for any future doubts. :)
Comment: No problem. Glad I could be of some assistance. Be sure to click the answer button so when other people are searching for similar questions, they can see that this question was answered. It'll make their searches easire.

What is /dev/ttyAMA0


Chat page has disappeared

Question: I recently looked at an old question of mine (well, old, but the answer & discussion  this refers to happened less than 2 years ago.) After a long discussion with the answerer in the comments, I had followed the automated suggestion "Let us continue this discussion in chat", and IIRC, we did. But this link is broken now ("Page not found"). Why?
Comment: I think chat is anyway not a good place for a discussion on a particular post. In my opinion, such discussion should always be in the comments below the corresponding post. Rather than suggesting to move the discussion to chat, it would seem reasonable to me if the SE software would instead remind to polish the discussion afterwards (i.e. delete comments which are not interesting for future readers, etc.). Besides -- when I see the suggestion to move a discussion to chat, it usually either makes me stop it, or if it is sufficiently important, to continue it off-site (e.g. via email etc.).
Comment: @StefanKohl Comments are really inconvenient to use if the discussion goes beyond 3-4 comments, chat has features like clearly indicating which message you 're replying to, possibility to embed images etc. which are useful. *Ideally* all discussions on a post would be quick and on point, but we're not living in an ideal world.
Comment: It seems that users can still see deleted rooms if they have 10k+ networkwide reputation - judging from the answers to: [Cannot see chat room transcript while another user can](https://meta.stackexchange.com/q/288603) and [Is there a list of SE chat privileges, and the minimum reputation required for those privileges?](https://meta.stackexchange.com/q/87761)
Answer: That room was deleted, since it contained less than 15 messages, see this FAQ. I used my chat superpowers to undelete it, although it is bizarre that this happens for rooms created from comments. I've added two messages, so that this won't happen again.
There seems to be a feature request to make this not happen, but apparently it is a sufficiently rare corner case that SE hasn't got around implementing it yet. See also this on meta.SE.
Comment: @Wolfgang Note also that when the discussion is between three or more people the system suggests to move it to a chatroom much later, so that this problem is relatively rare. But it does happen, and it should be fixed.
Comment: @Wolfgang Yeah, I totally agree. I hope terdon's post on meta.SE produces some results (although with the usual reaction times of SE I wouldn't hold my breath). In any case, if anyone has the same problem, feel free to ping me and I'll fix it if I can.
Comment: Oh, now I see - this probably depends on reputation (a user needs 10k+ networkwide to see deleted rooms): [Cannot see chat room transcript while another user can](https://meta.stackexchange.com/q/288603). (And also:[Is there a list of SE chat privileges, and the minimum reputation required for those privileges?](https://meta.stackexchange.com/q/87761))
Comment: Thank you! I guess the fact that it said only 8 days after the discussion "This room has been automatically deleted for inactivity" really does not sound very serious ... In any case, there is quite a gap between 6 messages (when the system starts suggesting to move the discussion) and 15 (when the discussion is considered worthy to survive) which should be bridged...
Comment: Actually I thought that even if a room is deleted (i.e., no longer shown among active room) it can still be accessed. Here are some examples of deleted rooms, where I can still see transcript: https://chat.stackexchange.com/transcript/79123 or https://chat.stackexchange.com/transcript/90405 (And if you display [rooms associated with MO](https://chat.stackexchange.com/rooms?tab=site&sort=active&page=1&nohide=true&host=mathoverflow.net) and choose "show frozen/deleted rooms", you can find other such rooms.)

Chat page has disappeared


Where can you buy US craft beer in Europe that will ship to other EU countries?

Question: anyone know where you can buy US/American craft beers in Europe. Which shops/websites sell US craft beer and will ship it to other EU countries? Or any wholesalers/distributors to contact.
Answer: Since I don't know which EU country you're referring to, here are some of my picks that ship to Sweden.

shop.mikkeller.dk
boxbeers.dk
www.bieresgourmet.be
www.bier-deluxe.de
www.biere-revolution.com
www.beergium.com
Answer: www.beersofeurope.co.uk are very good, used them 4 times.
www.beersofeurope.co.uk/usa lists a number of beers, just a case of scrolling through and selecting into the cart/basket.
Delivery is £7.50 but I find it's worth paying a bit extra to get what you want / try new beers.
Answer: I can recommend www.alesbymail.co.uk I used them at Christmas 2014 to send a mixed case (chosen by myself) to my family in France. Can't remember exact European delivery costs but it was very reasonable compared to the cost of the beers or I wouldn't have used it. Check their Twitter @alesbymail for regular discount codes. (I have no affiliation with them other than being a satisfied customer).


SLAM without landmarks?

Question: First, is it possible to build map without landmarks for a robot in 2D? Let's say we have an aisle surrounded  by two walls. The robot moves in this environment. Now is it feasible to build such a SLAM problem? Or landmarks must be available to do so?
Comment: Do you really need both localisation and mapping ? The answer to your question depends on what sensors you're using. Like Josh said, do a bit more research on occupancy grid maps and feature based maps. Now, let us assume you've got a LRF module. Then the answer to the question "is it possible to build map without landmarks for a robot in 2D?" is 'Yes'.
Answer: I think you misunderstand what a landmark is. It is a generic, catch-all term for anything that a robot can recognize and use as part of a map. In particular, "landmarks" are important for feature-based SLAM algorithms, such as EKF-based slam. What you use for "landmarks" depends on what sensors are available to the robot.
In your case, since you haven't specified any sensing, then we'll assume the robot knows when it hits an object. Then any "landmark" is simply any time the robot bumps into something. If you do this with pen and paper, you'd just wander around and put an X any time you hit something, then turn and keep wandering. As time goes to infinity, you'd have a reasonable map of where object boundaries are, and what the object shapes are, as long as everything is static.
In this case, the "map" can just be a bitmap, where each pixel is 0 or 1, depending on if it has an object in that space or not. Scaling is up to the application.
I suggest doing a bit more research on these topics:

Occupancy Grid representation
Feature-based mapping
Comment: thanks for being helpful and informative. I'm still confused though. Can I consider in the aforementioned example the walls as landmarks? I'm still confused because I've seen some videos in which there are some white circles which are recognized by the robot to determine its place. What the difference between the white circles and the walls?
Comment: I don't know what videos you refer to. But The white circles are landmarks, and the walls are just walls with landmarks on them. Think about the word "marker" it doesn't mean anything particular, anything can be a "marker": a door handle marks a door, an X marks the spot, etc. Landmarks are just markers which are useful for mapping. They can be corners (which are easily recognized by lasers), or color blobs (which are easily recognized by cameras). The term landmark is flexible and determined by *you* the algorithm designer.
Answer: I think it is necessary to define what a landmark actually is. The other answer just defines them as markers and gives some examples. Something more formal and distinctive would be the following:
Landmarks are features which can easily be re-observed and distinguished from the environment. They are used by the robot to find out where it is (to localize itself).
Landmarks should be easily re-observable. Individual landmarks should be distinguishable from each other. Landmarks should be plentiful in the environment. Landmarks should be stationary.
This would for example exclude a simple pixel to act as a landmark, since in the real world it corresponds to an object which will become more or less pixels depending on distance. A blob would be more suitable since we just rely on finding a closed shape of a certain color (again with some threshold because colors change depending on lightening conditions and angle). In the real world the blob would be some orange sticker attached to the wall for example.
Answer: I just posted a similar question, trying to locate a paper than a co-worker remembered (ICRA? 2011? Not from Mudd nor the Foxe paper). I'd second @JustSomeHelp -- they need to be distinguishable. So a bump sensor alone won't help as you'll basically have (in naive form), one landmark that keeps getting different locations. That's going to end badly.
Clearly though, the recti-linear assumption is super helpful -- there's a 99 paper that address this. However I've not yet found a canonical approach to doing it
Z. J. Butler, A. A. Rizzi, and R. L. Hollis. Contact sensor-based coverage
of rectilinear environments. In Proc. of IEEE Int'l Symposium
on Intelligent Control, 1999.
Comment: As I mentioned, this only works with a static environment.

SLAM without landmarks?


Why all miners produce the same blocks

Question: My understanding is that all miners are feeded with transactions published by full node servers, but I didn't understand why they end up with exactly the same transactions in their created blocks ? Why miner A doesn't produce a block with saying 4 transactions and miner B produce a block with, for instance again, 3 transactions ?
Comment: Where do you get the idea that miners produce the same blocks? No transaction can be mined twice (that would be a double spend), so by definition every block must be distinct.
Answer: Nodes will relay all transactions to each other, true. But, how do you know all miners have the same block if only one is actually published? In any case, miners are incentivized monetarily to include the transactions with the highest fee rate (fee/kB) because the miner gets all of the transaction fees. So, it would not be surprising if miners had similar blocks since they all would presumable try to maximize the transaction fees.
Comment: Theoretically multiple blocks could be mined at nearly the same time in different parts of the network, but the blocks are relayed very quickly so that window is very short. Furthermore, you will never know multiple blocks exist unless you happen to have nodes in different parts of the network that happen to witness that event because 1 of the blocks will be discarded and only 1 will eventually be added to the chain (because the others would contain some transactions that exist in the other block, making them double spends -> invalid)
Comment: I get your point and you perfectly answered to my misunderstanding. But "if only one is actually published" : it is totally true ? I mean, sometimes several blocks exist during a short period of time; a subset of the network see blockchain A and another subset see blockchain B. Even if at the end, of couse, everyone see the same (that why several block confirmations is required)

Why all miners produce the same blocks


What is the difference between volatility and variance?

Question: How do volatility and variance differ in finance and what do both imply about the movement of an underlying?
Comment: Volatility is the standard deviation, which is the square root of variance. This standard deviation is usually expressed as an annualized number.
Answer: Volatility is typically unobservable, and as such estimated --- for example via the (sample) variance of returns, or more frequently, its square root yielding the standard deviation of returns as a volatility estimate.
There are also countless models for volatility, from old applied models like Garman/Klass to exponential decaying and formal models such as GARCH or
Stochastic Volatility.
As for forecasts of the movement: well, that is a different topic as movement is the first moment (mean, location) whereas volatility is a second moment (dispersion, variance, volatility).  So in a certain sense, volatility estimates do not give you estimates of future direction but of future ranges of movement.
Comment: Volatility is not ever the "(sample) variance of returns". Volatility is always expressed as standard deviation and hence squared results in variance.
Comment: So what is the difference from your pov ?
Answer:
The main underlying difference is in their definition. Variance has a fixed mathematical definition, however volatility does not as such. Volatility is said to be the measure of fluctuations of a process.
Volatility is a subjective term, whereas variance is an objective term i.e. given the data you can definitely find the variance, while you can't find volatility just having the data. Volatility is associated with the process, and not with the data.
In order to know the volatility you
need to have an idea of the process
i.e you need to have an
observation of the dispersion of the
process. All the different processes will have different methods to compute volatilities based on the underlying assumptions of the process.
Comment: Variance is also associated with the underlying process (population variance vs. sample variance).
Answer: Volatility = Variance^1/2 = Standard Deviation
Answer: By volatility people usually refer to to annualized standard deviation of an asset. For an asset it's usually quoted as a percentage of the asset price (i.e. the return volatility). For a portfolio, it is often quoted in currency units. Variance is the square of the standard deviation. It is usually not quoted directly because it doesn't have an intuitive unit of measure. Instead, it is used in variance decomposition, e.g. the idiosyncratic variance of a portfolio is 6% of the total portfolio variance.
Answer: Suppose X is a random variable representing the returns of an asset having finite mean $\mu$ and variance $\sigma^2>0$.

Variance $\sigma^2$ represents the expected squared deviation of $X$
from $\mu$.  Intuitively, this is a measure of how dispersed returns
are about the mean.  If returns are measured in $\%$, then the units
of variance are $\%^2$.  However, for many people $\%^2$ is difficult
to interpret.
Volatility $\sigma$ is the square root of variance, and has units
$\%$. This change in units makes volatility more interpretable,
furthermore a better tool for analysis.  If we further assume $X$
follows a Gaussian distribution, then $\sigma$ provides many more
additional insights.

Volatility is a tool commonly used in univariate cases, e.g. when speaking of returns of one stock, one bond, or one portfolio.
In the multivariate setting, variance is used, e.g. a covariance matrix, because taking the square root of a matrix is an unecessary additional layer of complexity.
Answer: the only difference between volatility and variance is the square. everything else is bs, as concept that apply to one applies to the other (historical vs implied, blabla)
Comment: i dont know who down voted, but I stand by this comment. there is no difference except the square. if you disagree, please argue.
Comment: Variance has properties that standard deviation does not. For example, variance is additive with stable distributions while standard deviation is not. I didn't down vote btw.
Comment: @strimp099 yes, variance is additive, and is an easier, less error prone way of manipulating additive quantities. but then standard deviation is square root additive. and then standard deviation is multiplicative. bottom line is, the difference is technical, not conceptual.
Answer: Volatility is essentially quadratic variation.  It is a property of sample paths, not probability measures.  In other words, it can be calculated given a single historical path and doesn't depended upon the probability you assign to that path.
Variance, and standard deviation, are functions of the probability you assign to events.
Comment: I think you missed the point, Harpreet. If you take e.g. a standard Brownian motion and an Ornstein-Uhlenbeck (aka Vasicek) process, they both have the same (constant) instantaneous volatility. But their variances are different ; in the BM case the variance grows like time, whereas in the OU case the variance converges rapidly to a finite limit (stationary regime).
Comment: I think variance is called quadratic measure, or double moment, not volatility.
Answer: Variance is a measure of the dispersion and is not bound by any time period. On the other hand, volatility captures the degree of variation of a time series over time. In finance, volatility is a measure of the standard deviation over a certain time horizon (typically annual).
Answer: In quant environments, there are many different things that we call volatility (this is one thing I am quite unhappy, and think we should do better):

The statistical definition, as the standard deviation of the returns (usually logarithmic returns) of a stochastic process
The number you have to put in the Black Scholes formula to get the price you get in the market for a given option (that is the implied volatility)
A parameter of a model (that can be constant, or a function of time, prices, etc) that you have calibrated (from historical or market prices) to describe the dynamics of a process. You might have different volatilities in a single model (in a stochastic volatility model, for example, you have a volatility price, which is a stochastic process itself, and a volatility of volatility). So volatility is model dependent: the same process, describe by different models, will have different volatilities (the one I descibed before, the Black-Scholes implied volatility, is also the simplest example of this)

And probably more I cannot think about right now. As someone said before, there a fixed mathematical definition for variance, but the meaning of volatility is quite subjective


Why do Native Americans think photographs steals their souls?

Question: Native Americans, including some from here, Brazil, are afraid of photos. They don't like it when you take pictures of them because they think that you are stealing their souls.
Why do they think that?
Answer: Well, not many do anymore. I found this on a question on the skeptics stack exchange

[Carolyn J. Marr] illustrates a change in Native Americans' attitudes towards photography from the late 19th to the early 20th century.
At first, many Native Americans were wary of having their photographs taken and often refused. They believed that the process could steal a person's soul and disrespected the spiritual world.
Over time, however, some Native Americans came to cherish photographs as links to ancestors and even integrated them into important ceremonies.
Source: Historical Analysis and Interpretation: Photographs and Symbols

As to why, the indigenous people didn't understand this technology. In their minds, they saw this as magic that could trap a person or an image inside something. Hence the idea that it would steal your soul. This is similar to the ideas of medieval peoples that found alien things magical and often evil (hence the witch hunts, even though they weren't as huge as they seem), I'm sure the reaction of a medieval person to photographs would be very similar.
Comment: I like this answer, but is there a source for the quoted material?  (I don't doubt the veracity, but we like citations wherever possible.)
Comment: Unfortunately, all of those links are dead except one that doesn't have the quote :( but I did manage to find an archived source: http://web.archive.org/web/20091113050027/www.loc.gov/teachers/classroommaterials/connections/pacific/thinking3.html
Comment: @DukeZhou the source can be found on the skeptics stack exchange post
Answer: The question suggests that the notion of photographs 'stealing souls' is primitive and without foundation and what one might expect pre-literate and pre-media societies to misunderstand, I'd like to present a different view.
First, this has a parallel within Western thinking. For example, the Society of the Spectacle by Guy Debord, was a very influential thesis which touches upon exactly this point, suitably interpreted. And this is only underlined today by the pervasiveness of the digital and virtual worlds where the darker dystopic vision is knocking up against the earlier, and it seems, naively utopian picture  sold to everywhere. This is only underlined by the fact of the immense corporate monopoly power wielded by the big five tech giants and which only very recently has been challenged by democratic means - for example, Facebook was fined $4 Billion dollars after the Cambridge Analytica scandal.
What was Cambridge Analytica upto, other than 'stealing souls'? And what was Facebook upto, but facilitating the 'stealing of souls'? All for a price of course to their real clientele - advertisers.
It seems to me, that the Plains Indians were spot on.


What, if any, is the difference between covalently closed circular DNA and plasmids?

Question: Are cccDNA (covalently closed circular DNA) and plasmids the same thing? What about DNA topoisomers?
Comment: Please add some indication that you've performed prior research to try to answer your own question. This is a requirement on Bio.SE. Unfortunately, if you do not, your question will remain closed and possibly deleted.
Answer: As a descriptive term, we can take covalently closed, circular DNA (cccDNA) at face value: any DNA that is circular, with the ends joined by covalent bonds, can be described as cccDNA. Thus, plasmids are a type of cccDNA, but not all cccDNA are plasmids. Textbooks and lecturers describe plasmids as cccDNA for the purposes of DNA topology. This usage also appears in literature. cccDNA can also refer to circularized viral DNA, which is another type of episome. Note that the linked to papers are merely examples of how the term is used, not authoritative definitions.
Comment: What about DNA topoisomers then?
Comment: @JewelJohnson I don't follow you completely with that question. cccDNA can have topoisomers, but so can topologically constrained linear DNA.
Comment: I'm sorry, I thought DNA topoisomers are a different class. My bad.
Answer: The short answer to this question is no, they are not the same thing.
The long answer, however, is in some cases they can be interchangeable. I would like to make the comparison with the coin-just like you can flip it on one side or the other in some(actually, far from always)cases a cccDNA can become a plasmid and the vice versa. cccDNA isn't an entity on its own right-it isn't a component of the cell like a plasmid can be. It is a phase of the replication cycle of some viruses. It can be found in the group I and VII viruses according to the Baltimore classification. This means viruses containing DNA in their virion(the virion is what you would normally consider to be the virus, it is what you see on all those electron microscope pictures on the Internet and is what exists out of the cell as the virus). Some of the members of those groups of viruses have genomes which once inside the cell can replicate using cccDNA, Here is an example of a virus using its circular DNA to replicate:

It uses this form of its genome, because it makes its replication easier since once the enzyme starts to replicate it can do several circles without stoping. It is a replication strategy viruses use, while a plasmid is a mobile genetic element. It means it always needs a cell by definition. Now, it is true plasmids can become viruses and viruses plasmids if genes coding for the proteins needed to construct their virions are present but from a purely definitial point of view they are different things. In reality however it is possible for a plasmid to acquire the genes it needs to become a virus and for a virus to lose them and become a plasmid. Actually this is process often used in recombinant DNA technology to transfer genes from one bacterium to another by viruses because often these plasmids can get included in the cellular genome and include in it the genes they carry. See 3 This is the big difference between a circular viral genome replicating in the cell and a plasmid. Yes, they can look similar in shape but they are not the same as function.
Topoisomers are different forms of DNA which are the same in sequence but differ in their special structure. DNA can have different forms depending on the particular way it folds in space. These different shapes are what is called topoisomers.
Comment: Woah, thanks for the detailed answer, I appreciate your help.


Cheapest Gin in the UK?

Question: Just visiting the good old UK, and discover that gin is so expensive - what and where can I buy a cheap gin in the UK, are there any online stores? Yes I have looked but to no avail.  Thanks guys.....
Comment: all alcohol is expensive in the UK for tax reasons. What do you mean by "cheapest"? How much are you willing to skimp on quality?also would you describe £15 per litre as cheap?
Comment: where about in the UK and what kind of gin you after are you looking for known brads or willing to try anything?
Comment: @Jamie Eltringham Willing to try as my liver is still in tact (I think), and for the sake of my art I will put my liver and soul forward so that others may follow!
Answer: I buy quite a lot of Gin from Amazon and their prices are often cheaper than the main UK supermarkets on a direct match basis, but not against Aldi or Lidl who often sell almost identical products to say Bombay Sapphire, but at a much cheaper price.
Answer: In Scotland we have MUP (minimum unit pricing) which means you cannot sell alcohol for less than 50p per unit of alcohol so an average bottle of gin (38%) cannot be sold for less than £13.88 per 75cl bottle. The rest of the UK doesn't have this law so can be sold as low as cost price so is subject to supplier but can start from as low as £10 per 75cl bottle.
The following link is for a calculator to work out how much you can legally charge for alcohol in Scotland (oh and don't forget the 'no incentive to buy more' no multi-buy offers meaning no buy 2 get 3rd free etc deals).
https://app.calculoid.com/#/calculator/50913
Answer: Just go to a supermarket (the bigger the better and I'd suggest Tesco or Asda) and buy their own brand london dry. It's not nice but it's cheap. If you really don't mind the taste, consider vodka instead as it's often a little bit cheaper and essentially the same stuff without the botanicals.
Tesco gin
Asda gin
Sainsburys gin
You're unlikely to get it for under £14 per L but you might find it on offer occasionally.
Answer: Gordon's London Dry Gin in a clear plastic bottle with a yellow label is the cheapest gin I've ever seen, but it's tasty and potent. You can find it in nearly any liquor store, or online if you're really not up to walk around the corner to a store. Do not confuse it with the Gordon's Gin which is in a green glass bottle with white text. Happy travels!

Cheapest Gin in the UK?


Fujitsu Eternus dx80 storage - Intake temp error

Question: I've managed to configure Fujitsu Eternus dx80 storage (network/RAID group/volume) and from the moment I powered it I get an error message and a warning.
From Event log:
DB010000    DE Intake temperature sensor DE#00 Fault
06A31000    Controller Module#0(iSCSI 1.2GHz) BE Expander Warning

Looking into storage status it says: Intake temp error code 0x0002.
I found info on error in Eternus DX60 S2 Disk Storage System - User's Guide - Operation and it says:
CE intake temperature error or DE intake
temperature error (sensor failure) is detected.
SS: Component subtype
dd: DE-ID ("00" for a controller enclosure)
These messages are notified when "Module was broken" is enabled for Error Severity Level in the event notification setting. They are not notified during maintenance operations.
The other one:
Controller Module#m(zz xxHz) BE Expander
Warning
CM BE Expander error is detected.
SS: Component subtype
MM: CM module ID (10 – 11)
m: CM number (0 – 1)
zz: Model name (FC4G, SAS, or iSCSI)
xx: CPU frequency (1.2GHz)
pp...: Component number
ss...: Serial number
rr...: Version
What is there to do?
Comment: Contact Fujitsu support.
Answer: That looks like a hardware fault. Have your vendor replace the hardware.


"Mysterious" vs. "Perplexing"

Question: Is there a difference between 'mysterious' and 'perplexing' when used with regard to some unexplained phenomena?
Answer: A mystery is something you do not understand, probably because it is (very) difficult to understand based on what you know about it; you may or may not care about this lack of understanding.
If a phenomenon is perplexing, you are emotionally moved because you have come upon a phenomenon that you do not understand: you might be merely very surprised, or possibly annoyed owing to your failure to understand, or (rarely) pleasantly surprised. Perplexity is mostly a stronger version of surprise.
Answer: Mysterious refers to a vague unknown, with an implication that there is something exotic, maybe even dangerous going on. You don't necessarily want to find out what it is.
Perplexing refers to something more specific, something like a puzzle you want to solve.
Answer: Perplexing means "completely impossible to understand", while mysterious means "difficult or impossible to understand, explain, or identify".

This is a perplexing problem.
  His colleague had vanished in mysterious circumstances.
  She is a mysterious woman.

"Mysterious" vs. "Perplexing"


What are the rules regarding airlines picking up passengers at stops in foreign countries?

Question: Suppose Air Canada flies from Vancouver to Santiago with a stop in LAX. I am vaguely of the belief that they are not allowed to pickup Americans who wish to travel from LAX to Santiago, but I'm curious to know more about these rules (if they exist). Also, how they apply (or not) internationally, ie. not just in America.
Answer: The short answer to your first question is that an airline can pick up passengers at an intermediate stop as long as it's previously been agreed by all the countries involved (see below). One example is Singapore Airlines SQ12, which flies SIN-NRT-LAX; many passengers leave and board the aircraft in Tokyo.
More generally, these rules are known as the freedoms of the air but they aren't consistently or fully implemented everywhere and a lot depends on agreements between individual countries. Your first question is about the fifth freedom:

the right to fly between two foreign countries on a flight originating
  or ending in one's own country

As Wikipedia describes, this isn't always straightforward:

The negotiations for fifth freedom traffic rights can be lengthy
  because in practice the approval of at least three different nations
  is required

If an airline stops in an intermediate country to refuel or for other technical reasons but isn't allowed to board or deplane customers, that would be the second freedom:

the right to refuel or carry out maintenance in a foreign country
  without embarking or disembarking passengers or cargo

There's an interesting discussion of fifth freedom flights from a passenger perspective here, and you may get better answers on this topic on travel.SE.
Answer: Another important consideration is each planned OR potential stop for the aircraft (potential meaning a diversion or extra stop for fuel, maintenance, weather or passenger issues such as illness). Any passenger boarding an international flight must have all the appropriate documentation for both entry AND exit for stops even if they are to remain aboard while some other passengers enplane or deplane. The reason is, so that a person is not arrived physically in a destination they have no proper credentials for (EX: a VISA or passport or both)
Comment: Aircraft certainly make planned diversions (and even planned fuel stops) in countries where passengers do not have permission or documentation to enter or exit. For instance, a flight from the US to Europe may divert to Canada for a serious medical emergency, even though everyone on board is unlikely to be admissible to Canada. A flight from San Francisco to Hong Kong may make a planned fuel stop in Taipei due to strong headwinds, even though everyone on board doesn't have documentation to enter Taiwan. The requirements will depend on each country's rules of course.


Why we require high voltage swing at the output of line drivers?

Question: Why we require high voltage swing at the output of line drivers? ( My knowledge in this area is limited and please correct me if am asking an irrelevant question ) just like + or - 15V at the output of a line driver even though the pro audio line voltage swing is only 3.47Vpp ?
Answer: Headroom, mainly.  Your peak voltage is 1.736 volt only when you have a sine wave signal of exactly +4 dBu (0VU on professional equipment).  That never happens in the real world.. 0 on the meters is an averaged level, so with real-world audio signals you will have peaks far higher than 0VU.
A peak of +20 (+24 dBu) would result in 35Vpp output which would clip your +/- 15V rails...
Comment: Then what are the main factors which should be considered to chose a line driver or receiver IC ?
Answer: 600 ohm line driver IC's such as the SSM2142 have supply rails of +/- 18 vdc. The output voltage of this IC is +/- 10 volts into a 600 ohm load. These are often use for long signal runs, such as a 100 foot 'snake' from stage to mixer, or in some studios. This wide voltage helps over come EMI noise and 'ghost' sounds from adjacent channels. The extra high supply voltage is to account for the voltage drop you get on long cable runs to a 600 ohm load. The receiver has balanced 600 ohm inputs that divide the signal by 2, bringing the signal peaks down to +/- 5 volts, well within the range of IC's that use +/- 15 volt supplies. This rather expensive setup is used mostly in studios that record in 24 bit SACD format(120dB dynamic range), the default format (after RSCC) for DVD and Blu-Ray audio tracks. If the recording is a musical event such as a concert, another compressed version is made for 16 bit CD audio(90dB dynamic range). Third party studios will get the rights to make various grades of MP3 versions(14-15 bits dynamic range). For each drop in dynamic range lower voltage IC's can be used. Todays best audio IC's run on 5 volts or even 3.3 volts, mostly for MP3 players, because newer technologies have pushed their noise floor way down, needing less voltage to produce about 60dB to 90dB of dynamic range. The next generation of audio IC's may have 120dB of dynamic range with only 5 volts of power. Then the higher voltages will be found mostly in power amplifiers. The Cerwin-Vega Metron series has supply rails of +/- 130 volts for its 1500 watt mono-block amplifiers.


Remove a content type from search results

Question: How do I go about removing a content type such as webforms from the site search results?
Answer: Drupal's contrib module Search Restrict is a lightweight module that just does the basics - it allows administrators to restrict by role who can search for each content type. It may be a better option than Search configuration in that it only does what you're asking for - restrict content types from search results based on a user's permissions. If you're looking for something more configurable, Search configuration may be the way to go.
From the module's page:

Approach of this module is to re-write the search query, so that
  content is indexed and available as search results to users in role(s)
  that have permissions to view it, but not displayed to other roles.
  Integrates with Apache Solr to exclude results based on the role of
  the person searching.

Simply download, install, and enable the module. Then to restrict (by role) which users can search which content types, edit each Content Type individually and there will now be a 'Search Restrict' section option (below the Display Settings). It allows you to specific, for each content type, which roles can search nodes of that content type.
Answer: You need Search configuration module.
It will allow you to exclude a content type from search results and even particular nodes.
Comment: I have apply search restrictions on content types using this module for specific role and it worked. Can I apply it for admnistrator too?I tried but this did not work for me..


ParametricNDSolve: Fails to differentiate an matrix differential equation

Question: It seems like there is a problem with differentiating a ParametricNDSolve object when the underlying system contains an matrix differential equation.
Create a simple ParametricNDSolveValue object which returns x[2], depending on parameter k.
pfun1 = ParametricNDSolveValue[{x'[t] == -k*x[t], x[0] == 10}, x[2], {t, 0, 10}, k]
ParametricFunction[SequenceForm["<", ">"]]

Now we have the same system but we add a matrix differential equation independent of the state x[t]. Here P[t] should be zero for all t due to the inital condition.
pfun2 = ParametricNDSolveValue[{x'[t] == -k*x[t], x[0] == 10,
P'[t] == P[t], P[0] == {{0, 0}, {0, 0}}}, x[2], {t, 0, 10}, k]
ParametricFunction[SequenceForm["<", ">"]]

We can take out the values for k=0.4.
pfun1[0.4]
pfun2[0.4]
4.49329
4.49329

Now we differentiate the systems and take out the value for k=0.4.
pfun1'[0.4]
pfun2'[0.4]
-8.98658
Thread::tdlen: Objects of unequal length in {{0.},{0.},{0.},{0.},{0.}}+{{0.},{-10.}} cannot be combined. >>*
Experimental`NumericalFunction::nlnum1: The function value {{{0.},{-10.}}+{{0.},{0.},{0.},{0.},{0.}}} is not a list of numbers with dimensions {5} when the arguments are {0.,{0.,0.,0.,0.,10.},{0.4},{{0.},{0.},{0.},{0.},{0.}}}.

The derivative of the ParametricNDSolveValue object seems to fail when there is a matrix differential equation in the system.
Is this a bug?
Comment: pretty bad; I filed this as a bug.
Answer: This was confirmed to be a bug.


What can i do if my boss gives me an image to use and says he has rights for but wont show me that he does?

Question: So my boss buys tons of old images and asks me to use them on some of our work. I notice that these are images of classic/old famous stars and he wants me to make calender's and posters. He says he has rights for them but doesn't want to show them or tells me not to worry about it. not sure what to do in this situation and i have looked online for a legal document that i would like him to sign to protect me. any advice?
Comment: Possible duplicate of [How to handle client requests to violate copyrights?](https://graphicdesign.stackexchange.com/questions/26844/how-to-handle-client-requests-to-violate-copyrights)
Comment: related and relevant: https://graphicdesign.stackexchange.com/questions/26844/how-to-handle-client-requests-to-violate-copyrights
Answer: It doesn't matter.
He's your boss do what you are instructed to do or quit.
Your superior has told you it's okay... you seem to assume you are being lied to... that doesn't matter.
Your boss has informed you of something, it's your job to do what you are asked to do. You are not in any "legal" jeopardy here. If anyone were to get sued for infringement it would be your company not you or your boss personally. If the company were then to seek punitive action against its employees, they'd land on your boss first. If your boss then shirked responsibility and blamed you.. then you may have to defend yourself for your job. That's a far cry from worrying about the initial infringement. And if you think your boss is this untrustworthy... yeah.. find a new job.
Answer: Write a document on either your or your bosses' letterhead, in which you use language similar to this:
"The Client agrees to indemnify and hold harmless Consultant against any and all claims, costs, and expenses, including attorney's fees, due to materials included in the Work at the request of the Client for which no copyright permission or previous release was requested or uses which exceed the uses allowed pursuant to a permission or release."
In which you replace "Client" with  your boss's name, and you replace consultant with your own, and indicate in it that you will be happy to comply with the request for design work executed with provided images with the explicit proviso that he sign two copies of this: one for his records, and one for yours.
I copied this language from another copyright thread on Stack Exchange (see link below) because it's very well done.
How to handle client requests to violate copyrights?
I have a similar clause in my own freelance contract language, and can tell you it's effective.
Be very careful: as already said in a previous answer, folks who feel free and easy playing fast and loose with copyright in one arena (scanned physical images) often feel just as free and easy ignoring IP (Intellectual Property) rights in other venues. Review your contract with your boss, looking for language related to IP: if there's no direct statement about ownership of works created, and there isn't the phrase "work for hire", then you own copyright to anything you create whilst working for said boss. If there is language about IP, or there is the "work for hire" phrase, your Boss may own all IP rights for work you execute. This all matters not only for how and what you get paid both now and later, but also for assignment of liability in case later someone gets sued for IP violation.
Caveats: I'm not a lawyer or solicitor, and do not play one on TV: I'm a freelancer of many years standing; my reply is based on my limited understanding of US IP law from my limited point of view as a freelancer.
Comment: @Jay: well, this or [any of the other answers](https://graphicdesign.stackexchange.com/help/someone-answers) ... Also, as a new member you probably want to read the [tour] some time soon. Welcome to Graphic Design SE!
Comment: Got it thank you. I have been looking online for anything i can use that makes this exact statement. you have no idea how helpful this is. all i was able to fine are liability ones that don't help as much.
Answer: First - save the mail, print it with a date, put company stamp on it, just keep it for later use.
Second - check your contract. In mine they state that all materials are provided by company as well as all what I create belong to them.
Third - does your boss want to use exactly the photo as in likeness of a star? Like this

Or like the one used in Charlie Chaplin Wikipedia page?
You may need to educate your boss on law and say that buying a physical copy of a photo don't give you rights to use it/make money on it/ or even duplicate.
In the end you may think about changing jobs. A boss who infringe copyright on purpose may act the same way toward you and later use you as a scape goat.
Comment: So what he does is buy vintage images with stamps of the year on the back on ebay. He asks me to come in and use that image to make changes or print posters for him or commercial use later. I have avoided doing any of it but he mentioned it yesterday on my progress. I have talked to him about copyrights but he tells me not to worry about it that he does have rights, but when i ask to see the rights to i know what i can and can not do he just says i have all rights.
Comment: and yes just like this image its just a physical image he wants me to scan.
Answer: Any opinion on this forum is just an opinion, not a legal advice.
Are you on the legal department?
If you are, then, regardless he/she is your boss ask for the proper documentation and do your job.
If you are not, well he/she is your boss. Just design the proper stuff and prepare your next job/backup plan when the legal owners sue the company you work in.
Depending on the country they can get away with it or not. How to manipulate a photograph so that it becomes original artwork?
Try to send a memo to your legal department if you have one warning them to check the necessary permissions.
Comment: This sounds a lot like i was "[superior orders defence](https://en.wikipedia.org/wiki/Superior_orders)" There is no way that it actually works
Comment: im in California,all i really want to know is if i can have a written statement that can protect me so i can use or how much at fault will i be if i just do what he says. i just started to work in graphic design and im learning as i go. i don't want something like this to bite me in ass later in the future and prevent me form furthering my career.
Comment: Short answer: depends on who/how much money/how dedicated anyone filing IP claims are to getting a resolution.

My take as a designer is that one should avoid the risk; either by having such a caveat / disclaimer as already described, or by avoiding doing work you have reason to believe is in violation of another's IP rights.

Morally too: if someone played fast and loose with your work, how would you feel about it, and how far might you go legally to defend it?

https://en.wikipedia.org/wiki/Copyright_infringement
Answer: First question. Are you employed by your boss and the company? Not 'freelance' but rather a full-time employee?  If full-time then the fault would technically be on the company but you can possible be a fall guy and get fired. If freelance, then you can possible be sued as well.
Second are you documenting the conversation via email with him in regards to asking him if the images are legal to us and his responses? If you are, at least you have a little proof in the event they try to put on you. You're boss will totally cover his own ass if push came to shove. The email chain can stop that in its tracks.
This is by no means legal advice, just wisdom from previous jobs. Good luck!
Comment: yes im employed by my boss and most of the exchanges are face to face, but i will start with the emails because i can already see him covering his ass. and thank you for the advice i really appreciate it. this is my fist job as a designer so its an experience.