text:
# Integration along fibers

In differential geometry, the integration along fibers of a k-form yields a ${\displaystyle (k-m)}$-form where m is the dimension of the fiber, via "integration". More precisely, let ${\displaystyle \pi :E\to B}$ be a fiber bundle over a manifold with compact oriented fibers. If ${\displaystyle \alpha }$ is a k-form on E, then let:

${\displaystyle (\pi _{*}\alpha )_{b}(w_{1},\dots ,w_{k-m})=\int _{\pi ^{-1}(b)}\beta }$

where ${\displaystyle \beta }$ is the induced top-form on the fiber ${\displaystyle \pi ^{-1}(b)}$; i.e., an ${\displaystyle m}$-form given by

${\displaystyle \beta (v_{1},\dots ,v_{m})=\alpha ({\widetilde {w_{1}}},\dots ,{\widetilde {w_{k-m}}},v_{1},\dots ,v_{m}),\quad {\widetilde {w_{i}}}{\text{ the lifts of }}w_{i}.}$

(To see ${\displaystyle b\mapsto (\pi _{*}\alpha )_{b}}$ is smooth, work it out in coordinates; cf. an example below.)

${\displaystyle \pi _{*}}$ is then a linear map ${\displaystyle \Omega ^{k}(E)\to \Omega ^{k-m}(B)}$, which is in fact surjective. By Stokes' formula, if the fibers have no boundaries, the map descends to de Rham cohomology:

${\displaystyle \pi _{*}:\operatorname {H} ^{k}(E)\to \operatorname {H} ^{k-m}(B).}$

This is also called the fiber integration. Now, suppose ${\displaystyle \pi }$ is a sphere bundle; i.e., the typical fiber is a sphere. Then there is an exact sequence ${\displaystyle 0\to K\to \Omega ^{*}(E){\overset {\pi _{*}}{\to }}\Omega ^{*}(B)\to 0}$, K the kernel, which leads to a long exact sequence, using ${\displaystyle \operatorname {H} ^{k}(B)\simeq \operatorname {H} ^{k+m}(K)}$:

${\displaystyle \dots \rightarrow \operatorname {H} ^{k}(B){\overset {\delta }{\to }}\operatorname {H} ^{k+m+1}(B){\overset {\pi ^{*}}{\rightarrow }}\operatorname {H} ^{k+m+1}(E){\overset {\pi _{*}}{\rightarrow }}\operatorname {H} ^{k+1}(B)\rightarrow \dots }$,

called the Gysin sequence.

## Example

Let ${\displaystyle \pi :M\times [0,1]\to M}$ be an obvious projection. For simplicity, assume ${\displaystyle M=\mathbb {R} ^{n}}$ with coordinates ${\displaystyle x_{j}}$ and consider a k-form:

${\displaystyle \alpha =f\,dx_{i_{1}}\wedge \dots \wedge dx_{i_{k}}+g\,dt\wedge dx_{j_{1}}\wedge \dots \wedge dx_{j_{k-1}}.}$

Then, at each point in M,

${\displaystyle \pi _{*}(\alpha )=\pi _{*}(g\,dt\wedge dx_{j_{1}}\wedge \dots \wedge dx_{j_{k-1}})=\left(\int _{0}^{1}g(\cdot ,t)\,dt\right)\,{dx_{j_{1}}\wedge \dots \wedge dx_{j_{k-1}}}.}$

From this the next formula follows easily: if ${\displaystyle \alpha }$ is any k-form on ${\displaystyle M\times I,}$

${\displaystyle \pi _{*}(d\alpha )=\alpha _{1}-\alpha _{0}-d\pi _{*}(\alpha )}$

where ${\displaystyle \alpha _{i}}$ is the restriction of ${\displaystyle \alpha }$ to ${\displaystyle M\times \{i\}}$. This formula is a special case of Stokes' formula. As an application of this, let ${\displaystyle f:M\times [0,1]\to N}$ be a smooth map (thought of as a homotopy). Then the composition ${\displaystyle h=\pi _{*}\circ f^{*}}$ is a homotopy operator:

${\displaystyle d\circ h+h\circ d=f_{1}^{*}-f_{0}^{*}:\Omega ^{k}(N)\to \Omega ^{k}(M),}$

which implies ${\displaystyle f_{1},f_{0}}$ induces the same map on cohomology. For example, let U be an open ball with center at the origin and let ${\displaystyle f_{t}:U\to U,x\mapsto tx}$. Then ${\displaystyle \operatorname {H} ^{k}(U)=\operatorname {H} ^{k}(pt)}$, the fact known as the Poincaré lemma.


text:
# Single spacing long entries in List of Figures and moving page number [closed]

I'm assembling my master's thesis in latex and I'm currently having trouble with spacing in my List of Figures. Currently, if there is an entry that extends more than one line, it is double spaced and the page number is on the bottom line. My university requires subsequent lines in a single entry to be single spaced, individual entries double spaced, and page numbers to be on the first line of each entry.

-
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. This will give community members an idea of the packages you already use/cannot use and help diagnose the problem quicker. –  Werner Jul 19 '12 at 19:49
For single spacing long entries, one of the solutions previously offered in this forum works: Single Spacing Long Subsection Header in Table of Contents The solution \caption[\protect\vspace{-0.5ex}{long caption text}]{long caption text} works, it may be a roundabout since you have to do it for each figure that has a long caption text, but atleast fixes it.

format: plain


text:
class paddle.fluid.optimizer.AdamOptimizer(learning_rate=0.001, beta1=0.9, beta2=0.999, epsilon=1e-08, parameter_list=None, regularization=None, grad_clip=None, name=None, lazy_mode=False)[source]

The Adam optimizer uses an optimization described at the end of section 2 of Adam paper , it can dynamically adjusts the learning rate of each parameter using the 1st moment estimates and the 2nd moment estimates of the gradient.

The parameter param_out update rule with gradient grad:

\begin{align}\begin{aligned}t & = t + 1\\moment\_1\_out & = {\beta}_1 * moment\_1 + (1 - {\beta}_1) * grad\\moment\_2\_out & = {\beta}_2 * moment\_2 + (1 - {\beta}_2) * grad * grad\\learning\_rate & = learning\_rate * \ \frac{\sqrt{1 - {\beta}_2^t}}{1 - {\beta}_1^t}\\param\_out & = param - learning\_rate * \frac{moment\_1}{\sqrt{moment\_2} + \epsilon}\end{aligned}\end{align}

Related paper: Adam: A Method for Stochastic Optimization

Parameters
• learning_rate (float|Variable, optional) – The learning rate used to update Parameter. It can be a float value or a Variable with a float type. The default value is 0.001.

• beta1 (float|Variable, optional) – The exponential decay rate for the 1st moment estimates. It should be a float number or a Variable with shape [1] and data type as float32. The default value is 0.9.

• beta2 (float|Variable, optional) – The exponential decay rate for the 2nd moment estimates. It should be a float number or a Variable with shape [1] and data type as float32. The default value is 0.999.

• epsilon (float, optional) – A small float value for numerical stability. The default value is 1e-08.

• parameter_list (list, optional) – List of Variable names to update to minimize loss. This parameter is required in dygraph mode. The default value is None in static mode, at this time all parameters will be updated.

• regularization (WeightDecayRegularizer, optional) – The strategy of regularization. There are two method: L1Decay , L2Decay . If a parameter has set regularizer using ParamAttr already, the regularization setting here in optimizer will be ignored for this parameter. Otherwise, the regularization setting here in optimizer will take effect. Default None, meaning there is no regularization.

• grad_clip (GradientClipBase, optional) – Gradient cliping strategy, it’s an instance of some derived class of GradientClipBase . There are three cliping strategies ( GradientClipByGlobalNorm , GradientClipByNorm , GradientClipByValue ). Default None, meaning there is no gradient clipping.

• name (str, optional) – Normally there is no need for user to set this property. For more information, please refer to Name. The default value is None.

• lazy_mode (bool, optional) – The official Adam algorithm has two moving-average accumulators. The accumulators are updated at every step. Every element of the two moving-average is updated in both dense mode and sparse mode. If the size of parameter is very large, then the update may be very slow. The lazy mode only update the element that has gradient in current mini-batch, so it will be much more faster. But this mode has different semantics with the original Adam algorithm and may lead to different result. The default value is False.

Examples

import paddle

place = fluid.CPUPlace()
main = fluid.Program()
with fluid.program_guard(main):
x = fluid.data(name='x', shape=[None, 13], dtype='float32')
y = fluid.data(name='y', shape=[None, 1], dtype='float32')
y_predict = fluid.layers.fc(input=x, size=1, act=None)
cost = fluid.layers.square_error_cost(input=y_predict, label=y)
avg_cost = fluid.layers.mean(cost)

fetch_list = [avg_cost]
feeder = fluid.DataFeeder(place=place, feed_list=[x, y])
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())
exe.run(main, feed=feeder.feed(data), fetch_list=fetch_list)

# Adam with beta1/beta2 as Variable

place = fluid.CPUPlace()
main = fluid.Program()
with fluid.program_guard(main):
x = fluid.data(name='x', shape=[None, 13], dtype='float32')
y = fluid.data(name='y', shape=[None, 1], dtype='float32')
y_predict = fluid.layers.fc(input=x, size=1, act=None)
cost = fluid.layers.square_error_cost(input=y_predict, label=y)
avg_cost = fluid.layers.mean(cost)

# define beta decay variable
def get_decayed_betas(beta1_init, beta2_init, decay_steps, decay_rate):
global_step = lr_scheduler._decay_step_counter()

beta1 = fluid.layers.create_global_var(
shape=[1],
value=float(beta1_init),
dtype='float32',
# set persistable for save checkpoints and resume
persistable=True,
name="beta1")
beta2 = fluid.layers.create_global_var(
shape=[1],
value=float(beta2_init),
dtype='float32',
# set persistable for save checkpoints and resume
persistable=True,
name="beta2")

div_res = global_step / decay_steps
decayed_beta1 = beta1_init * (decay_rate**div_res)
decayed_beta2 = beta2_init * (decay_rate**div_res)
fluid.layers.assign(decayed_beta1, beta1)
fluid.layers.assign(decayed_beta2, beta2)

return beta1, beta2

beta1, beta2 = get_decayed_betas(0.9, 0.99, 1e5, 0.9)
learning_rate=0.01,
beta1=beta1,
beta2=beta2)

fetch_list = [avg_cost]
feeder = fluid.DataFeeder(place=place, feed_list=[x, y])
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())
exe.run(main, feed=feeder.feed(data), fetch_list=fetch_list)

clear_gradients()

Clear the gradients of all optimized parameters for model.

Returns

None

Examples

import paddle.fluid as fluid
import numpy as np

with fluid.dygraph.guard():
value = np.arange(26).reshape(2, 13).astype("float32")
a = fluid.dygraph.to_variable(value)
linear = fluid.Linear(13, 5, dtype="float32")
# This can be any optimizer supported by dygraph.
parameter_list = linear.parameters())
out = linear(a)
out.backward()

current_step_lr()

