共找到 20 条结果
We present a novel quantum storage algorithm for k binary vectors of dimension m into a superposition of a m qubit quantum state based on a permutation technique. We compare this algorithm to the storage algorithm proposed by Ventura and Martinez. The permutation technique is simpler and can lead to an additional reduction through the reduce algorithm. To retrieve a binary vector from the superposition of k vectors represented by a m qubit quantum state, we must use a modified version of Grover algorithm, as Grover algorithm does not function correctly for non uniform distributions. We introduce the permutation trick that enables an exhaustive search by Grover algorithm in square root of k steps for k patterns, independent of n equal two power m. We compare this trick to the Ventura and Martinez trick, which requires square root of n steps for k patterns.
Given a smooth deformation of a Lie subalgebra, we establish a necessary and sufficient condition for its smooth triviality and derive an analogous criterion for Lie ideals. We then give a direct proof of the Moser trick for foliations, which forms the basis for extending this result to general Lie subalgebroids.
Fitch Cheney's 5-card trick was introduced in 1950. In 2013, Mulcahy invented a 4-card trick in which the cards are allowed to be displayed face down. We suggest our own invention: a 3-card trick in which the cards can be face down and also allowed to be placed both vertically and horizontally. We discuss the theory behind all the tricks and estimate the maximum deck size given the number of chosen cards. We also discuss the cases of hiding several cards and the deck that has duplicates.
We present a comprehensive analysis of Bredon's trick, a powerful local-to-global extension principle with broad applications across differential geometry and computational topology. Our main contributions include: (1) novel applications to stratified pseudomanifolds via Verona cohomology with explicit verification of axiomatic conditions; (2) new frameworks for Ricci flow singularity analysis using local curvature concentration; (3) stability theorems for persistent homology in distributed computational settings; and (4) rigorous applications to medical imaging and neural network topology. By systematically developing the theoretical foundations and providing concrete implementations, this work establishes Bredon's trick as a unifying framework for modern local-to-global arguments in geometric analysis and applied topology.
This micro-paper describes a trick to speed up inference of transformers with RoPE (such as LLaMA, Mistral, PaLM, and Gemma). For these models, a large portion of the first transformer layer can be precomputed, which results in slightly lower latency and lower cost-per-token. Because this trick optimizes only one layer, the relative savings depend on the total number of layers. For example, the maximum savings for a model with only 4 layers (such as Whisper tiny) is limited to 25%, while a 32-layer model is limited to 3% savings. See https://github.com/OpenMachine-ai/transformer-tricks for code and more transformer tricks.
We generalize the classical "1089-number trick", which states that a certain combination of addition, subtraction and swapping the digits of a three-digit number will always output 1089. More precisely, we show that any pair of zero divisors $fg=0$ in the group ring ${\mathbb Z}[Σ_n]$ on the n-th symmetric group gives rise to a partition of the set of n-digit numbers into subsets $U_{\mathbf e}$ defined by linear inequalities, such that the zero divisors act constantly on each $U_{\mathbf e}$ and hence define a number trick.
The following magic trick is at the center of this paper. While the audience writes the first ten terms of a Fibonacci-like sequence (the sequence following the same recursion as the Fibonacci sequence), the magician calculates the sum of these ten terms very fast by multiplying the 7th term by 11. This trick is based on the divisibility properties of partial sums of Fibonacci-like sequences. We find the maximum Fibonacci number that divides the sum of the Fibonacci numbers 1 through $n$. We discuss the generalization of the trick for other second-order recurrences. We show that a similar trick exists for Pell-like sequences and does not exist for Jacobhstal-like sequences.
Categorical random variables can faithfully represent the discrete and uncertain aspects of data as part of a discrete latent variable model. Learning in such models necessitates taking gradients with respect to the parameters of the categorical probability distributions, which is often intractable due to their combinatorial nature. A popular technique to estimate these otherwise intractable gradients is the Log-Derivative trick. This trick forms the basis of the well-known REINFORCE gradient estimator and its many extensions. While the Log-Derivative trick allows us to differentiate through samples drawn from categorical distributions, it does not take into account the discrete nature of the distribution itself. Our first contribution addresses this shortcoming by introducing the CatLog-Derivative trick - a variation of the Log-Derivative trick tailored towards categorical distributions. Secondly, we use the CatLog-Derivative trick to introduce IndeCateR, a novel and unbiased gradient estimator for the important case of products of independent categorical distributions with provably lower variance than REINFORCE. Thirdly, we empirically show that IndeCateR can be efficiently imple
Trajectories are optimized for a two-dimensional simplified skateboarding system to allow it to perform a fundamental skateboarding trick called an "ollie". A methodology for generating trick trajectories by controlling the position of a point-mass relative to a board is presented and demonstrated over a range of peak jump heights. A hybrid dynamics approach is taken to perform this optimization, with contact constraints applied along a sequence of discrete timesteps based on the board's position throughout designated sections of the trick. These constraints introduce explicit and implicit discontinuities between chosen sections of the trick sequence. The approach has been shown to be successful for a set of realistic system parameters.
Algorithms for partition refinement are actively studied for a variety of systems, often with the optimisation called Hopcroft's trick. However, the low-level description of those algorithms in the literature often obscures the essence of Hopcroft's trick. Our contribution is twofold. Firstly, we present a novel formulation of Hopcroft's trick in terms of general trees with weights. This clean and explicit formulation -- we call it Hopcroft's inequality -- is crucially used in our second contribution, namely a general partition refinement algorithm that is functor-generic (i.e. it works for a variety of systems such as (non-)deterministic automata and Markov chains). Here we build on recent works on coalgebraic partition refinement but depart from them with the use of fibrations. In particular, our fibrational notion of $R$-partitioning exposes a concrete tree structure to which Hopcroft's inequality readily applies. It is notable that our fibrational framework accommodates such algorithmic analysis on the categorical level of abstraction.
The Kunneth trick is a formula for the top cohomology of the derived tensor product of two complexes of modules over a ring. In this note we present two improvements of this formula. The first improved Kunneth trick is a formula for the top cohomology of the plain tensor product of two DG modules over a nonpositive DG ring. The second trick handles the derived tensor product of two DG modules over a nonpositive DG ring. The proofs are elementary.
Adversarial training (AT) with samples generated by Fast Gradient Sign Method (FGSM), also known as FGSM-AT, is a computationally simple method to train robust networks. However, during its training procedure, an unstable mode of "catastrophic overfitting" has been identified in arXiv:2001.03994 [cs.LG], where the robust accuracy abruptly drops to zero within a single training step. Existing methods use gradient regularizers or random initialization tricks to attenuate this issue, whereas they either take high computational cost or lead to lower robust accuracy. In this work, we provide the first study, which thoroughly examines a collection of tricks from three perspectives: Data Initialization, Network Structure, and Optimization, to overcome the catastrophic overfitting in FGSM-AT. Surprisingly, we find that simple tricks, i.e., a) masking partial pixels (even without randomness), b) setting a large convolution stride and smooth activation functions, or c) regularizing the weights of the first convolutional layer, can effectively tackle the overfitting issue. Extensive results on a range of network architectures validate the effectiveness of each proposed trick, and the combinat
We present a convenient trick for computing the sizes of clusters within a network. The rationale relies on the mathematics of the geometric series and the fundamental matrix of a Markov Chain.
We discuss the modifications of the Kripke trick simulating binary predicate letters of classical first-order formulas with monadic modal first-order formulas and the situations where the trick does not work. As a result, we obtain results on algorithmic upper bounds for monadic fragments of some modal and superintuitionistic first-order logics.
We propose a trick for calculating the surface gravity of the Killing horizon, especially for cases of rotating black holes. By choosing nice slices, the surface gravity and angular momentums can be directly read from relevant components of the inverse metric. We give several cases to show how to apply the trick step by step.
Quantum computing is a hotspot technology for its potential to accelerate specific applications by exploiting quantum parallelism. However, current physical quantum computers are limited to a relatively small scale, simulators based on conventional machines are significantly relied on to perform quantum computing research. The straightforward array-based simulators require a tremendous amount of memory that increases exponentially with respect to the number of qubits. To mitigate such computing resource concerns, decision diagram based simulators were proposed that can efficiently exploit data redundancies in quantum states and operations. In this paper, we study two classes of quantum circuits on which the state-of-the-art decision diagram based simulators failed to perform well in terms of simulation time. We also propose a simple and powerful reorder trick to boost the simulation of such quantum circuits. Preliminary evaluation results demonstrate the usefulness of the proposed trick. Especially, for the Quantum Phase Estimation circuits, the proposed trick achieved speedups up to 313.6x compared to a state-of-the-art approach that relies on an auxiliary tool to optimize simulat
The 21 card trick is well known. It was recently shown in an episode of the popular YouTube channel Numberphile. In that trick, the audience is asked to remember a card, and through a series of steps, the magician is able to find the card. In this article, we look into the mathematics behind the trick, and look at a complete generalization of the trick. We show that this trick can be performed with any number of cards.
The 21-card trick is a way of dealing cards in order to predict the card selected by a volunteer. We give a mathematical explanation of why the well-known 21-card trick works using a simple linear discrete function. The function has a stable fixed point which corresponds to the position where the selected card reaches at the end of the trick. We then generalize the 21(7 x 3)-card trick to a p x q - card trick where p and q are odd integers greater than or equal to three, determine the fixed point and prove that it is also stable.
The Gumbel-Max trick is the basis of many relaxed gradient estimators. These estimators are easy to implement and low variance, but the goal of scaling them comprehensively to large combinatorial distributions is still outstanding. Working within the perturbation model framework, we introduce stochastic softmax tricks, which generalize the Gumbel-Softmax trick to combinatorial spaces. Our framework is a unified perspective on existing relaxed estimators for perturbation models, and it contains many novel relaxations. We design structured relaxations for subset selection, spanning trees, arborescences, and others. When compared to less structured baselines, we find that stochastic softmax tricks can be used to train latent variable models that perform better and discover more latent structure.
Classifying phases of local quantum systems is a general problem that includes special cases such as free fermions, commuting projectors, and others. An important distinction in this classification should be made between classifying periodic and aperiodic systems. A related distinction is that between homotopy invariants (invariants which remain constant so long as certain general properties such as locality, gap, and others hold) and locally computable invariants (properties of the system that cannot change from one region to another without producing a gapless edge between them). We attack this problem using a technique inspired by Kirby's "torus trick" in topology. We use this trick to reproduce results for free fermions (in particular, using the trick to reduce the aperiodic classification to the simpler problem of periodic classification). We also show that a similar trick works for interacting phases which are nontrivial but lack anyons; these results include symmetry protected phases. A key part of this work is an attempt to classify quantum cellular automata (QCA).