HackerTrans
TopNewTrendsCommentsPastAskShowJobs

amavect

93 karmajoined 2 वर्ष पहले

comments

amavect
·13 घंटे पहले·discuss
You sound like you believe in philosophical skepticism. Tell me: can a map ever properly describe the territory? When would a map properly describe the territory? (Can a theory ever properly describe reality? What does a theory need to properly describe reality?)

We know that universal Turing machines can emulate other Turing machines. Weirdos like Wolfram believe that a universal Turing machine can emulate reality. In a quick skim of this lecture series, the presenter doesn't talk about that, rather he just calls computation a scientific principal (universal and fundamental in the sense of physical laws, not fundamental in the sense of emulating reality on a computer).
amavect
·18 घंटे पहले·discuss
I included that to try to explain the symbol soup that correctly encodes the preconditions (the ∀ lines). I intended that to mean "I need to make sure that y+x doesn't overflow", even that unsigned arithmetic cannot express that precondition in that way, as you point out. From there, derive y ≤ INT_MAX-x as the actual precondition for unsigned addition. I forgot that "ensure" actually means something in some programming languages, sorry for the confusion.

More simply put, unsigned addition needs to check that y+x doesn't overflow, while signed addition needs to check that y+x doesn't overflow and doesn't underflow. So, unsigned arithmetic has a simpler precondition that would win a technical debate on whether to use signed or unsigned arithmetic, but since most programming languages lack theorem proving, signed arithmetic wins on the small integer assumption.
amavect
·19 घंटे पहले·discuss
Pedantically, that doesn't properly invert post-increment in the loop step. It decrements one extra time. If I need to use the loop index after the loop, then decrementing in the condition would cause problems.

  size_t i = size;
  while(i-- > 0){
    // loop body, possibly break
  }
  use(i); // i wraps below 0

  size_t i = size;
  while(i > 0){
    i--;
    // loop body, possibly break
  }
  use(i); // i doesn't wrap
Practically, i leaves the for-loop scope, so most never encounter this problem.
amavect
·कल·discuss
I believe the main issue lies in most programming languages lacking theorem proving capabilities to prove the safety of integer operations.

The safety conditions for unsigned arithmetic:

  Ensure y+x ≤ INT_MAX.
  If x ≤ UINT_MAX-y, then x+y evaluates correctly:
  ∀x∀y(x ≤ UINT_MAX-y → ∃z(z = y+x))

  Ensure y-x ≤ INT_MAX.
  If x≤y, then y-x evaluates correctly:
  ∀x∀y(x≤y → ∃z(z = y-x))
The safety conditions for signed arithmetic:

  Ensure INT_MIN ≤ y+x and y+x ≤ INT_MAX.
  To avoid overflow or underflow, first compare x to 0.
  In the case x≤0, INT_MIN-x cannot underflow, and y+x cannot overflow. If y compares greater than INT_MIN-x, then y+x evaluates correctly.
  In the case 0≤x, then INT_MAX-x cannot overflow, and y+x cannot underflow. And if y compares less than INT_MAX-x, then y+x evaluates correctly.
  ∀x∀y((x≤0 ∧ INT_MIN-x≤y)∨(0≤x ∧ y≤INT_MAX-x) → ∃z(z = y-x))

  Ensure INT_MIN ≤ y-x and y-x ≤ INT_MAX.
  To avoid overflow or underflow, first compare x to 0.
  In the case 0≤x, INT_MIN+x cannot underflow, and y-x cannot overflow. If y compares greater than INT_MIN+x, then y-x evaluates correctly.
  In the case x≤0, INT_MAX+x cannot overflow, and y-x cannot underflow. If y compares less than INT_MAX+x, then y-x evaluates correctly.
  ∀x∀y((0≤x ∧ INT_MIN-x≤y)∨(x≤0 ∧ y≤INT_MAX+x) → ∃z(z = y-x))
The programmers that prefer unsigned arithmetic intuitively feel the greater simplicity compared to signed integers, but without any theorem proving, I agree that your assumption of small integers strongly supports signed integers.
amavect
·कल·discuss
Post-increment inverts to pre-decrement, but for-loops don't support proper syntax sugar for pre-decrement.

  for(size_t i = 0; i < size; i++){
    // loop body
  }
  for(size_t i = size; i > 0;){ i--;
    // loop body
  }