Note

This API is ONLY available in Dygraph mode

Get current step learning rate. The return value is all the same When LearningRateDecay is not used, otherwise return the step learning rate.

Returns

The learning rate of the current step.

Return type

float

Examples

import paddle.fluid as fluid
import numpy as np

# example1: LearningRateDecay is not used, return value is all the same
with fluid.dygraph.guard():
emb = fluid.dygraph.Embedding([10, 10])
print(lr) # 0.001

# example2: PiecewiseDecay is used, return the step learning rate
with fluid.dygraph.guard():
inp = np.random.uniform(-0.1, 0.1, [10, 10]).astype("float32")
linear = fluid.dygraph.nn.Linear(10, 10)
inp = fluid.dygraph.to_variable(inp)
out = linear(inp)
loss = fluid.layers.reduce_mean(out)

bd = [2, 4, 6, 8]
value = [0.2, 0.4, 0.6, 0.8, 1.0]
parameter_list=linear.parameters())

# first step: learning rate is 0.2
np.allclose(adam.current_step_lr(), 0.2, rtol=1e-06, atol=0.0) # True

# learning rate for different steps
ret = [0.2, 0.2, 0.4, 0.4, 0.6, 0.6, 0.8, 0.8, 1.0, 1.0, 1.0, 1.0]
for i in range(12):
np.allclose(lr, ret[i], rtol=1e-06, atol=0.0) # True

minimize(loss, startup_program=None, parameter_list=None, no_grad_set=None)

Add operations to minimize loss by updating parameter_list.

Parameters
• loss (Variable) – A Variable containing the value to minimize.

• startup_program (Program, optional) – Program for initializing parameters in parameter_list. The default value is None, at this time default_startup_program will be used.

• parameter_list (list, optional) – List of Variable or Variable.name to update to minimize loss. The default value is None, at this time all parameters will be updated.

• no_grad_set (set, optional) – Set of Variable or Variable.name that don’t need to be updated. The default value is None.

Returns

tuple (optimize_ops, params_grads), A list of operators appended by minimize and a list of (param, grad) variable pairs, param is Parameter, grad is the gradient value corresponding to the parameter. The returned tuple can be passed to fetch_list in Executor.run() to indicate program pruning. If so, the program will be pruned by feed and fetch_list before run, see details in Executor.

Return type

tuple

Examples

Please refer to the example of current Optimizer.

set_dict(state_dict)

Load optimizer state dict. For Adam optimizer, contains beta1, beta2, momentum etc. If LearningRateDecay have been used, global_step will be changed.

Parameters

state_dict (dict) – Dict contains all the Variable needed by optimizer

Returns

None

Examples

with fluid.dygraph.guard():
emb = fluid.dygraph.Embedding([10, 10])

state_dict = emb.state_dict()

parameter_list=emb.parameters())

state_dict()

Get state dict information from optimizer. It contain all the variable used by optimizer. For Adam optimizer, contains beta1, beta2, momentum etc. If LearningRateDecay have been used, global_step will be include in state dict. If the optimizer never be called(minimize function), the state_dict is empty.

Args: None :returns: dict contains all the variable used by optimizer :rtype: state_dict(dict)

Examples

import paddle.fluid as fluid

with fluid.dygraph.guard():
emb = fluid.dygraph.Embedding([10, 10])


text:
Targeted, Robust, and Model-free Differential Methylation Analysis

Authors: Nima Hejazi and Mark van der Laan

## What’s methyvim?

methyvim is an R package that provides facilities for differential methylation analysis based on variable importance measures (VIMs), statistical target parameters inspired by causal inference.

The statistical methodology implemented computes targeted minimum loss estimates of several well-characterized variable importance measures:

For discrete-valued treatments or exposures:

• The average treatment effect (ATE): The effect of a binary exposure or treatment on the observed methylation at a target CpG site is estimated, controlling for the observed methylation at all other CpG sites in the same neighborhood as the target site, based on an additive form. In particular, the parameter estimate represents the additive difference in methylation that would have been observed at the target site had all observations received the treatment versus the scenario in which none received the treatment.

• The relative risk (RR): The effect of a binary exposure or treatment on the observed methylation at a target CpG site is estimated, controlling for the observed methylation at all other CpG sites in the same neighborhood as the target site, based on an geometric form. In particular, the parameter estimate represents the multiplicative difference in methylation that would have been observed at the target site had all observations received the treatment versus the scenario in which none received the treatment.

For continuous-valued treatments or exposures (WIP: support planned):

• A nonparametric variable importance measure (NPVI) (Chambaz, Neuvial, and van der Laan 2012): The effect of continous-valued exposure or treatment (the observed methylation at a target CpG site) on an outcome of interest is estimated, controlling for the observed methylation at all other CpG sites in the same neighborhood as the target (treatment) site, based on a parameter that compares values of the treatment against a reference value taken to be the null. In particular, the implementation provided is designed to assess the effect of differential methylation at the target CpG site on a (typically) phenotype-level outcome of interest (e.g., survival), in effect providing an nonparametric evaluation of the impact of methylation at the target site on said outcome.

These methods allow differential methylation effects to be quantified in a manner that is largely assumption-free, especially of the variety exploited in parametric models. The statistical algorithm consists in several major steps:

1. Pre-screening of genomic sites is used to isolate a subset of sites for which there is cursory evidence of differential methylation. For the sake of computational feasibility, targeted minimum loss-based estimates of VIMs are computed only for this subset of sites. Several screening approaches are available, adapting core routines from the following R packages: limma, tmle.npvi.
2. Nonparametric VIMs are estimated for the specified parameter, currently adapting routines from the tmle.npvi and tmle R packages.
3. Since pre-screening is performed prior to estimating VIMs, we make use of a multiple testing correction uniquely suited to such settings. Due to the multiple testing nature of the estimation problem, a variant of the Benjamini & Hochberg procedure for controlling the False Discovery Rate (FDR) is applied (Benjamini and Hochberg 1995). Specifically, we apply the modified marginal Benjamini & Hochberg step-up False Discovery Rate controlling procedure for multi-stage analyses (FDR-MSA) (Tuglus and van der Laan 2009).

For a general discussion of the framework of targeted minimum loss estimation and its myriad applications, the canonical references are van der Laan and Rose (2011) and van der Laan and Rose (2018). Hernan and Robins (2019) and Pearl (2000) may be of interest to those desiring a more general introduction to statistical causal inference.

## Installation

For standard use, install from Bioconductor using BiocManager:

if (!requireNamespace("BiocManager", quietly=TRUE)) {
install.packages("BiocManager")
}
BiocManager::install("methyvim")

To contribute, install the bleeding-edge development version from GitHub via remotes:

remotes::install_github("nhejazi/methyvim")

Current and prior Bioconductor releases are available under branches with numbers prefixed by “RELEASE_”. For example, to install the version of this package available via Bioconductor 3.6, use

remotes::install_github("nhejazi/methyvim", ref = "RELEASE_3_6")

## Example

For details on how to best use the methyvim R package, please consult the most recent package vignette available through the Bioconductor project.

## Issues

If you encounter any bugs or have any specific feature requests, please file an issue.

## Contributions

Contributions are very welcome. Interested contributors should consult our contribution guidelines prior to submitting a pull request.

## Citation

