text:
# Is it possible to generate a key from a hash function, being the key larger than the hash function digest output without spliting the seed?

Let's suppose I have a 2MB photo and I want to generate a key from it, and the key should have 2048-bits of size.

A hash function such as SHA3-512 would not deliver a key with with the desired strength.

Is it possible to generate such a key with a hash function having the hash function a maximum digest output/internal state smaller that it, without having to split the file in many parts?

I have been thinking on hashing the file using chaining, as described here: https://crypto.stackexchange.com/a/99579/89581

But I don't know if it would serve for this purpose.

If $$F$$ is the file, and $$H$$ the 512-bit hash, three good options to build the 2048-bit key are

1. $$key = H(\mathtt{00}\mathbin\|F)\mathbin\|H(\mathtt{01}\mathbin\|F)\mathbin\|H(\mathtt{02}\mathbin\|F)\mathbin\|H(\mathtt{03}\mathbin\|F)$$

2. $$key = H(F\mathbin\|\mathtt{00})\mathbin\|H(F\mathbin\|\mathtt{01})\mathbin\|H(F\mathbin\|\mathtt{02})\mathbin\|H(F\mathbin\|\mathtt{03})$$

3. $$key = H(H(F)\mathbin\|\mathtt{00})\mathbin\|H(H(F)\mathbin\|\mathtt{01})\mathbin\|H(H(F)\mathbin\|\mathtt{02})\mathbin\|H(H(F)\mathbin\|\mathtt{03})$$

where $$\mathtt{00}$$, $$\mathtt{01}$$, $$\mathtt{02}$$, $$\mathtt{03}$$ are one-byte bytestrings.

In all the options, the whole entropy of $$F$$ goes into each of the 4 output segments, and one can't find a portion of the output from the other outputs with partial knowledge of $$F$$ (or of it's hash). In the first option, entering the 4 bytes as prefixes maximizes the diffusion. The second and third options allow faster implementation for large $$F$$, and are safe enough.

The practitioner will use the SHA-3 Extendable-Output Function $$\operatorname{SHAKE256}(F,2048)$$, which is a pre-engineered method to do the job.

As noted in comment: If we are low on entropy in $$F$$, then we want a purposely slow entropy/key-streching hash function, as used to turn passwords into key. That could be Argon2. Like SHAKE256 it has a tagLength parameters that controls the output size (but it's in bytes, thus we want to set it to 256 for 2048-bit output).

For methods 2, 3, SHAKE256 and Argon2, the actual entropy in the output has a limit sizably lower than 2048 bit (more like 512 bit), even if there is ample entropy in $$F$$. This is not a practical security issue.

• Maybe Argon2 is a better candidate due to Key stretching though it is limited to 512, too Oct 14, 2022 at 10:22
• @kelalaka This is the exact reason why I wouldn't use Argon2 to produce a key larger than its internal state. Oct 14, 2022 at 17:33
• @fgrieu I got, but if it's only adding 01, 02, 03 and so on, chaining would work well, am I right? crypto.stackexchange.com/a/99579/89581 Oct 14, 2022 at 19:07
• @phantomcraft : yes. We can replace 00 with a fixed string (including empty), and the other 01 02 03 with the previous 512-bit output segment. The risk of entering a short cycle remains small.
– fgrieu
Oct 14, 2022 at 19:22
• @phantomcraft: 00, 01, 02, 03 can be replaced by any distinct byte strings. 777 will do if it's the bytestring with 3 bytes 37 37 37.
– fgrieu
Oct 15, 2022 at 5:09

The concept you're looking for is a key derivation function. A key derivation function takes one or more inputs and produces a stream of bytes such that:

• The output is pseudorandom: given part of the output, it's infeasible to guess the rest, unless you manage to find the inputs.
• Given the output, it's infeasible to guess the input except by trying candidates and comparing the given output with output from the candidates.
• Outputs for different inputs are independent: knowing the output for some inputs doesn't help to guess the output for a different input.

Some key derivation functions have a limited output size, while others can deliver practically unlimited output.

It's possible to use a hash function to construct a key derivation function. In fact, that's a very popular design. The basic idea is to concatenate the inputs together to form a string S, and emit an output stream of the form H(S || 0) || H(S || 1) || H(S || 2) || … where || is string concatenation and 0, 1, etc. are string encodings of the integer. As always with cryptography, you need to get the details right, and I won't go into all the details here. (With this basic idea, the main pitfall is that you must make the concatenations unambiguous.)

HKDF is a popular hash-based key derivation function which is based on this principle, with extra scaffolding to protect against some potential weaknesses of the underlying hash, and with an interface tailored for one secret input and two non-secret inputs (that's a pretty common interface). Beware that HKDF does have one pitfall: it applies some preprocessing to the salt that maps different salt values to the same intermediate value; to avoid this, always use salt of the same size for a given secret.

Do not use hash chaining: that's a bad way of constructing a key derivation function from a hash. If the output is H(S) || H(S||H(S)) || H(S||H(S||H(S))) || …, then it's possible to reconstruct the whole output from the first n bytes where n is the length of the hash. How bad this is depends on how you're using the output material, but even if it's not completely broken, it's less secure than it could be with the same level of complexity and performance.

If you have access to SHA3, you probably have access to SHAKE, which is a family of two extendable output functions (SHAKE128 and SHAKE256). An extendable output function can be used as a key derivation function whose input is a single string.

Note that a photo is rarely a good input for a key derivation. Trivial changes to the photo, such as a reencoding, compressions, changing metadata, etc. will make it completely different. So you need to save the exact photo file. And since you need to have this exact file, it doesn't really matter that it represents a photo. You might as well save the key. The only advantage of a photo is that it's more discreet than a random-looking file if you're under casual surveillance. (But as soon as someone takes interest in your device, they'll likely make a copy of all your files including that photo, so you should assume they have the key anyway.)

To protect against an adversary who obtains your photo library but doesn't know which photo you're using as a key, you can use key stretching. A key stretching function is a key derivation function that is constructed to be slow. The idea is that the slowness hurts someone trying all candidate inputs by brute force more than it hurts someone who knows the correct input. Some key stretching functions offer functionally unlimited output; many don't. If you pick one that doesn't, just use its output as the input to an ordinary key derivation function.

Key stretching is only a limited protection. In this scenario, it won't help much. For example, if it's acceptable for you that reconstructing the key takes 1s, and you want the adversary to spend a day of computer time (assuming their computer isn't more powerful than yours), then your library must have at least 86400 photos (so 173 GB of photos at 2 MB each).

As a final note, 2048 bits of key material is a weird size. Symmetric cryptography doesn't need keys that big. Some asymmetric cryptography uses larger private keys, but then the key is either even larger than 2048 bits or else it has some mathematical structure. For example, you don't get a 2048-bit RSA key by just taking a random 2048-bit string: you need a complex process that can consume much more than that from a pseudorandom generator. Of course you can use the 2048 bits as a seed for the pseudorandom generator, but then we're back to my earlier consideration about symmetric cryptography: a 256-bit seed would be plenty enough.

• You can think I'm crazy, but I really need a huge key size (in my case Kuznyechik with secret S-boxes), 2048-bits was just an example. But if the key size is bigger that the internal state or digest output size of underlying hash function?. Can HKDF using HMAC-SHA256 emit a 2048-bit key if the size of internal state of SHA-256 is only 256-bits? Oct 14, 2022 at 23:00
• Just for curiosity, you wrote H(S || 0) || H(S || 1) || H(S || 2) || … Can S be the same for all hashings? Oct 14, 2022 at 23:04
• @phantomcraft The internal state can be exponentially shorter than the output. That's the whole point of symmetric cryptography: you go from protecting a small key to a very large amount of data. Yes, S is the same each time. Oct 15, 2022 at 10:20
• Ah, I got. So, this user that replied one of my question about internal state of Argon2 is wrong? ==> crypto.stackexchange.com/a/96583/89581 Oct 15, 2022 at 17:45
• @phantomcraft No, it's talking about different things. $n$-bit security means that it would take $2^n$ attempts to crack something by brute force. Once $2^n$ becomes larger than humanly available computing power, the notion becomes purely theoretical. 128 bits of security protects against an NSA-level adversary willing to spend about as long as the universe has existed running current-era computers. 256-bit security protects against quantum computers, in case they turn out to be possible. A SHA256-based KDF on a seed with 256 bits of entropy gives you 256 bits of security for any output size. Oct 15, 2022 at 18:04


text:
G01 Chapter Contents
G01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG01SFF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

G01SFF returns a number of lower or upper tail probabilities for the gamma distribution.

## 2  Specification

 SUBROUTINE G01SFF ( LTAIL, TAIL, LG, G, LA, A, LB, B, P, IVALID, IFAIL)
 INTEGER LTAIL, LG, LA, LB, IVALID(*), IFAIL REAL (KIND=nag_wp) G(LG), A(LA), B(LB), P(*) CHARACTER(1) TAIL(LTAIL)

## 3  Description

The lower tail probability for the gamma distribution with parameters ${\alpha }_{i}$ and ${\beta }_{i}$, $P\left({G}_{i}\le {g}_{i}\right)$, is defined by:
 $P Gi ≤ gi :αi,βi = 1 βi αi Γ αi ∫ 0 gi Gi αi-1 e -Gi/βi dGi , αi>0.0 ,  βi>0.0 .$
The mean of the distribution is ${\alpha }_{i}{\beta }_{i}$ and its variance is ${\alpha }_{i}{{\beta }_{i}}^{2}$. The transformation ${Z}_{i}=\frac{{G}_{i}}{{\beta }_{i}}$ is applied to yield the following incomplete gamma function in normalized form,
 $P Gi ≤ gi :αi,βi = P Zi ≤ gi / βi :αi,1.0 = 1 Γ αi ∫ 0 gi / βi Zi αi-1 e -Zi dZi .$
This is then evaluated using S14BAF.
The input arrays to this routine are designed to allow maximum flexibility in the supply of vector parameters by re-using elements of any arrays that are shorter than the total number of evaluations required. See Section 2.6 in the G01 Chapter Introduction for further information.

## 4  References

Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth

## 5  Parameters

1:     LTAIL – INTEGERInput
On entry: the length of the array TAIL.
Constraint: ${\mathbf{LTAIL}}>0$.
2:     TAIL(LTAIL) – CHARACTER(1) arrayInput
On entry: indicates whether a lower or upper tail probability is required. For , for $\mathit{i}=1,2,\dots ,\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{LTAIL}},{\mathbf{LG}},{\mathbf{LA}},{\mathbf{LB}}\right)$:
${\mathbf{TAIL}}\left(j\right)=\text{'L'}$
The lower tail probability is returned, i.e., ${p}_{i}=P\left({G}_{i}\le {g}_{i}:{\alpha }_{i},{\beta }_{i}\right)$.
${\mathbf{TAIL}}\left(j\right)=\text{'U'}$
The upper tail probability is returned, i.e., ${p}_{i}=P\left({G}_{i}\ge {g}_{i}:{\alpha }_{i},{\beta }_{i}\right)$.
Constraint: ${\mathbf{TAIL}}\left(\mathit{j}\right)=\text{'L'}$ or $\text{'U'}$, for $\mathit{j}=1,2,\dots ,{\mathbf{LTAIL}}$.
3:     LG – INTEGERInput
On entry: the length of the array G.
Constraint: ${\mathbf{LG}}>0$.
4:     G(LG) – REAL (KIND=nag_wp) arrayInput
On entry: ${g}_{i}$, the value of the gamma variate with ${g}_{i}={\mathbf{G}}\left(j\right)$, .
Constraint: ${\mathbf{G}}\left(\mathit{j}\right)\ge 0.0$, for $\mathit{j}=1,2,\dots ,{\mathbf{LG}}$.
5:     LA – INTEGERInput
On entry: the length of the array A.
Constraint: ${\mathbf{LA}}>0$.
6:     A(LA) – REAL (KIND=nag_wp) arrayInput
On entry: the parameter ${\alpha }_{i}$ of the gamma distribution with ${\alpha }_{i}={\mathbf{A}}\left(j\right)$, .
Constraint: ${\mathbf{A}}\left(\mathit{j}\right)>0.0$, for $\mathit{j}=1,2,\dots ,{\mathbf{LA}}$.
7:     LB – INTEGERInput
On entry: the length of the array B.
Constraint: ${\mathbf{LB}}>0$.
8:     B(LB) – REAL (KIND=nag_wp) arrayInput
On entry: the parameter ${\beta }_{i}$ of the gamma distribution with ${\beta }_{i}={\mathbf{B}}\left(j\right)$, .
Constraint: ${\mathbf{B}}\left(\mathit{j}\right)>0.0$, for $\mathit{j}=1,2,\dots ,{\mathbf{LB}}$.
9:     P($*$) – REAL (KIND=nag_wp) arrayOutput
Note: the dimension of the array P must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{LG}},{\mathbf{LA}},{\mathbf{LB}},{\mathbf{LTAIL}}\right)$.
On exit: ${p}_{i}$, the probabilities of the beta distribution.
10:   IVALID($*$) – INTEGER arrayOutput
Note: the dimension of the array IVALID must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{LG}},{\mathbf{LA}},{\mathbf{LB}},{\mathbf{LTAIL}}\right)$.
On exit: ${\mathbf{IVALID}}\left(i\right)$ indicates any errors with the input arguments, with
${\mathbf{IVALID}}\left(i\right)=0$
No error.
${\mathbf{IVALID}}\left(i\right)=1$
 On entry, invalid value supplied in TAIL when calculating ${p}_{i}$.