amavect
·19 दिन पहले·discuss
Hah, I can use this to give decibels an actual unit.

  dB_P = log(10)/10
  dB_F = log(10)/20
  log(10*V) = log(V) + 20*dB_F  // the level of 10 V equals 20 dB more than the power level of 1 V.

  SPL = 20*10^-6 * Pa
  hearing_damage = log(SPL) + 90*dB_F  // hearing damage occurs over 90 dB_F above SPL (neglecting A-weighting)
  pow(hearing_damage) = pow(log(SPL) + 90*dB_F))
  pow(hearing_damage) = pow(log(SPL) + 90*log(10)/20))
  pow(hearing_damage) = SPL*pow(90*log(10)/20))
  pow(hearing_damage) = SPL*31622.7766  // the pressure of hearing damage occurs above 31622 times SPL
  pow(hearing_damage) = 0.632455532 Pa  // the pressure of hearing damage occurs above 0.632 Pa
Very helpful!! Imagine combining the goofy list of decibel suffixes into a uniform notation. Write the logarithm first so the + or - stays in the same spot.

  log(reference_unit) + value*dB_F (or dB_P)
  log(reference_unit) - value*dB_F (or dB_P)
https://en.wikipedia.org/wiki/Decibel#List_of_suffixes
amavect
·19 दिन पहले·discuss
>You might ask: if we have a baseless logarithm log(N), do we also have a “baseless exponential”?

Sure we can, with some naive algebra. If we can take log(x,base) and drop the base, then we can also take pow(base,x) and drop the base. Since bits=log(2), then pow(bits)=2. You can probably connect it to the reverse of things, like integrals.

Also, for fun, I'll play with some notation tricks.

  log(freq) = pitch
  freq = pow(pitch)
  octave = log(2)

  400*Hz = 100*Hz*4  // the frequency 400 Hz equals 4 times 100 Hz
  log(400*Hz) = log(100*Hz) + log(4)
  log(400*Hz) = log(100*Hz) + 2*log(2)
  log(400*Hz) = log(100*Hz) + 2*octave
  log(400*Hz) = log(100*Hz) + 2*octave  // the pitch of 400 Hz equals 2 octaves above the pitch of 100 Hz

  cent = log(2)/1200
  A4 = log(440*Hz)
  B4 = A4 + 200*cent  // the pitch B4 equals 200 cents above A4
  B4 = log(440*Hz) + 200*log(2)/1200
  B4 = log(440*Hz) + log(2^(2/12))
  B4 = log(440*Hz * 2^(2/12))
  pow(B4) = 493.883 Hz  // the frequency of B4 equals 493.883 Hz
I like the intuition that baseless logarithm notation gives, and it also avoids needing to choose a specific reference point. I can also directly calculate by choosing an arbitrary base:

  pow(log(440*Hz) + 200*log(2)/1200)
  exp(ln(440) + 200*ln(2)/1200)
amavect
·25 दिन पहले·discuss
That graph ends in 2015. The 2025 graph flattens. Looks like we can explain this trend by the economic development of East Asia.

https://en.wikipedia.org/wiki/File:Total_population_living_i...

https://en.wikipedia.org/wiki/Extreme_poverty
amavect
·27 दिन पहले·discuss
Perceptible latency goes well below 10 ms. https://www.youtube.com/watch?v=vOvQCPLkPt4
amavect
·पिछला माह·discuss
>The tone is generated using two sawtooth oscillators

I interpreted "acoustically-accurate" to mean physically modeled in some way. Filtered sawtooth makes a simple brass-like timbre, but 80% still sounds synthetic.

