text:
# Scala Intro

Week 1

The following series of notes and related resources were compiled while taking Martin Odersky's Coursera course, Functional Programming Principles in Scala.

I plan to use these as a reference for myself, to review concepts and examples from the course in the future. Also plan to further elaborate on external links I include here.

## Week 1 Outline: Getting Started + Functions & Evaluation

### Why Scala?

Concurrency and Parallelism, see Working Hard to Keep It Simple, 2011

• Parallel programming executes programs faster on parallel hardware
• Programs could just as simply run sequentially, but take advantage of specific hardware for speed
• Concurrent programming manages concurrent execution threads explicitly
• Why are both difficult?
• Non-determinism caused by concurrent threads accessing shared mutable state
•    var x = 0
async {x = x+1}
async {x = x*2}
//can yield 0, 1, or 2

• to get deterministic processing, we must avoid the mutable state
• Avoiding the mutable state means programming functionally

Imperative vs. Functional Programming

• Imperative programming focuses on the time dimension, executing commands sequentially with some deterministic control flow
• Functional programming focuses on ‘space’, seeking to complete tasks as a graph of dependent subtasks

Scala: Combines Object-Oriented and Functional Programming

• Parallelism:
• Collections; parallel and distributed collections
• Concurrency:
• Actors, Software transactional memory, Futures –> Akka

### SBT: Simple Build Tool

Some resources

SBT Project Directory:

• Base or project's root directory:
• the “base or project's root directory” is the directory containing the project.
• build.sbt is declared in the top-level directory that is, the base directory.
• project directory
• another build inside your build, which knows how to build your build.
• To distinguish the builds, we sometimes use the term proper build to refer to your build, and meta-build to refer to the build in project

### Source Files, Classfiles and the JVM

• How Java Works
• Scala and JVM
• Scala source code is stored in text files with the extension .scala
• The scala compiler compiles .scala source files to .class files
• Classfiles are binary files containing machine code for the Java Virtual Machine and are stored to classpath

Scala Language Notes and Resources

A paradigm describes distinct concepts or thought patterns

• imperative
• functional
• logical
• OO: orthogonal to previous 3, in that it can be combined with these paradigms

Imperative:

• modifying mutable variables
• using assigments
• using control structures (if-then-else, loops, break, return)
• Imperative programs understood as instruction sequences for a Von Neumann architecture
• Von Neumann Architecture
• CPU (Datapath and Control FSM), Main Memory, and I/O
• mutable variables, variable de-references and assignments, and control sturctures all can be mapped to aspects of the Von Neumann computer

Correspondance Between Imperative Prog. and VN Architecture

• Pure imperative programming is limited by the Von Neumann bottleneck, coined by Backus, whereby one tends to conceptualize data strutures “word-by-word”
• There is a strong correspondance between mutable variables and memory cells, variable dereferences and load instructions, variable assignments and store instructions, control structures and jumps.

Need techniques for defining high level abstractions and theories for these higher level abstractions in order to reason about them

• Theory consists of:

• one or more data tyes
• operations on these types
• laws that describe relationship between values and operations
• Theories do not account for mutation

• theory of polynomials defines the sum of polynomials for any degree, but does NOT define an mutation operator to change a coeffiecient while keeping the polnomial the same
• Consequences for programming:

• if we want to implement high level concepts following mathematical theories, no place for mutation
• Therefore, focus on defining theories for operators expressed as functions, avoid mutations, define ways to abstract and compose functions
• John Backus’ 1977 Turning Award lecture, Can Programming be LIberated from the von Neumann Style? A Functional Style and its Algebra of Programs

• A bigger topic than what I can address here

Functional Programming:

• restricted sense: FP means programming without mutable vars, assignments, loops, and other imperative control structues
• wider sense (Scala): FP means focuseing on the functions –> for example, functions can be values that are prduced, consumed, and compsued (first-class citizens)

Why FP Matters, John Hughes

### Lecture 1.2: Elements of Programming

Operator Evaluation Pattern:

• take leftmost operator, then evaluate its operands (l before r), and finally apply the operator to the operands
• (1+2) + (6+7) --> (3) + (13) --> 16
• a name is evaluated by replacing it with the right hand side of its definition
• the eval process stops once it results in a value, rather than another function evaluation
• for the moment, consider a value to be a number
• Substitution Model or Call by Value
// call by value (CBV) implementation --> NAMES after ARGS
sumOfSquares(3,2+2)
sumOfSquares(3,4)
square(3) + square(4)
9 + square(4)
9 + 16
25

• this substituion model is formalized in the lambda calculus
• Note that this model cannot express operators with side effects

Termination

• not every expression reduces to a value (in an infinite number of steps)

Note an alternative evaluation strategy for SumofSquares: Call by Name, CBN

• CBN is another implementation of substitution model
// CBN --> NAMES before ARGS
sumOfSquares(3,2+2)
square(3) + square(2+2)
3*3 + square(2+2)
9 + square(2+2)
9 + (2+2) * (2+2)
9 + (2+2) * 4
9 + 4 * 4
25

Both strategies reduce to the same final value if:

• reduced expressions consist of pure functions
• both evals terminate
• CBV has advantage that it evaluates every function arg only Once
• CBN has advantage that a function arg is not evluated if the corresponding param is unused in the eval of the function body

Examples

def test(x:Int, y:Int) = x * x

=================
CBV
test(3+4,8)
test(7,8)
7*7
49

CBN
test(3+4,8)
(3+4)*(3+4)
7*(3+4)
7*7
49
=================
CBV
test(3+4,2*4)
test(7,2*4)
test(7,8)
7*7
49

CBN
test(3+4,2*4)
(3+4)*(3+4)
7*(3+4)
7*7
49

### Lecture 1.3: Eval strategies and Termination:

CBV, CBN, and termination

• what if termination is not guaranteed?

Theorem: If CBV eval of an expr, e, terminates, then CBN eval of e terminates as well

• the opposite is not necessarily true

Example:

• def first(x: Int, y: Int) = x
• def loop() = loop --> an inf loop
• if first(2,loop) is called using CBN, the function will evaluate, as the second parameter, y, is not invoked in the function definition and thus never evaluated by CBN.
• CBV, however, evaluates expressions as soon as they are encountered rather than waiting to see if they will be invoked in function definition.
• CBV attempt to evaluate value passed to y, and enters inf loop

Scala's eval strategy:

• Scala normally uses CBV
• if the type of a function parameter stars with =>, it uses CBN
• def constOne(x: Int, y: => Int) = 1
• In practice, CBV is often exponentially faster
• Also plays nicer with imperative effects and side effects

Evaluation Strategy Resources

### Lecture 1.4: Conditionals and Value Definitions:

Conditional Expression

• if-else is an expression, not a statement
• def abs(x: Int) = if (x>=0) x else -x

Value Definition

• we saw that function parameters can be passed by value or by name
• the def form is “by-name”, its rhs is evaluated on each use (invocation)
• val is “by value”
• val y = square(x), the rhs of a val def is evaluated At the point of the definition itself
• val y refers to 4, not square(2)
• Note that def loop: Boolean = loop evaluates, but val x = loop does not –> inf loop

### Lecture 1.5/1.6: Blocks and Lexical Scope

Newton's Method

• achieve estimate of square root by successive approximations

Fixed Point Iterative Implementation Newton's Method

def isGoodEnough(guess: Double, x: Double): Boolean = {
//abs(guess*guess - x) < .001 // the absolute error
// relative error accounts for very large and very small values
abs(guess*guess - x)/x < .001

}

def improve(guess: Double, x: Double): Double = {
(guess + x/guess)/2
}

def sqrtIter(guess:Double, x: Double): Double = {
// note that only recursive functions require an explicit return type in Scala
if (isGoodEnough(guess, x)) x)
else sqrtIter(improve(guess,x),x)
}

def sqrt(x: Double): Double = {
// can nest prevous functions here to avoid name-space pollution
sqrtIter(1.0, x)
}

Avoid name-space pollution

• nested functions; nest improve, isGoodEnough functions inside the sqrtIter() def
• Note that values defined within the scope of the function is visible to any nested functions
• Note the redudant assignments of the variable, x, in the function definitions above

Blocks

• a block is delimited by {}
• contains a seq of defs or expressions
• the last element of a block is an expression that defines its value
• Blocks are themselves expressions
• Note that values defined in the block are only visible within the block, and that values in the name space are visible in the block unless they are shadowed (overwrite)

### Lecture 1.7: Tail Recursion

JVM Stacks and Stack Frames

• Stack definition: Each JVM thread has a private Java virtual machine stack, created at the same time as the thread. A JVM stack stores frames, also called “stack frames”…it holds local variables and partial results, and plays a part in method invocation and return
• When a new thread is launched, the JVM creates a new stack for the thread. A Java stack stores a thread’s state in discrete frames. The JVM only performs two operations directly on Java stacks: it pushes and pops frames.
• When a thread invokes a Java method, the JVM creates and pushes a new frame onto the thread’s stack. This new frame then becomes the current frame. As the method executes, it uses the frame to store parameters, local variables, intermediate computations, and other data.
• Stack Frame: consists of local variables, operand stack, and frame data (constant pool ref)
• As the method is executed, the code can only access the values in the current stack frame, which you can visualize as being the top-most stack frame.

Tail Recursion

• A tail-recursive function is just a function whose very last action is a call to itself (or another function)
• “When you write your recursive function in this way, the Scala compiler can optimize the resulting JVM bytecode so that the function requires only one stack frame — as opposed to one stack frame for each level of recursion!”
• Reuses stack frame, avoids stack overflow in functions susceptible to deep recursive chains
• equivalent to a loop in an imperative program
• remember to avoid premature optimization

Pattern to make recursive function tail-recursive:

• nest original function in a new function
• insert “accumulator” object into super function
• modify the nested function to utilize accumulator
• A way to prove that sum isn’t tail-recursive is to tag the function with a Scala annotation named @tailrec. This annotation won’t compile unless the function is tail-recursive.

Consider Factorial

def factorial_nonTR(n: Int) : Int = {
if (n == 0) 1 else n*factorial_nonTR(n-1)
}