${\mathbf{IVALID}}\left(i\right)=2$
 On entry, ${g}_{i}<0.0$.
${\mathbf{IVALID}}\left(i\right)=3$
 On entry, ${\alpha }_{i}\le 0.0$, or ${\beta }_{i}\le 0.0$.
${\mathbf{IVALID}}\left(i\right)=4$
The solution did not converge in $600$ iterations, see S14BAF for details. The probability returned should be a reasonable approximation to the solution.
11:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{ or }1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{ or }1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{ or }\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
On entry, at least one value of G, A, B or TAIL was invalid, or the solution did not converge.
${\mathbf{IFAIL}}=2$
On entry, $\text{array size}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{LTAIL}}>0$.
${\mathbf{IFAIL}}=3$
On entry, $\text{array size}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{LG}}>0$.
${\mathbf{IFAIL}}=4$
On entry, $\text{array size}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{LA}}>0$.
${\mathbf{IFAIL}}=5$
On entry, $\text{array size}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{LB}}>0$.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.

## 7  Accuracy

The result should have a relative accuracy of machine precision. There are rare occasions when the relative accuracy attained is somewhat less than machine precision but the error should not exceed more than $1$ or $2$ decimal places.

## 8  Further Comments

The time taken by G01SFF to calculate each probability varies slightly with the input parameters ${g}_{i}$, ${\alpha }_{i}$ and ${\beta }_{i}$.

## 9  Example

This example reads in values from a number of gamma distributions and computes the associated lower tail probabilities.

### 9.1  Program Text

Program Text (g01sffe.f90)

### 9.2  Program Data

Program Data (g01sffe.d)

### 9.3  Program Results

Program Results (g01sffe.r)

format: plain


text:
# Beamer does not restore roman style for emph inside emph

It seems that \em and \emph do not alternate between itshape and normal shape. How can this be restored?

Test case:

\documentclass{beamer}
\begin{document}
\frame{\em abc \emph{def \emph{ghi} jkl} mno}
\end{document}

With "article" it works as expected.

This is beamer 2011/09/12 development version 3.20.

-
Almost certainly this is one of the many things that Till didn't allow for when writing beamer, I guess here as it likely use cases are pretty rare. –  Joseph Wright Jan 5 '13 at 9:47
Before anything else, remember that a change between rm and it shapes isn't as visible on a presentation as on a paper, that's why beamer defines the command \alert. About your problem, nesting emph commands should be used to over-emphasize a part of text, not to make the text back to its default level of emphasization, so defining a second emphasize command for that purpose would be a solution. In case what you want is simply to come back to the default level, the natural way of doing so is to close the macro and open a second one. –  T. Verron Jan 5 '13 at 10:00
The problem is not on the use of \em and \emph. It is just for nested \emphs. –  Guido Jan 5 '13 at 10:02
@JosephWright I frequently rely on nested \emphs. –  Marc van Dongen Jan 5 '13 at 10:49
@T.Verron Creating a second command defeats the purpose. If, for some reason, you decide to remove the top-level emphasis command, you have to change the status of the second-level command to top-level command. If the second-level command is visible, this may not be a problem and you may spot it. However, if it's the result of a macro call, you may very well not notice it. –  Marc van Dongen Jan 5 '13 at 10:51

beamerbaseoverlay.sty contains