Really neat anyways, thanks for sharing.
amavect
·पिछला माह·discuss
Thinking about this more, dithering requires negative values to cancel out when adding. Works for audio, but color doesn't have negative numbers.
amavect
·पिछला माह·discuss
I agree. Additionally, both 0.0 and 1.0 don't really exist for dithered signals, so a byte should map to [0.5, 255.5] before division by 256. This also solves the signed integer asymmetry, as a signed byte maps to [-127.5, 127.5] before division by 128. I wonder if audio DSP folks have done this already.
amavect
·2 माह पहले·discuss
Optimizing for "radix economy", an argument that attempts to balance the digit cost against the choice of base. When the cost per digit equals the base, e turns out optimal. But when the cost per digit equals the digit's information content (bit, trit, etc; 1 trit = log(3,2) bits), all bases turn out about equal.

https://en.wikipedia.org/wiki/Optimal_radix_choice
amavect
·2 माह पहले·discuss
I have an axe to grind. Radix economy makes a shallow argument when calculating the wrong per-digit information cost.

I need some functions to show what I mean. Calculate logarithms, calculate the number of digits, and convert a base-n unit of information into base-2 units of information. Finally, calculate the information cost: the number of digits, times the information needed per digit.

  import ln, floor
  define log := (num,base) -> ln(num) / ln(base)
  define digits := (num,base) -> floor(log(num,base) + 1)
  define tobits := (base) -> log(base,2)
  define infocost := (num,base) -> digits(num,base) * tobits(base)
  define infocost_wikipedia := (num,base) -> digits(num,base) * base
  define infocost_tbwtc := (num, base) -> (digits(num,base) - 1) * tobits(base) + tobits(base- 1)
https://www.desmos.com/calculator/1wfdtsuaav

I define a logarithmic per-digit information cost, following information theory. For example, 1 trit = log(3,2) bits. This results in no advantage for any base (in which case, choose base 2).

Wikipedia uses a linear per-digit information cost equal to the base. This holds when communicating options takes linear time (Wikipedia's example of a phone menu). This results in advantage for base e (in which case, choose base 3).

The video "The Best Way To Count" uses the logarithmic digit cost, and also notes that the leading digit carries less information (it excludes 0, like a IEEE floating point mantissa). This results in advantage for base 2.

Therefore, know the context to apply the right cost analysis!

https://en.wikipedia.org/wiki/Optimal_radix_choice

https://en.wikipedia.org/wiki/Talk:Optimal_radix_choice#Why_...?

https://en.wikipedia.org/wiki/Talk:Optimal_radix_choice#Bina...

https://youtu.be/rDDaEVcwIJM?t=701 timestamp 11:41
amavect
·2 माह पहले·discuss
A way to exit the adversarial process is by ending the separation between owners and workers, through things like worker cooperatives, employee ownership, and workplace democracy.
amavect
·2 माह पहले·discuss
I imagine an OS where the system remembers to keep permanent permission for a program to manage its own files. An app data folder would work. The system should pass the capability on program start.

I also imagine a system where graphical programs must call a trusted system file picker to receive a fd. Receiving the capability grants permission. Ideally, Chrome could export browser history to a file, but we live in a fallen world. In any case, an alternative browser must request access through the system file picker, selecting an exported file or selecting the Chrome app data folder. It trades automatic import with user selection. The user has ultimate power, and programs make noise when doing such requests.

Please forgive me that I don't know Android system architecture. Searching tells me something about the Storage Access Framework, but I don't know if that truly meets what I describe.
amavect
·2 माह पहले·discuss
That condition usually doesn't hold in practice. Very few programs have a reason for reading browser history or cookies. Excel has no purpose accessing the Notepad++ appdata folder. Not all-or-nothing.
amavect
·2 माह पहले·discuss
I too would like an OS where called programs don't need to call open() on strings. The shell already has <input >output redirection, but hamstrung so few ever use them. So many programs recreate the functionality with -i -o in some manner to make up for the flaws (read multiple inputs, avoid creating a file on error). Graphical programs could request a fd from a trusted file picker instead of requesting a string to call open() immediately after. That just scratches the surface, so much security and convenience to gain.
amavect
·2 माह पहले·discuss
One of my friends had his credentials stolen from a trojan infostealer masquerading as a video game, sent from a rando who he mistakenly trusted. If only it had to request user permission to access files outside of its folder. There's a spectrum between full access and full lockdown.
amavect
·2 माह पहले·discuss
Of course, proper systems analysis would really require modelling and simulation.

Thanks for chatting.