// Tail Recursive
def factorial(n: Int) : Int = {

def factorial_Acc(n:Int, acc:Int): Int = {
if (n==0) acc*1 else factorial_Acc(n-1, n*acc)
}

factorial_Acc(n, 1)
}
`

Exercises: Recursion

##### Miguel Rivera-Lanas
###### Data Scientist / Engineer

Currently a Data Scientist/Engineer at a hedge fund. Primarily focused on empirical methods to study quantitative and social effects of disinformation propagation, content moderation systems, and computational social science generally.


text:
Understanding of fracture behavior is useful in selecting materials for product designs, and it is incredibly valuable to know if a material will experience a ductile-brittle transition and what temperature this transition occurs. Knowledge of a material's ductile-brittle transition temperature can prevent catastrophes such as the WW2 Liberty Ship failure.

Ductile fracture is characterized by a large amount of plastic deformation which leads to slow fracture that is often detectable before the material reaches a critical point. Conversely, brittle fracture contains very little plastic deformation and often little warning before fracture occurs.

The Charpy impact test, depicted below, measures the amount of energy absorbed upon impact. A weighted pendulum, which is held at some height $h$ from the sample, swings and impacts the sample at a very high strain rate. The pendulum then continues to swing until reaching a final height of $h'$. The difference between the potential energies at height $h$ and $h'$ is considering to be the energy that the sample absorbed upon impact.

The sample for a Charpy impact test is notched to in order to control crack propagation and ensure consistent results across samples. The photo below displays a generic Charpy sample- note the V-shaped notch in the middle of the sample.

Fracture mechanics in materials ultimately extends to ease of dislocation movement. For samples in which dislocation motion in uninhibited, the material may accommodate an applied load through plastic deformation. For FCC metals, slip systems allow dislocations to move very easily along the close-packed planes. However, for BCC metals, there are no close-packed planes that allow for easy dislocation migration, and thus dislocation movement in these materials (BCC metals) require a thermal activation in order to slip. Otherwise, the material accommodates the applied stress through more drastic mechanisms, such as breaking of bonds.

An FCC unit cell with the close-packed plane shown in red.

A BCC unit cell with no true close-packed plane. These psuedo-"slip" systems need some degree of thermal activation before they will operate.

The figure below displays the general behaviors for various materials including FCC metals, BCC metals, and high-strength materials with regard to the Charpy impact test. A ductile-brittle transition temperature is observed for metals with a body-centered cubic structure as a result of the dependence on temperature for dislocation motion.

I'll provide some data from an undergrad lab experiment which examines the impact behavior for annealed 1018 steel and 304 stainless steel. Annealed 1018 steel is a low-strength BCC steel, which exhibits a ductile-brittle transition as shown above in the general behavior schematic. 304 stainless steel is a low-strength FCC metal, which has close-packed planes that allow for dislocation movement at all temperatures. Thus, this metal does not exhibit a ductile-brittle transition. The ductile-brittle transition temperature, $DBTT$, may be approximated as the temperature that corresponds with the energy calculated from

$DBTT = LSE + \frac{{USE - LSE}}{2}$

where $USE$ and $LSE$ represent the upper and lower shelf energies respectively. Generally, it reflects the inflection point on the logistic-type curves.

format: plain


text:
## Integration Sequence

Students learn/review how to do integrals in a multivariable context, using the vector differential $d\vec{r}=dx\, \hat{x}+dy\, \hat{y}+dz\, \hat{z}$ and its curvilinear coordinate analogues as a unifying strategy. This strategy is common among physicists, but is NOT typically taught in vector calculus courses and will be new to most students.
##### 1. Activity: Vector Differential--Rectangular

In this introductory lecture/SWBQ, students are given a picture as a guide. They then write down an algebraic expression for the vector differential in rectangular coordinates for coordinate equals constant paths.

This activity can be done as a mini-lecture/SWBQ as an introduction to Vector Differential--Curvilinear where students find the vector differential in cylindrical and spherical coordinates..

##### 2. Activity: Vector Differential--Curvilinear

In this small group activity, students are given a picture as a guide. They then write down an algebraic expression for the vector differential in different coordinate systems (cartesian, cylindrical, spherical).

Use Vector Differential--Rectangular as an introduction. This activity can be done simultaneously with Pineapples and Pumpkins where students or the instructor cut volume elements out of pineapples and/or pumpkins to show the geometry.

##### 3. Activity: Pineapples and Pumpkins

There are two versions of this activity:

As a whole class activity, the instructor cuts a pumpkin in order to produce a small volume element $d\tau$, interspersing their work with a sequence of small whiteboard questions. This version of the activity is described here.

As a small group activity, students are given pineapple rounds and pumpkin wedges to explore area volume elements in cylindrical and spherical coordinate systems. In this version of the activity, the fruit is distribued to the students with appropriate children's pumpkin cutting equipment, as part of activities Vector Differential--Curvilinear, Scalar Surface and Volume Elements, or Vector Surface and Volume Elements.

##### 4. Activity: Acting Out Charge Densities
Students, pretending they are point charges, move around the room acting out various prompts from the instructor regarding charge densities, including linear $\lambda$, surface $\sigma$, and volume $\rho$ charge densities, both uniform and non-uniform. The instructor demonstrates what it means to measure these quantities. In a remote setting, we have students manipulate 10 coins to model the prompts in this activity and the we demonstrate the answers with coins under a doc cam.
##### 5. Homework Problem: Helix

A helix with 17 turns has height $H$ and radius $R$. Charge is distributed on the helix so that the charge density increases like (i.e. proportional to) the square of the distance up the helix. At the bottom of the helix the linear charge density is $0~\frac{\textrm{C}}{\textrm{m}}$. At the top of the helix, the linear charge density is $13~\frac{\textrm{C}}{\textrm{m}}$. What is the total charge on the helix?

##### 6. Activity: Scalar Surface and Volume Elements

Students use known algebraic expressions for length elements $d\ell$ to determine all simple scalar area $dA$ and volume elements $d\tau$ in cylindrical and spherical coordinates.

This activity is identical to Vector Surface and Volume Elements except uses a scalar approach to find surface, and volume elements.

##### 7. Activity: Vector Surface and Volume Elements

Students use known algebraic expressions for vector line elements $d\vec{r}$ to determine all simple vector area $d\vec{A}$ and volume elements $d\tau$ in cylindrical and spherical coordinates.

This activity is identical to Scalar Surface and Volume Elements except uses a vector approach to find directed surface and volume elements.

##### 8. Homework Problem: Cube Charge
1. Charge is distributed throughout the volume of a dielectric cube with charge density $\rho=\beta z^2$, where $z$ is the height from the bottom of the cube, and where each side of the cube has length $L$. What is the total charge inside the cube? Do this problem in two ways as both a single integral and as a triple integral.
2. In a new physical situation: Charge is distributed on the surface of a cube with charge density $\sigma=\alpha z$ where $z$ is the height from the bottom of the cube, and where each side of the cube has length $L$. What is the total charge on the cube? Don't forget about the top and bottom of the cube.
##### 9. Activity: Total Charge
In this small group activity, students integrate over non-uniform charge densities in cylindrical and spherical coordinates to calculate total charge.
##### 10. Homework Problem: Total Charge

For each case below, find the total charge.

1. A positively charged (dielectric) spherical shell of inner radius $a$ and outer radius $b$ with a spherically symmetric internal charge density $$\rho(\vec{r})=3\alpha\, e^{(kr)^3}$$
2. A positively charged (dielectric) cylindrical shell of inner radius $a$ and outer radius $b$ with a cylindrically symmetric internal charge density $$\rho(\vec{r})=\alpha\, \frac{1}{s}\, e^{ks}$$

##### 11. Activity: Flux through a Cone
Students calculate the flux from the vector field $\vec{F} = C\, z\, \hat{z}$ through a right cone of height $H$ and radius $R$ .
##### 12. Activity: Acting Out Current Density
Students, pretending they are point charges, move around the room so as to make an imaginary magnetic field meter register a constant magnetic field, introducing the concept of steady current. Students act out linear $\vec{I}$, surface $\vec{K}$, and volume $\vec{J}$ current densities. The instructor demonstrates what it means to measure these quantities by counting how many students pass through a gate.
##### 13. Homework Problem: Total Current, Circular Cross Section

A current $I$ flows down a cylindrical wire of radius $R$.

1. If it is uniformly distributed over the surface, give a formula for the surface current density $\vec K$.
2. If it is distributed in such a way that the volume current density, $|\vec J|$, is inversely proportional to the distance from the axis, give a formula for $\vec J$.

##### 14. Homework Problem: Total Current, Square Cross-Section
1. Current $I$ flows down a wire with square cross-section. The length of the square side is $L$. If the current is uniformly distributed over the entire area, find the current density .
2. If the current is uniformly distributed over the outer surface only, find the current density .


text:
# 多轴飞行器 PID 调参指南

## 简介

PX4 使用 P 比例、 I 积分、 D 微分 (PID) 控制器, 是使用最广泛的控制技术。

The controllers are layered, which means a higher-level controller passes its results to a lower-level controller. The lowest-level controller is the the rate controller, then there is the attitude contoller, and then the velocity & position controller. The PID tuning needs to be done in the same order, starting with the rate controller, as it will affect all other controllers.

## 前置条件

• 您已为您的飞行器选择了最接近的 默认机型配置 。 这应该可以让你的飞行器飞起来。
• 您应该已经执行过 电调（ESC）校准
• PWM_MIN 正确设置。 它需要设置一个小值, 但当飞行器解锁时, 需要保证 电机不停转

可以在 特技 Acro 模式 手动/自稳模式 中进行测试：

• 卸下螺旋桨
• 解锁，并将油门杆拉到最低
• 把飞行器倾斜到各个方向, 大约60度
• 确保没有电机停转
• 可以通过 SDLOG_PROFILE 参数，启用高速率日志记录配置文件, 以便使用日志来查看角速率和姿态跟踪性能 (之后可以禁用该选项) 。

## 调参步骤

For safety reasons, the default gains are set to low values. You must increase the gains before you can expect good control responses.

• 调整增益时，所有的增益值都应该慢慢增加, 因为增益过大可能会导致危险的振荡! 一般情况下，每次增益值的调整幅度大约在20%到30%，获得最优增益值后，基于最优值再下调5%到10%。
• 在修改参数之前务必先着陆。 慢慢增加油门，观察振荡的现象。
• Tune the vehicle around the hovering thrust point, and use the thrust curve parameter to account for thrust non-linearities or high-thrust oscillations.

### 速率控制器

• 我们更推荐特技模式， 但这种模式比较难飞。 如果你选择特技模式，记得把把特技模式指数因子都禁用了：
• MC_ACRO_EXPO = 0, MC_ACRO_EXPO_Y = 0, MC_ACRO_SUPEXPO = 0, MC_ACRO_SUPEXPOY = 0
• MC_ACRO_P_MAX = 200, MC_ACRO_R_MAX = 200
• MC_ACRO_Y_MAX = 100
• 手动/自稳模式更好飞，但这种模式也比较难观察姿态和角速度控制器到底调好了没。

• If you notice strong oscillations when first trying to takeoff (to the point where it does not fly), decrease all P and D gains until it takes off.
• 但如果你的飞行器对遥控器的所有指令都没什么反应的话，可以增加P增益试试。

#### P增益

P增益(比例增益) 用来减小误差。 它可以加快响应速度，因此应该在不引入震荡的前提下设的尽量的高。

• 如果P增益太高了，会有高频率的振荡。
• 如果 P 增益太低了:
• 飞行器会对遥控器的输入很迟钝。
• 如果是在特技模式下，飞行器会漂移，你会一直要矫正它来让它水平。

#### D 增益

D增益(微分增益) 用来增加阻尼，可以防止超调。 同样地，这个值应该尽量设大一些来避免超调。

• D增益太大，电机可能会抽搐、发热(也有可能不会) 。这是因为D项同时也会放大震动等带来的噪声。
• D增益太低会导致超调，即相比设定的值「冲过头了」。

#### I增益

I（积分）增益可以「记住误差」。 如果你发现过了一段时间了，角速度还是达不到设定值，那就该增加 I 了。 它很重要(尤其在特技模式下) ，但我们不应该把它设得太高。

• 如果积分增益太高：你会看到缓慢的振荡。
• If the I gain is too low: this is best tested in Acro mode, by tilting the vehicle to one side about 45 degrees, and keeping it like that. 他应该始终保持相同的角度。 如果它往回漂移，增加 I 。 通过观察日志我们也可以发现 I 增益太小的问题，可以看到实际的角速度过很久也达不到期望的角速度。

I 增益一般在0.3~0.5之间，俯仰角的一般要大一点。

#### 测试步骤

You can create a step-input for example for roll, by quickly pushing the roll stick to one side, and then let it go back quickly (be aware that the stick will oscillate too if you just let go of it, because it is spring-loaded — a well-tuned vehicle will follow these oscillations).

### Thrust Curve

To counteract that adjust the thrust curve with the THR_MDL_FAC parameter.

The rate controller might need to be re-tuned if you change this parameter.

The mapping from motor control signals (e.g. PWM) to expected thrust is linear by default — setting THR_MDL_FAC to 1 makes it quadratic. Values in between use a linear interpolation of the two. Typical values are between 0.3 and 0.5.

If you have a thrust stand (or can otherwise measure thrust), you can determine the relationship between the PWM control signal and the motor's actual thrust, and fit a function to the data. This Notebook shows how the thrust model factor THR_MDL_FAC may be calculated from previously measured thrust data.

The mapping between PWM and static thrust depends highly on the battery voltage.

If you don't have access to a thrust stand, you can also tune the modeling factor empirically. Start off with 0.3 and increase it by 0.1 at a time. If it is too high, you will start to notice oscillations at lower throttle values. If it is too low you'll notice oscillations at higher throttle values.

### Airmode & 混控器饱和

The rate controller outputs torque commands for all three axis (roll, pitch and yaw) and a scalar thrust value, which need to be converted into individual motor thrust commands. This step is called mixing.

It can happen that one of the motor commands becomes negative, for example for a low thrust and large roll command (and similarly it can go above 100%). This is a mixer saturation. It is physically impossible for the vehicle to execute these commands (except for reversible motors). PX4 has two modes to resolve this:

• Either by reducing the commanded torque for roll such that none of the motor commands is below zero (Airmode disabled). In the extreme case where the commanded thrust is zero, it means that no attitude correction is possible anymore, which is why a minimum thrust is always required for this mode.
• Or by increasing (boosting) the commanded thrust, such that none of the motor commands is negative (Airmode enabled). This has the big advantage that the attitude/rates can be tracked correctly even at low or zero throttle. It generally improves the flight performance.

However it increases the total thrust which can lead to situations where the vehicle continues to ascend even though the throttle is reduced to zero. For a well-tuned, correctly functioning vehicle it is not the case, but for example it can happen when the vehicle strongly oscillates due to too high P tuning gains.

Both modes are shown below with a 2D illustration for two motors and a torque command for roll r. On the left motor r is added to the commanded thrust, while on the right motor it is subtracted from it. The motor thrusts are in green. With Airmode enabled, the commanded thrust is increased by b. When it is disabled, r is reduced.

![Airmode](../../images/mc_pid_tuning/MC_PID_tuning-Airmode.svg)

If mixing becomes saturated towards the upper bound the commanded thrust is reduced to ensure that no motor is commanded to deliver more than 100% thrust. This behaviour is similar to the Airmode logic, and is applied whether Airmode is enabled or disabled.

Once your vehicle flies well you can enable Airmode via the MC_AIRMODE parameter.


text:
Copied to
clipboard

## G = C3×Q8.D10order 480 = 25·3·5

### Direct product of C3 and Q8.D10

Series: Derived Chief Lower central Upper central

 Derived series C1 — C20 — C3×Q8.D10
 Chief series C1 — C5 — C10 — C20 — C60 — D5×C12 — C3×Q8⋊2D5 — C3×Q8.D10
 Lower central C5 — C10 — C20 — C3×Q8.D10
 Upper central C1 — C6 — C12 — C3×Q16

Generators and relations for C3×Q8.D10
G = < a,b,c,d,e | a3=b4=e2=1, c2=d10=b2, ab=ba, ac=ca, ad=da, ae=ea, cbc-1=dbd-1=ebe=b-1, dcd-1=b-1c, ece=bc, ede=b2d9 >

Subgroups: 464 in 124 conjugacy classes, 54 normal (34 characteristic)
C1, C2, C2, C3, C4, C4, C22, C5, C6, C6, C8, C8, C2×C4, D4, Q8, D5, C10, C12, C12, C2×C6, C15, C2×C8, D8, SD16, Q16, C4○D4, Dic5, C20, C20, D10, D10, C24, C24, C2×C12, C3×D4, C3×Q8, C3×D5, C30, C4○D8, C52C8, C40, C4×D5, C4×D5, D20, D20, C5×Q8, C2×C24, C3×D8, C3×SD16, C3×Q16, C3×C4○D4, C3×Dic5, C60, C60, C6×D5, C6×D5, C8×D5, D40, Q8⋊D5, C5×Q16, Q82D5, C3×C4○D8, C3×C52C8, C120, D5×C12, D5×C12, C3×D20, C3×D20, Q8×C15, Q8.D10, D5×C24, C3×D40, C3×Q8⋊D5, C15×Q16, C3×Q82D5, C3×Q8.D10
Quotients: C1, C2, C3, C22, C6, D4, C23, D5, C2×C6, C2×D4, D10, C3×D4, C22×C6, C3×D5, C4○D8, C22×D5, C6×D4, C6×D5, D4×D5, C3×C4○D8, D5×C2×C6, Q8.D10, C3×D4×D5, C3×Q8.D10

Smallest permutation representation of C3×Q8.D10
On 240 points
Generators in S240
(1 38 161)(2 39 162)(3 40 163)(4 21 164)(5 22 165)(6 23 166)(7 24 167)(8 25 168)(9 26 169)(10 27 170)(11 28 171)(12 29 172)(13 30 173)(14 31 174)(15 32 175)(16 33 176)(17 34 177)(18 35 178)(19 36 179)(20 37 180)(41 235 207)(42 236 208)(43 237 209)(44 238 210)(45 239 211)(46 240 212)(47 221 213)(48 222 214)(49 223 215)(50 224 216)(51 225 217)(52 226 218)(53 227 219)(54 228 220)(55 229 201)(56 230 202)(57 231 203)(58 232 204)(59 233 205)(60 234 206)(61 92 139)(62 93 140)(63 94 121)(64 95 122)(65 96 123)(66 97 124)(67 98 125)(68 99 126)(69 100 127)(70 81 128)(71 82 129)(72 83 130)(73 84 131)(74 85 132)(75 86 133)(76 87 134)(77 88 135)(78 89 136)(79 90 137)(80 91 138)(101 150 193)(102 151 194)(103 152 195)(104 153 196)(105 154 197)(106 155 198)(107 156 199)(108 157 200)(109 158 181)(110 159 182)(111 160 183)(112 141 184)(113 142 185)(114 143 186)(115 144 187)(116 145 188)(117 146 189)(118 147 190)(119 148 191)(120 149 192)
(1 86 11 96)(2 97 12 87)(3 88 13 98)(4 99 14 89)(5 90 15 100)(6 81 16 91)(7 92 17 82)(8 83 18 93)(9 94 19 84)(10 85 20 95)(21 126 31 136)(22 137 32 127)(23 128 33 138)(24 139 34 129)(25 130 35 140)(26 121 36 131)(27 132 37 122)(28 123 38 133)(29 134 39 124)(30 125 40 135)(41 189 51 199)(42 200 52 190)(43 191 53 181)(44 182 54 192)(45 193 55 183)(46 184 56 194)(47 195 57 185)(48 186 58 196)(49 197 59 187)(50 188 60 198)(61 177 71 167)(62 168 72 178)(63 179 73 169)(64 170 74 180)(65 161 75 171)(66 172 76 162)(67 163 77 173)(68 174 78 164)(69 165 79 175)(70 176 80 166)(101 229 111 239)(102 240 112 230)(103 231 113 221)(104 222 114 232)(105 233 115 223)(106 224 116 234)(107 235 117 225)(108 226 118 236)(109 237 119 227)(110 228 120 238)(141 202 151 212)(142 213 152 203)(143 204 153 214)(144 215 154 205)(145 206 155 216)(146 217 156 207)(147 208 157 218)(148 219 158 209)(149 210 159 220)(150 201 160 211)
(1 51 11 41)(2 200 12 190)(3 53 13 43)(4 182 14 192)(5 55 15 45)(6 184 16 194)(7 57 17 47)(8 186 18 196)(9 59 19 49)(10 188 20 198)(21 110 31 120)(22 229 32 239)(23 112 33 102)(24 231 34 221)(25 114 35 104)(26 233 36 223)(27 116 37 106)(28 235 38 225)(29 118 39 108)(30 237 40 227)(42 87 52 97)(44 89 54 99)(46 91 56 81)(48 93 58 83)(50 95 60 85)(61 152 71 142)(62 204 72 214)(63 154 73 144)(64 206 74 216)(65 156 75 146)(66 208 76 218)(67 158 77 148)(68 210 78 220)(69 160 79 150)(70 212 80 202)(82 185 92 195)(84 187 94 197)(86 189 96 199)(88 191 98 181)(90 193 100 183)(101 127 111 137)(103 129 113 139)(105 131 115 121)(107 133 117 123)(109 135 119 125)(122 234 132 224)(124 236 134 226)(126 238 136 228)(128 240 138 230)(130 222 140 232)(141 176 151 166)(143 178 153 168)(145 180 155 170)(147 162 157 172)(149 164 159 174)(161 217 171 207)(163 219 173 209)(165 201 175 211)(167 203 177 213)(169 205 179 215)
(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20)(21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40)(41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60)(61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80)(81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100)(101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120)(121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140)(141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160)(161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180)(181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200)(201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220)(221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240)
(1 10)(2 9)(3 8)(4 7)(5 6)(11 20)(12 19)(13 18)(14 17)(15 16)(21 24)(22 23)(25 40)(26 39)(27 38)(28 37)(29 36)(30 35)(31 34)(32 33)(41 60)(42 59)(43 58)(44 57)(45 56)(46 55)(47 54)(48 53)(49 52)(50 51)(61 78)(62 77)(63 76)(64 75)(65 74)(66 73)(67 72)(68 71)(69 70)(79 80)(81 100)(82 99)(83 98)(84 97)(85 96)(86 95)(87 94)(88 93)(89 92)(90 91)(101 112)(102 111)(103 110)(104 109)(105 108)(106 107)(113 120)(114 119)(115 118)(116 117)(121 134)(122 133)(123 132)(124 131)(125 130)(126 129)(127 128)(135 140)(136 139)(137 138)(141 150)(142 149)(143 148)(144 147)(145 146)(151 160)(152 159)(153 158)(154 157)(155 156)(161 170)(162 169)(163 168)(164 167)(165 166)(171 180)(172 179)(173 178)(174 177)(175 176)(181 196)(182 195)(183 194)(184 193)(185 192)(186 191)(187 190)(188 189)(197 200)(198 199)(201 212)(202 211)(203 210)(204 209)(205 208)(206 207)(213 220)(214 219)(215 218)(216 217)(221 228)(222 227)(223 226)(224 225)(229 240)(230 239)(231 238)(232 237)(233 236)(234 235)

G:=sub<Sym(240)| (1,38,161)(2,39,162)(3,40,163)(4,21,164)(5,22,165)(6,23,166)(7,24,167)(8,25,168)(9,26,169)(10,27,170)(11,28,171)(12,29,172)(13,30,173)(14,31,174)(15,32,175)(16,33,176)(17,34,177)(18,35,178)(19,36,179)(20,37,180)(41,235,207)(42,236,208)(43,237,209)(44,238,210)(45,239,211)(46,240,212)(47,221,213)(48,222,214)(49,223,215)(50,224,216)(51,225,217)(52,226,218)(53,227,219)(54,228,220)(55,229,201)(56,230,202)(57,231,203)(58,232,204)(59,233,205)(60,234,206)(61,92,139)(62,93,140)(63,94,121)(64,95,122)(65,96,123)(66,97,124)(67,98,125)(68,99,126)(69,100,127)(70,81,128)(71,82,129)(72,83,130)(73,84,131)(74,85,132)(75,86,133)(76,87,134)(77,88,135)(78,89,136)(79,90,137)(80,91,138)(101,150,193)(102,151,194)(103,152,195)(104,153,196)(105,154,197)(106,155,198)(107,156,199)(108,157,200)(109,158,181)(110,159,182)(111,160,183)(112,141,184)(113,142,185)(114,143,186)(115,144,187)(116,145,188)(117,146,189)(118,147,190)(119,148,191)(120,149,192), (1,86,11,96)(2,97,12,87)(3,88,13,98)(4,99,14,89)(5,90,15,100)(6,81,16,91)(7,92,17,82)(8,83,18,93)(9,94,19,84)(10,85,20,95)(21,126,31,136)(22,137,32,127)(23,128,33,138)(24,139,34,129)(25,130,35,140)(26,121,36,131)(27,132,37,122)(28,123,38,133)(29,134,39,124)(30,125,40,135)(41,189,51,199)(42,200,52,190)(43,191,53,181)(44,182,54,192)(45,193,55,183)(46,184,56,194)(47,195,57,185)(48,186,58,196)(49,197,59,187)(50,188,60,198)(61,177,71,167)(62,168,72,178)(63,179,73,169)(64,170,74,180)(65,161,75,171)(66,172,76,162)(67,163,77,173)(68,174,78,164)(69,165,79,175)(70,176,80,166)(101,229,111,239)(102,240,112,230)(103,231,113,221)(104,222,114,232)(105,233,115,223)(106,224,116,234)(107,235,117,225)(108,226,118,236)(109,237,119,227)(110,228,120,238)(141,202,151,212)(142,213,152,203)(143,204,153,214)(144,215,154,205)(145,206,155,216)(146,217,156,207)(147,208,157,218)(148,219,158,209)(149,210,159,220)(150,201,160,211), (1,51,11,41)(2,200,12,190)(3,53,13,43)(4,182,14,192)(5,55,15,45)(6,184,16,194)(7,57,17,47)(8,186,18,196)(9,59,19,49)(10,188,20,198)(21,110,31,120)(22,229,32,239)(23,112,33,102)(24,231,34,221)(25,114,35,104)(26,233,36,223)(27,116,37,106)(28,235,38,225)(29,118,39,108)(30,237,40,227)(42,87,52,97)(44,89,54,99)(46,91,56,81)(48,93,58,83)(50,95,60,85)(61,152,71,142)(62,204,72,214)(63,154,73,144)(64,206,74,216)(65,156,75,146)(66,208,76,218)(67,158,77,148)(68,210,78,220)(69,160,79,150)(70,212,80,202)(82,185,92,195)(84,187,94,197)(86,189,96,199)(88,191,98,181)(90,193,100,183)(101,127,111,137)(103,129,113,139)(105,131,115,121)(107,133,117,123)(109,135,119,125)(122,234,132,224)(124,236,134,226)(126,238,136,228)(128,240,138,230)(130,222,140,232)(141,176,151,166)(143,178,153,168)(145,180,155,170)(147,162,157,172)(149,164,159,174)(161,217,171,207)(163,219,173,209)(165,201,175,211)(167,203,177,213)(169,205,179,215), (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)(21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40)(41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60)(61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80)(81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100)(101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120)(121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140)(141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160)(161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180)(181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200)(201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220)(221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240), (1,10)(2,9)(3,8)(4,7)(5,6)(11,20)(12,19)(13,18)(14,17)(15,16)(21,24)(22,23)(25,40)(26,39)(27,38)(28,37)(29,36)(30,35)(31,34)(32,33)(41,60)(42,59)(43,58)(44,57)(45,56)(46,55)(47,54)(48,53)(49,52)(50,51)(61,78)(62,77)(63,76)(64,75)(65,74)(66,73)(67,72)(68,71)(69,70)(79,80)(81,100)(82,99)(83,98)(84,97)(85,96)(86,95)(87,94)(88,93)(89,92)(90,91)(101,112)(102,111)(103,110)(104,109)(105,108)(106,107)(113,120)(114,119)(115,118)(116,117)(121,134)(122,133)(123,132)(124,131)(125,130)(126,129)(127,128)(135,140)(136,139)(137,138)(141,150)(142,149)(143,148)(144,147)(145,146)(151,160)(152,159)(153,158)(154,157)(155,156)(161,170)(162,169)(163,168)(164,167)(165,166)(171,180)(172,179)(173,178)(174,177)(175,176)(181,196)(182,195)(183,194)(184,193)(185,192)(186,191)(187,190)(188,189)(197,200)(198,199)(201,212)(202,211)(203,210)(204,209)(205,208)(206,207)(213,220)(214,219)(215,218)(216,217)(221,228)(222,227)(223,226)(224,225)(229,240)(230,239)(231,238)(232,237)(233,236)(234,235)>;

G:=Group( (1,38,161)(2,39,162)(3,40,163)(4,21,164)(5,22,165)(6,23,166)(7,24,167)(8,25,168)(9,26,169)(10,27,170)(11,28,171)(12,29,172)(13,30,173)(14,31,174)(15,32,175)(16,33,176)(17,34,177)(18,35,178)(19,36,179)(20,37,180)(41,235,207)(42,236,208)(43,237,209)(44,238,210)(45,239,211)(46,240,212)(47,221,213)(48,222,214)(49,223,215)(50,224,216)(51,225,217)(52,226,218)(53,227,219)(54,228,220)(55,229,201)(56,230,202)(57,231,203)(58,232,204)(59,233,205)(60,234,206)(61,92,139)(62,93,140)(63,94,121)(64,95,122)(65,96,123)(66,97,124)(67,98,125)(68,99,126)(69,100,127)(70,81,128)(71,82,129)(72,83,130)(73,84,131)(74,85,132)(75,86,133)(76,87,134)(77,88,135)(78,89,136)(79,90,137)(80,91,138)(101,150,193)(102,151,194)(103,152,195)(104,153,196)(105,154,197)(106,155,198)(107,156,199)(108,157,200)(109,158,181)(110,159,182)(111,160,183)(112,141,184)(113,142,185)(114,143,186)(115,144,187)(116,145,188)(117,146,189)(118,147,190)(119,148,191)(120,149,192), (1,86,11,96)(2,97,12,87)(3,88,13,98)(4,99,14,89)(5,90,15,100)(6,81,16,91)(7,92,17,82)(8,83,18,93)(9,94,19,84)(10,85,20,95)(21,126,31,136)(22,137,32,127)(23,128,33,138)(24,139,34,129)(25,130,35,140)(26,121,36,131)(27,132,37,122)(28,123,38,133)(29,134,39,124)(30,125,40,135)(41,189,51,199)(42,200,52,190)(43,191,53,181)(44,182,54,192)(45,193,55,183)(46,184,56,194)(47,195,57,185)(48,186,58,196)(49,197,59,187)(50,188,60,198)(61,177,71,167)(62,168,72,178)(63,179,73,169)(64,170,74,180)(65,161,75,171)(66,172,76,162)(67,163,77,173)(68,174,78,164)(69,165,79,175)(70,176,80,166)(101,229,111,239)(102,240,112,230)(103,231,113,221)(104,222,114,232)(105,233,115,223)(106,224,116,234)(107,235,117,225)(108,226,118,236)(109,237,119,227)(110,228,120,238)(141,202,151,212)(142,213,152,203)(143,204,153,214)(144,215,154,205)(145,206,155,216)(146,217,156,207)(147,208,157,218)(148,219,158,209)(149,210,159,220)(150,201,160,211), (1,51,11,41)(2,200,12,190)(3,53,13,43)(4,182,14,192)(5,55,15,45)(6,184,16,194)(7,57,17,47)(8,186,18,196)(9,59,19,49)(10,188,20,198)(21,110,31,120)(22,229,32,239)(23,112,33,102)(24,231,34,221)(25,114,35,104)(26,233,36,223)(27,116,37,106)(28,235,38,225)(29,118,39,108)(30,237,40,227)(42,87,52,97)(44,89,54,99)(46,91,56,81)(48,93,58,83)(50,95,60,85)(61,152,71,142)(62,204,72,214)(63,154,73,144)(64,206,74,216)(65,156,75,146)(66,208,76,218)(67,158,77,148)(68,210,78,220)(69,160,79,150)(70,212,80,202)(82,185,92,195)(84,187,94,197)(86,189,96,199)(88,191,98,181)(90,193,100,183)(101,127,111,137)(103,129,113,139)(105,131,115,121)(107,133,117,123)(109,135,119,125)(122,234,132,224)(124,236,134,226)(126,238,136,228)(128,240,138,230)(130,222,140,232)(141,176,151,166)(143,178,153,168)(145,180,155,170)(147,162,157,172)(149,164,159,174)(161,217,171,207)(163,219,173,209)(165,201,175,211)(167,203,177,213)(169,205,179,215), (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)(21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40)(41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60)(61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80)(81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100)(101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120)(121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140)(141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160)(161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180)(181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200)(201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220)(221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240), (1,10)(2,9)(3,8)(4,7)(5,6)(11,20)(12,19)(13,18)(14,17)(15,16)(21,24)(22,23)(25,40)(26,39)(27,38)(28,37)(29,36)(30,35)(31,34)(32,33)(41,60)(42,59)(43,58)(44,57)(45,56)(46,55)(47,54)(48,53)(49,52)(50,51)(61,78)(62,77)(63,76)(64,75)(65,74)(66,73)(67,72)(68,71)(69,70)(79,80)(81,100)(82,99)(83,98)(84,97)(85,96)(86,95)(87,94)(88,93)(89,92)(90,91)(101,112)(102,111)(103,110)(104,109)(105,108)(106,107)(113,120)(114,119)(115,118)(116,117)(121,134)(122,133)(123,132)(124,131)(125,130)(126,129)(127,128)(135,140)(136,139)(137,138)(141,150)(142,149)(143,148)(144,147)(145,146)(151,160)(152,159)(153,158)(154,157)(155,156)(161,170)(162,169)(163,168)(164,167)(165,166)(171,180)(172,179)(173,178)(174,177)(175,176)(181,196)(182,195)(183,194)(184,193)(185,192)(186,191)(187,190)(188,189)(197,200)(198,199)(201,212)(202,211)(203,210)(204,209)(205,208)(206,207)(213,220)(214,219)(215,218)(216,217)(221,228)(222,227)(223,226)(224,225)(229,240)(230,239)(231,238)(232,237)(233,236)(234,235) );

G=PermutationGroup([[(1,38,161),(2,39,162),(3,40,163),(4,21,164),(5,22,165),(6,23,166),(7,24,167),(8,25,168),(9,26,169),(10,27,170),(11,28,171),(12,29,172),(13,30,173),(14,31,174),(15,32,175),(16,33,176),(17,34,177),(18,35,178),(19,36,179),(20,37,180),(41,235,207),(42,236,208),(43,237,209),(44,238,210),(45,239,211),(46,240,212),(47,221,213),(48,222,214),(49,223,215),(50,224,216),(51,225,217),(52,226,218),(53,227,219),(54,228,220),(55,229,201),(56,230,202),(57,231,203),(58,232,204),(59,233,205),(60,234,206),(61,92,139),(62,93,140),(63,94,121),(64,95,122),(65,96,123),(66,97,124),(67,98,125),(68,99,126),(69,100,127),(70,81,128),(71,82,129),(72,83,130),(73,84,131),(74,85,132),(75,86,133),(76,87,134),(77,88,135),(78,89,136),(79,90,137),(80,91,138),(101,150,193),(102,151,194),(103,152,195),(104,153,196),(105,154,197),(106,155,198),(107,156,199),(108,157,200),(109,158,181),(110,159,182),(111,160,183),(112,141,184),(113,142,185),(114,143,186),(115,144,187),(116,145,188),(117,146,189),(118,147,190),(119,148,191),(120,149,192)], [(1,86,11,96),(2,97,12,87),(3,88,13,98),(4,99,14,89),(5,90,15,100),(6,81,16,91),(7,92,17,82),(8,83,18,93),(9,94,19,84),(10,85,20,95),(21,126,31,136),(22,137,32,127),(23,128,33,138),(24,139,34,129),(25,130,35,140),(26,121,36,131),(27,132,37,122),(28,123,38,133),(29,134,39,124),(30,125,40,135),(41,189,51,199),(42,200,52,190),(43,191,53,181),(44,182,54,192),(45,193,55,183),(46,184,56,194),(47,195,57,185),(48,186,58,196),(49,197,59,187),(50,188,60,198),(61,177,71,167),(62,168,72,178),(63,179,73,169),(64,170,74,180),(65,161,75,171),(66,172,76,162),(67,163,77,173),(68,174,78,164),(69,165,79,175),(70,176,80,166),(101,229,111,239),(102,240,112,230),(103,231,113,221),(104,222,114,232),(105,233,115,223),(106,224,116,234),(107,235,117,225),(108,226,118,236),(109,237,119,227),(110,228,120,238),(141,202,151,212),(142,213,152,203),(143,204,153,214),(144,215,154,205),(145,206,155,216),(146,217,156,207),(147,208,157,218),(148,219,158,209),(149,210,159,220),(150,201,160,211)], [(1,51,11,41),(2,200,12,190),(3,53,13,43),(4,182,14,192),(5,55,15,45),(6,184,16,194),(7,57,17,47),(8,186,18,196),(9,59,19,49),(10,188,20,198),(21,110,31,120),(22,229,32,239),(23,112,33,102),(24,231,34,221),(25,114,35,104),(26,233,36,223),(27,116,37,106),(28,235,38,225),(29,118,39,108),(30,237,40,227),(42,87,52,97),(44,89,54,99),(46,91,56,81),(48,93,58,83),(50,95,60,85),(61,152,71,142),(62,204,72,214),(63,154,73,144),(64,206,74,216),(65,156,75,146),(66,208,76,218),(67,158,77,148),(68,210,78,220),(69,160,79,150),(70,212,80,202),(82,185,92,195),(84,187,94,197),(86,189,96,199),(88,191,98,181),(90,193,100,183),(101,127,111,137),(103,129,113,139),(105,131,115,121),(107,133,117,123),(109,135,119,125),(122,234,132,224),(124,236,134,226),(126,238,136,228),(128,240,138,230),(130,222,140,232),(141,176,151,166),(143,178,153,168),(145,180,155,170),(147,162,157,172),(149,164,159,174),(161,217,171,207),(163,219,173,209),(165,201,175,211),(167,203,177,213),(169,205,179,215)], [(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20),(21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40),(41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60),(61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80),(81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100),(101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120),(121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140),(141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160),(161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180),(181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200),(201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220),(221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240)], [(1,10),(2,9),(3,8),(4,7),(5,6),(11,20),(12,19),(13,18),(14,17),(15,16),(21,24),(22,23),(25,40),(26,39),(27,38),(28,37),(29,36),(30,35),(31,34),(32,33),(41,60),(42,59),(43,58),(44,57),(45,56),(46,55),(47,54),(48,53),(49,52),(50,51),(61,78),(62,77),(63,76),(64,75),(65,74),(66,73),(67,72),(68,71),(69,70),(79,80),(81,100),(82,99),(83,98),(84,97),(85,96),(86,95),(87,94),(88,93),(89,92),(90,91),(101,112),(102,111),(103,110),(104,109),(105,108),(106,107),(113,120),(114,119),(115,118),(116,117),(121,134),(122,133),(123,132),(124,131),(125,130),(126,129),(127,128),(135,140),(136,139),(137,138),(141,150),(142,149),(143,148),(144,147),(145,146),(151,160),(152,159),(153,158),(154,157),(155,156),(161,170),(162,169),(163,168),(164,167),(165,166),(171,180),(172,179),(173,178),(174,177),(175,176),(181,196),(182,195),(183,194),(184,193),(185,192),(186,191),(187,190),(188,189),(197,200),(198,199),(201,212),(202,211),(203,210),(204,209),(205,208),(206,207),(213,220),(214,219),(215,218),(216,217),(221,228),(222,227),(223,226),(224,225),(229,240),(230,239),(231,238),(232,237),(233,236),(234,235)]])

84 conjugacy classes

 class 1 2A 2B 2C 2D 3A 3B 4A 4B 4C 4D 4E 5A 5B 6A 6B 6C 6D 6E 6F 6G 6H 8A 8B 8C 8D 10A 10B 12A 12B 12C 12D 12E 12F 12G 12H 12I 12J 15A 15B 15C 15D 20A 20B 20C 20D 20E 20F 24A 24B 24C 24D 24E 24F 24G 24H 30A 30B 30C 30D 40A 40B 40C 40D 60A 60B 60C 60D 60E ··· 60L 120A ··· 120H order 1 2 2 2 2 3 3 4 4 4 4 4 5 5 6 6 6 6 6 6 6 6 8 8 8 8 10 10 12 12 12 12 12 12 12 12 12 12 15 15 15 15 20 20 20 20 20 20 24 24 24 24 24 24 24 24 30 30 30 30 40 40 40 40 60 60 60 60 60 ··· 60 120 ··· 120 size 1 1 10 20 20 1 1 2 4 4 5 5 2 2 1 1 10 10 20 20 20 20 2 2 10 10 2 2 2 2 4 4 4 4 5 5 5 5 2 2 2 2 4 4 8 8 8 8 2 2 2 2 10 10 10 10 2 2 2 2 4 4 4 4 4 4 4 4 8 ··· 8 4 ··· 4

84 irreducible representations

 dim 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4 4 type + + + + + + + + + + + + + image C1 C2 C2 C2 C2 C2 C3 C6 C6 C6 C6 C6 D4 D4 D5 D10 D10 C3×D4 C3×D4 C3×D5 C4○D8 C6×D5 C6×D5 C3×C4○D8 D4×D5 Q8.D10 C3×D4×D5 C3×Q8.D10 kernel C3×Q8.D10 D5×C24 C3×D40 C3×Q8⋊D5 C15×Q16 C3×Q8⋊2D5 Q8.D10 C8×D5 D40 Q8⋊D5 C5×Q16 Q8⋊2D5 C3×Dic5 C6×D5 C3×Q16 C24 C3×Q8 Dic5 D10 Q16 C15 C8 Q8 C5 C6 C3 C2 C1 # reps 1 1 1 2 1 2 2 2 2 4 2 4 1 1 2 2 4 2 2 4 4 4 8 8 2 4 4 8

Matrix representation of C3×Q8.D10 in GL4(𝔽241) generated by

 225 0 0 0 0 225 0 0 0 0 1 0 0 0 0 1
,
 1 0 0 0 0 1 0 0 0 0 177 204 0 0 0 64
,
 240 0 0 0 0 240 0 0 0 0 176 140 0 0 49 65
,
 240 51 0 0 190 190 0 0 0 0 203 83 0 0 151 38
,
 240 51 0 0 0 1 0 0 0 0 203 8 0 0 151 38
G:=sub<GL(4,GF(241))| [225,0,0,0,0,225,0,0,0,0,1,0,0,0,0,1],[1,0,0,0,0,1,0,0,0,0,177,0,0,0,204,64],[240,0,0,0,0,240,0,0,0,0,176,49,0,0,140,65],[240,190,0,0,51,190,0,0,0,0,203,151,0,0,83,38],[240,0,0,0,51,1,0,0,0,0,203,151,0,0,8,38] >;

C3×Q8.D10 in GAP, Magma, Sage, TeX

C_3\times Q_8.D_{10}
% in TeX

G:=Group("C3xQ8.D10");
// GroupNames label

G:=SmallGroup(480,712);
// by ID

G=gap.SmallGroup(480,712);
# by ID

G:=PCGroup([7,-2,-2,-2,-3,-2,-2,-5,701,344,1094,303,268,1271,648,102,18822]);
// Polycyclic

G:=Group<a,b,c,d,e|a^3=b^4=e^2=1,c^2=d^10=b^2,a*b=b*a,a*c=c*a,a*d=d*a,a*e=e*a,c*b*c^-1=d*b*d^-1=e*b*e=b^-1,d*c*d^-1=b^-1*c,e*c*e=b*c,e*d*e=b^2*d^9>;
// generators/relations

׿
×
𝔽


text:
# Tag Info

15

"I am interested in Theorem statement, corollary, or Trick or Logic which solves this problem within one minute." Ok, so perhaps you are looking at Fermat's Little Theorem, where $n$ is prime, and $a$ is not a multiple of $n$: $$a^{n-1}\equiv1\ mod\ n$$ So in your case of $$a^{24}\equiv6a+2\ mod\ 13$$ Therefore using Fermat's Little Theorem: ...

9

If we don't have any restriction to $F$ (besides -I guess- that $F$ is a natural number) then $F=0,1,2$ produce rational numbers ($0,0,1$, respectively). Your proof is valid for $F\ge 3$ as you are assuming $3|F!$ in step (5).

8

Hint: $64\times 65 \dots \times 70 \equiv -7\times -6 \dots \times -1$ To break it down further try

8

If $3\mid a$ we are done, if not either $a = 1 \pmod 3$ or $a = 2 \pmod 3$, either case $a^2+2 = 0 \pmod 3$.

7

I will do exactly the same thing. I just finished my degree in mathematics but in our department there is not a single course of Number Theory, and since I will start my graduate courses in October I thought it will be a great idea to study Number Theory on my own. So, I asked one of my professors, who is interested in Algebraic Geometry and Number Theory, ...

6

The main result is Euclid's lemma: If $p$ is prime and $p$ divides $ab$, then $p$ divides $a$ or $p$ divides $b$. Now $6$ divides $m$ iff $2$ and $3$ divide $m$. Apply these two facts to $6$ divides $n^2$ to conclude that $2$ and $3$ divide $n^2$ and so that $2$ and $3$ divide $n$.

6

By Fermat's little theorem, $a^{24} = (a^{12})^2 \equiv 1^2 = 1 \pmod{13}$ (assuming $13\nmid a$, which is the case here).Thus you're really trying to solve $1\equiv6a+2\pmod{13}$, which is much easier.

5

This time I let the target Carmichael number be the least common multiple of the numbers from $1$ to $w.$ This is more efficient in terms of the number of divisors. The Superior Highly Composite Numbers and the Colossally Abundant Numbers share the main property of this LCM, which is that the exponent of some prime $p$ is proportional to $1/ \log p.$ As a ...

5

The solutions $a^{2} \equiv 1$ mod $29 \equiv (a-1)(a+1) \equiv 0$ mod $29$. Since $29$ is prime, it follows that $a-1 \equiv 0$ mod $29$ or $a+1 \equiv 0$ mod $29$. So we need to solve $2x \equiv 1$ mod $29$ or $2x \equiv -1 \equiv 28$ mod $29$. The first has solution $15$, the second $14$.

5

Alternatively, we first prove the following claim. Let $x,y,p,q\in\mathbb{N}$ be such that $\gcd(p,q)=1$ and $x^p=y^q$. Then, there exists $u \in \mathbb{N}$ such that $x=u^q$ and $y=u^p$. Proof: As $\gcd(p,q)=1$, there exist $r,s\in\mathbb{Z}$ such that $pr+qs=1$. Hence, ...

5

In my opinion Hardy &Wright's book on Number Theory is not the best possible book for someone "who has no prior training in Number Theory", I would suggest the following books. Elementary Number theory by David M. Burton. Number Theory A Historical Approach by John H. Watkins Higher Arithmetic by H. Davenport All the books are ...

4

One of the best is An Introduction to the Theory of Numbers by Niven, Zuckerman, and Montgomery.

4

You can write the numerator as $$a^3-a\mod 3.$$ Fermat's little theorem says all $a$ are congruent to $a^3$ mod $3$, hence the numerator is divisible by $3$.

4

Alternative to other answers: Note that $9^2=81\equiv 1\pmod{16}$, so $777^{777}\equiv 9^{777}=9\cdot(9^2)^{388}\equiv 9\pmod{16}$.

4

Rewrite this as $$3^z-4=5^x7^y$$ Then we see, because $x>0$, that $$3^z-4\equiv 0\mod 5 \iff 3^z\equiv -1\mod 5$$ so $z=2j$ is even. Then we have $(3^j-2)(3^j+2)=5^x7^y$. Since the gcd of these two divides $4$--because $(3^j-2)+(3^j+2)=4$--we have that they are coprime (any larger factor would then be a factor of $5^x7^y$ which is odd), i.e. one ...

4

If you want $10$ pairs, or infinitely many, note that if $k\ge 1$ then $\varphi(3\cdot 2^k)=\varphi(2^{k+1})$. One can also generate infinitely many triples, playing a similar game with $5\cdot 2^k$, $3\cdot 2^{k+1}$, and $2^{k+2}$. By playing with small numbers, we can find many other examples. For instance, $\varphi(7)=\varphi(9)$ and we can get an ...

4

To check that $x^{100} - 1$ is divisible by $1000$, it will suffice to check that it is divisible by $8$ and $125$. For each of these, you can use Euler's theorem, which will tell you that $x^{p^{k-1}(p-1)} \equiv 1 \pmod {p^k}$, where $p$ is a prime not dividing $x$. In this particular case, you have $x^{4} \equiv 1 \pmod{8}$ (so in particular $x^{100} ... 4 The relation "go modulo 4" is very nice. It respects addition and multiplication. So $$6 \cdot 7^{32} + 7 \cdot 9^{45}$$ is the same as $$6 \cdot 1 + 7 \cdot 1$$ by what you have already computed! 4 Let$d=(a,b)$be the g.c.d. of$a$and$b$. We will show that$a+b=d^2$. Write$a=a_1d$and$b=b_1d$. You also have$(a_1,b_1)=1$. We thus have $$\frac{1}{a}+\frac{1}{b}=\frac{1}{d}\left(\frac{1}{a_1}+\frac{1}{b_1}\right)=\frac{1}{c}$$$$\frac{a_1+b_1}{a_1b_1}=\frac{d}{c}$$ Observing that$(d,c)=1$and$(a_1+b_1,a_1b_1)=1$, we get that$a_1+b_1=d$and ... 4 In the real numbers, a method of finding a solution to a quadratic equation is to complete the square. This would involve adding and subtracting$(b/2)^2$.$b=3$in your case, and remember that$1/2 = 19 \mod 37$. Specifically notice: $$(x+3 \cdot 19)^2 \equiv x^2 + 2\cdot 3 \cdot 19 x + (3 \cdot 19)^2$$ $$\equiv x^2 + 3x + (20)^2 \mod 37$$ Note that$3 ...

4

$$\frac{26+11}{13}=2+\frac{1}{\frac{13}{11}}=2+\frac{1}{1+\frac{1}{\frac{11}{2}}}=2+\frac{1}{1+\frac{1}{5+\frac{1}{2}}}$$

4

When you’re speaking of the $p$-adic domain, the concepts of “real” and “complex” don’t make sense. Those concepts relate only to the archimedean metric on $\Bbb Q$. You’re correctly observing that every root of the $n$-th cyclotomic polynomial is complex, but what about $X^6-5$? Irreducible, all the roots are equivalent in a Galois-theoretic viewpoint, and ...

3

Well if $q$ is also rational, i.e. $q\equiv 3\mod 4$ is a rational prime, then it's really easy, you just have $$\Bbb Z[i]/(q)=\{a+bi : 0\le a,b<q\}.$$ You already knew that, but I like to be complete. If $q=1+i$, then note that $(1+i)(1-i)=2$ so $2\equiv 0\mod (1+i)$ so $$\Bbb Z[i]/(1+i)\subseteq \{a+bi : 0\le a,b\le 1\}$$ Since $1= (1+i)+i$ ...

3

$$x^2+3x+7\equiv x^2+40x+400+(-393)\equiv 0$$ $$\iff (x+20)^2\equiv 393\equiv 23\pmod{\! 37}$$ Use Quadratic Reciprocity: $$\left(\frac{23}{37}\right)=\left(\frac{37}{23}\right)=\left(\frac{14}{23}\right)=\left(\frac{7}{23}\right)\left(\frac{2}{23}\right)$$ $$=-\left(\frac{23}{7}\right)=-\left(\frac{2}{7}\right)=-1$$ In general, you can always complete ...

3

Hint: We have $p-1\equiv -1\pmod{p}$, $p-2\equiv -2\pmod{p}$, $p-3\equiv -3\pmod{p}$, and so on up to $\frac{p+1}{2}\equiv -\frac{p-1}{2}\pmod{p}$. It follows that $$(p-1)!\equiv (-1)^{(p-1)/2}\left(\left(\frac{p-1}{2}\right)!\right)^2\pmod{p}.$$ Now use Wilson's Theorem.

3

Got a reference on MO; see http://mathoverflow.net/questions/210144/number-of-primes-one-larger-than-divisors-of-a-fixed-number-which-is-lcm-of-1-2#comment520981_210144 and http://www.math.drexel.edu/~eschmutz/PAPERS/lambda.pdf In Theorem $1$ on the first page of the Erdos-Pomerance-Schmutz article, they announce the existence of a constant $c$ and a ...

3

You were correct. $$x^2\equiv 24\pmod{\! 60}\iff \begin{cases}x^2\equiv 24\equiv 0\pmod{\! 3}\\ x^2\equiv 24\equiv 0\pmod{\! 4}\\ x^2\equiv 24\equiv 4\pmod{\! 5}\end{cases}$$ $$\iff \begin{cases}x\equiv 0\pmod{\! 3}\\ x\equiv 0\pmod{\! 2}\\ x\equiv \pm 2\pmod{\! 5}\end{cases}$$ If and only if at least one of the two cases holds: $1)$ $\ x\equiv 0\pmod{\! ... 3 Edit: (June 29th 2015) I misread this question as asking for sum of$1/|\mathfrak{p}|^2$over those elements of$\mathbb{Z}[\alpha]$that are irreducible over$\mathcal{O}_K$. This is clearly not what the question asks, I am just use to irreducibility in a number field being defined with respect to the ring of integers, so I must have skipped some words. ... 3 Perhaps rather strangely, there is not a simple standard definition of "number". In the third century BC, Euclid took "number" to mean one of$2,3,4,5,\ldots$, a sequence starting with$2$and closed under the operation of adding a unit, i.e. if$n$is a number, then so is$n+1$, so the sequence continues infinitely. Euclid did not consider the "unit" to ... 3 That is equivalent to: $$3x^2+6x+39\equiv 0\pmod{19}$$ or to: $$x^2+2x+13\equiv 0\pmod{19}$$ or to: $$(x+1)^2 \equiv 7\pmod{19}.$$ Since$\left(\frac{7}{19}\right)=-\left(\frac{5}{7}\right)=-\left(\frac{2}{5}\right)=+1$and$19$is a prime of the form$4k-1$, a square root of$7\$ is given by $$7^{\frac{19+1}{4}}\equiv 7^{5}\equiv 11\pmod{19}$$ and ...

Only top voted, non community-wiki answers of a minimum length are eligible


text:
Making an 8-page 7″x4.25″ captioned photo book with Org Mode and LaTeX

|

Here’s another technique that makes a simple photo book. I wanted to
make an 8-page book that could be printed 4 pages to a 8.5″x14″ sheet
(duplex, flip along the short edge), with a final page size of
7″x4.25″.

Sample with my own photos:

Prerequisites

• ImageMagick
• Texlive (probably)
• latex-beamer
• Org Mode and Emacs

Process

We can define the labels and their captions in a named table like this:

 Let’s Go for a Walk Caption for photo 1 placeholder.png Caption for photo 2 placeholder.png Caption for photo 3 placeholder.png Caption for photo 4 placeholder.png Caption for photo 5 placeholder.png

Note that the first page is row #1 this time, instead of starting with
the last page.

Then we generate the LaTeX code with some Emacs Lisp, like so:

#+begin_src emacs-lisp :var pages=story :results value latex :exports results
(mapconcat (lambda (row) (format "\\graphicframe{%s}{%s}" (cadr row) (org-export-string-as (car row) 'latex t))) pages "\n")
#+end_src

I put that in a subtree for easier exporting with C-c C-e C-s l b (org-export-dispatch, subtree, LaTeX, Beamer).

Process

• Set up Org Mode export to Beamer
(eval-after-load "ox-latex"
;; update the list of LaTeX classes and associated header (encoding, etc.)
;; and structure
("beamer"
,(concat "\\documentclass[presentation]{beamer}\n"
"[DEFAULT-PACKAGES]"
"[PACKAGES]"
"[EXTRA]\n")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))))

• Set up the header.tex

This file gets included in the LaTeX file for the children’s book.
Tweak it to change the appearance. In this example, I use black serif
text text on the left side of a picture, both occupying roughly half
of the page. I also experimented with using a different font this time, which you might need to install (for me, I did apt-get install texlive-fonts-extra).

\geometry{paperwidth=7in,paperheight=4.25in,left=0.5in,right=0.5in}
\usepackage{etoolbox}
\usepackage[T1]{fontenc}
\usepackage{Alegreya}
\usefonttheme{serif}
\setbeamercolor{normal text}{fg=black,bg=white}
\setbeamercolor{structure}{fg=black,bg=white}
%% \setbeamertemplate{frametitle}
%% {
%%   \begin{center}
%%   \noindent
%%   \insertframetitle
%%   \end{center}
%% }
\newcommand{\graphicframe}[2] {
{
%% \if #1\empty
%% \usebackgroundtemplate{}
%% \fi
\ifstrempty{#1}{
\begin{frame}[plain]
\begin{center}
\noindent
\textbf{\huge{#2}}
\end{center}
\end{frame}
}{
\begin{frame}[plain]
\begin{columns}
\begin{column}{0.48\textwidth}
\huge{#2}
\end{column}
\begin{column}{0.48\textwidth}
\includegraphics[height=\textheight,width=\textwidth,keepaspectratio=true]{#1}
\end{column}
\end{columns}
\end{frame}
}
}
}
\usepackage[noframe]{showframe}
\renewcommand{\maketitle}{}

• Create the PDF
pdflatex index.tex

• Create one PNG per page
mkdir pages
convert -density 300 index.pdf -quality 100 pages/page%d.png

• Create the 4-up imposition

The diagram at https://pressnostress.com/iw/howto/booklets/1.html was helpful.

montage $$page4.png -rotate 180$$ $$page3.png -rotate 180$$ page7.png page0.png -tile 2x2 -mode Concatenate front.png
montage $$page2.png -rotate 180$$ $$page5.png -rotate 180$$ page1.png page6.png -tile 2x2 -mode Concatenate back.png
convert front.png back.png -density 300 ../print.pdf

Other notes

Placeholder image from https://en.wikipedia.org/wiki/File:Portrait_placeholder.png – public domain.

|

Story

• It’s time to make a smoothie!
• I pour blueberries into the blender.
• Mama adds hemp seeds.
• I add spinach.
• Mama blends it all with some water.
• I peel and add a banana.
• I add some yogurt.
• Mama blends it again.
• Yum yum!

Process

• Prerequisites

• ImageMagick
• Texlive (probably)
• latex-beamer
• Org Mode and Emacs
• Set up Org Mode export to Beamer

(eval-after-load "ox-latex"
;; update the list of LaTeX classes and associated header (encoding, etc.)
;; and structure
("beamer"
,(concat "\\documentclass[presentation]{beamer}\n"
"[DEFAULT-PACKAGES]"
"[PACKAGES]"
"[EXTRA]\n")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))))

• Set up image directories

mkdir text-pages blank-spreads drawn drawn-pages

 text-pages Will contain one image per page of just the plain text. blank-spreads Will contain text spreads ready for drawing drawn Export one image per spread (without the text layers) from your drawing program drawn-pages Will contain one image per page combining text and drawing
• Tweak the header.tex

This file gets included in the LaTeX file for the children’s book. Tweak it to change the appearance. In this example, I use black serif text at the bottom of the page.

\geometry{paperwidth=7in,paperheight=8.5in,left=0.5in,top=0.5in,right=0.5in,bottom=0.5in}
\setbeamercolor{normal text}{fg=black,bg=white}
\setbeamercolor{structure}{fg=black,bg=white}
\usefonttheme{serif}
\setbeamertemplate{frametitle}
{
\begin{center}
\vspace{0.7\textheight}
\noindent
\insertframetitle
\end{center}
}
\usepackage[noframe]{showframe}
\renewcommand{\maketitle}{}

• Write the story

I used Org Mode to make it easy to write the story.

Some considerations:

• Because we’re printing this as a saddle-stitched booklet, the number of lines should be a multiple of four. Sixteen is probably a good maximum.
• The first heading is actually for the last page.
• The second heading is for the cover page.
• The third heading is for the first inner page, the fourth heading is for the second inner page, and so on.
#+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc author:nil date:nil
#+OPTIONS: H:1
#+startup: beamer
#+LaTeX_CLASS: beamer
#+LaTeX_CLASS_OPTIONS: [20pt]
#+BEAMER_FRAME_LEVEL: 1
#+PROPERTY: header-args :var pages=12

* Story

**
**
**
** It's time to make a smoothie!
** I pour blueberries into the blender.
** Mama adds hemp seeds.
** I add spinach.
** Mama blends it all with some water.
** I peel and add a banana.
** I add some yogurt.
** Mama blends it again.
** Yum yum!

• Make the tex, PDF, page PNGs, and spread PNGs

1. Go to the subtree for the story and use M-x org-export-dispatch (C-c C-e) with the subtree option (C-s) to export it as a Beamer file (option l b).
2. Use pdflatex to convert the .tex to PDF.

pdflatex index.tex

3. Create one PNG per text page with:

convert -density 300 index.pdf -quality 100 text-pages/page%02d.png

4. Create spreads to draw on with:

montage text-pages/page*.png -tile 2x1 -mode Concatenate blank-spreads/spread%d.png

5. Optionally, create a layered PSD with:

convert blank-spreads/spread*.png $$-clone 1,0 -background white -flatten -alpha off$$ -reverse spreads-for-drawing.psd

• Draw

I imported the PNG layers into MediBang Paint on a Samsung Note 8 Android phone, and then:

• imported photos
• traced them
• painted and shaded them
• hid the text layers
• exported one PNG per spread to QuickPic, renamed them, and uploaded them to Dropbox, because I couldn’t figure out how to export to Dropbox directly

Layer folders were handy for organizing spread-related images. I couldn’t seem to move all of the layers in a layer folder together on Android, but the iPad was able to do so. If I didn’t have the iPad handy, I combined the layers by exporting a PNG and then importeing it back into MediBang Paint.

This was a decent setup that allowed me to draw and paint even when I was in bed nursing A- and waiting for her to fall asleep. I held the phone with one hand and rotated the canvas as needed so that it was easier for me to draw lines with my right. Because of the awkward position and the small screen size, the lines are not as smooth as I might like, but the important thing is that they’re there. Whee! =)

It turns out to be possible to use the free MediBang Pro drawing program under Wine on Linux to import the PSD and save it to the cloud. I was also sometimes able to switch to drawing with iPad Pro with Pencil, but it was harder to find time to do that because that usually made A- want to draw too.

Anyway, after I drew and exported the PNGs, the next step was to…

• Convert the drawn spreads back to pages and combine them with the text

Here’s some code that combines the drawing and the text. Keeping the drawing and the text separate until this stage (instead of exporting the PNGs with the text) makes it easier to change the text later by recreating the text PNGs and running this step.

(defun my/combine-spread-drawing-and-text (page num-pages)
(let ((gravity (if (= (% page 2) 1) "West" "East"))
(spread (/ (% page num-pages) 2)))
(shell-command
(format
(concat "convert \$$" "drawn/spread%d.png -gravity %s " "-chop 50%%x0 +repage \$$ "
"text-pages/page%02d.png -compose darken "
"-composite drawn-pages/page%02d.png")
spread gravity page page))))

(cl-loop for i from 0 to (1- pages) do

This code pairs up the drawn pages into a PDF that can be printed duplex. Make sure to choose the option to flip along the short edge. I hard-coded the page orders for 4-, 8-, 12-, and 16-page booklets.

(let* ((page-order
'((0 1 2 3)   ; hard-coded page sequences
(0 1 2 7 6 3 4 5)
(0 1 2 11 10 3 4 9 8 5 6 7)
(0 1 2 15 14 3 4 13 12 5 6 11 10 7 8 9)))
(sequence
(mapconcat (lambda (d) (format "drawn-pages/page%02d.png" d))
(elt page-order (1- (/ pages 4))) " ")))
(shell-command
(format
"montage %s -tile 2x1 -mode Concatenate print-duplex-short-edge-flip.pdf"
sequence)))

• Print and bind

After printing and folding the book, I used tape to make the book hold together. Tada!

• Create on-screen PDF for reading

A little bit of manipulation so that the last page is in the right place:

(shell-command
(format "convert %s onscreen.pdf"
(mapconcat 'identity (cl-loop for i from 1 to pages
collect (format "drawn-pages/page%02d.png" (% i pages))) " ")))

• Create thumbnails of spreads

(cl-loop
for i from 0 to (1- (/ pages 2)) do
(shell-command
(format
(concat "convert "
"\$$blank-spreads/spread%d.png " "drawn/spread%d.png " "-compose darken " "-resize %dx -flatten \$$ "
"\$$+clone -background black -shadow 50x1+%d+%d \$$ "
"+swap -compose src-over -composite "

• Ideas for next steps

• Better thumbnails for easy previews
• PDF for online reading
• More layout possibilities (photos, verses, etc.)
• Smaller books:

• crop marks on a full-page print, or
• the right imposition rules to print more pages on a sheet

Org Mode: Inserting a function definition

Posted: - Modified: |

While nudging jcs to add a definition of jcs-insert-url to the blog post about Making Things Easier, I realized it might be handy to have a quick function for inserting a function definition without thinking about where it’s defined. This tries to use the definition from the source, and it can fall back to using the stored function definition if necessary. There’s probably a better way to do this, but this was small and fun to write. =)

Naturally, I used it to insert itself:

(defun my/org-insert-defun (function)
"Inserts an Org source block with the definition for FUNCTION."
(let* ((buffer-point (condition-case nil (find-definition-noselect function nil) (error nil)))
(new-buf (car buffer-point))
(new-point (cdr buffer-point))
definition)
(if buffer-point
(with-current-buffer new-buf ;; Try to get original definition
(save-excursion
(goto-char new-point)
(setq definition (buffer-substring-no-properties (point) (save-excursion (end-of-defun) (point))))))
;; Fallback: Print function definition
(setq definition (concat (prin1-to-string (symbol-function function)) "\n")))
(insert "#+begin_src emacs-lisp\n" definition "#+end_src\n")))

Sorting Org Mode lists using a sequence of regular expressions

|

I manually categorize Emacs News links into an Org unordered list, and then I reorganize the list by using M-S-up (org-shiftmetaup) and M-S-down (org-shiftmetadown). I decide to combine or split categories depending on the number of links. I have a pretty consistent order. John Wiegley suggested promoting Emacs Lisp and Emacs development links at the top of the list. I like to sort the rest of the list roughly by interest: general links first, then Org, then coding, then other links at the bottom.

Here’s some code that sorts Org lists in a custom sequence, with unknown items at the bottom for easy re-ordering. It will take a list like:

- Other:
- Emacs development:
- Emacs Lisp:

and turn it into:

- Emacs Lisp:
- Emacs development:
- Other:

(defun my/org-sort-list-in-custom-order (order)
"Sort the current Org list so that items are in the specified order.
ORDER is a list of regexps."
(org-sort-list
nil ?f
(lambda ()
(let ((case-fold-search t)
(item
(when (looking-at "[ \t]*[-+*0-9.)]+\$$[ \t]+\$[- X]\$\$$?[ \t]+")
(org-sort-remove-invisible (buffer-substring (match-end 0) (point-at-eol))))))
(or (cl-position item order :test (lambda (a b) (string-match b a))) (1+ (length order)))))
'<))

(defun my/emacs-news-sort-list ()
(interactive)
(my/org-sort-list-in-custom-order
'("Emacs Lisp"
"Emacs development"
"Appearance"
"Dired"
"Org Mode"
"Coding"
"Calc"
"Email and news"
"Other"
"Discussion"
"Outside Emacs"
"New packages?")))

One more little thing automated… The next thing would probably be to write some code that autocategorizes links based on an alist of (item . regexp) pairs, which would also reduce the need to re-sort the items afterwards. Still, this is good for dealing with manual categorization. =)

External brains – current state

Posted: - Modified: |

Being the primary caregiver for a toddler means I’m distracted, often interrupted, and somewhat sleep-deprived, so using external brains (paper, phone, laptop) helps a lot. Here are a few things I rely on them to keep so that I can declutter my mind, worry less, and be more present:

• Daily journal: This lets me tell W- stories about A-, appreciate A-‘s progress, and feel good about where the time went. I use Memento Database on my Android phone to add datestamped, categorized text notes to a Google Sheets spreadsheet.
• Weekly/monthly review: This lets me appreciate progress over a longer period and plan for the next one. I edit the daily journal entries in Memento to set their importance (1: weekly highlight, 2: monthly), then filter, sort, group, and export the entries. I copy the text into Tasks Free (which synchronizes via Google Tasks) and then edit the text on my phone while A- nurses and sleeps. If I manage to have computer time, I might use Emacs to fill in more of my weekly or monthly review.
• Tasks (next actions, inbox, waiting, thoughts, and assorted other lists): Tasks Free on my phone, since I can check it or add to it any time. I jot ideas/thoughts down here too, since I can write while nursing A- in bed. If I run out of battery, I charge my phone and move to W-‘s old phone, so I can keep writing. After I draft a thought that might be a good blog post, I copy it into the WordPress app and post it so that I can find it again later. (And so that other people might chime in with insights!) If I have time, I might copy a thought into Emacs, flesh it out further, and post it with org2blog.
• Calendar: Google calendars – one for appointments, one for activity options. This way, I can hide all the optional stuff quickly.
• Longer-term reminders, notes, work in progress: Org files. It’s so nice to be able to schedule tasks and have detailed notes on how to complete those tasks. I also really like being able to break things down with outlines and think out loud with code snippets. The weekly agenda review helps me catch reminders.
• Photos and videos: I sync a Wi-Fi-enabled camera with my phone, then erase everything off the camera. Google Photos automatically uploads everything and shares them with W-. I post selected things to a Facebook closed group for kiddo updates.
• Time and activity log: I track my time for curiosity. I made my own tracker (quantifiedawesome.com), and I made another button-based interface for easier tracking on my phone. That interface also lets me quickly log data to baby-connect.com, where I track A-‘s sleep, nursing, and potty use. I made my own visualizations, too.
• Reference info: Org. Document scans in Dropbox or Owncloud, some GPG-encrypted.
• Book notes: I’ve been reading mostly e-books from the library, so I take screenshots on my phone and they go through my photo workflow. I use Tasks Free to capture quick notes about paper books. I’d like to get back to sketchnotes when I have more focused time.
• New words: I’m tracking this out of curiosity. She has said 350+ different words, and she’s not even 2 years old yet. :) Many of the words come from songs and books, so it helps to think of concrete experiences she can associate them with.
• Scenarios, just-in-case notes: Org. Good for managing risks and worrying less.
• Processes: Org. Good for step-by-step instructions when I’m sleep-deprived or doing something infrequently.
• Finances: Ledger-cli. Text-based accounting, yay! I have some reports in ledger-mode and some in an Org file. I update this monthly or so.
• Cooking: We manage our grocery list in OurGroceries because of the multiuser real-time sync. Recipes tend to be looked up on the Internet and then copied into a paper notebook or onto an index card when we like them. Meal plan is written on scrap paper and stuck to the front of the fridge.

I want to get better at structuring my observations of A-‘s progress, planning follow-up activities, and keeping the overall picture in mind. Since I’m roughly categorizing the daily journal entries in Memento / Google Sheets, I can probably create a table that will make it easy to see if there are neglected areas, and then extend that to plan ideas. Or, well, as much planning as one can do with a toddler, really – more like keeping an eye out for opportunities to build on A-‘s interests. So far it’s been okay, though. I’ve been learning about basic principles and skill components from textbooks on early childhood education, and that makes it a bit easier for me to improvise. I have a rough outline of areas to think about on a regular basis, and a few ideas to explore over the next few months.

I also want to get better at managing my book notes and other ideas I want to revisit at the appropriate time. I’m a little lacking on the review side, since most of my writing time is taken up by capturing observations and the occasional reflection. So far, this has also been okay. I just have to trust that whatever I’m writing down will still make sense to me in a few months or years, and the most important stuff will turn up on my radar at the appropriate time. Schedule-based reminders are easy, but things wait for all sorts of other factors. For example, there are lots of practical life skill exercises I picked up from the Montessori education books that will be a better fit when A-‘s fine motor skills improve.

I’d like to get back to drawing someday, although it may have to wait until I have more dedicated time. Whenever I start sketching out a thought, A- likes drawing on my paper or asking me to draw stuff for her. It’s all good, though, since it encourages us to scribble. It just means that I can’t take a picture and reuse the drawing – I have to type it up anyway, so I may as well explore the thought on my phone unless I want to think nonlinearly.

I’ll experiment with using timestamped notes in Memento to help me with offline logging when we go on our trip. I might also just spring for Internet access once we’re off the plane, since that’s useful for other things as well.

I’ve got a fair bit of clutter in my Org files, but I trust that the outlining tools will help me reorganize as needed. I tend to do just-in-time organizing: instead of starting with an outline and drilling down, I might capture a bunch of thoughts, refile them as the structure becomes clearer, and then work up and down from there.

I don’t spend nearly as much time on the computer as I might want to for optimal external-brain management, but the current system is surprisingly workable. Shifting more of my writing to my phone (including the weekly/monthly summaries) made a difference, since I don’t have to keep as much in my head or get constrained by computer time. I look forward to tweaking how things work as A- becomes more independent and as I learn more.

What do I want from my Org Mode files?

Posted: - Modified: |

What do I want from the notes I keep in Org Mode, how’s that working out, and how can I improve?

Remind me of important tasks, especially recurring ones or ones in the far future
This works pretty well, especially with my weekly review. I mostly trust it, although it might be nice to use the timeline view to review tasks over the next few years just to make sure the important ones are there. And backups!
Keep detailed checklists, instructions, and notes, so that I don’t miss any steps or have to figure things out again when I’m sleep-deprived
I’ve found this useful when dealing with my business paperwork, and I look forward to documenting more routines.
Capture quick thoughts and tasks so that they don’t clutter up my mind
org-capture is good when I’m at my computer, and Google Tasks is a decent inbox when I’m away. Not very good at reviewing and refiling the items, though, but I can do that when I have more discretionary time.
Break bigger projects down into manageable tasks
I don’t have the brainspace right now to work on projects, so most of these have been shelved. I need to tweak my Org refile targets to make organizing things easier. I might be running into a limit with too many targets. Sometimes I can’t use org-refile to select a task that I already know exists.
Help me untangle my thoughts or keep a trail of breadcrumbs as I solve problems
Pretty good at this. Limited by computer time at the moment.
Pull together information and help me summarize
The code I wrote for my weekly and monthly reviews is working well. The code for Emacs News is decent, too, although I can save a little more time if I fix my function for opening all links in a region.
Draft blog posts
This is working well. It could be a little better if I sorted out image uploading and resizing, but my current workflow is fine.
Help me make the most of my limited computer time by prioritizing small tasks that move me forward
This is probably the weakest area. Right now, I tend to prioritize drawing, then checking my agenda for urgent/quick tasks, and maybe writing if I can squeeze it in. I mostly save writing for my phone, though, because I can write on my phone and I can’t do the other tasks then. Coding might help me improve efficiency, but that might have to wait until I have more focused time. It’s okay, I’ll get back to that someday. I think getting better at writing and posting will pay off well enough in the short term. If I give myself permission to post short, possibly incomplete thoughts (like I tell people to! :) ), I’ll get more stuff out there, and then I can build up from there.
Keep notes on people
Little memories, triggers for thoughtfulness, etc. I’m definitely the bottleneck here, not Org.
Help me review my decisions
It’s good to write down goals, options considered, criteria, trade-offs, reasons, predicted results, and so on. My bottleneck is probably taking the time to do so. People are good at rationalization, so I’m not trying to judge whether something was a good decision or a bad decision, but it’s interesting to see what decisions and evaluations reveal about my preferences and values.
Remind me about tools, how to use them, why, and so on
This is partly why I have a literate configuration – so the outline can remind me about stuff I’ve already coded. It’s also handy to keep track of commands and scripts that help me with various tasks. I just need to remember to copy and paste stuff as I do things.

Overall, I’m okay with input and output. Processing is my bottleneck at the moment. If I either fix that org-refile issue I’ve been running into, or come up with an alternative flexible search that will help me find outline entries when I don’t quite remember the headline, that should make processing a bit easier. A bit of outline gardening would help, too – archiving things that are no longer relevant, refiling notes and improving their headlines/text for searchability, maybe prioritizing tasks based on costs and benefits… I’m not entirely sure I’d be comfortable doing that on my phone, so it will have to wait for computer time.

In the meantime, I’m glad I have a place to accumulate (and eventually organize) all those notes!

Using categories to organize your Org agenda

Posted: - Modified: |

D.C. Toedt wanted to share this tip for Org Mode agenda organization:

I’ve just discovered that it helps to add a :CATEGORY: property to the top-level, non-TODO heading that identifies the project.  Using your example:

* Project ABC
:PROPERTIES:
:CATEGORY: ABC
:END:

** TODO A task related to Project ABC
** TODO Another task related to ABC
SCHEDULED:

In my bog-standard org-mode setup, this results in “ABC” being displayed in the far-left column of the agenda instead of just “todo” (which seems to be the default). This is great — it means that, in the text of the “Subtask” todo entry itself, I don’t need to include a reminder of what project the todo entry is associated with.

Here’s an agenda mockup to illustrate the point, augmented with a “default” entry from my own to-do list:

  todo:       Scheduled:  Follow up on expense reimbursement request

This also allows filtering the agenda by the category.

Thanks for sharing, D.C.!

The category actually defaults to the first part of your filename.org, so todo.org becomes todo, organizer.org becomes organizer, etc. I keep an organizer.org, routines.org, business.org, etc. Keeping my routine tasks in routines.org allows me to filter them with a custom agenda command like:

            ("w" "Weekly review" agenda ""
((org-agenda-span 7)
(org-agenda-log-mode 1)) "~/Dropbox/agenda/this-week.html")

("W" "Weekly review sans routines" agenda ""
((org-agenda-span 7)
(org-agenda-log-mode 1)
(org-agenda-tag-filter-preset '("-routine"))) "~/Dropbox/agenda/this-week-nonroutine.html")

so that I can see all the tasks (including routine tasks) in my regular weekly review, and just the special stuff in a separate view. You can see the whole definition of org-agenda-custom-commands in my Emacs configuration.

Update 2016-12-18: Oops! I just remembered that filtering by -routine is actually made possible by the #+FILETAGS: :routine: I have in routines.org, which has the additional benefit of allowing me to mark tasks in other files as routine by adding the :routine: tag to them. You can, however, still use categories to filter your agenda. < (org-agenda-filter-by-category) in an agenda view will filter by category, or use a match filter like CATEGORY="routines" to match on the category. Also, it turns out you can set up category icons by customizing org-agenda-category-icon-alist – hmm…

D.C.’s tip is handy if you want to keep those groups of tasks in one file, but still want that kind of visual indication in your agenda (and the ability to filter by it).

Have fun!


text:
# Many-One Reductions vs Turing-Reductions and PH

One definition of $\mathsf{PH}$ uses Oracles and in this definition both $\mathsf{NP}$ and $\mathsf{coNP}$ are contained in P^NP which equals $\mathsf{P^{coNP}}$. It is believed that $\mathsf{NP}$ does not equal $\mathsf{coNP}$, in other words they are not many-one reducible to each other. If indeed this is proved, then doesn't it also hold that $\mathsf{P^{NP}}$ doesn't equal $\mathsf{P^{coNP}}$ since many-one reducibility imply Turing reducibility?

-

## migrated from cstheory.stackexchange.comNov 25 '11 at 15:24

This question came from our site for theoretical computer scientists and researchers in related fields.

The fact that many-one reductions are weaker than Turing reductions only means that NP = coNP implies P^NP = P^coNP, but not the converse. To illustrate this, think about the following: many-one polytime reductions are weaker than many-one exponential time reductions. But even though P and EXP are not equal by the time hierarchy, they are exp-time reducible to each other.

-
Your answer is totally the opposite of the answer to this question... cstheory.stackexchange.com/questions/8759/… –  Tayfun Pay Nov 25 '11 at 2:48
So if A is many-one reducible to B then it means A is Turing reducible to B. If A is not many-one reducible to B then it doesn't necessarily mean that A is not Turing reducible to B. OKAY!!!! Phew! –  Tayfun Pay Nov 25 '11 at 3:01


text:
problem with cummeRbund using latest R version
3
0
Entering edit mode
mmateos • 0
@mmateos-13598
Last seen 4.3 years ago

I installed the latest version of R (R version 3.4.1 (2017-06-30) -- "Single Candle"), Bioconductor, and cummeRbund

Platform: x86_64-apple-darwin15.6.0 (64-bit)

Mac OS X 10.11.6

I've seen posts of similar problems in the last few days.  Is it possible that there cummeRbund is incompatible with updated R or Bioconductor?  Could it be that my sqlite3 version is too old? SQLite version 3.8.10.2 2015-05-20 18:17:19  If so, I can't seem to find a way to replace with with a newer one.  If I compile the newest one, it still calls the old one when I type sqlite3 at the Terminal window.

We have ruled out the input folder (cuffdiff output); it works on prior version.  Below I post the warning messages I receive when running cuff_data.

I would appreciate any prompt help with this.

Thanks,

Mariana

---------------------------------

> library(cummeRbund)

Creating database multiple_test_T2/cuffData.db

Writing runInfo Table

Writing replicates Table

Writing varModel Table

Checking samples table...

Populating samples table...

Error: Column name mismatch.

In addition: There were 50 or more warnings (use warnings() to see the first 50)

> warnings()

Warning messages:

1: In rsqlite_fetch(res@ptr, n = n) :

Don't need to call dbFetch() for statements, only for queries

2: In rsqlite_fetch(res@ptr, n = n) :

Don't need to call dbFetch() for statements, only for queries

3: In rsqlite_fetch(res@ptr, n = n) :

Don't need to call dbFetch() for statements, only for queries

cummeRbund • 2.6k views
1
Entering edit mode
loyalgoff ▴ 20
@loyalgoff-6786
Last seen 4.3 years ago
United States

Hi Mariana,

Apparently RSQLite has changed a bit recently, and I'm only now becoming aware of this.  I will try to put together a fix in the next few days and push it up to devel.  Thanks.

-Loyal

0
Entering edit mode

Hi Loyal -- is your address in the DESCRIPTION file current? We tried to contact you through various means several weeks ago. Also, you can 'subscribe' to the 'cummerbund' tag and get notifications when questions are posted about packages of interest to you (click on your user, edit your profile and add 'my tags').

1
Entering edit mode
loyalgoff ▴ 20
@loyalgoff-6786
Last seen 4.3 years ago
United States

Hi Mariana,

I just pushed a (hopefully) corrected version up to BioC devel.  If you would like to try and install it before it gets auto-built, you can find it here:

https://github.com/Bioconductor-mirror/cummeRbund/tree/master

Please let me know if you have any other issues getting cummeRbund up and running.

Cheers,

Loya

0
Entering edit mode

Hi Loya,

I was getting the same error message described by Mariana, so have tried to update my cummeRbund.  For an R newbie, can you please advise how to correctly update my cummeRbund library?  I have cloned the repository from github, then replaced the old files/folders in cummerBund with the new versions.  I'm now getting the following error:

> library(cummeRbund)
Error: package or namespace load failed for 'cummeRbund' in namespaceExport(ns, exports):

I'm running R version 3.4.1 (2017-06-30) -- "Single Candle"

Many thanks!

Paul

0
Entering edit mode

Sorry - should also add platform info:

Platform: x86_64-apple-darwin15.6.0 (64-bit)

OSX 10.11.6

0
Entering edit mode
@serenaspartano-14008
Last seen 4.2 years ago

Hi Paul,

I'm a newbie too but I've just discovered that is not sufficient to replace files after cloning a repo.

You have to build and install it.

You can build the repo using devtools, i've done that in this way:

install.packages("devtools")
library(devtools)
build("~/put/the/package/path/here")

a tar.gz will be developed and you can install it in R(i've solved with R studio.

CummeRbund perfectly works with this repo, without column mismatches. Now I'm fighting with some troubles on annotate XLOC but I think it depends on GTF reference....I'm trying to repeat cuffmerge with an IGenome GTF.

Good luck!

Serena