\newcommand<>{\emph}[1]{{\only#2{\itshape}#1}}

so \emph only produces italic shape. However, \em is not changed and you can write

\documentclass{beamer}

\begin{document}
\frame{\em abc {\em def {\em ghi} jkl} mno}
\end{document}

giving

which produces the shapes you expect, but is not overloaded with the overlay options beamer provides in its modified \emph. Theses options mean that you can write \emph<3>{text} to print the text on all slides but italise it only on slide 3. If you are willing to forego this functionality and just want \emph to behave like {\em ...} then you can put

\renewcommand<>{\emph}[1]{{\em #1}}

in your preamble. Added: As you comment, the above may be combined to get the overlay behaviour via:

\renewcommand<>{\emph}[1]{{\only#2{\em}#1}}

As other posters note, often one would prefer to use beamer commands such as \alert for extra contrast in presentations.

-
Thanks, I have chosen to reimplement \emph with \renewcommand<>{\emph}[1]{{\only#2{\em}#1}} because (i) I want \emph and I consider it a bug that Beamer turns the feature off without saying, and (ii), yet I want to use the <> features. –  akim Jan 6 '13 at 11:09


text:
SMS scnews item created by Daniel Hauer at Thu 24 Mar 2016 1347
Type: Seminar
Distribution: World
Expiry: 29 Mar 2016
Calendar1: 29 Mar 2016 1400-1500
CalLoc1: AGR Carslaw 829
CalTitle1: The existence of solutions and of invariant measures to stochastic Navier-Stokes equations in unbounded domains
Auth: dhauer@pdhauer.pc (assumed)

# PDE Seminar: Zdzislaw Brzezniak -- The existence of solutions and of invariant measures to stochastic Navier-Stokes equations in unbounded domains

Dear friends and colleagues,

on Tuesday 29 March, 2-3pm 2016 Zdzislaw Brzezniak (University of York, UK) is giving a
talk in the PDE Seminar on

"The existence of solutions and of invariant measures to stochastic Navier-Stokes
equations in unbounded domains"

An abstract is available at

http://www.maths.usyd.edu.au/u/PDESeminar/abstracts16/brzezniak.xhtml

The talk is in Carslaw, level 8, Rm 829 (AGR) at the University of Sydney.

Everybody is invited to attend the talk and take part at the discussion afterwards in
Carslaw Common Room 727 on level 7.

Kind regards,

Daniel D and Daniel H

P.S: If you know suitable speakers or want to give a talk yourself, please let us know.

If you are registered you may mark the scnews item as read.
School members may try to .


text:
J. Peterson's Writing About Electronics, Reviews, 3D Modeling, etc.

## The Fit Testing Block

### How Accurate is Your 3D Print?I Tested Nine Services to Find Out

Decades ago, if you wanted to create your own printed circuit board, you had to make it yourself. This was quite involved – you bought a copper plated blank board, created the circuit patterns on it with resist (tape, rub-on patterns, or Sharpie), then dunked it in noxious chemicals to etch the unmarked copper away. It was also up to you to drill the holes. Then you tracked down problems because too much (or not enough) copper was dissolved, opening or shorting your circuits. It was messy, tedious and frustrating.

Here in the future, all those problems are solved. You design the board in a CAD program, then the Internet whisks the design to a far-off fabrication house. A few weeks later your boards arrive, perfectly manufactured with solder masks, silk-screen markings, plated through holes – things you’ll never get making them at home.

I do some amount of 3D printing, but I have no desire to own a 3D printer. Running your own 3D printer still feels like those early days of homemade circuit boards. The tedious details of bed leveling and heating, getting the model to stick in place, support sprues, filament moisture content, speed settings all have to be carefully looked after to get good results. I prefer the modern circuit board model for 3D prints – send the model off to a factory with equipment and materials you’ll never afford, and get your polished results back in the mail.

When I started ordering 3D prints, I had a basic question: when designing two parts that fit together, how much space do you need to leave between them to fit properly? To research this, I designed a set of fit-testing sets and printed them with various processes to see what sort of tolerances are necessary. So far I’ve tried nine different prints, and (unlike circuit boards) the results vary considerably.

The fit testing sets consist of two parts, a pair of pegs, each with round and square ends. One peg has 5mm ends, the other is 10mm. The other component is a block with a range of holes of different sizes to test fit each peg. Printing these and testing which hole each peg fits in helps to determine how much extra margin your design needs to have parts fit together well. For example, if the peg fits comfortably in the +0.2mm hole, that means you’d better leave a 0.2mm gap in your design for the parts to work smoothly.

The first blocks I made ranged from -9.85 to 10.15 (in increments of 0.05mm) for the large holes, and -4.875 to 5.125 (with 0.025mm steps) for the small ones. I quickly discovered this wasn’t enough range for coarser printing processes, so I created additional blocks with wider ranges of 9.7 to 10.3 (9.75 to 10.25) and 0 to 0.6 (0 to 0.5). These doubled the increment steps of the previous blocks, from 0.05 / 0.025 mm to 0.1 / 0.05.

The last block works well for the coarsest printing technologies, and is the best place to start for basic FDM (fused deposition modelling) printers. The rendering above also shows some quarter-step peg sets I modeled for even more precise tests, but you won’t need those anywhere outside of a Swiss watch factory.

Over the past few years I’ve printed blocks and pegs with a number of different services, to get a feel for the accuracy and tolerances of each. Read on for a review of what I discovered.

## Design Lesson Learned: Model the Environment

On a recent trip I picked up a art-glass marble for my wife. She liked it so much she bought a nice lighted display stand for it. The stand wasn’t designed to display that particular marble though, so it didn’t work too well.

This was a problem easily solved with a bit of 3D printing. I figured it’d be trivial to make an adapter ring for the marble to sit securely on. However, when I examined the stand, I discovered the LEDs were flush with the base, and likely to get in the way. The marble needed to be held up above them. Before starting on the adapter, I did a simple model of the stand, so I could check everything cleared.

With the stand and LEDs modeled, I could verify my design properly fit. The project worked great, and fit perfectly with the first print. Success.

The next CAD project I did was a stand for a screwdriver set I purchased. I carefully measured the handle and the various blades, but (perhaps over-confident) didn’t bother to model them.

It wasn’t until I got the print back I discovered a major ergonomic fail: You can’t easily reach the handle because the blades are in the way! Had I taken the time to actually model the blades and handle, I would have visualized this immediately, and chosen another layout.

Moral – it’s a good idea to model the whole environment, not just the piece you’re printing.

## A Clip for the Apple Pencil

The original Apple Pencil, in addition to its phenomenally bad charging method, has no means to keep it with the iPad. The nice leather Sena case we keep the iPad in doesn’t have a loop for the pencil. I solved the problem by coming up with a clip that’s easily tucked into the case when it’s closed.

This was a quick project, created in less than an hour of CAD work. The first print back from Shapeways had a couple of problems. I made the inner radius of the clip match the pen, thinking it would shrink enough from the spec dimensions to fit securely. Nope, it fit perfectly – and slid right off. The second issue was the original spike was only about 1.5mm thick; turns out that’s pretty bendy in Shapeway’s nylon. For the second revision, I made the clip diameter a full millimeter less than the pencil and it clips on securely now. Making the spike about 3mm across is rigid enough to stay in place.

Ironically, Sena now sells the case with a loop to store the pencil. But it’s still fun to solve the problem in less than an hour of design time. The STL is up on Thingiverse if you want to print one.

## How to Make Apple’s Mac Pro Holes

Apple’s recently introduced Mac Pro features a distinctive pattern of holes on the front grill. I’m not likely to own one anytime soon (prices for a well configured machine approach a new car), but that pattern is very appealing, and re-creating it is a fun exercise.

The best clue about the pattern comes from this page pitching the product. About halfway down, by the heading “More air than metal” is a short video clip showing how the hemispherical holes are milled to create the pattern.

Let’s start with a screen grab of the holes from the front. The holes are laid out with their centers equally spaced apart and the tops of the lower circles fall on the same line as the bottom of the circles above them. So the circles are spaced 2r apart vertically, where r is the radius of the circle.

The horizontal spacing is a bit more work. The angles of the equilateral triangle formed by the centers are 180°/3 = 60° (or π/3 as they say in the ‘hood). If you draw a vertical line from the center of the top circle to the line connecting the centers of the bottom circles, that line (as you see above) is 2r long. With a bit of trig, you can find half the horizontal spacing x by using the right triangle formed by that line, x and the side of the equilateral triangle. The angle from the vertical center line to the equilateral triangle edge is half of π/3, π/6. So,

$x=2r\tan \frac{\pi }{6}$

and 2x is the horizontal spacing of the circles.

The hemispherical holes are milled into both sides of the plate, but the holes on the other side are offset so the hole centers on one side fall exactly in the middle of the triangle formed by the hole centers on the other side:

You already know the horizontal offset for the centers from one side to the other is x, but how far up do you go to hit the center of that triangle? Let’s call that h.

You’ll use the same tan(π/6) trick we used above, this time using the triangle formed by x and h. Like the triangle used to find x, the angle here is also π/6. So:

$h=x\tan \frac{\pi }{6}$

Let’s clean this up a bit:

$h=x\tan \frac{\pi }{6}=2r\tan \frac{\pi }{6}\tan \frac{\pi }{6}$
$\tan \frac{\pi }{6}=\frac{1}{\sqrt{3}}$ so…
$h=2r\frac{1}{\sqrt{3}}\frac{1}{\sqrt{3}}=\frac{2r}{3}$

There’s still the issue of how thick the plate is, relative to the size of the holes. I took screen grabs of the film clip and compared them by counting pixels:

Examining the images, the thickness was about 101, with the diameter (2r) of the holes coming in at 176. Now, these numbers aren’t at all precise, because of the perspective introduced by whatever animation software was used. But I can’t help but notice the following coincidence:

$\frac{101}{176}=0.573\approx \tan \frac{\pi }{6}=\frac{1}{\sqrt{3}}=0.577$

Yeah. The ratio of the plate thickness to the hole diameter is just like the ratio of the hole horizontal spacing to the hole diameter. So let’s turn this around, and summarize by saying for a plate of any thickness t, use:

$r=\frac{t\sqrt{3}}{2}$
$x=2r\tan \frac{\pi }{6}=\frac{2r}{\sqrt{3}}=t$
$h=\frac{2r}{3}$

Where r is the radius (half the diameter) of the spheres and 2x is the horizontal spacing of the sphere centers on a given row. For the next row, the centers are offset by x horizontally from the centers of the previous row. The rows are spaced 2r apart vertically, from sphere center to center. The same grid of spheres carved into the back side is displaced by x horizontally, and h vertically from the spheres in the front. The centers of the front spheres are on the front surface of the plate, the back spheres on the back.

So to CAD this up, all you need to do is start with a rectangular block of thickness t, and use the formulas above to place the centers of the spheres (with diameter 2r) on the front and back of the block.

If you just want to quickly print or look at the result in 3D, I’ve posted some sample STL files on Thingiverse.

## Delete – A Design History of Computer Vaporware

Even if “history is written by the victors”, that doesn’t mean the losers don’t have interesting stories to tell. Delete – a Design History of Computer Vaporware is the story of various computer systems that either never saw the light of day, or saw relatively little of it. This is one of the most unique computer history books I’ve run across.

The book introduces the concept of vaporware – systems promised but never delivered. It starts off with the grandfather of all computer vaporware, Babbage’s difference engine. Conceived in the early 1800s as a way to accurately print mathematical tables, Babbage kept tweaking and improving the design, instead of finishing it. The device became a moving engineering target that was never hit, with only a small section actually fabricated in his lifetime. Undaunted, Babbage went on to conceive the Analytical Engine, a full programmable computer made of shafts and gears. It was never fabricated.

From there the book moves on to the evolution of computers post WWII. The book covers the developments in Europe, in particular several early computer projects in Scandinavia I’d never heard of before. As the early mainframes transitioned to minicomputers in the 60s and 70s, the book covers machines like Honeywell’s “kitchen computer”. Featured in the 1969 Neiman-Marcus Christmas catalog as an absurd home accessory, the vaporware product nevertheless generated a welcome shot of publicity for both Honeywell and the retailer.

Some of Atkinson’s best revelations surround the development of the personal computer in the 1970s and ‘80s. In the 70s, IBM created a bright yellow plastic PC prototype called the “Yellow Bird” and another colorful red machine, the Aquarius. These were designed in response to the success of early computers by Apple and Atari. They were much more charming than the bland white IBM PC of 1981, and featured (then) exotic technologies such as bubble memory for mass storage. Alas, neither made it out of IBM’s labs.

The book reviews the influence of Xerox PARC’s research in the 1970s. Their creation of the Alto prototype with bitmapped displays displaying overlapping windows is well known. Atkinson, however, also reveals the “Notetaker”, another Alan Kay design for a luggable computer with a keyboard fastening over the display screen on the top. This design was successfully commercialized by other companies, including Osborn, Kaypro and Compaq. From there, the book moves through PCs to pen computing in the 1990s, the precursor to today’s touchscreen phones and tablets.

Atkinson’s primary focus for much of the book is industrial design; what the devices looked and felt like. Often, the work of the same designer reverberated across multiple product concepts, even if it only rarely made it to store shelves. The book is beautifully illustrated, filled color photographs of ingenious computer designs. I did find a few minor quibbles with his history (Berkeley Unix fans won’t appreciate Sun co-founder William Joy described as a “fellow Stanford graduate”), but on the whole, he sheds welcome light on a fascinating swath of the history of computer design.

Published in 2013, Delete isn’t a new book. However, the evolution of physical computer design seems to have plateaued since then anyway. Phones – everybody’s primary computer these days – have devolved into featureless glass slabs. And one of my favorite computer designs, the Macbook Air, is over a decade old now. The vaporware covered in Delete had significant influence on today’s computer products, even if they never made it to the store shelves themselves.

## The Three Piece Burr Puzzle

Somewhere around middle-school, I came across a diagram of the classic three-piece burr puzzle.

It looked fun, so I endeavored to make one. Unfortunately, the materials available to me then (a scrap of plywood and a janky power scroll saw) didn’t produce very good results. It worked, but was crude and wobbly. Spray painting it black didn’t help.

A couple years ago, I revisited the project, this time with 3D printing.

Printed at Shapeways in dyed plastic, it works great. It’s kind of pricey though, running just over $90 for the three solid pieces. Similar puzzles retail for less than$5. I tried making hollow versions to lower the price, but it reduced it less than 20%, and required annoying holes to drain the trapped material.

Yes, I could just have bought one. But there’s something fun about precisely realizing something you envisioned decades ago.

## The Raspberry Cup and Saucer

My mom collects teacups, and I liked the idea of creating one using 3D tech. She also grows raspberries in her garden – eating them off the vines is always a treat when we visit in the summer. I was mulling over ideas for a raspberry teacup design when the idea struck of using a raspberry leaf as the saucer. Then I started in earnest. This is perhaps an afternoon project for an experienced ceramics artist. But I’m more fond of CAD then wet clay, so I designed it in Fusion 360, and had it fabricated with Shapeway’s porcelain process.

## Backup Software

I started working with computers when they were much less reliable than they are now.  Old operating and file systems frequently lost or corrupted your data, teaching you the importance of a backup copy.  Then the fire at our house reinforced the importance of offsite backups.  The \$50-150 a year cost is cheap insurance against losing all your creative work, financial and (ahem) insurance records.

A few months after the fire I set up our computers with CrashPlan. We used it at work, and it worked very well at home. But this summer CrashPlan announced they were pulling the plug on home usage, and their commercial offerings weren’t very economic for few home PCs.

CrashPlan gave plenty of warning their home service is discontinued, but watching smoke roll in to Silicon Valley from the 2017 North Bay fires was a grim reminder. To my surprise, it took a few tries to get find a reliable replacement. Here’s my experience.

## Book Review: The Neptune File

The Neptune File: A Story of Astronomical Rivalry and the Pioneers of Planet Hunting

You might expect planet Neptune’s discovery to be worthy of a footnote, or a magazine article at most. Yet Tom Standage manages to bring alive a fascinating story with an entertaining cast of characters from the 19th century around this discovery.

Man has known about the first six planets since ancient times. They’re bright enough to be seen with the naked eye, and their movements across the sky clearly distinguish them from the stars.

Searching the sky with his advanced (for the time) telescope, amateur astronomer William Hershel discovers a seventh planet, Uranus, in 1781. This created a sensation among astronomers, and opened up the possibility of more planets in the sky.

While trying to compute the precise orbit of Uranus, astronomers noted something wasn’t quite right. It was speeding up and slowing down from where it was expected to be. Two astronomers, the brash Frenchman Urbain Le Verrier and the quiet Englishman John Adams begin undertaking the complex calculations to try and predict where the new planet should appear.

With the calculations underway, the race is on to actually find the new planet, an amazing achievement with 19th century technology. The acrimony and infighting resulting from the discovery also makes for a great story.

## Tingbot Review

One of my more prized positions is was a Chumby prototype, right off the desk of it’s hardware designer.  I won it in one of the designer’s monthly Name That Ware contests. The idea behind the Chumby was to have a box on your desk or nightstand running casual applications to tell the time, weather, photos, or other entertaining data. A back-end service made it easy to download new apps, which were written in Flash (this was in the late 2000’s, Flash was still a thing then). It was beautifully designed, featuring graphics by Susan Kare and a classy soft leather case.

But Chumby, Inc. died. A combination of bad timing (missing Christmas in 2007, followed by the global economic meltdown in 2008) and the introduction of the iPhone – the gadget to end all gadgets – made it tough for Chumby to find a market. Kudos to Duane Maxwell for keeping the remaining Chumbys on life support.

Recently Tingbot introduced a Raspberry Pi based computer with a small LCD display in a nice desktop case.  It immediately reminded me of the Chumby.


text:
# NCERT : Electromagnetic Induction

Q: 1. Predict the direction of induced current in situations described by the following Figures (see in Textbook)

Sol.
(a) South pole developes at q, current induced must be clockwise at q.
In the coil, induced current is form p to q.

(b) Coil pq in this case would develop s pole at q and coil XY would also develop S pole at X. Therefore induced current in coil pq
will be form q to p and induced current in coil XY will be form X to Y

(c) Induced current in the right loop will be along XYZ.

(d) Induced current in the left loop will be along ZYX as seen from front.

(e) Induced current in the right coil is from X to Y

(f) No current is induced because magnetic lines of force lie in the plane of the loop.

Q:2. Use Lenz’s law to determine the direction of induced current in the situation described by Fig.(see in Textbook)

(a) A wire of irregular shape turning into a circular shape
(b) a circular loop being deformed into a narrow straight wire. The crosses indicate the magnetic field into the paper and the dots indicate magnetic field out of the paper.

Sol:
(a) When a wire of irregular shape turns into a circular loop, area of the loop trends to increases. Therefore, magnetic. flux linked with the loop increases. According to Lenz’s law the direction of induced current must oppose the magnetic field, for which induced current should flow along adcba

(b) In this case, the magnetic flux tends to decrease. Therefore, induced current must support the magnetic field, for which induced current should flow along adcba.

Q:3. A long solenoid with 15 turns per cm has a small loop of area 2.0 cm2 placed inside the solenoid normal to its axis. If the current carried by the solenoid changes steadily from 2.0 A to 4.0 A in 0.1 s, what is the induced emf in the loop while the current is changing ?

Sol. Number of turns per unit length , n = 15 cm-1 = 1500 m-1
Area , A = 2 cm2 = 2 × 10 m-4 , μo = 4π × 10 -7

Change in current , dI = 4-2 = 2A ,

Change in time , dt = 0.1 sec

Magnetic field B = μo n I

Magnetic Flux , φ = B A = (μo n I) A

A/c to Formula , induced emf , $\displaystyle e = -\frac{d\phi}{dt}$

$\displaystyle e = -\frac{d(\mu_0 nIA)}{dt}$

$\displaystyle e = -(\mu_0 n A)\frac{dI}{dt}$

On putting all the given values we get

e = − 7.54 × 10-6

Q:4. A rectangular wire loop of sides 8 cm and 2 cm with a small cut is moving out of a region of uniform magnetic field of magnitude 0.3 T directed normal to the loop. What is the emf developed across the cut if the velocity of the loop is 1 cm s–1 in a direction normal to the
(a) longer side,
(b) shorter side of the loop? For how long does the induced voltage last in each case ?

Sol. using formula ,  e = B l v  and time t = length of wire / v

(a) along longer side

length , l = 8 cm = 0.08 m  , B = 0.3 T , v= 1 cm/s = 0.01 m/s

emf developed , e= B l v = 0.3 × 0.08 × 0.01 = 0.24 mV

time of emf = length of shorter arm/v = 0.02/0.01 = 2 sec.

(since , emf developed as long as loop does not get out the field , i.e. distance travelled by shorter arm )

(b)along longer side

emf developed , e= B l v =0.3 x 0.02 x 0.01 = 0.06mV

time of emf = length of longer arm/v = 0.08/0.01 =8 sec.

Q :5. A 1.0 m long metallic rod is rotated with an angular frequency of
400 rad s–1 about an axis normal to the rod passing through its one end. The other end of the rod is in contact with a circular metallic ring. A constant and uniform magnetic field of 0.5 T parallel to the axis exists everywhere. Calculate the emf developed between the centre and the ring.

Sol . Induced emf , e = Blv

Average velocity of the rod , v = (0 + ωl)/2 = ωl/2

Induced emf , $\displaystyle e = \frac{1}{2}B\omega l^2$

On putting the values , B = 0.5 T , l = 1 m ,  ω = 400 rad s–1

e = 100 V .

Q:6. A circular coil of radius 8.0 cm and 20 turns rotates about its vertical diameter with an angular speed of 50 s-1 in a uniform horizontal magnetic field of magnitude 3 × 10-2T. Obtain the maximum and average e.m.f. induced in the coil. If the coil forms a closed loop of resistance. 10 Ω, calculate the maximum value of current in the coil. Calculate the average power loss due to joule heating. Where does this power come from?

Sol.

Here, r = 8.0 cm = 8×10-2 m, N = 20, ω = 50 s-1, B = 3 × 10-2 T, e0 = ?,eav = ?,R = 10 Ω, P = ?

As e0 = NAB ω

= N(π r2 )Bω

e0 = 20 × (22/7) (8×10-2)2 × 3×102×50

= 0.603 volt

Average value of emf induced over a full cycle, eav = 0

l0 = e0/R

= 0.603/10 = 0.0603 A

Power dissipated = (e0l0 )/2

= (0.603×0.0603)/2 = 0.018 W

The induced current causes a torque opposing the rotation of the coil. An external agent (rotor) must supply torque (and do work) to counter this torque in order to keep the coil rotating uniformly. Thus, the source of power dissipated as heat in the coil is the external rotor.

Q:7. A horizontal straight wire 10 m long extending from east to west is falling with a speed of 5.0 ms-1 at
Right angles of the horizontal component of the earth’s magnetic field 0.30 ×10-4 Wb m2.
What is the instantaneous value of the e.m.f induced in the wire ?.
(b) what is the direction of the e.m.f. ? (b) which end of the wire is at higher electric potential

Sol .
Here,l = 10 m, v = 5.0 ms-1 ; B = 0.30 × 10-4 T

e = B l v

= 0.30 × 10-4× 10 × 5.0

= 1.5×10-3 V

According to Fleming’s right hand rule, the direction of induced e.m.f is from west to east.

West and of the wire must be at higher electric potential.

Q:8.Current in a circuit falls from 5.0 A to 0.0 A in 01 s. if an average e.m.f of 200 V is induced, give an estimate of the self inductance of the circuit ?

Sol.
here , $\displaystyle \frac{dI}{dt} = \frac{I_2 – I_1}{t}$

$\displaystyle = \frac{0 – 5}{0.1} = 50 A/s$ ; e=200 V, L = ?

As $\displaystyle e = L |\frac{dI}{dt}|$

$\displaystyle L = \frac{e}{|\frac{dI}{dt}|}$

$\displaystyle L = \frac{200}{50}$

L = 4 H

Q:9. A pair of adjacent coils has a mutual inductance of 1.5 H. if the current in one coil changes from 0 to 20 A in 0-5 s, what is the change in flux linkage with the other coil ?

Sol.
Here, M =1.5 H, dI/dt =(20-0)/0.5 = 40 As-1

Form $\displaystyle e = M\frac{dI}{dt}$

$\displaystyle \frac{d\phi}{dt} = M\frac{dI}{dt}$

$\displaystyle d\phi = M dI$

$\displaystyle = 1.5 (20 – 0) = 30 wb$

Q:10. A jet plane is travelling west at the speed of 1800 km/h What is the voltage between the ends of the wing 25 m long, if the earth’s magnetic field at the location has a magnitude of 5.0 ×10-4 T and the dip angle is 30° .

Sol: v = 1800 km/h = 1800 x(5/18) = 500 m/s ; B = 5.0 ×10-4 T ; δ = 30°

$\displaystyle B_V = B sin\delta$

$\displaystyle e = B_V l v$

$\displaystyle e = (B sin\delta) l v$

$\displaystyle e = (5 \times 10^{-4} sin30) 25 \times 500$

e = 3.1 volt

Next Page →


text:
# Timer0 and Timer2 configuration on atmega1280

I want to setup Timer0 and Timer2 to control the intensity of the LED (L) on the Arduino Atmega1280.

The frequency has to be 10khz and the duty cycle will be controlled by a switch or using serial comm via uart (increment and decrement); currently the only part where I'm having issues is initializing the timers and not being sure if my approach is the correct one, which is the following:

Since I need control over freq and on the duty cycle I think that I need to use two timers, I've searched if it can be done using only one but most of the tutorials and guides only focus on changing freq or duty so I've reached the conclusion that by using one timer you can only control either frequency or the duty cycle.

My plan is to use Timer2 as the 10khz clock for Timer0, when Timer0 overflows it will toggle it's signal, the duty cycle is controlled using OCROA and the freq for Timer2 is set with the pre-scaler being 8 and OCR2A = 200:

$$f_{pwm} = \frac{f_{clk}}{N \cdot R_{OCR0A}}$$ $$10000 = \frac{16000000}{8 \cdot 200 }$$

I've set Timer0 to have no clock source since I'll be incrementing it manually with the TIMER2_OVF_vect, here is the routine that sets up both timers.

/**
* Configures a PWM with variying duty cycle at 10Khz.
*
* First we set Timer2 to be the 10khz clock source:
*     f = 16e6 / (8 * 200)
*
* Second we set Timer0 to be the duty cycle specifier
* Timer2 is incremented by each tick of Timer0 and the one that
* sends the signal to the Led (L)
*
*/
void setupPWM(void) {
// Timer2
// Set the top to be 200
OCR2A = (uint8_t) 200;

// Set the clock source to use Pre-scale 8
CLR_BIT(TCCR2B, CS20);
SET_BIT(TCCR2B, CS21);
CLR_BIT(TCCR2B, CS22);

// Set the Waveform generation mode to OVF on top
SET_BIT(TCCR2A, WGM20);
SET_BIT(TCCR2A, WGM21);
SET_BIT(TCCR2B, WGM22);

// We don't need to set COM2A, because
// we won't use wiring, we'll use
// interrupts as a counter inc for Timer0
SET_BIT(TIMSK2, TOIE2);

// Timer0
// Set PB7 for output and clear the value
SET_BIT(DDRB, PB7);
CLR_BIT(PORTB, PB7);

// Disable the internal clock source, we will clock it with the TOVI
CLR_BIT(TCCR0B, CS00);
CLR_BIT(TCCR0B, CS01);
CLR_BIT(TCCR0B, CS02);

// Set waveform gen to FPWM with OCRA as the
// top, OCRA will be set by the duty cycle functions
// We start at 50%
SET_BIT(TCCR0A, WGM00);
SET_BIT(TCCR0A, WGM01);
SET_BIT(TCCR0B, WGM02);

// Set COM mode to toggle the output on
// OCROA match
SET_BIT(TCCR0A, COM0A0);
CLR_BIT(TCCR0A, COM0A1);

SET_BIT(TIMSK0, TOIE0);

OCR0A = (uint8_t) 128; // Set it to 50% duty initially
TCNT0 = 0;
}

Timer2 overflows correctly, however Timer0 seems to be not working as it should my guess is that since the CS0:2 bits are 0 the TIMER0_OVF_vect ISR is not triggered, however I'm not sure that if I set Timer0 to Fast PWM I'll loose the 10khz freq.

Any help is really appreciated.

• the internal clock generator is somewhat variable, can use use that to clock the timer and tune it to the frequency you want, – Jasen Jan 4 '16 at 4:58
• Yes, and that is what I am doing for Timer2, I adjust the OCR2A and set the pre-scale to 8 to have a 10khz based on the frequency formula for Fast PWM – Tristian Jan 4 '16 at 5:07
• no, the internal RC oscillator – Jasen Jan 4 '16 at 5:51
• You mean the 16Mhz crystal?, how would, I'd rather not add more HW components. – Tristian Jan 4 '16 at 6:35

I believe it's trivial to control frequency and PWM using one timer even without interrupt. You need select timer mode supporting TOP value to specify frequency precisely (16-bit timer can do it more accurately but I don't think it's so critical for LED). FastPWM is mostly sufficient hence select mode 7. OCRnA specifies frequency f=fclk/(N*(OCRxA+1)). Output pin is selected as a OCnx (x>A) and duty cycle is controlled via OCRnx (x>A) register in range (0..OCRnA). You need select correct compare output mode (how behaves output pin) but it's well specified in datasheet. There are also such issues as double buffering because there is potencial race condition as you are changing params in runtime but it's not so critical.

So, after thinking more about it, the main issue was that I wasn't able control the freq of Timer0 with Timer2 overflows, however after reading more on Timer0 section, we can configure Timer0 to use T0 as an external clock source that is ticked on rising or falling edge. T0 is wired to port D so we have to configure port D correctly as output.

void setupTimer0(void) {
// Set the clock source to be T0 (PD7)
SET_BIT(TCCR0B, CS00);
SET_BIT(TCCR0B, CS01);
SET_BIT(TCCR0B, CS02);

// Set waveform gen to FPWM with OCRA as the
// top, OCRA will be set by the duty cycle functions
// We start at 50%
SET_BIT(TCCR0A, WGM00);
SET_BIT(TCCR0A, WGM01);
SET_BIT(TCCR0B, WGM02);

// Set COM mode to toggle the output on
// OCROA match
SET_BIT(TCCR0A, COM0A0);
CLR_BIT(TCCR0A, COM0A1);
}

void setupTimer2(void) {
// f = 16e6 / (8 * 200)
// Set the top to be 200
OCR2A = (uint8_t) 200;

// Set the clock source to use Pre-scale 8
CLR_BIT(TCCR2B, CS20);
SET_BIT(TCCR2B, CS21);
CLR_BIT(TCCR2B, CS22);

// Set the Waveform generation mode to OVF on top
SET_BIT(TCCR2A, WGM20);
SET_BIT(TCCR2A, WGM21);
SET_BIT(TCCR2B, WGM22);

// Disconnect OC2A as we don't use it
CLR_BIT(TCCR2B, COM2A0);
CLR_BIT(TCCR2B, COM2A0);

// Set PD7 (T0) for output
SET_BIT(DDRD, PD7);
CLR_BIT(PORTD, PD7);

// Enable the timer2 overflow interrupt
SET_BIT(TIMSK2, TOIE2);
}

ISR ( TIMER2_OVF_vect ) {
SET_PIN(PIND, PD7); // Toggle the pin value to create a 'tick'
}

Here is the CS0:2 table for reference


text:
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Hyungsuk Tak, Xiao-Li Meng and David van Dyk just arXived a paper on a multiple choice proposal in Metropolis-Hastings algorithms towards dealing with multimodal targets. Called “A repulsive-attractive Metropolis algorithm for multimodality” [although I wonder why XXL did not jump at the opportunity to use the “love-hate” denomination!]. The proposal distribution includes a [forced] downward Metropolis-Hastings move that uses the inverse of the target density π as its own target, namely 1/{π(x)+ε}. Followed by a [forced] Metropolis-Hastings upward move which target is {π(x)+ε}. The +ε is just there to avoid handling ratios of zeroes (although I wonder why using the convention 0/0=1 would not work). And chosen as 10⁻³²³ by default in connection with R smallest positive number. Whether or not the “downward” move is truly downwards and the “upward” move is truly upwards obviously depends on the generating distribution: I find it rather surprising that the authors consider the same random walk density in both cases as I would have imagined relying on a more dispersed distribution for the downward move in order to reach more easily other modes. For instance, the downward move could have been based on an anti-Langevin proposal, relying on the gradient to proceed further down…

This special choice of a single proposal however simplifies the acceptance ratio (and keeps the overall proposal symmetric). The final acceptance ratio still requires a ratio of intractable normalising constants that the authors bypass by Møller et al. (2006) auxiliary variable trick. While the authors mention the alternative pseudo-marginal approach of Andrieu and Roberts (2009), they do not try to implement it, although this would be straightforward here: since the normalising constants are the probabilities of accepting a downward and an upward move, respectively. Those can easily be evaluated at a cost similar to the use of the auxiliary variables. That is,

– generate a few moves from the current value and record the proportion p of accepted downward moves;
– generate a few moves from the final proposed value and record the proportion q of accepted downward moves;

and replace the ratio of intractable normalising constants with p/q. It is not even clear that one needs those extra moves since the algorithm requires an acceptance in the downward and upward moves, hence generate Geometric variates associated with those probabilities p and q, variates that can be used for estimating them. From a theoretical perspective, I also wonder if forcing the downward and upward moves truly leads to an improved convergence speed. Considering the case when the random walk is poorly calibrated for either the downward or upward move, the number of failed attempts before an acceptance may get beyond the reasonable.

As XXL and David pointed out to me, the unusual aspect of the approach is that here the proposal density is intractable, rather than the target density itself. This makes using Andrieu and Roberts (2009) seemingly less straightforward. However, as I was reminded this afternoon at the statistics and probability seminar in Bristol, the argument for the pseudo-marginal based on an unbiased estimator is that w Q(w|x) has a marginal in x equal to π(x) when the expectation of w is π(x). In thecurrent problem, the proposal in x can extended into a proposal in (x,w), w P(w|x) whose marginal is the proposal on x.

If we complement the target π(x) with the conditional P(w|x), the acceptance probability would then involve

{π(x’) P(w’|x’) / π(x) P(w|x)} / {w’ P(w’|x’) / w P(w|x)} = {π(x’) / π(x)} {w/w’}

so it seems the pseudo-marginal (or auxiliary variable) argument also extends to the proposal. Here is a short experiment that shows no discrepancy between target and histogram:

nozero=1e-300
#love-hate move
move<-function(x){
bacwa=1;prop1=prop2=rnorm(1,x,2)
while (runif(1)>{pi(x)+nozero}/{pi(prop1)+nozero}){
prop1=rnorm(1,x,2);bacwa=bacwa+1}
while (runif(1)>{pi(prop2)+nozero}/{pi(prop1)+nozero})
prop2=rnorm(1,prop1,2)
y=x
if (runif(1){pi(x)+nozero}/{pi(prop1)+nozero}){
fowa=fowa+1;prop1=rnorm(1,x,2)}
for (t in 2:T)
luv8[t]=move(luv8[t-1])

Filed under: Books, pictures, R, Statistics, Travel Tagged: auxiliary variable, doubly intractable problems, Metropolis-Hastings algorithm, Monte Carlo Statistical Methods, multimodality, normalising constant, parallel tempering, pseudo-marginal MCMC, The night of the hunter, unbiased estimation


text:
# Aligning an equation at multiple places

I want to align an equation at two places, and I have a code segment that looks like this:

\documentclass[a4paper]{paper}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}

\begin{document}

\begin{alignat*}{2}
g_P^x &= 3x_P^2 + a, \quad g_P^y &&= -2y_P, \\
v_P &= 2g_P^x, \quad u_P &&= (g_P^y)^2, \\
v &= \sum_{P \in G^+} v_P, \quad w &&= \sum_{P \in G^+} u_P + x_Pv_P.
\end{alignat*}

\end{document}

And this works to a certain extend, but there is a big gap between u_P and the equal sign. How can I get it closer to the equal sign so it is aligned with the stuff above and below it?

• Why &&? Try putting the extra & before g_P, u_P, and w. – Phelype Oleinik Mar 10 '18 at 19:00
• Because I thought, the first alignment point should be specified with & and the second one with &&. Can you write as answer, what you mean? – pixel Mar 10 '18 at 19:01
• No, each & is an alignment point, just like in tables. Put an & before g_P, u_P, and w to align them too. – Phelype Oleinik Mar 10 '18 at 19:03
• @PhelypeOleinik: I don't interpret &s like that: the first one introduces a new column of alignment,, and the second one marks the alignment point inside this column. – Bernard Mar 10 '18 at 19:06
• @Bernard Hmmm... I didn't know that. Looking at your answer, it makes total sense. +1 :) – Phelype Oleinik Mar 10 '18 at 19:30

You must understand that in an align(at) environment with multiple alignment points, each even order & introduces a new column of alignment, and each odd order & marks the alignment point inside its column . That's why n alignment points require 2n-1 &s.

Applying this rule, and using the \smashoperator command from mathtools to improve the layout of big operators with wide sub/superscripts, you get this code (note you need only one \qquad in a well-chosen row):

\documentclass[a4paper]{paper}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{mathtools}

\begin{document}

\begin{alignat*}{2}
g_P^x &= 3x_P^2 + a, &\qquad g_P^y&= -2y_P, \\
v_P &= 2g_P^x, & u_P &= (g_P^y)^2, \\
v &= \smashoperator{\sum_{P \in G^+}} v_P, & w&= \smashoperator{\sum_{P \in G^+}} u_P + x_Pv_P.
\end{alignat*}

\end{document}


text:
### When should we stop listening to oppressed people?

On the Astronomers Facebook page, Dr. David Spiegel asks a very straightforward yet, to date, unanswered question regarding the TMT debate:
On the one hand, there are some people (whether a fractionally small minority or not), whose land was colonized and whose culture is disappearing, who think of Mauna Kea as a sacred location that should not have more ground broken on it for giant new telescopes.
Then, there are some astronomers who say, essentially, "We really ought to listen more to these marginalized people who are objecting to the plans to build a giant new telescope."
And finally, there are some astronomers who say, essentially, "Nope. We had a very listeny process already. The time for listening is over; the time for pouring concrete has arrived." And some high-profile astronomers who take this position have used some offensive, insensitive, and, yes, racist language in making this argument to several hundred of their closest friends.
Am I right that the dispute among astronomers is basically between those who argue, "Let's listen more to the colonized people who are objecting to our plans to build the world's largest optical telescope on their sacred mountain, find out whether compromise solutions are available, and, if not, take a whole lot more time to figure out whether ignoring the complaints of victims of colonialism in order to build a big telescope is the right course of action," and those who are arguing, "Let's go ahead and build right now because our process already involved 7 years of listening and we'd rather build the telescope than listen more."?
If I'm wrong in this understanding, which part of it is wrong?
If I'm right in this understanding, can people help me understand how the latter argument makes moral and logical sense? In other words, what are the steps of moral logic that go from (A) "We've already listened a whole lot." to (B) "We should go ahead and build the telescope despite the complaints of some victims of colonialism who think that we'll be desecrating their sacred mountain by building it."?

Steve Bryson said…
My first reaction to hearing "Nope. We had a very listeny process already. The time for listening is over; the time for pouring concrete has arrived." is that this sounds like someone who listens to opinions but has no willingness to their course of action. Does my reaction indicate a straw man? Did the process of spending years listening to indigenous opinions ever really include possibly not siting TMT on Mauna Kea?

### On the Height of J.J. Barea

Dallas Mavericks point guard J.J. Barea standing between two very tall people (from: Picassa user photoasisphoto).

Congrats to the Dallas Mavericks, who beat the Miami Heat tonight in game six to win the NBA championship.

Okay, with that out of the way, just how tall is the busy-footed Maverick point guard J.J. Barea? He's listed as 6-foot on NBA.com, but no one, not even the sports casters, believes that he can possibly be that tall. He looks like a super-fast Hobbit out there. But could that just be relative scaling, with him standing next to a bunch of extremely tall people? People on Yahoo! Answers think so---I know because I've been Google searching "J.J. Barea Height" for the past 15 minutes.

So I decided to find a photo and settle the issue once and for all.

I then used the basketball as my metric. Wikipedia states that an NBA basketball is 29.5 inches in circumfe…

### Finding Blissful Clarity by Tuning Out

It's been a minute since I've posted here. My last post was back in April, so it has actually been something like 193,000 minutes, but I like how the kids say "it's been a minute," so I'll stick with that.
As I've said before, I use this space to work out the truths in my life. Writing is a valuable way of taking the non-linear jumble of thoughts in my head and linearizing them by putting them down on the page. In short, writing helps me figure things out. However, logical thinking is not the only way of knowing the world. Another way is to recognize, listen to, and trust one's emotions. Yes, emotions are important for figuring things out.
Back in April, when I last posted here, my emotions were largely characterized by fear, sadness, anger, frustration, confusion and despair. I say largely, because this is what I was feeling on large scales; the world outside of my immediate influence. On smaller scales, where my wife, children and friends reside, I…

### The Force is strong with this one...

Last night we were reviewing multiplication tables with Owen. The family fired off doublets of numbers and Owen confidently multiplied away. In the middle of the review Owen stopped and said, "I noticed something. 2 times 2 is 4. If you subtract 1 it's 3. That's equal to taking 2 and adding 1, and then taking 2 and subtracting 1, and multiplying. So 1 times 3 is 2 times 2 minus 1."

I have to admit, that I didn't quite get it at first. I asked him to repeat with another number and he did with six: "6 times 6 is 36. 36 minus 1 is 35. That's the same as 6-1 times 6+1, which is 35."

Ummmmm....wait. Huh? Lemme see...oh. OH! WOW! Owen figured out

x^2 - 1 = (x - 1) (x +1)

So $6 \times 8 = 7 \times 7 - 1 = (7-1) (7+1) = 48$. That's actually pretty handy!

You can see it in the image above. Look at the elements perpendicular to the diagonal. There's 48 bracketing 49, 35 bracketing 36, etc... After a bit more thought we…


text:
Free Version
Difficult

# Predicting Ions Present

APCHEM-QSWUL1

Analyze the graph above.

Which of the following types of ions will predominate in solution at Point D on the graph?

A

$OH^-$

B

$OH^-$ and $A^-$

C

$HA, A^-$, and $OH^-$

D

$A^-$


text:
# My list of Ludovico Einaudi music! Simply beautiful.

It's been a long time since I've posted anything meaningful and resourceful to this world, so here goes another attempt into helping you rediscover yourself through some extremely beautiful music! 🙂

I think the first song of his which I heard was back in my 12th, called Nuvole Bianche - Ludovico Piano. It was a complete accident that I stumbled upon it and thank god I did. It's one of those songs that you hear once in your lifetime which completely enlightens you and changes your perception towards music and life in general.

Since then, I started playing the piano (just fingering :p nothing professional) and eventually heard a lot more of piano. So, here goes my list of tracks of einaudi which not only inspired me but also made me cry my heart out when I had no words. 🙂

NOTE: Its really advisable to listen to these pieces in your own personal space with some peace around you. For instance, if you are trying to appreciate this beauty while stuck in traffic or under the scorching sun trying to burn down the whole of chennai, then you will simply ruin it for yourself and heir commander Ludocivo :p

# 5. Nuvole Bianche

Which means "White Clouds" in Italian. A typical ludovico piece, starts out extremely slowly with a few gentle touches and chords. 1 minute into the song, you realise he is trying to tell you a story, a slow, melodious one, another minute in, you realise he has roped you into his thoughts in with the continuous flow of melody. Though, it is named as "White clouds", I picture a sweet child asking questions, its probably becase the video has her picture and my psychology influenced my thoughts but ah well .. lets not kill it with logic shall we!

# 4. I giorni

Which means 'The Days' is another piece, the first time I heard it I reminded me of laughs and memories with my friends. And why shouldn't I be surprised? It's got a very subtle vibe to it and if you look at the video you would be surprised how involved the audience is, almost as if they were shy to shed a drop from their eye!

# 3. Divenire

Which means 'Divine', is one such piece that definitely lives upto its name and expectations. There is no better word for this piece. Divine. The way the whole orchestra builds up for the first 1:47 minutes is really gripping and leaves you awestruck after how all the tension is released in the next segement. (This track was also used by UN in one of their commercials).

# 2. Experience

(26:15 - 33:18) I suppose, this piece requires a more technical understanding of music to appreciate it. For me, the way it sustains such a great tune with a few minute changes and the set of instruments which really come in together is really amazing. If you listen closely, every instrument just adds to its persona! And ofcourse, the motivation is tremendous, it sounds as if someone you love left you heartbroken and you try desperately want to get them back. Coincidently, this composition was used for something very similar! Ahh.. the power of music .. https://www.youtube.com/watch?v=LxGfmAT3iAI

# 1. Waterways

(6:00 - 12:50) I was surprised I didn't hear this before and no one had mentioned it in his best works. It's been only a week since I discovered this piece, an absolute beauty this is. I can literally feel my blood rushing all over my body with excitement. Every time I'm down, doing something worthless (like watching movies or playing games all day long), I listen to this ... and you realise how minuscule all this is (expect the girl you love :)) ... there are people in people in space right now!  There are other galaxies with life out there!  There are so many things to learn and do with your life..  and here I am..

PS: I was listening to each of these pieces while trying to write a description. Do the same and tell me what you think! 🙂

# Beautiful notes on QFT by Tong!

So, I'm taking a course of Classical Field Theory here are IMSc. I was just reading Tong's notes, the way he wrotes is extremely motivational! Also listening to some really nice relaxing music by Kevin Kern. The moment I read this.

Feels so right to do physics! 🙂

# TIL: Synchronization of clocks with Light in a medium is the same

Well, I thought I landed up with some good idea this time. Sadly, nothing new and this is resolved very easily. In Special Theory of Relativity, we have the postutate about the speed of light being the maximum speed of transmission. Now, with this postutate and a few other postulates about measurement of position,time and $c$ being same in all interntial frames, we can get nice results. One of them being the Invariance equation.

Question: Now what would happen if I use a similar signal in a medium? We know the "effective velocity" of light that we observe in a medium is $v < c$. (If this wasn't the case, then when it exists the medium it would be $v > c$ which isn't possible.Does it imply I can make measurements only using this upper bound of velocity on the medium?

Answer: It's fairly straight forward. There are two ways of looking at it this. Either, I can remove the medium entirely and make the measurements of events the same as in vacuum and then replace the medium back. This is more of a frame by frame approach. If you want a more convincing answer then you could argue that, we send signals of light even before any interaction with the molecules of the medium. We consider such a scale and hence in that scale, it is effectively the same concepts of SPR we use. We can extend this throughout the whole of the medium as this through bits.

So today, an interesting question was raised in my Optics lecture.We know that $v < c$ velocity of light in medium is less than $c$. Therefore, we can move in an inertial frame where the photon has no velocity. Hence it would be possible to compute the rest mass of a photon. (Which is obviously not true, as photon has no mass.) Where are we going wrong? Further, adding to the confusion, we have cherenkov radiation which says that a charged particle traveling at a speed greater than the "phase velocity" photon emits electromagnetic radiation which gives rise to the blue color in the above picture. Answer: Thanks to a senior of mine. He was able to give me an outline of what is the reason. It is often misunderstood that velocity of light changes in the medium. But in effect, this isn't true. The velocity of light is and always will be $c$ in any medium. Just that, when the photon enters the medium, the dielectric of the medium absorbs the light and emits another photon. If the medium is a crystal, due to its isotropic nature, the absorption and emission of light is more systematic and the effective velocity due to the time delays between this process gives a "net" reduction of velocity of light. This is an outline of what happens but a clear understanding can be got by looking more into the quantum mechanical aspects of refraction.   Kudos!


text:
## anonymous 3 years ago .

1. anonymous

Thank you!

2. hartnn

do u know how to get -1/4 @toristar9504

3. anonymous

no

4. hartnn

The slope of the line through points (x1,y1) and (x2,y2) is given by : $$\huge m=\frac{y1-y2}{x1-x2}$$ now,just put the values and find m.


text:
Multiplying Decimals

Multiplying Decimals

GCSE(F),

To work out where the decimal point will go in the answer:

• work out the multiplication without decimals; then

add the decimal place in at the end.

The number of decimal places in the answer is the same as the total number of decimal places in the original two numbers.

Examples

1. Calculate 25.66 x 2.3.


text:
## Heat equation, initial and boundary numerical conditions

Hello to all!
1. The problem statement, all variables and given/known data
for testing my program i need a heat equation with numerical initial and boundary conditions:
Derivative[2, 0][f][x, t] == Derivative[0, 1][f][x, t]

f[x, 0] == numerical
f[0, t] == numerical, f[numerical, t] == numerical

PS. to moders: please, if you delete my message, PM me what I've done wrong, thanks!
 Recognitions: Gold Member Science Advisor Staff Emeritus It's not clear what you are asking. You know what the heat equation is, I presume. Why can't you just make up arbitrary initial and boundary values yourself?
 yeap! i think i know what is heat equation: http://en.wikipedia.org/wiki/Heat_eq...Fourier_series for example if i put these: Code: init = f[x, 0] == 1 bc = {f[0, t] == 0, f[1, t] == 0} in mathematica i got this warning: A warning is generated in this example because the initial conditions and boundary conditions give two different values for the value of f[0,0]. that's why i need correct example!


text:
Windows vs Linux: 7 Reasons to Switch to Linux

The view that Linux is a server operating system only is an outdated view. There are hundreds of Linux distributions designed specifically to be beneficial for the average desktop/laptop user, and it is perhaps time you consider switching to Linux from Windows.

When we talk about switching to Linux, we talk about using distributions like Ubuntu or Linux Mint instead of your Windows installation. Of course, you don’t have to get rid of Windows at the same day either; you can install Linux side by side with Windows if you wish, until you have finally made your mind about it.

## Windows vs Linux: Top 7 Reasons to Switch to Linux from Windows

In today’s article we’ll be seeing the top 7 reasons to switch to Linux from Windows, and why it could be a viable option for you in the future.

### 1- To Save Costs

This has to be the most straightforward reason to switch to Linux: Saving costs.

If you are a Windows user, then you already paid for a Windows license. Not necessarily directly, but when you bought your desktop/laptop, the price was already increased by $100-$200 for the included activated Windows installation.

For example, a laptop may cost $1000 if it comes with Windows, but$800 if it comes with Linux (or no OS). And sadly people don’t realize that they have already paid for a Windows license when they made such purchase.

Over the years, you’ll see that you are paying hundreds of dollars on your devices just for the basic operating system. This is also especially true in the case of enterprise installations, where they have to sign many contracts with Microsoft in order to keep getting new Windows releases for all their machines.

On Linux, almost all desktop distributions like Ubuntu, Linux Mint, Ubuntu MATE and many others are 100% free of cost, forever. This means you’ll be saving few hundreds of dollars over the years by just switching your default OS.

### 2- To Fully Own Your PC

When you use Linux, you don’t just use the kernel of the OS, you use the entire open source ecosystem.

Thanks for this ecosystem, you can do things like:

• Fully changing your desktop environment and using a different one.
• Get rid of any software piece on your system, no matter what it is, unlike on Windows.
• Fully control updates timing and settings, putting an end to Windows updates during meetings or critical work times.
• Use any supported software however you like, unlike how Windows tries to suppress your freedom to choose a web browser.
• Much more.

With Linux, you are completely in charge of how your system should work and behave. You can replace the login screen, the desktop, the default programs or even the kernel itself with other more optimized kernels (Like Liquorix)!

### 3- For Customization Abilities

The above point results in having much more customization abilities on Linux than on Windows.

Basically, you can customize the following things on Linux:

• The login screen system & theme.
• The desktop environment used, like Cinnamon desktop.
• The selected installed applications.
• The file manager.
• The underlying OS infrastructure such as packages, updates, permissions, services… etc.
• Much more.

Since every piece is open source, then you’ll always find alternatives to that piece or other customization options available to tweak according to your own needs.

### 4- For Better Security

It is true that Windows has improved a lot in terms of security in the last few years, and that an average power user no longer needs an antivirus like before.

However, Linux changes the mentality of security handling completely. You don’t go around on the Internet looking for software to download and install like .exe files on Windows, instead, you download software from your official Linux distribution repositories.

And even the few ones which you may download from outside these repositories, you don’t get them from any source. Instead, you get them from the official developers for these apps at least, or from a trusted source.

Also, many Linux distributions have started moving to more advanced software distribution mechanisms like Flatpak and Snaps, which take security to the next level with how they handle app permissions and sandboxing in a way similar to android and iOS devices.

So to sum up, if you are concerned about security, then Linux is a no-brainier for you.

### 5- To Forget About Cracked Software

In many countries around the world, especially in poor countries where copyright laws are not fully implemented, cracked software prevail as the default software selection for end users.

Here, we are not just talking about the default OS like Windows, but also the other normal apps like Microsoft Office, Adobe programs, AutoCAD… etc and basically any other proprietary premium software.

Users tend to not pay for them, and prefer to used the cracked (aka “hacked”) versions for free. But this may not be wise for two main reasons:

• You do not guarantee that the cracked software you are using are not full of spyware, malware or other malicious codes inserted by the people who cracked the software. At the end, no one does these things for free.
• You’ll be missing on updates and new features coming each year to the same software you use, which could result in a more reduced security for your PC and the data on it.

Cracked software are nightmare for any person who values his/her safety and privacy, and should not be used or encouraged.

But on Linux, since almost all software are both free and open source, this problem does not exist.

### 6- To Enhance Your Technical Experience

Let’s be honest and admit that there is a learning curve to beat when switching to Linux. It won’t be an easy task and it may take time and effort, but at the end, it will increase your technical experience like never before.

Ever wanted to understand how your system works? How the desktop gets to its current working status and how apps integrate with the system to provide you with the pleasant experience you are having? What these software companies are all competing about and what useful business cases are being solved thanks to open source and Linux?

All of these things you’ll learn, and much more, when you use Linux as your daily driver. You’ll no longer remain an ordinary newbie user who needs to contact tech support because his or her mouse isn’t working, instead, you’ll become a power user.

### 7- For Getting Rid of Spyware

It is a widely known fact that Windows, and by extension, Microsoft, collects huge data about you when you use Windows (Even if you are paying customer). And you can’t disable it completely even if you wish to.

You may also see ads in your start menu from time to time, or in any other Microsoft services that you use.

On Linux, and in the open source ecosystem in general, no one likes these things here. Many years ago, Ubuntu was heavily criticized and called as “Spyware” just for including Amazon results in the search page in the desktop, which forced the company to turn that feature off by default. Most recently, we have also covered a story where Audacity developers were forced to do the same in order to defend users’ privacy.

When you switch to Linux, you’ll never see ads running on your desktop. You will never see a notification that tells you to switch to Microsoft Edge when you are running browsers like Firefox.

And your system only collects non-personal and non-identifiable information about you, if ever at all. And you can disable these data collecting mechanisms in one click if you wish to.

## How to Switch to Linux?

After you have read enough information on how to switch to Linux form Windows, and got the enough technical knowledge about what to expect, you can start the switch by downloading and installing your Linux distribution of choice.

You can, for example, download Linux Mint and burn it to a USB stick in order to install it side by side with your Windows installation. And when you boot your PC, you’ll be able to select which OS you want to use at that session.

The process is simple and isn’t complicated, but you should be ready to learn few key concepts before you do so.

At the end, and just like we explained, the benefits of switching to Linux from Windows could be huge and life-changing for you.

Here is a full breakthrough of the process if you wish:

8 Comment
Miguel December 5, 2021
|
Great article. I would add some about Live ISO, and Ventoy to test and install. Advice to select nvidia proprietary drivers if you use nvidia. And explain that the savings using FOSS can also be done in MS WOS to smooth the transition.
Barry December 5, 2021
|
Not that I particularly like Windows, but in #1 you state that it cost $100 to$200 per year to keep Windows up to date. That's not true. Since Windows 7 all the updates and upgrades have been free. As a matter of fact, you can still use a Windows 7 license key to activate a Windows 10 installation (Windows 11 also, I think). Certain products are on a subscription basis, like Office 365 or OneDrive, but not the operating system.
Bill Dietrich December 5, 2021
|
"If you are a Windows user, then you have to pay $100 to$200 per year to continue receiving updates for your Windows installation." In what world ?  We have several Windows laptops in our home, we've never paid any annual fee.
LoosingFaith December 5, 2021
|
All that is well and good, except if you are the unlucky owner of a laptop sporting an AMD CPU/GPU. From the linux kernel after 5.10 suspend to ram is a nightmare. With the kernel 5.15 let's not even talk about suspend to ram, try a cold boot (restart). The machine goes into la-la land requiring a force power off. The worst of all this, Mr Torvald and the rest of the Linux community are quite happy with this state of affair. Windows may not be great, but in comparison, my advice is Don't make the switch.
|
I use linux for years, but no Netflix HD for Linux is really bummer


text:
# Assignment problem with constraints - dual formulation - auction algorithm

I have to solve with an auction algorithm a typical assignment problem between $$N$$ agents and $$M\ge N$$ objects, but with some less usual constraints.

Let me first introduce the general formulation without any additional constraints.

The benefit for assigning object $$j$$ to agent $$i$$ is the non negative value $$\beta_{ij}$$. So, the assignment problem turns to maximizing the sum of benefits :

$$$$\sum_{ij} \beta_{ij}x_{ij}$$$$

where $$x_{ij} = 1$$ if object $$j$$ is assigned to $$i$$, $$0$$ otherwise.

This is known as the primal formulation, which usually comes with some constraints :

• an object $$j$$ can only be assigned once : $$$$\forall j~,~~\sum_i x_{ij} = 1$$$$
• an agent $$i$$ has to assign $$M_i$$ objects : $$$$\forall i~,~~\sum_j x_{ij} = M_i$$$$

Let's say $$\sum_{i=1}^N M_i = M$$ to ensure the problem is feasible and assume $$M_i = 1~,~\forall i$$ for the moment.

To solve this with an auction algorithm, I need to write the dual formulation, which is obtained by writing the lagrangian : $$$$L = \sum_{ij} (-\beta_{ij}) x_{ij} + \sum_i \pi_i (\sum_j x_{ij} - 1) + \sum_j p_j (\sum_i x_{ij} - 1)$$$$ $$$$L = \sum_{ij}(\pi_i + p_j - \beta_{ij}) x_{ij} - \sum_i \pi_i -\sum_j p_j$$$$ where I replaced the maximization problem by a minimization one and introduced dual variables for constraints on agents ($$\pi_i$$) and objects ($$p_j$$).

The dual function is the minimum of the Lagrangian on $$x_{ij}$$ values. If $$\pi_i + p_j > \beta_{ij}$$, the minimum is obtained with $$x_{ij} = 0$$, if $$\pi_i + p_j < \beta_{ij}$$, there is no minimum as $$x_{ij}$$ goes to infinity. When $$\pi_i + p_j = \beta_{ij}$$, $$x_{ij}$$ can be taken to unity. So the dual function to maximize is $$$$- \sum_i \pi_i -\sum_j p_j$$$$ with the constraint $$\pi_i + p_j \ge \beta_{ij}$$ and there is equality for the optimal assignment set.

The dual variables $$p_j$$ for objects are called their prices, the ones for agents are called marginal profits and equal : $$$$\pi_i = \max_j (\beta_{ij} - p_j)$$$$

Very shortly, the auction algorithm consists in letting each agent bid on its most profitable object $$$$j_i = \arg\max_j (\beta_{ij} - p_j)$$$$ and its bid $$b_i$$ is computed by the difference between $$\pi_i$$ and the second one most profitable object : $$$$b_i = \pi_i - \max_{j\ne j_i} (\beta_{ij} - p_j) + \varepsilon$$$$ where $$\varepsilon$$ is a small value guaranting bids to never be null.

Then, the bidded objects are attributed to the agent with highest bid and the object price is raised by that bid, so that prices can only strictly increase.

And so on, until there are no more unassigned agents.

===============

I come now to my question which is how to adapt the previous development in order to account for additional constraints on objects.

These ones consist in saying that if one object is assigned then some other ones will be forbidden to be assigned by any other agent.

You may think for example as renting cars. People may bid to get the car but at different times. You have several benefits at renting a given car at several times, say you want it more in the morning than in the afternoon, the opposite for another person.

Assume further that the car is rented for all day, which means that if you rent it for the morning, it will not be available in the afternoon for anyone. Conversely, if someone rents if for the afternoon, it is lost for you in the morning.

The object is then the couple (car, time) where time is either morning or afternoon. It is then clear that if you win the bid for (car, morning), the object (car, afternoon) becomes unassignable, and conversely.

Coming back to the mathematical formulation, such a constraint on a set $$J$$ of objects can be formulated as follows : $$$$\sum_{j\in J} \sum_i x_{ij} = 1$$$$ from which it is clear that if there is $$j'\in J$$ such that $$x_{ij} =1$$ then $$\forall j\in J~, j\ne j'~,~\forall i~,~~x_{ij} = 0$$

My question is then how to integrate this constraint in the lagrangian in order to get the right dual function to optimize, with the auction algorithm.

Here is how I would do.

Because the new constraint on objects in J is stronger than the former one $$\sum_i x_{ij} = 1$$. This latter could be completely relaxed because implied by the additional constraint. So $$$$L = \sum_{ij} (-\beta_{ij}) x_{ij} + \sum_i \pi_i (\sum_j x_{ij} - 1) + \sum_{j\notin J} p_j (\sum_i x_{ij} - 1) + \lambda (\sum_{j\in J} \sum_i x_{ij} - 1)$$$$ then $$$$L = \sum_{i,j\in J}(\pi_i + \lambda - \beta_{ij}) x_{ij} +\sum_{i,j\notin J}(\pi_i + p_j - \beta_{ij}) x_{ij}- \sum_i \pi_i -\sum_{j\notin J} p_j -\lambda$$$$

where $$\lambda$$ is the dual variable for the additional constraint.

I wonder if this is the correct formulation and how the auction algorithm can be adapted to this case. How agents bids on objects in $$J$$ ?

Regards

I wonder if my problem could be better managed by reviewing completely the assignment problem.

Indeed, consider still $$N$$ agents bidding on $$M$$ objects at $$P$$ time slots. The sum of benefits to maximize is $$$$\sum_{i=1}^N\sum_{j=1}^M\sum_{k=1}^P \beta_{ijk}x_{ijk}$$$$ with the constraints :

• an agent $$i$$ has to allocate $$M_i$$ (objects-time slots) $$(j,k)$$ $$$$\forall i~,~\sum_{j,k} x_{ijk} = M_i~,~~0\le x_{ijk} \le M_i$$$$ consider objects as being the parkings where you want to rent $$M_i$$ cars. You may want to rent all of them in the same parking $$j$$ and at the same time slot, $$x_{ijk} = M_i$$, or dispatch the rentings on several parkings and several time slots.

• the number of rentings for a given parking must not exceed its capacity : $$$$\forall j~,~\sum_{i,k} x_{ijk} \le Q_j$$$$

• the additional constraint is that for a given parking $$j$$, there is a limited number of renting per time slot : $$$$\forall j,k~,~\sum_{i} x_{ijk} \le P_{jk}$$$$

The benefit cannot be defined apart of either the parking or the time slot : an agent $$i$$ has a benefit at renting a car from that parking $$j$$ at a given time slot $$k$$ : $$\beta_{ijk}$$.

Then the Lagrangian is : $$$$L = \sum_{ijk}(-\beta_{ijk})x_{ijk} + \sum_i \pi_i (\sum_{jk} x_{ijk} - M_i) +\sum_j p_j (\sum_{ik} x_{ijk} - Q_j) + \sum_{jk} \lambda_{jk} (\sum_i x_{ijk} - P_{jk})$$$$ $$$$L = \sum_{ijk}(\pi_i + p_j + \lambda_{jk}-\beta_{ijk})x_{ijk} - \sum_i\pi_iM_i - \sum_j p_jQ_j -\sum_{jk} \lambda_{jk} P_{jk}$$$$

Then, we have to minimize $$$$\sum_i\pi_iM_i + \sum_j p_jQ_j +\sum_{jk} \lambda_{jk} P_{jk}$$$$ with the constraints : $$$$\pi_i + p_j + \lambda_{jk}\ge \beta_{ijk}$$$$ and $$0\le x_{ijk}\le M_i$$

I wonder if this formulation is more tractable and efficiently solvable by an auction algorithm than previous one.


text:
# ActionLink with Image in ASP.NET MVC 2

As far as I know, this is one of the simplest ways to insert an ActionLink into your ASP.NET MVC 2 View with an image instead of text:

<a href="<%: Url.Action("Detail", new  { param1 = "blah" } )  %>">

Any simpler solutions?