After using the methyvim R package, please cite the following:

    @article{hejazi2018methyvim,
doi = {10.12688/f1000research.16047.1},
url = {https://dx.doi.org/10.12688/f1000research.16047.1},
year = {2018},
publisher = {Faculty of 1000 Ltd},
volume = {7},
number = {1424},
author = {Hejazi, Nima S and Phillips, Rachael V and Hubbard, Alan E
and {van der Laan}, Mark J},
title = {{methyvim}: Targeted, robust, and model-free differential
methylation analysis in {R}},
journal = {F1000Research}
}

@manual{hejazi2019methyvimbioc,
author = {Hejazi, Nima S and {van der Laan}, Mark J},
title = {{methyvim}: Targeted, robust, and model-free differential
methylation analysis},
doi = {10.18129/B9.bioc.methyvim},
url = {https://bioconductor.org/packages/methyvim},
note = {R package version 1.8.0}
}

## Funding

The development of this software was supported in part through grants from the National Institutes of Health: T32 LM012417-02, R01 ES021369-05, and P42 ES004705-29.

The contents of this repository are distributed under the MIT license. See file LICENSE for details.


text:
# At a given instant there are 25 % undecayed radioactive nuclei in a same. After 10 sec the number of undecayed nuclei reduces to 6.25 %, the mea

39 views
in Physics
At a given instant there are 25 % undecayed radioactive nuclei in a same. After 10 sec the number of undecayed nuclei reduces to 6.25 %, the mean life of the nuclei is.
A. 14.43 sec
B. 7.21 sec
C. 5 sec
D. 10 sec

by (24.7k points)


text:
시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
6 초 512 MB 0 0 0 0.000%

## 문제

Go is an adversarial game with the objective of surrounding a larger total area of the board with one's stones than the opponent's. The core idea of the game is the concept of liberty, which is an open point, or rather, an intersection of vertical and horizontal lines on the chessboard with no stones on it, bordering the group.

A stone, white or black, is called alive if it has at least one liberty directly orthogonally adjacent (up, down, left, or right), or must be in the same connected group with a stone of the same color which is alive. We say two stones of the same color are directly connected if they're orthogonally adjacent. We say two stones $s_1$ and $s_k$ of the same color are in the same connected group if there exists a sequence of stones $s_1, s_2,\cdots, s_k$ such that for all $1 \le i < k$, $s_{i-1}$ and $s_i$ are of the same color and are directly connected.

For example, in the left part of the below figure, neither of the two white stones is alive, as they're captured by the surrounding black stones; While in the right part, the rightmost white stone is also not alive, even if the leftmost black stone is also not alive.

Given a chessboard with $n$ vertical and $n$ horizontal lines where some stones might be lying on, please calculate the number of white stones captured by the black ones (that is to say, calcaulate the number of white stones not alive). The results for the above examples are $2$ and $1$, respectively.

However, our dear friend Kotori thinks that this problem is too simple for our clever contestants to solve, so she would like to heat things up by instead asking you to flip the color of each stone (that is to say, change a black stone to a white one, or vice versa1) independently and find out the corresponding answer after each flip.

By flipping independently we mean that before flipping the color of a stone, the other stones should change back to their original color. Also note that the data in this problem is not from the real world, which means that the size of the chessboard is not necesssarily $19 \times 19$, and the number of white and black stones can be any integer.

1Vice versa: The reverse is also true. Here it can be replaced with "change a white stone to a black one". This is a very common phrase in modern English especially in academic writing, so please bear it in mind.

## 입력

There are multiple test cases. The first line of the input contains an integer $T$ indicating the number of test cases. For each test case:

The first line contains one integer $n$ ($2\le n \le 10^3$) indicating the length of the board side.

For the next $n$ lines, the $i$-th line contains a string $s_{i,1},s_{i,2},\cdots,s_{i,n}$ ($s_{i,j}$ $\in$ $\{\text{'x' (ascii: 120)}$, $\text{'o' (ascii: 111)}$, $\text{'.' (ascii: 46)}\}$), where $s_{i,j} = \text{'x'}$ indicates that the intersection on the $i$-th row and the $j$-th column contains a black stone. Similarly $s_{i, j} = \text{'o'}$ for a white stone and $s_{i,j} = \text{'.'}$ for an empty intersection.

It's guaranteed that the sum of $n$ over all test cases does not exceed $5 \times 10^3$.

## 출력

For each test case output an integer $E$ modulo $(10^9 + 7)$ which is the answer encoded as follows:

• Sort all the stones with their row number (from top to bottom) as the primary sort key and their column number (from left to right) as the secondary sort key;
• $E=\sum \limits_{i=1}^m (10^6 + 7)^{m-i}a_i$, where $m$ is the number of stones and $a_i$ is the number of white stones not alive after flipping the color of the $i$-th stone.

NOTE that the MODULUS and the BASE are DIFFERENT. (We're begging you to notice this sentence. If this is not a pdf file I would rather it flashes and twinkles like crazy.

## 예제 입력 1

3
2
.o
..
3
.x.
xoo
ox.
2
oo
oo

## 예제 출력 1

0
870527216
485539347

## 힌트

For the second sample test case, after flipping the stones in the order of $(1,2)$, $(2,1)$, $(2,2)$, $(2,3)$, $(3,1)$, $(3,2)$, the number of dead white stones are $1$, $0$, $1$, $2$, $0$, $0$, repectively.

For the third sample test case all stones on the chessboard, black or white, are not alive.


text:
# LaTeX conditional expression

I would like to be able to set a flag at the beginning of the main flag (say output) that tells if I want to produce a paper document or an electronic document.

Then I should check this flag to define or not empty pages, hypperref, oneside or twosides, etc.

How could I do that ?

-

There are many ways.

# Plain LaTeX

Perhaps the most canonical is:

\newif\ifpaper

Then either

\papertrue % or
\paperfalse

And to use it:

\ifpaper
% using paper
\else
% electronic
\fi

However, using these primitive conditionals can lead to unexpected problems if you're not entirely familiar with the way TeX processes them, and the following solutions are recommended.

# etoolbox

A more user-friendly and modern approach is taken by etoolbox, where you'd write instead

\newtoggle{paper}

which is set with either

\toggletrue{paper}
\togglefalse{paper}

And to use it:

\iftoggle{paper}{%
% using paper
}{%
% electronic
}

Why do I say this is more friendly? You'll never run into troubles with nesting, for which LaTeX's \newif conditions can sometimes be a bit of a pain to deal with.

etoolbox also supports boolean expressions such as

\ifboolexpr { togl {paper} and togl {pdf} } {true} {false}

which can also be combined with various testing functions also provided by that package (and others):

\ifboolexpr { togl {paper} or test {\ifdef{\foo}} } {true} {false}

# expl3

Finally, for package writers (not really document authors): expl3 as part of LaTeX3 provides booleans that can be used in all sorts of interesting ways. For basic use, they look like this:

\bool_new:N \l_tmpa_bool

\bool_set_true:N \l_tmpa_bool
\bool_set_false:N \l_tmpa_bool

\bool_if:NTF \l_tmpa_bool {true} {false}
\bool_if:NT \l_tmpa_bool {true}
\bool_if:NF \l_tmpa_bool {false}

You can use boolean logic as follows:

\bool_if:nTF { ( \l_tmpa_bool || \l_tmpb_bool ) && !( \l_tmpc_bool ) } {true} {false}

Everything is expandable and lazy evaluation is used to avoid performing tests that don't need to be checked.

You can also combine boolean variables above with conditional functions such as \cs_if_eq_p:NN (‘are two control sequences equal?’) which can be tested in exactly the same way:

\bool_if:nTF { \l_tmpa_bool && \cs_if_eq_p:NN \foo \bar } {true} {false}

The overlap between etoolbox and expl3 here is rather pronounced; I think of the difference between the two as the separation between document authors (for etoolbox) and package writers (for expl3). But it's purely a matter of taste, when it comes down to it.

-
Thanks ! Just perfect. –  Cedric H. Nov 24 '10 at 13:53
+1 for not mentioning the obsolete ifthen package. –  Philipp Nov 27 '10 at 10:24
"troubles with nesting" - you might link to your excellent digression/answer. –  Charles Stewart Nov 27 '10 at 11:05
your answer is very useful for me. –  xport Dec 9 '10 at 7:24
@Philipp: Waht’s the problem with ifthen I use it often an think it’s syntax is easier that that one shown by Will with etoolbox. –  Tobi Jul 7 '11 at 15:16

ifthen can be your friend also-

but Will R's solutions are more low level and possibly closer to what you want.

I use ifthen with my CV, since I have to have an internal version as well as an external version. Not to mention that it makes having a 'long' and 'short' version.

-
How is etoolbox low level? –  Charles Stewart Nov 27 '10 at 11:06
I just meant the dive into straight TeX, but yes, etoolbox is decidedly not. –  flip Nov 27 '10 at 14:47

Another approach is with the optional package, which I use for many purposes, along with boolexpr, which has a nice \switch and \case command.

Here's a minimal to illustrate.

%%%my-varient-for-different-output.tex
%%%This is the file that you actually call with pdftex/lualatex/etc.
\documentclass{minimal}
%\usepackage{xifthen}
\usepackage[foo]{optional}
%\input{themain-file.tex}
%%%EOF my-varient-for-different-output.tex

%%%%START OF themain-file.tex
\usepackage{boolexpr}

\makeatletter
%Check if optional is loaded. Otherwise, you don't
%want to define these commands.
%%Don't do anything here because you've got it covered.
}{%
%%%What are the defaults if no optional class was loaded?
\usepackage[bar]{optional}
}
%%%Let's make an ifthenelse version of the \opt command that's
%%%provided by the optional package
\newcommand\ifopt[3]{%
\ifboolexpr{%
0 = \pdfstrcmp{true}{%
\opt{#1}{true}%
}%
}{#2}{#3}%
}%
%%%This command is a wrapper around the \switch command that's
%%%provided by boolexpr. It lets you quickly create a switch
%%%that checks if an option is set.
\newcommand*\switchopt[1]{%
\switch[\pdfstrcmp{\opt{#1}{#1}}]%
}
%%%I'm sure there is a way to embed the \switch
%%%command in here, but I'm not that smart. Is
%%%there some application of \noexpand?
%%%
%%%Anyway, this is more common to use than \switchopt
%%%You'll use \switch (with no optional argument)
%%%and \case[\caseopt{myoption}] Do stuff...
%%%
\newcommand*\caseopt[1]{%
\pdfstrcmp{#1}{\opt{#1}{#1}}% = 0%
}

\makeatother

\begin{document}
I'm writing some text but \opt{foo}{don't want this
unless foo is there.} If I want an else as part of
the deal, then \ifopt{bar}{bar must be there}{bar
is out to lunch} and it's time to go.

Nesting ifopt commands can be tedious. Best to use
a case if we've got a ton of definitions\ldots
%%%NOTICE THE {{ and }}. They are required when using
%%% an optional argument in \switch.
\switchopt{bar}
\case{{foo}} Foo stuff here!
\case{{bar}} Bar stuff here!
\case{{third}} Some other thingy-dingy!
\otherwise Nothing I know of was set.
\endswitch%

\switch
\case{\caseopt{foo}} Foo stuff here!
\case{\caseopt{bar}} Bar stuff here!
\otherwise Nothing I know of was set.
\endswitch%
\end{document}

Although the chosen answer is probably better, this may lead to more ideas.

-

You can at the command line do something like \def\MYFLAG{} and then test if \MYFLAG is undefined in your document (or an included style file).

This allows you to run a document in different ways without having to change it, something like command line options to a program.

Not exactly the question asked, but strongly related to the use case you give.

-
How to test if \MYFLAG is undefined? –  Xiè Jìléi Feb 1 '13 at 1:11
@XièJìléi: I normally use \ifdefined\MYFLAG ... \else ... \fi. –  Peter Grill Mar 24 at 22:46


text:
datahacker.rs@gmail.com

# Category: Other

### #005B Logistic Regression: from scratch vs. Scikit-Learn

Logistic Regression: from scratch vs. Scikit-Learn Let’s now compare Logistic Regression from scratch and Logistic Regression from scikit – learn. Our dataset are class 0 and class 1, which we generated randomly. Training set has 2000 examples coming from the first and second class. The test set has 1000 examples, 500 from each class.  When we plot these datasets it looks like this: Python’s library scikit-learn has  function LogisticRegression and we will implement it on…

### #006B Vectorization and Broadcasting in Python

What is a Vectorization ? A vectorization is basically the art of getting rid of explicit for loops whenever possible. With the help of vectorization operations are applied to whole arrays instead of individual elements. The rule of thumb to remember is to avoid using explicit for loops in your code. Deep learning algorithms tend to shine when trained on large datasets, so it’s important that your code runs quickly. Otherwise, your code might take…

### #012A Building a Deep Neural Network

Building blocks of a Deep Neural Network   In this post we will see what are the building blocks of a Deep Neural Network. We will pick one layer, for example layer $$l$$ of a deep neural network and we will focus on computatons for that layer. For layer $$l$$ we have parameters $$\textbf{W}^{[l]}$$ and . Calculation of the forward pass for layer we get as we input activations from the previous…
In this post we will see how to implement gradient descent for one hidden layer Neural Network as presented in the picture below. One hidden layer Neural Network   Parameters for one hidden layer Neural Network are $$\textbf{W}^{[1]}$$, $$b^{[1]}$$, $$\textbf{W}^{[2]}$$ and $$b^{[2]}$$. Number of unitis in each layer are:  input of a Neural Network is feature vector ,so the length of “zero” layer $$a^{[0]}$$ is the size of an input feature…
Activation functions When we build a neural network, one of the choices we have to make is what activation functions to use in the hidden layers as well as at the output unit of the  Neural Network. So far, we’ve just been using the sigmoid activation function but sometimes other choices can work much better.  Let’s take a look at some of the  options. $$sigmoid$$ activation function In the forward propagation steps for Neural Network there are two steps…


text:
# Gradient of a vector field

We did in lectures gradient of a scalar field and I am wondering how is the grad of a vector field. I tried the following Let

$$V = f(x,y,z)\hat{\imath} + g(x,y,z)\hat{\jmath} + h(x,y,z)\hat{k} \, .$$

Then by definition

$$\mathrm{grad}(V)= \hat{\imath} V_x + \hat{\jmath}V_y + \hat{k}V_z \, ,$$

where $$V_x$$, $$V_y$$, $$V_z$$ denote the partial derivatives of $$V$$ with respect to to $$(x,y,z)$$. But $$i V_x = f(x,y,z)x$$ since $$\hat{\imath}\cdot\hat{\imath}=1$$, $$\hat{\imath}\cdot\hat{\jmath}=0$$, and $$\hat{\imath}\cdot\hat{k}=0$$.

Similarly, $$\hat{\jmath}V_y = g(x,y,z)y$$ and $$\hat{k}V_z=h(x,y,z)$$. So we end up with

$$\mathrm{grad}(V) = f(x,y,z)x + g(x,y,z)y + h(x,y,z)z = \mathrm{div}(V) \, .$$

I guess that is wrong but what is wrong with the method.

The gradient of a vector field in ordinary $R^3$ is a tensor field. You will need to use the tensor product to represent it $\otimes$.
$$\nabla V = \left( \hat{e}_i \frac{\partial}{\partial x_i} \right ) (V_m \hat{e}_m) \\ = \frac{\partial V_m}{\partial x_i} \hat{e}_i \otimes \hat{e}_m$$


text:
# scipy.special.kn#

scipy.special.kn(n, x, out=None) = <ufunc 'kn'>#

Modified Bessel function of the second kind of integer order n

Returns the modified Bessel function of the second kind for integer order n at real z.

These are also sometimes called functions of the third kind, Basset functions, or Macdonald functions.

Parameters:
narray_like of int

Order of Bessel functions (floats will truncate with a warning)

xarray_like of float

Argument at which to evaluate the Bessel functions

outndarray, optional

Optional output array for the function results.

Returns:
scalar or ndarray

Value of the Modified Bessel function of the second kind, $$K_n(x)$$.

kv

Same function, but accepts real order and complex argument

kvp

Derivative of this function

Notes

Wrapper for AMOS [1] routine zbesk. For a discussion of the algorithm used, see [2] and the references therein.

References

[1]

Donald E. Amos, “AMOS, A Portable Package for Bessel Functions of a Complex Argument and Nonnegative Order”, http://netlib.org/amos/

[2]

Donald E. Amos, “Algorithm 644: A portable package for Bessel functions of a complex argument and nonnegative order”, ACM TOMS Vol. 12 Issue 3, Sept. 1986, p. 265

Examples

Plot the function of several orders for real input:

>>> import numpy as np
>>> from scipy.special import kn
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(0, 5, 1000)
>>> for N in range(6):
...     plt.plot(x, kn(N, x), label='$K_{}(x)$'.format(N))
>>> plt.ylim(0, 10)
>>> plt.legend()
>>> plt.title(r'Modified Bessel function of the second kind $K_n(x)$')
>>> plt.show()

Calculate for a single value at multiple orders:

>>> kn([4, 5, 6], 1)
array([   44.23241585,   360.9605896 ,  3653.83831186])


text:
# Linear model selection (AIC/dredge function) with non parametric data (residuals are autocorrelated)

I used the dredge function with MuMIn & lme4 package to do a linear model selection with AIC principle. I have about 10 predictors (year, length of whale, 8 different fatty acid concentrations) to test for their effect on the dependent variable (Log transformed PCB concentration in whale blubber).

The best model is very interesting, there is no multicollinearity and the fitted residuals plot looks OK. HOWEVER, the Durbin-Watson test always fails (p < 0.05), meaning our residuals are autocorrelated... Does this invalidate my results and/or is this a problem? I am using model selection as it was advised by my supervisor, but the fatty acids I am including as predictors are proportional data (all adding to one) and tend to violate assumptions of normality and can be highly correlated. I had originally used a multivariate analysis (factor analysis) for my work, but was advised to use model selection to examine important predictors of sumPCB concentrations in whales (individual fatty acids, body size, and year). ... I tried a GLM model to correct for this autocorrelation but the results are different and less interesting, only one significant predictor...

Thank you for your feedback. As I am very new to these methods and approach (I am starting an MSc) I would appreciate any advice you have as I'm finding my dataset quite complicated for the model selection approach I was advised to do.

• Your model selection procedure invalidates your results. I'm not sure whether it's meaningful to determine if the DW result makes them 'more' invalid. The name of the function ("dredge") is an allusion to the fact that it is data dredging. It's worth reading the note in the documentation for the function. – gung - Reinstate Monica Jun 10 at 16:39
• 1) What are "parametric" and "nonparametric" data? // 2) Stepwise regression has been debunked on Cross Validated, and Gelman opposes stepwise regression. // 3) If you have many observations, tests are going to result in small p-values, even if the autocorrelation is not of practical significance. All the test is saying is, loosely speaking, there is not zero autocorrelation, but the autocorrelation could be $1/TREE(3)$ (unbelievably close to zero, yet not equal to zero). – Dave Jun 10 at 16:40
• @ReinstateMonica Well, my boss suggested the model selection in order to make sense of this huge multivariate dataset and find out more about which variables are more important in this beluga whale study. Other analyses will confirm this and be required of course. – Laura Zeppetelli-Bedard Jun 10 at 18:58
• You ask if it is a problem not to have parametric data, but what are parametric data? – Dave Jun 10 at 20:47


text:
Problem 4: Find the largest palindrome made from the product of two 3-digit numbers.

Commentary: Believe it or not, I don’t have much to say about this problem. There are cuter, more general ways to attack this problem, but computer scientists suffer from an acute case of overgeneralizationitis. I had a math professor once who loved to say “never do a calculation before its time”. This is good advice, even in programming, but I think there’s a useful addendum to this. Never generalize before it’s necessary. Encapsulating an idea into a function is a stupid waste of time unless you’re pretty sure there’s a good reason to do it. But in my experience, most programmers don’t bother thinking much about anything. They literally behave like computers, as though some algorithm needs to be fed to them and that is then all they are capable of doing from that point forward.

My biggest problem with programmers is they have this mindset that there’s only one possible solution. I hesitate to say this of computer scientists in general, but it’s certainly true of people who call themselves programmers: these people lack imagination. They talk about “right” and “wrong” solutions, when what they really mean is “good” and “bad”, or more often, “elegant” and “inelegant”, a completely subjective, ill-defined notion.

I’m not advocating that we make every proof (or program) into a brutal slog of calculations and appeals to first principles. But elegance without insight can be very costly.

And that is why programmers are terrible at mathematics.

R Code:

ElapsedTime <- system.time({
##########################
RearrangeVector <- function(vec, n=1){
vec
}

palindromes <- numeric(9*10*10)
i <- 1
for (a1 in 1:9){
for (a2 in 0:9){
for (a3 in 0:9){
palindromes[i] <- a1*10^5 + a2*10^4 + a3*10^3
+ a3*10^2 + a2*10^1 + a1
i <- i+1
}
}
}

palindromes <- sort(palindromes, decreasing=TRUE)

prod <- numeric(0)
temp <- 899:999
for (n in 1:100){
prod <- c(prod, temp*RearrangeVector(temp, n))
}

acceptable <- palindromes[palindromes %in% prod]


text:
## 2.3 Packages

When you download and install R for the first time, you are installing the Base R software. Base R will contain most of the functions you’ll use on a daily basis like mean() and hist(). However, only functions written by the original authors of the R language will appear here. If you want to access data and code written by other people, you’ll need to install it as a package. An R package is simply a bunch of data, from functions, to help menus, to vignettes (examples), stored in one neat package.

A package is like a light bulb. In order to use it, you first need to order it to your house (i.e.; your computer) by installing it. Once you’ve installed a package, you never need to install it again. However, every time you want to actually use the package, you need to turn it on by loading it. Here’s how to do it.

### 2.3.1 Installing a new package

Installing a package simply means downloading the package code onto your personal computer. There are two main ways to install new packages. The first, and most common, method is to download them from the Comprehensive R Archive Network (CRAN). CRAN is the central repository for R packages. To install a new R package from CRAN, you can simply run the code install.packages("name"), where “name” is the name of the package. For example, to download the yarrr package, which contains several data sets and functions we will use in this book, you should run the following:

# Install the yarrr package from CRAN
#   You only need to install a package once!
install.packages("yarrr")

When you run install.packages("name") R will download the package from CRAN. If everything works, you should see some information about where the package is being downloaded from, in addition to a progress bar.

Like ordering a light bulb, once you’ve installed a package on your computer you never need to install it again (unless you want to try to install a new version of the package). However, every time you want to use it, you need to turn it on by loading it.

Once you’ve installed a package, it’s on your computer. However, just because it’s on your computer doesn’t mean R is ready to use it. If you want to use something, like a function or dataset, from a package you always need to load the package in your R session first. Just like a light bulb, you need to turn it on to use it!

To load a package, you use the library() function. For example, now that we’ve installed the yarrr package, we can load it with library("yarrr"):

# Load the yarrr package so I can use it!
#   You have to load a package in every new R session!
library("yarrr")

Now that you’ve loaded the yarrr package, you can use any of its functions! One of the coolest functions in this package is called pirateplot(). Rather than telling you what a pirateplot is, let’s just make one. Run the following code chunk to make your own pirateplot. Don’t worry about the specifics of the code below, you’ll learn more about how all this works later. For now, just run the code and marvel at your pirateplot.

# Make a pirateplot using the pirateplot() function
#  from the yarrr package!

pirateplot(formula = weight ~ Time,
data = ChickWeight,
pal = "xmen")

There is one way in R to temporarily load a package without using the library() function. To do this, you can simply use the notation package::function notation. This notation simply tells R to load the package just for this one chunk of code. For example, I could use the pirateplot function from yarrr package as follows:

# Use the pirateplot() function without loading the yarrr package first
yarrr::pirateplot(formula = weight ~ Diet,
data = ChickWeight)

Again, you can think about the package::function method as a way to temporarily loading a package for a single line of code. One benefit of using the package::function notation is that it’s immediately clear to anyone reading the code which package contains the function. However, a drawback is that if you are using a function from a package often, it forces you to constantly retype the package name. You can use whichever method makes sense for you.


text:
# Smoothing L1 norm, Huber vs Conjugate

I'm trying to minimize a convex (not necessarily strictly convex) function involving an L1 norm (similar to lasso), which makes it non-differentiable at some points. So I'd like to smooth it and treat it as an L2 norm problem.

The two approaches I've seen ( http://www.ee.ucla.edu/~vandenbe/236C/lectures/smoothing.pdf ) are directly smoothing the L1 norm using the Huber function, and smoothing the conjugate (i.e, derive the dual norm, here it's L-infinity, which is still non-differentiable, then smooth that).

The Huber approach is much simpler, is there any advantage in the conjugate method over Huber? I can't see the point of smoothing the dual instead of just smoothing the primal.

-
Smoothing the dual will not give you a smooth primal. However, you get a strongly convex primal by dual smoothing (as opposed to merely a strictly convex primal by Huber smoothing). Hence, it depends on what kind of regularity you are aiming at: A smoother primal or a "more convex" primal - both can be helpful algorithmically. Moreover, note that there are numerous methods to treat nonsmooth convex minimization problems efficiently. – Dirk Jan 8 '13 at 7:15
@Dirk: why don't you write an answer about these? What you write here might interest more people. – András Bátkai Jan 8 '13 at 7:18

## 1 Answer

Following the suggestion of András Bátkai I post my comment as an answer:

Smoothing the dual or the primal problem are quite different things: Smoothing the dual will not give you a smooth primal. However, you get a strongly convex primal by dual smoothing (as opposed to merely a strictly convex primal by Huber smoothing). Hence, it depends on what kind of regularity you are aiming at: A smoother primal or a "more convex" primal - both can be helpful algorithmically. A smooth primal allows you to use gradients instead of subgradients and in turn allows you to apply gradient methods with appropriate stopping rules and such. A strongly convex primal leads to a proximal mapping of the primal objective which is not only non-expansive but contractive which is favorable for proximal-splitting methods.

Of course, you can also apply both primal and dual smoothing if you like.

Moreover, note that there are numerous methods to treat nonsmooth convex minimization problems efficiently

-
Great answer, thanks. One more clarification: are there any guarantees that minimizing the smoothed dual will actually produce good (optimal?) solutions to the original primal? – digdug Jan 8 '13 at 23:04
I don't think so - I even think that a dual solution does not always give you a way to infer a primal solution... (regardless of smoothing). Probably an answer can be found in Nesterov's "Smooth minimization of non-smooth problems". – Dirk Jan 9 '13 at 9:52
Smoothing the dual, we get a strongly convex primal. Then, is it true that the primal is smooth because the primal is strongly convex? – jakeoung Nov 17 '15 at 22:19
@jakeoung No, this is not true in general. – Dirk Nov 18 '15 at 5:25


text:
# Ignition Control with AVR

#### ratlifflj

Joined Nov 4, 2008
11
Hi,
I am using an atmega128 for developing an ignition system for a 3/4 cylinder engine (needs to be usable for both).
I have things working great at a fixed rpm. Even if I change rpm all I need to do is reset and pulses for ignition fire correctly.
The problem is that I cant reset. I need this to work during transient times as well as at a fixed rpm. If it cant then it will not work on start up, etc.
I am using ICP on timer 1 to catch the "long tooth" portion of the signal from the cam sensor. I developed an external board to convert the cam signal (Hall effect sensor) to a digital pulse. The long tooth indicates cylinder #1. Once I have detected this I start timer 2 which counts the pulses from the cam sensor digital signal on the falling edge starting with the long tooth as 0. And I turn off the ICP sense switching (initially it comes in on both the rising and falling edges in order to calculate pulse width). The reason I turn off the ICP is that I was having interrupt conflicts as T2 counts on the falling edge as well. after I start T2, it counts up on falling edge and ICP catches the rising edge so we have no conflicts. But because I am doing this I have no way to calculate the pulse width and the delay time calculation for time to fire before top dead center is dependent on this. Thus, I have the issue of not being able to operate when the rpm is changing. I can provide more detail which I think will be necessary if someone thinks they can help.
Any thoughts or ideas will help immensely as I am really stuck.
Thanks

#### hgmjr

Joined Jan 28, 2005
9,029
Post your schematic and your code and we can have a look to see what can be changed to alter the behavior. Are you using Assembly or C-language coding?

hgmjr

#### hgmjr

Joined Jan 28, 2005
9,029
All we can do is guess at what lies at the heart of your problem if you are not willing to provide us with more details (i.e. code, schematic, flowchart).

If you need any assistance with how to attach a file to a post then you can refer to the FAQ Help section. You can find the link at the top of this forum page in the tool bar.

If you have questions about the attachment process that are not answered in the FAQ section then feel free to post them here.

hgmjr

#### ratlifflj

Joined Nov 4, 2008
11
I havent been at my computer until just now. so I havent had time to respond.
but as I said in the original post I am willing to provide whatever information necessary if there are suggestions. I am attaching my code and here is the board I am using:
http://www.futurlec.com/ATMEGA_Controller.shtml
the digital input from the cam sensor goes into both Timer2 as an external clock and ICP of timer 1.
excuse the code as it is a work in progress...
thanks for any help.

#### ratlifflj

Joined Nov 4, 2008
11
files. I am using C.

#### hgmjr

Joined Jan 28, 2005
9,029
Rich (BB code):
//***********************************************************************
/* **********************************************************************
*
*
* - File              : main.c
* - Compiler          : GCC
*
* - Support mail
*
* - Devices     : ATMega128
*
* - Description       : Pulse Width Demodulation to drive Ignition Spark...
*      Adapted from the AVR135 application note
*
* Revision: 09/11/2008
*****************************************************************************/
/*
* Description:
* icp.c contains functions for use of the demodulator.
* main.c contains a simple program to demonstrate the demodulator operation. It
* generates a PWM signal on OC2, then samples the demodulator output using calls
* to icp_rx() and writes the values obtained to PORTC.
* Approximately twice per second, OCR2 is incremented such that the PWM duty cycle
* steps through the entire [0:256) range.
* The intended use is on the STK500/STK501, with a 10-wire jumper connecting the
* PORTC header with the LEDs header and a single-wire jumper connecting PB7 (OC2)
* with PD4 (ICP1).
* The expected result is that the LED display cycles repeatedly from 0x00 to 0xFF.
*/
//ucontroller defintion:
#define __AVR_ATmega128__ 1
//include files:              /* sei */
#include "icp.h"
//Defines:
#define F_CPU = 8200000UL
#define SEI() sei()
#define CLI() cli()
#define SLEEP() __asm__ __volatile__ ("sleep \r\n" :: )
#define OUT_PORT        PORTF
#define OUT_DDR         DDRF

// Function prototypes
void oversampled(void);
void hb_init(void);
//void pwm_init(void);
void ig_init(void);

void timer3_init(void);
void timer3_reint(void);
void timer3_off(void);
void invert_input_init(void);
//void reset_led(void);

// Global variables
double  accumulator       = 0;  //!< Accumulated 10-bit samples
double  Vin               = 0;  //!< 16-bit float number result
short   temp              = 0;  //!< Temporary variable
short   samples           = 0;  //!< Number of conversions
int  count = 0;
//static uint8_t ledon = 0;
unsigned char hb_count;               /* counts [0:4] to make the test visible */
int repetitions = 0, f = 0;
//int fire_coil_1 = 0, fire_coil_2=0;
int flag = 0;
int bin_flag1 =1;
int timer_flag =1;
int m,c_index=4;
int coil[3];
int ind=0;
int r = 0;
int d = 0;
int s_delta[6];
int run_1_done = 0;
int bin_flag = 1;
int norm_op = 1;
int t_index[3];
int d_old = 0, d_older=0,d_oldest=0,d_older_still=0;
int d_current = 0;
//int coil_t3 = 5;
int second_run =0;
int icp_init_flag = 0;
icp_timer_t c_btdc=0,c_d=0, cnt1=0;
int flagg=0;
int j = 0, k = 0;
int distance = 0;
int delay_time;
int delta_right = 0;
int init_flag_delta = 0;
//Initialize and Define External Variables (psuedo-global):
extern int k, tooth_index, delay_time, t_i;
extern icp_timer_t glob_delay;
extern int pre_t_ind, t_count, delta_left;
extern int store_period[6], store_delta[6], tooth_pre_index;
extern long sec_deg, sum_period;
//-----------------------------------------------------------------------------

// main()
int main(void)
{
DDRF = 0x00;
PORTF = 0x00;
DDRE = 0xFF;
// PORTC for LED debug
//LED_DEBUG_PORT = 0x00;              /* initially off */
LED_DEBUG_DDR = 0xFF;              /* all output */
PORTA = 0xFF;                /* display port A is set to initially off*/
DDRA = 0xFF;                /* all output */
OUT_DDR       = 0xFF;              /* all output */
OUT_PORT = 0x00;               /*initially off*/
SEI();
MCUCR |= (1 << SE);               /* enable (idle mode) sleep */
// Init subsystems                 /* main.c */
icp_init();                 /* icp.c */                 /* main.c */
// invert_input_init();
//    cam_count_init();
// delta_timer3_init();
//set up array with coil output addresses
m = 4;
coil[0]=4;
coil[1]=5;
coil[2]=6;
t_index[0]=0;
t_index[1]=2;
t_index[2]=4;

//begin infinite loop
for (;;)                 /* Loop Forever */
{                 /* Fetch the latest reading and display it on the LEDs. */
//if(icp_init_flag == 0){
// if(TCNT2 == 1){
//  icp_init();
//  icp_init_flag = 1;
// }
//}
// start of ADC conversion for degrees BTDC
//  sbi(ADCSRA,ADSC);             //Start a conversion by writing 1 to the ADSC bit (6)
//  while (ADCSRA & 0b01000000);           //wait for conversion to complete
//  ADC_count = ((ADCL)| ((ADCH)<<8));         //10 bit conversion for channel 0 (PF0)
//  display_7seg(glob_delta);        /*Display values for testing, not needed for actual operation */
SLEEP();
}

return(0);
}
//--------------------------------------------------------------------------------------
//Subroutines:
void delta_timer3_init(void){
TCCR3B = (1<<CS30)|(0<<CS31)|(1<<CS32);
TCNT3 = 0;
}
void cam_count_init(void){
TCCR2 = (1<<CS22)| (1<<CS21) | (0<<CS20)|(0<<WGM21); //makes external clock on T2, ie counts up
// on CS20= 0 is falling edge of cam in
// CS20 = 1 is rising edge
OCR2 = 5;
TIMSK |= (1<<OCIE2);
TCCR3B = (1<<CS30)|(0<<CS31)|(1<<CS32);
TCNT3 = 0;
// delta_timer3_init();
}
SIGNAL(SIG_OUTPUT_COMPARE2){      //when OCR2 reaches 5 and interrupt is generated and comes here

j = ind*2;
if (j == 0){
d=4;
}
else if( j == 1){
d = 5;
}
else{
d=j-2;
}
if (j == 0){
k=5;
}
else{
k=j-1;
}
if(tooth_index==5){
m=0;
}
else{
m=tooth_index+1;
}
delta_right = TCNT3;
// TCCR3B = (1<<CS30)|(0<<CS31)|(1<<CS32);
TCNT3 = 0;
d_older_still=d_oldest;
d_oldest=d_older;
d_older = d_old;
d_old = d_current;
d_current = delta_right-delta_left;
s_delta[r] = delta_right-delta_left;
r++;
if (r == 6){
init_flag_delta = 1;
r = 0;
}
// if(init_flag_delta == 0){
distance = store_period[k]-store_delta[tooth_index]+store_period[j]-(store_period[j]-store_delta[m])/2;
// }
// else{
// distance = store_period[k]-s_delta[k]+store_period[j]-(store_period[j]-s_delta[j])/2;
// distance = store_period[k]-d_older+store_period[j]-(store_period[j]-d_current)/2;
// }
// delay_time = d_current;
delay_time = (distance - (sec_deg+14400))/128;
// delay_time = 2;
// delay_time=s_delta[5]/4;
timer0_init();
// if(flagg==0){
//  sbi(LED_DEBUG_PORT,4);
//  }
// if(flagg==1){
//  cbi(LED_DEBUG_PORT,4);
//  }
// flagg^=1;
OCR2= 1;
TCNT2 = 0;
ind++;
if ( ind == 3 ) ind = 0;

}
void timer0_reint(void){
TCCR0=(1<<CS00)|(1<<CS01)|(1<<CS02)|(0<<COM00)|(0<<COM01);    //1024 prescale
TCNT0=0;
OCR0 = 112;               // conducting duration
TIMSK |= (1<<OCIE0);
}
void timer0_off(void){
TCCR0=(0<<CS00)|(0<<CS01)|(0<<CS02)|(0<<COM00)|(0<<COM01);
TCNT0=0;
OCR0 = 0;
TIMSK |= (0<<OCIE0);
}
void timer0_init(void){
TCCR0=(1<<CS00)|(1<<CS01)|(1<<CS02)|(0<<COM00)|(0<<COM01);      //1024 prescale
OCR0 = delay_time;
// OCR0 = 25;
// sbi(LED_DEBUG_PORT,c_index);
TIMSK |= (1<<OCIE0);
}
SIGNAL(SIG_OUTPUT_COMPARE0){
if(bin_flag == 0){
cbi(LED_DEBUG_PORT,c_index);
timer0_off();
TCCR0=(0<<CS00)|(0<<CS01)|(0<<CS02)|(0<<COM00)|(0<<COM01);
TIMSK |= (0<<OCIE0);
c_index++;
if (c_index==7) c_index =4;
}
if (bin_flag == 1){
sbi(LED_DEBUG_PORT,c_index);
timer0_reint();
}

bin_flag ^= 1;
}

{
ADCSRA &= ~(BV(ADFR));             //single sample conversion by clearing bit 5 (ADFR)
ADCSRA = ((ADCSRA & 0b11111000)|0b00000110);       //selects div by 64 clock prescaler
ADMUX = ((ADMUX & 0b00111111)|0b01000000);       //selects AVCC as Vref
ADMUX &= 0b11100000;            //selects single ended conversion of PF0
}
Here is your main.c routine.

Last edited:

#### ratlifflj

Joined Nov 4, 2008
11
as you will see in my code commented out is the use of Timer 3 to calculate pulse width without the use of the ICP. When I do this on an engine stand everything works smoothly. But when I do it on an actual unit (engine running a heat pump) I have some random skipping. The signal for the ignition shifts randomly. If I reset everything returns to normal and then begins to shift again. I am running in parallel with another ignition module in order to do testing and only one of them controls actual ignition process. I am also using a VFD for controlling the blower motor. I think that this could be causing noise as well as the way the unit is grounded. My purpose of posting my code and problem is to have someone else look at the code to see if I am missing something in the code. Since you cannot see my project in detail analysis of the code would be ideal. Sometimes fresh eyes on a project helps to offer insight.

#### ratlifflj

Joined Nov 4, 2008
11
I am also trying to add in the use of an external interrupt to calculate pulse width as external interrupts can be asynchronous and this may allow me to continuously calculate the pulse width even during the transient periods.
I havent tested this but it is what I am doing now.

#### hgmjr

Joined Jan 28, 2005
9,029
Of course it will take a bit to digest the overall code to get a sense of what is what.

Let me see what I can do. Is there any urgency to complete the project that I should know about?

hgmjr

#### hgmjr

Joined Jan 28, 2005
9,029
You mentioned that you had designed an external interface board. Can you post a schematic of the board?

hgmjr

#### ratlifflj

Joined Nov 4, 2008
11
No urgency for project.
The board just uses a LM311 and a 2n3904 (logic inverter circuit) to create a digital pulse from the cam sensor signal. The pulse is 0-5V and has varying pulse width and period. it repeats every 6 pulses. I can provide a circuit if you want. I will have to prepare one. its a simple circuit. the lm311 is just is a low power comparator since the cam sensor signal cannot stand high impedance and the lm 311 just inverts the signal.

#### hgmjr

Joined Jan 28, 2005
9,029
It sounds simple enough that it need not be provided at this time. If I see any need for it I will make a request here.

hgmjr


text:
# Page numbering sending me crazy.

So I spend a long time getting page numbering right for the book. I have first chapter as page 1 etc. The only way I could do it was to offset the number. I had roman numerals where needed in the front matter and send the file with TOC as I wanted it to my friend to check.

Page 1 has bizarrely ended up as page 79. It was page 1 when I sent the documents to her.

all other page numbers are messed up and even in pdf form (we did odt, pdf and she seems to have tried to create an epub to send back to menot realising you do not have page numbers and headers) for her all the page nos are changed.

How can a pdf change like that? I used the export function. I saw it all correct and now it is not in any form. I think tools-outline numbering is correct. Last night this pdf opened with correct page numbering for me on my Chromebook both in L0 and as a pdf in my Chrome browser.

I made two files and included the front matter by inserting a document. It changed the page numbering and had to redo all of it. This has taken forever. But I KNOW I saw it all correct in the pdf form I sent and the ODT.

Surely a pdf with file embedded could not change page numbers?????????????

Yet, mid air and on my Chromebook it is as if Gremlins got to work in the night.

The friend then says page numbering messed up and it has even changed in he sourrce file and pdf on my laptop. Gremlins???????????

I used the function to offset page numbers and had roman numerals at the start of the book and ordinary ones for the chapters. It took forever as the function to update the index is missing in L0 5.

Friend using a PC. I am using a Chromebook but how can the whole thing in PDF form, change mid-air? She says LibreOffice crashed three times for her and doesn't usually.

Now she is saying she might use WORD but couldn't that add to the problem?

Page 1 was start of first chapter. (Was going to delete on first page once we checked TOC.)

TOC has it as page 1 but it is page 79 and page 2 as 10 etc......(9 pages front matter.)

ALL was correct in the ODT file I sent. ALL was correct in the PDF I exported in libreoffice and sent.

So how on earth does page 1 become page 79? (If page nos began at 1 at the start it would be page 9. It was NOT page 89 when I sent it and went to bed.

It is 3 am so apologies if this is a bit muddled. Just in shock as it is so much work down the drain. You cannot imagine how difficult it was to get this all right ...

edit retag close merge delete

The only way I could do it was to offset the number

here the problem begins. Offsetting a number is guaranteed to bring problems: offsetting page number is a way to reference a different page (like in "see page {here goes number of the page offset by N}"), not to change current page.

The correct way to set some page number is using page break with page style in the page's first paragraph, and set desired page number there in the paragraph properties dialog.

( 2019-06-26 06:00:24 +0200 )edit

Mike.. I tried to do that and could not do it. I ended up offsetting as each time I made toc it included itself as page 1

( 2019-06-26 06:06:38 +0200 )edit

That just suggests some user error - and that needs addressing. I advise you to post a question on that (with a problematic file), and solving that. It's unreasonable to try solving problems resulting from incorrect use of functionality, without addressing the root of the problem.

My guess is that you somehow made your TOC use a paragraph style(s) not meant for that; or that you modified your paragraph (styles) on ToC to have outline level other than body text.

( 2019-06-26 06:16:58 +0200 )edit

The symptoms you describe suggest bad configuration of both page and paragraph styles. Also, co-writing is a difficult matter requiring strict procedure. In particular, at no moment the document should be saved other than .odt otherwise you add conversion issues.

Also you may have problems with manual formatting vs. styling. I think of the various page breaks used to switch page styles and force page numbers. In complex or long documents, you should exclude any manual formatting and rely only on styles.

Try to reduce the size of your document (on a copy of course) to the minimum still exhibiting the problem and attach it to your question. To anonymise content if desired, replace it with "lorem ipsum".

( 2019-06-26 08:11:58 +0200 )edit

Quote: "Surely a pdf with file embedded could not change page numbers?"

I'm almost certain that the PDF part of that document wasn't changed by gremlins ,-) But with which viewer did you check the content of the PDF? LO? Then you saw most likely the embedded part while the real PDF content allready was malformed. It degenerated in that moment as you saved to PDF. In general it's a good idea to pass a document as PDF to fellows. It should ship with all that is needed to display the content as it was intended by sender. Even with embedded fonts that are not present on the target system. Of course this won't work in case the source (the LO file) has allready a problem.

( 2019-06-26 14:57:52 +0200 )edit

Sort by » oldest newest most voted

I've also had challengs with pages in LO. Not an answer to your specific problem, but try the page number add on for future documents: https://extensions.libreoffice.org/ex... It will ease the pain a little!

more


text:
Astronomy

# Out of the Dark Ages

Light from the most distant sources known, emitted when the Universe was only a billion years old, hints at a complex history of star and galaxy formation, and at their effect on the primordial gas around them.

The appearance of the first sources of light in the Universe ended the so-called cosmic Dark Ages, which had lasted a few hundred million years. The ultraviolet light from these sources also changed the physical state of the gas (hydrogen and helium) that fills the Universe, from a neutral state to a nearly fully ionized one. This was the era of reionization. Quasars — the brightest and most distant objects known (Fig. 1) — offer a window on the reionization era, because neutral hydrogen gas absorbs their ultraviolet light. On page 815 of this issue, Wyithe and Loeb1 provide a new interpretation of the hydrogen-absorption spectra of the most distant quasars known. They conclude that a significant fraction of the cosmic hydrogen was still neutral about a billion years after the Big Bang. Coupled with other observations, their analysis adds to a growing body of evidence that the early history of galaxy formation was more complex than was supposed even a couple of years ago.

When the Universe was about 380,000 years old, it underwent a phase transition, changing from an incandescent plasma containing the heat of the Big Bang, to a space filled with dark matter, energy and neutral gas. The glow of the primordial plasma is what we now observe as the cosmic microwave background (CMB). The Universe then entered the Dark Ages, with embryonic structures growing from the seeds of dark-matter fluctuations (fluctuations that are observed today as ripples in the CMB). After a few hundred million years, these condensations became dense enough for the first stars to form, leading to the appearance of the first galaxies and the growth of the massive black holes that are believed to power quasars.

As these first objects lit up, they also modified the gas between them, ionizing the hydrogen and making it transparent to ultraviolet light. Effectively, the Universe underwent another phase transition, from a neutral to an ionized state. Each of the primordial sources of light — most of them powered by young, massive stars, but some powered by the accretion of matter into growing black holes (the early quasars) — excavated a bubble of ionized gas, called a Strömgren sphere, in the otherwise neutral surrounding medium. When these bubbles began to overlap, reionization was complete. The reionization era is thus a cosmological milestone, marking the appearance of the first stars, galaxies and quasars.

The light reaching us now from distant quasars was emitted just before reionization was complete. Any neutral hydrogen remaining in the Universe at that point would have been a very effective absorber of this radiation at a particular set of wavelengths (extending up to 91.2 nanometres) known as the Lyman series. Even minuscule quantities of neutral hydrogen — as little as 10−4 or 10−5 by mass fraction in intergalactic clouds — can leave a tell-tale absorption signature in the spectra of quasars; this is the ‘Lyman α forest’ of absorption lines in quasar spectra. As the fraction of the neutral gas increases, the forest thickens; as the fraction approaches 100%, essentially all of the observed flux at wavelengths below the so-called Lyman α line (at a wavelength of 121.6 nanometres, in the restframe) is absorbed.

The existence of such an extended trough in the spectra of quasars was predicted in 1965 by Gunn and Peterson2, and was indeed detected3,4 in the spectra of quasars at redshifts greater than 6. (Redshift is a measure of how much the Universe has expanded since the light was emitted; a redshift of 6 corresponds to a time roughly one billion years after the Big Bang in the favoured cosmological models.) Analysis5 of the spectra of the handful of quasars now known at such redshifts indicates that there is an abrupt change in the physical state of the intergalactic gas at this epoch. However, the actual fraction of the neutral gas is hard to constrain, because it involves measurements of fluxes that are very close to zero. Even with the best data available, all we can say is that the neutral fraction is at least 10−3, which is not a very strong limit.

But a surprise was provided by the measurement of the polarized fluctuations of the CMB by the Wilkinson Microwave Anisotropy Probe (WMAP)6. These data indicated that the Universe was reionized at a redshift of 10 to 20 — that is, some 200 million to 500 million years after the Big Bang. How can this be reconciled with the quasar data, which suggest that the last stages of reionization occurred after one billion years?

Several authors7,8 have proposed that the Universe was in fact reionized twice. The first time was by a generation of massive luminous stars, and this gives rise to the WMAP result. But the radiation from these stars and their eventual explosions as supernovae could have disrupted further star formation in their vicinity, leading to a hiatus during which ionized gas in the Universe might have recombined to become neutral again. A later generation of stars in young galaxies and quasars might have completed the reionization, at the end of the cosmic Dark Ages, when the Universe was about a billion years old.

Wyithe and Loeb1 have put a clever new twist on the interpretation of the quasar spectra in which the Gunn–Peterson absorption effect is seen. They have used the extent of the ionized regions around the quasars themselves to derive a fresh constraint on the fraction of the neutral hydrogen at this time. A quasar will excavate its own bubble of ionized gas in the neutral gas around it. The extent of this bubble would depend on several factors, including the history of the quasar's own luminosity, and the neutral-gas fraction in the surrounding medium (more neutral gas would mean a smaller bubble radius). By making reasonable assumptions and modelling the possible growth history of these quasars, Wyithe and Loeb conclude that, as the observed ionized bubbles around quasars seem small, the bubbles must have been embedded in a medium with a high fraction of neutral gas — as much as tens of per cent when the quasars turned on.

Coupled with the WMAP result, this implies that the Universe was indeed reionized at least twice. At any rate, the history of early galaxy formation and its effects on the primordial intergalactic medium seem complex. In our attempts to understand the reionization of the Universe, and the end of the cosmic Dark Ages, there are probably many more surprises to come.

## References

1. 1

Wyithe, J. S. B. & Loeb, A. Nature 427, 815–817 (2004).

2. 2

Gunn, J. E. & Peterson, B. Astrophys. J. 142, 1633–1642 (1965).

3. 3

Becker, R. et al. Astron. J. 122, 2850–2857 (2001).

4. 4

Fan, X. et al. Astron. J. 125, 1649–1659 (2003).

5. 5

Fan, X. et al. Astron. J. 123, 1247–1257 (2002).

6. 6

Kogut, A. et al. Astrophys. J. Suppl. Ser. 148, 161–173 (2003).

7. 7

Cen, R. Astrophys. J. 591, 12–37 (2003).

8. 8

Wyithe, J. S. B. & Loeb, A. Astrophys. J. 586, 693–708 (2003).

Authors

## Rights and permissions

Reprints and Permissions

Djorgovski, S. Out of the Dark Ages. Nature 427, 790–791 (2004). https://doi.org/10.1038/427790a

• Issue Date:

• ### Magnetic fields in the galactic Universe, as observed in supershells, galaxies, intergalactic and cosmic realms

• Jacques P. Vallée

New Astronomy Reviews (2011)

• ### Astrophysics in 2004

• Virginia Trimble
•  & Markus Aschwanden

Publications of the Astronomical Society of the Pacific (2005)

• T. Nagao
• , N. Kashikawa
• , M. A. Malkan
• , T. Murayama
• , Y. Taniguchi
• , K. Shimasaku
• , K. Motohara
• , M. Ajiki
• , Y. Shioya
• , K. Ohta
• , S. Okamura
•  & M. Iye

The Astrophysical Journal (2005)

• ### Cosmic magnetic fields – as observed in the Universe, in galactic dynamos, and in the Milky Way

• Jacques P. Vallée

New Astronomy Reviews (2004)


text:
# Slaughterhouse V Epilogue

Published:

A while ago, I stumbled upon an epilogue to Slaughterhouse V (by Kurt Vonnegut) written for an assignment in my english class. Reading back this epilogue, I remember some parts of this definitely weird story.

Note: This contains spoilers/interpretations of events!

1976, an old man is giving a speech to a convention in Chicago. It's about a supposed alien abduction. These supposed aliens can see throughout time. They supposedly say that a creature is both alive and death at all times, although at one certain moment it is just one of both. They supposedly live on a planet billions of miles away from earth, but they can supposedly travel there instantly.

This old man is already going bald. He's got glasses and somewhere an anxious daughter is waiting for him to end his speech and go home. She actually thinks this man is crazy but still supports him because he is her father. This man is called Billy Pilgrim.

This morning Billy thought about his life so far. He knew he would not experience the world after this day alive. You might be able to experience something at a moment you are dead. So it goes. Anyway, he had to prepare for the convention. He had attended multiple conferences before, and in only two, people hadn't laughed at him. Somehow, people must be frightened of not thinking they are in control he thought.

At this very moment, Billy is crossing the street. A masked man is following him. Billy already knew who it was. And he was in peace with it. A gun slipped out of a pocket, a soft but deafening sound was heard then the sound of a body dropping unto the streets. Nothing...

Barbara is waiting in the hospital. Her father is in surgery. It happened all so sudden. Right at the moment that he was alone, he was shot and robbed of the little money he had on him. How can a person live with himself if he kills over so little? The door slides open and a doctor comes right at her. She already knows he has passed. He has even said it this very morning. So it goes.

A person is rushed in. It's a 53 year old, half bald man. Shot in the left chest, immediate operation is needed. Three doctors are already waiting at the operation table, fully prepped to save this man's life. The bullet went straight into his heart and somehow ricocheted through his lungs. He was a mess. If he would be able to live on, he would be immobilised for the rest of his life. Still, they tried to get through the bloody mass that is this man's body. Despite their best efforts, they could not get him stable, they would have to let him go. The bullet had done too much damage. So it goes.

As they cleaned their equipment, the heart stopped beating. He was dead. The doctors talked about this man's body. How could one shot do so much damage? They stared at the body. Then for some reason, they saw an EEG giving high results. Who the heck would connect an EEG to a critical ICU patient? It was interesting. A dead man's brain was somehow still functioning while his entire body was already dead. It lasted for over 20 minutes. Then suddenly the graph dropped down too.

A deceased body is being carted down to the morgue. It had to be autopsied. First of all, this person was murdered, but the most interesting phenomenon had played out. This body's brain had lived considerably longer than the body it belonged to. Although the cause of death had already been assured, the examiner looked on, searching for clues to how the brain could have lived so much longer. When he cut open the head, the brain was misformed, a giant tumor had been there. He was reported to be kind of delusional. This might have been the cause. The tumor covered almost half of the brain.

<cool>
</cool>


text:
## Thursday, April 21, 2011

### Photoshop slices using divs creates gaps

If you've ever used Photoshop to create websites by drawing them and then slicing out the buttons and if you've ever used divs and css positioning to layout the slicing (done automatically by Photoshop, just follow this) then you probably found out that something like this happens:

This happened to me whilst doing my personal website (www.marctanti.com). The solution was found here. Apparently this happens because when the doctype of the html page is set to strict, images are by default set to display:inline which makes them vertically aligned so that the bottom of the image is in line with where the base line of the text is. In the case of sliced web pages, the slices are placed inside divs so the images are aligned with where the base line of text inside the div would be if there was any. But the divs make room for the "descenders" of text, that is, the extra room needed to display the bottom of the letters 'y' and 'g' for example. Therefore the images will not be aligned with the very bottom of the divs.

So to fix this problem we need to make the images aligned to the very bottom of the containing divs by setting the display css of each slice to block. I gave each slice image a class attribute called slice and then added the following css:

.slice
{
display:block;
}

That fixed it.


text:
Steinberg relations and symbol computations

Given a field F, Quillen defined K-groups $K_n(F)$ to be the higher homotopy groups of a space $K(F)$. Though apparently the space itself can be easily and explicitly constructed, the K-groups are mysterious gadgets. However the homology groups of the connected component of K(F) containing its base point coincide with the homology groups of the general linear group.

Anyway, back to Quillen K-groups. For $n\leq 2$, these groups coincide with the Milnor K groups $K^M_n(F)$ which are more algebraic in nature and much easier to define. The n-th Milnor K group of a field F is defined as follows :

Let $F^*$ denote the abelian group of non-zero elements of the field F. Then

$K^M_n(F) = (F^*\otimes_{\mathbb{Z}} F^*\otimes_{\mathbb{Z}}\otimes_{\mathbb{Z}} \ldots F^*)/J$

where $J$ is the subgroup generated by tensors $a_1\otimes a_2\otimes \ldots \otimes a_n$ where for some $i\neq j$, $a_i+a_j=0$. The class of the tensor $a_1\otimes a_2\otimes \ldots \otimes a_n$ in $K^M_n(F)$ is denoted $\{a_1,a_2,\ldots,a_n\}$.

Thus for $a\in F^*$, we have $\{\ldots, a, \ldots, 1-a, \ldots \} = 0$. These are the the so-called Steinberg relations.

Thus, we have

• $K^M_0(F) = \mathbb{Z}$
• $K^M_1(F) = F^*$
• $K^M_2(F) = (F^*\otimes_{\mathbb{Z}} F^*)/(a\otimes 1-a)$

Let us do some symbolic computations in $K^M_2(F)$ to get a feel for this object (and also because it is fun!)

The Rules

1. Since $\otimes$ is bilinear, $\{a, b\} + \{a, c\} = \{a, bc\}$.
2. Similarly $\{a, b\} + \{c, b\} = \{ac, b\}$.

So  $\{a,1\} + \{a,1\} = \{a,1\}$ which implies $\{a,1\} =0$. Similarly $\{1,b\}=0$. Using bilinearity repeatedly, $n\{a,b\} = \{a^n, b\} = \{a,b^n\}\forall n\in \mathbb{Z}$.

If $n<0$, maybe this needs some further explanation. For instance if $n=-1$ say, then $0= \{1,b\} = \{a,b\} +\{a^{-1},b\}$..

The Game

I. Show $\{x,-x\}=0$.

This is because  $\{x,-x\} = \{x,-x\} - \{1-x,x\} = \{\frac{x}{1-x},x\}= -\{\frac{x+1}{x}, x\} = - \{1+\frac{1}{x}, x\} = \{1+\frac{1}{x}, \frac{1}{x}\} = 0$.

II. Show $-\{a,b\}=\{b,a\}$.

This is because  $\{a,b\}+\{b,a\} = \{a,b\} + \{a,-a\}+\{b,-b\} + \{b,a\}=\{a,-ab\}+\{b, -ab\}=\{ab,-ab\}=0$.

III. Show $\{a,-1\}=\{a,a\}$.

This is because  $\{a,a\}=\{a,a\}-\{a,-a\} = \{a,a\} + \{a,\frac{-1}{a}\} = \{a,-1\}$.


text:
# School year

At the beginning of the school year, 396 notebooks and 252 textbooks are ready to be distributed in the classroom. All pupils receive the same number of notebooks and the same amount of textbooks. How many pupils are there in the class if you know that there are more than 30 and less than 50?

Result

n =  36

#### Solution:

$396=2^2 \cdot 3^2 \cdot 11 \ \\ 252=2^2 \cdot 3^2 \cdot 7 \ \\ \text{GCD}(396, 252)=2^2 \cdot 3^2=36 \ \\ \ \\ n=GCD(396,252)=36 \ \\ s=396/n=396/36=11 \ \\ u=252/n=252/36=7 \ \\ \ \\ 30

Our examples were largely sent or created by pupils and students themselves. Therefore, we would be pleased if you could send us any errors you found, spelling mistakes, or rephasing the example. Thank you!

Leave us a comment of this math problem and its solution (i.e. if it is still somewhat unclear...):

Be the first to comment!

Tips to related online calculators
Do you want to calculate least common multiple two or more numbers?

## Next similar math problems:

1. School
Headteacher think whether the distribution of pupils in race in groups of 4,5,6,9 or 10. How many pupils must have at least school at possible options?
2. Buildings
The school stands 110 m from the church, which is 100 m beyond the town hall. Which building are closer to the church and how many times?
3. Write decimals
Write in the decimal system the short and advanced form of these numbers: a) four thousand seventy-nine b) five hundred and one thousand six hundred and ten c) nine million twenty-six
4. Gears
The gearing fits wheel with 20 teeth to the wheel with 36 teeth. Before starting the machine is stained tooth smaller wheels in the designated space between the teeth of the larger wheels. How many times after starting the machine wheels turning that stai
5. The port
Four ships Berthed in the port. Together sail from a port. The first ship will return to port every two weeks, second ship after 4 weeks, third after 8 weeks and fourth ship after 12 weeks. After how many weeks all the boats gather at the port?
6. LCM of two number
Find the smallest multiple of 63 and 147
7. Lcm of three numbers
What is the Lcm of 120 15 and 5
8. Dance ensemble
The dance ensemble took the stage in pairs. During dancing, the dancers gradually formed groups of four, six and nine. How many dancers have an ensemble?
9. Counting number
What is the smallest counting number divisible by 2,5,7,8 and 15?
10. Balls groups
Karel pulled the balls out of his pocket and divide it into the groups. He could divide them in four, six or seven, and no ball ever left. How little could be a ball?
11. Apples 2
How many minimum apples are in the cart, if possible is completely divided into packages of 6, 14 and 21 apples?
12. Cents no more
Janko bought pencils for 35 cents each. Neither he nor the salesperson had small coins just a whole € 1 coin. At least how many pencils had to buy to pay for the whole euros?
13. Lcm simple
Find least common multiple of this two numbers: 140 175.
14. Four families
Four families were on a joint trip. In the first family, there were three siblings, namely Alica, Betka and Cyril. In the second family were four siblings, namely David, Erik, Filip and Gabika. In the third family, there were two siblings, namely Hugo an
15. Biketrial
Kamil was biketrial. Before hill he set the forward gear with 42 teeth and the back with 35 teeth. After how many exercises (rotation) of the front wheel both wheels reach the same position?
16. Division
Which number in division 16 give 12 and the rest 3?
17. Fewer than 500 sheep,
There are fewer than 500 sheep, but if they stand in a double, triple, quadruple, five and sixth order, one sheep will remain. But they can stand in the seventh order. How many are sheep?


text:
# Total domination in cubic Knödel graphs

Document Type : Original paper

Authors

1 Shahed University

2 Departtment of Mathematics, University of Mazandaran

3 Shahrood University of Technology

4 Tafresh University

Abstract

A subset $D$ of vertices of a graph $G$ is a dominating set if for each $u\in V(G) \setminus D$, $u$ is adjacent to some vertex $v\in D$. The domination number, $\gamma(G)$ of $G$, is the minimum cardinality of a dominating set of $G$. A set $D\subseteq V(G)$ is a total dominating set if for each $u\in V(G)$, $u$ is adjacent to some vertex $v\in D$. The total domination number, $\gamma_{t}(G)$ of $G$, is the minimum cardinality of a total dominating set of $G$. For an even integer $n\ge 2$ and $1\le \Delta \le \lfloor\log_2n\rfloor$, a Kn\"odel graph $W_{\Delta,n}$ is a $\Delta$-regular bipartite graph of even order $n$, with vertices $(i,j)$, for $i=1,2$ and $0\le j\le \frac{n}{2}-1$, where for every $j$, $0\le j\le \frac{n}{2}-1$, there is an edge between vertex $(1, j)$ and every vertex $(2,(j+2^k-1)$ mod $\frac{n}{2}$), for $k=0,1,\dots,\Delta-1$. In this paper, we determine the total domination number in $3$-regular Kn\"odel graphs $W_{3,n}$.

Keywords

Main Subjects

#### References

[1] J.-C. Bermond, H.A. Harutyunyan, A.L. Liestman, and S. Perennes, A note on the dimensionality of modified Knödel graphs, Int. J. Foundations Comput. Sci. 8 (1997), no. 2, 109–116.
[2] G. Fertin and A. Raspaud, Families of graphs having broadcasting and gossiping properties, International Workshop on Graph-Theoretic Concepts in Computer Science, Springer, 1998, pp. 63–77.
[3] G. Fertin and A. Raspaud, A survey of Knödel graphs, Discrete Appl. Math. 137 (2004), no. 2, 173–196.
[4] P. Fraigniaud and J.G. Peters, Minimum linear gossip graphs and maximal linear (δ, k)-gossip graphs, Networks 38 (2001), no. 3, 150–162.
[5] H. Grigoryan and H.A. Harutyunyan, Broadcasting in the Knödel graph, Ninth International Conference on Computer Science and Information Technologies, IEEE, 2013, pp. 1–6.
[6] H. Grigoryan and H.A. Harutyunyan, The shortest path problem in the Kn¨odel graph, J. Discrete Algorithms 31 (2015), 40–47.
[7] H.A. Harutyunyan, Multiple message broadcasting in modified Knödel graph, SIROCCO, vol. 7, 2000, pp. 157–165.
[8] H.A. Harutyunyan, Minimum multiple message broadcast graphs, Networks 47 (2006), no. 4, 218–224.
[9] H.A. Harutyunyan, An efficient vertex addition method for broadcast networks, Internet Math. 5 (2008), no. 3, 211–225.
[10] H.A. Harutyunyan and Z. Li, A new construction of broadcast graphs, Discrete Appl. Math. 280 (2020), 144–155.
[11] H.A. Harutyunyan and A.L. Liestman, More broadcast graphs, Discrete Appl. Math. 98 (1999), no. 1-2, 81–102.
[12] H.A. Harutyunyan and A.L. Liestman, Upper bounds on the broadcast function using minimum dominating sets, Discrete Math. 312 (2012), no. 20, 2992–2996.
[13] H.A. Harutyunyan and C.D. Morosan, On the minimum path problem in Knödel graphs, Networks 50 (2007), no. 1, 86–91.
[14] T.W. Haynes, S.T. Hedetniemi, and P.J. Slater, Domination in Graphs- Advanced Topics, Marcel Dekker, Inc., New York, 1998.
[15] M.A. Henning and A. Yeo, Total Domination in Graphs, Springer, 2013.
[16] L. Khachatrian and H. Harutounian, On optimal broadcast graphs, Fourth International Colloquium on Coding Theory, Dilijan, Armenia, 1991, pp. 36–40.
[17] W. Knödel, New gossips and telephones, Discrete Math. 13 (1975), no. 1, 95.
[18] D.A. Mojdeh, S.R. Musawi, and E. Nazari, Domination critical Knödel graphs, Iran J. Sci. Technol. Trans. Sci. 43 (2019), no. 5, 2423–2428.
[19] S. Varghese, A. Vijayakumar, and A.M. Hinz, Power domination in Knödel graphs and Hanoi graphs, Discuss. Math. Graph Theory 38 (2018), no. 1, 63–74.
[20] F. Xueliang, X. Xu, Y. Yuansheng, and X. Feng, On the domination number of Knödel graph W(3, n), International Journal of Pure and Applied Mathematics 50 (2009), no. 4, 553–558.


text:
# Math Help - paragraph numbering, A4 layout, undefined figure references (reftex4)

1. ## paragraph numbering, A4 layout, undefined figure references (reftex4)

Hi there,

I'm using LaTeX to typeset my phys reports for uni. I've noticed three issues I can't seem to fix; not sure where I'm going wrong!

1. I structure my report using \section, \subsection, \subsubsection and \paragraph. I like the paragraphs, but the paragraph numbering usually continues across sections (so I might for example have paragraphs a and b in subsection 1.1, but then in subsection 1.2 the next two paragraphs are labelled c and d instead of a and b.) However this is not always the case! In a recent, longer report I had: ... 1.3 a, b, c ... 2.1 d, e ... 4.3 a. So I am confused as to why this might be.

2. I print on A4 and so have set up TeXshop to output pdfs as A4, but the right-hand margins are narrower than the left, and the bottom margins much wider than the top. (On the pdf itself, not a printer setup issue.) What can I do to correct this?

3. When compiling the report, the console contains the error ' warning: there were undefined references' but I have taken care to label and refer to all figures consistently. I compile again but this does not change.

Sarah.

2. ## bump

Any thoughts?
Sarah

3. 2) Are you using the book format? You can manually adjust the margins with geometry, e.g.
\usepackage[left=2cm,right=2cm,top=1cm,bottom=1cm]{geometry}

Use the \oddsidemargin and \evensidemargin to adjust the odd and even pages.

3) You should see a (?) if you have an undefined reference. It could just be a misspelling. Can you not pinpoint the line it complains about?

4. thanks,

2) I'm using the report layout in revtex4. I'll give the geometry package a try.

3) Yes, I do get the ?? in place of these references. I have checked to ensure there's no misspelling. Most of the references are fine, while others are not (all are defined using an identical format). On one occasion I replaced one stubbornly undefined reference with text; the next time I compiled the report, the reference following that one was now undefined (whereas it was not before that). So I am unsure as to where the issue arises.

5. That sounds odd. By reference do you mean \ref or \cite?

6. I'm using \ref , for example:
.. Figure~\ref{visibilitycurve}...

\begin{figure}
\centerline{
\includegraphics[width=85mm]{visibility_curve.pdf}
}
\caption{Image curves and their corresponding visibility curves}
\label{visibilitycurve}
\end{figure}

7. Are you sure all your labels are after the captions? You could try putting the label inside the caption ( i.e. \caption{Bla bla bla \label{gibberish}} )

8. ok I'll give that a try, thanks!