text:
Textbook Notes (363,566)
Statistics (27)
STAT 230 (3)
<NAME> (1)
Chapter

Probability Notes.pdf

20 Pages
211 Views

School
University of Waterloo
Department
Statistics
Course
STAT 230
Professor
<NAME>
Semester
Winter

Description
Probability Definition: Probability P(A) – The probability of event A occur. Sample space/Events Definition: The set of all possible outcomes. Example: Tossing two dice, sample space, ( ) ( ) ( ) ( ) ( ) . Let A = {obtaining a total of 10}, B = {obtaining a total greater than 10}. ( ) ( ) | | Remark: If elementary outcomes equally likely, then ( ) | | Counting: Multiplicative Principle: Suppose p ways to do job 1, q ways to do job 2, then pxq ways to do both 1 and 2. Additive Principle: Suppose p ways to do job 1, q ways to do job 2, then p+q ways to do 1 or 2. Example: The letters in the word ‘statistics’ are arranged in random order; a. What is the probability of spelling ‘statistics’? P(spelling the word ‘statistics’) = . b. What is the probability of getting the same letters at both ends? P(getting same letters at both ends) = Note: Numbers of arrangement of the word ‘statistics’ = . Ways of choosing There is a total of n objects. How many different ways to choose objects? 1. Without replacement, order matters. ( ) ( ) ( ) 2. With replacement, order matters. 3. Without replacement, order doesn’t matter. Since it can be randomly shuffled, therefore: ( ) ( ) 4. With replacement, order doesn’t matter. ( ) Example: Birthday Problem a. Given there are n people. Let A be the event of none of them share the same birthday. ( ) ( ) b. How large does n need to be in order for the probability o be less than 50%? Answer: . Example: Poker ( )( )( )( ) ( ) ( ) ( ) ( ) ( ) Rules of Probability 1. ( ) 2. ( ) ( ) 3. ( ) ( ) 4. ( ) ( ) ( ) ( ) 5. Definition: A and B are mutually exclusive if , i.e. ( ) . 6. Definition: If A and B are independent, it means ( ) ( ) ( ) , i.eP(A|B) = P(A). 7. Definition: Conditional probability is the probability of event A happens given that event B has already happened. i.e. ( | ) ( ) ( | ) ( ) ( ). ( ) Note:  Not A = by  A and B =  A or B = Remark: 1. ( ) ( ) ( ) 2. ( ) ( ) ( ) Laws of Total Probability is a partition of , i.e.⋃ and . Clearly, ( ) ∑ ( ) ( ) ∑ ( | ) ( ) Figure 1: Partition of sample space Bayes’ Theorem Standard Form ( | ) ( ) ( | ) ( ) Extended Form By applying the Law of Total Probability, we can extend the form into the as below. ( | ) ( ) ( | ) ∑ ( | ) ( ) Random Variables & Distribution Discrete Random variables Probability density function (pdf) – f(x) 1. ( ) ( ) is non-negative 2. ∑ ( ) ( ( ) ( ) 3. ( ) Cumulative distribution function – F(X) 1. ( ) ( ) is monotonic, non-decreasing 2. ( ) ( ) ( ) 3. Note:  For discrete random variables, F(x) is not very useful.  For continuous random variable, F(x) is fundamental. Expectation/Mean – ( )/ ̅ Expectation is the weighted average of all possible outcomes of the random variable can take on. For discrete random variables, the expectation is denoted by ∑ ( ). Variance – ( )/ We define the variance as the measure of the uncertainty of the random variable. It is also the spreadness of the data from the mean point or how far away is the data from its expected value. It is calculated by taking the squared distance between the data and its expectation. For discrete random variables, variance is denoted by ( ) [( ( )) ]. Theorem: ( ) ( ) ( ) Note:  ( ( )) ∑ ( ) ( )  ( ( ) ) ( ( ))  ( ( ) ( ) ) ( ( ))  ( ) is a linear operator, i.e.)( ( ) where is constant and is variable.  ( ) ( )  ( ) ( ) ( ) ( )  If are independent, then ( ) . (Converse is false!) Distributions Bernoulli Distribution ( ) ( ) ( ) { ( ) ( ) { ( ) ( ) Example: Tossing a coin, probability of getting a ‘Head’. Binomial Distribution ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ∑( ) ∑( ) ( ) ( ) ( ) Example: Tossing a fair coin 50 times, the probability of getting x ‘Head’. Geometric Distribution ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) Example: Two player takes turn to flip a coin, the first one to get a ‘Head’ wins. Given the probability of getting a ‘Head’ is p, find the probability of the first one to go wins. Solution: 1. Let X be the one first to go, and Y be the one second to go. ( ) ( ) ( ) is hard to solve because both X & Y are random variables. Intuitionally, we will fix one of them so that it is easier to calculate. (Conditional probability) By using conditional probability, we have ) ( | ) ( ). ( | ) ( ) ( ) ( ) ∑ ( ) ( ) ( ) ∑ ( )( ) ( ) 2. Alternatively, we can use a table to show the relationship. X 1 2 3 … n P(X=x) p … ( ) Because we are finding the probability of the X wins, this means that whenever Y tosses a coin, the outcome must be a failure i.e. q. Therefore, if X success on the second try, this implies X fails the first time, hence we get a q. Then, Y fails too in order for X to win, we g. Since X success on second try, we get. The rest follows as above. ( ) ( ) ( ) ∑ Hypergeometric Distribution ( ) ( ) ( )( ) ( ) ( ) ( ) Example: Probability of x red balls are drawn from a total of N balls with R red balls, N-R black balls with k draws in total. Poisson Distribution ( ) ( ) ( ) ( ) ( ) ( ) ( ) Note: It is often used to model rare events. Poisson Process with rate ( ) ( ) 1. ( ) 2. For any , ( ) ( ) ( ) ( ) are all independent. 3. ( ) ( ) ( ) Example: The time at which customers arrive follows a Poisson Process with .Given that store opens at 9 am, find the probability of exactly one customer by 9:30 am and a total of 5 customers by 11 am. Let X be the event of getting x customers time, t after the initial time. ([ ( ) ( )] [ ( ) ( ) ]) ( ) ( ( ) ( ) ) ( ( ) ( ) ) Two consequences of (3) ( ) ( ) (i) ( ( ) ( ) ) ( )( ) ( ) (ii) ( ( ) ( ) ) ( ( ) ( ) ) ( ( ) ( ) ) ( ) ( ) ( ) ( ( ) ) ( ) In fact, ) ( ) ( ) Note: The definition of o(h) is if ( ) ( ) ( ). Negative Binomial Distribution Let X be the number of trials until k success(es), and Y be the Recall number of failures before achieving k success(es). Geometric(p), let X be the number of trials until first success, and Y be the number of Then, ( ) ( ) ( ) failures before first success. Then, ( ) ( ) ( ) ( ) ( ) ( )( ) , both X and Y are geometric , both are called negative binomials. random variables. Example: Pooled blood test Let n be the total number of people, divided into groups of k. (Assuming n is divisible by k), X be the total number of tests carried out, p be probability of infection, p is relatively small, independence for each person, q=1-p. 1. For each group, ( ) ( ) ( ) ( ) ( )( ) 2. How many test needed on average? We have ( ) groups. ( ) ( ) 3. We can optimize over k to make 2 as small as possible. For small p, we can approximate ( ) around . ( ) ( ) ( ) ( ) ( ) ( ) ( ) Multiple Random Variables Joint Distribution Probability of the event with values of variables X = x and Y = y occurs. For discrete case, ( ) ( ) Marginal Distribution Probability of an value of X = x regardless value of Y or vice versa. For discrete case ( ) ( ) ( ) ( ) Conditional Distribution Probability of value of X = x given that value of Y = y. For discrete case, ( | )( | ) ( | ), ( |)( | ) ( | ). Summary: Distribution Notation Discrete Case Joint Distribution ( ) ( ) Marginal Distribution ( ) ( ) ( ) ( ) Conditional Distribution (| )( | ) ( |)( | ) ( | ) ( | ) Note:  The sum of all probability is∑ ∑ ( ) . Also written as ( ) .  ( ) ∑ ( ) ( ) ∑ ( ) ( ) ( )  | ( | ) ( ) | ( | ) ( )  and are independent if ( ) ( ) ( ). Covariance ( ) – On average, do move together or in opposite direction ( ) ( ) ( ( ) Remark: ( ) ( ) Theorem: If given are non-random and are random variables, then: 1. (∑ ) ∑ ( ) ∑ ( ) ( ) 2. (∑ ∑ ) ∑ ( ) ( ) Note: 1 is like a square of sums i.e. ) and 2 is like multiplying two sums i.e. ( )( ). Theorem Fun fact: Which one is bigger, 1. ( ) ( ) ( ) ( ) (Proof: Same idea as Var(X)) 2. If are independent, then ( ) ( ) ( ) , so ( ) or ( )? ( ) Solution: ( ) Note: Converse of 2 is false. ( ) ( ) Counterexample:
More Less

Related notes for STAT 230

OR

Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.


text:
# Evolution Homework - Genetic Variation

1. Mar 12, 2012

### Youngster

1. The problem statement, all variables and given/known data

2. About 1 in 200 Amish are homozygous recessive for Ellis-van Crevald syndrome, which causes short stature, extra fingers and toes, and several other characters.

A) What % of Amish people are likely to be heterozygote carriers for the disorder?

B) If the proportion of heterozygotes in North America is generally around 2%, what 1 likely factor could result in a greater proportion of carriers amongst the Amish? (hint, consider that the Amish began as a group of ~30 individuals)

3. Consider the fruit fly that has a gene with two alleles, one for red (normal) eyes and another for mutant (white) eyes. In albinos, the lack of melanin (pigmentation) in the eyes can result in vision problems. An ecologist is interested in knowing if there may be a possible disadvantage of the mutant white-eyes with respect to their ability to detect and avoid predators. A very large population of fruit flies around a 500 acre plantation has been around for many years. Five years ago, researchers found that the allele for red eyes was found in 90% of the population and white eyes 10% of the population.

A) What proportion of homozygote and heterozygotes would you expect to find if there is no natural selection acting against white flies?

B) What would be the % of homozygote recessives if researchers found 84.5% homozygote dominant (red eyes) and 15.0% heterozygotes in recent samples? What would these genotype frequencies imply about any potential natural selection?

C) A small farmer growing similar foods on a nearby farm with a similar ecosystem surrounding it has reported a larger proportion of white eyed flies (36% of all the flies he finds are white eyed). What are the expected proportions of the % homozygote dominant and heterozygotes?

D) Give two reasonable explanations for how white eyed flies may have become more abundant in the farm described in C (incorporating the knowledge from the results in B)?

2. Relevant equations

I figure a good bunch of them are just proportions based on the information provided by the prompts. I utilized the Hardy-Weinberg Principle (H-WP for efficiency) to calculate allele frequencies:

p2 + q2 + 2pq = 1

3. The attempt at a solution

2. A) Using the given information that 1 in 200 Amish people are homozygous recessive for the disorder, I can find all the allele frequencies. To begin, I converted the given information into a decimal:

q2 = 1 $\div$ 200 = 0.005
q = $\sqrt{0.005}$ = 0.070711
p = 1 - q = 1 - 0.070711 = 0.929289
2pq = 2 $\times$ 0.929289 $\times$ 0.070711 = 0.131422

Therefore approximately 1% of Amish people are likely to be heterozygote carriers of the disorder.

3. A) Another problem to apply the H-WP to with 90% and 10% being the given values.

p = 90% = 0.9
q = 10% = 0.1
2pq = 2 $\times$ 0.9 $\times$ 0.1 = 0.18

So 18 % of the population is heterozygote. To obtain the homozygote values, I just squared the percentages given, as squaring them results in their respective allele frequencies.

p2 = 0.81
q2 = 0.01

The sum of those two values should be the homozygote frequency, and so we have 82 homozgotes to every 18 heterozygotes. This could be reduced to 41 to 9.

3. B) The percentage should be the difference between the two given percentages, so the percentage of homozygous recessives would be 0.5%. And this genotype frequency would suggest that natural selection is in great favor of the red eye allele.

3. C) Pretty much the same procedure as part A, only with a different value. I'll skip to my results:

q = 0.36
p = 0.64; p2 $\approx$ 0.41
2pq = 0.4608 $\approx$ 0.46

Therefore there are 41 homozygote dominants to 46 heterozygotes

3. D) I stated natural selection was in favor of the red-eyed flies, and since this environment is similar to the previous one, I don't see why the environment would suddenly be in favor of the white-eyed allele. My guesses here are that genetic drift and genetic flow are responsible for the different allele frequencies observed here. I mention these events because they both result in the reduction of genetic differences over a period of time (according to my textbook).

Hopefully I formatted this correctly ( I'm new with this), and hopefully, this isn't really long a read. I just want some confirmation on my answers here (especially on the last question). Any assistance would greatly be appreciated!

format: plain


text:
# Evaluating polymer interplay after hot water pretreatment to investigate maize stem internode recalcitrance

* Corresponding author
Abstract : Abstract Background Biomass recalcitrance is governed by various molecular and structural factors but the interplay between these multiscale factors remains unclear. In this study, hot water pretreatment (HWP) was applied to maize stem internodes to highlight the impact of the ultrastructure of the polymers and their interactions on the accessibility and recalcitrance of the lignocellulosic biomass. The impact of HWP was analysed at different scales, from the polymer ultrastructure or water mobility to the cell wall organisation by combining complementary compositional, spectral and NMR analyses. Results HWP increased the kinetics and yield of saccharification. Chemical characterisation showed that HWP altered cell wall composition with a loss of hemicelluloses (up to 45% in the 40-min HWP) and of ferulic acid cross-linking associated with lignin enrichment. The lignin structure was also altered (up to 35% reduction in β–O–4 bonds), associated with slight depolymerisation/repolymerisation depending on the length of treatment. The increase in ${T}_{1\rho }^{H}$ T 1 ρ H , ${T}_{HH}$ T HH and specific surface area (SSA) showed that the cellulose environment was looser after pretreatment. These changes were linked to the increased accessibility of more constrained water to the cellulose in the 5–15 nm pore size range. Conclusion The loss of hemicelluloses and changes in polymer structural features caused by HWP led to reorganisation of the lignocellulose matrix. These modifications increased the SSA and redistributed the water thereby increasing the accessibility of cellulases and enhancing hydrolysis. Interestingly, lignin content did not have a negative impact on enzymatic hydrolysis but a higher lignin condensed state appeared to promote saccharification. The environment and organisation of lignin is thus more important than its concentration in explaining cellulose accessibility. Elucidating the interactions between polymers is the key to understanding LB recalcitrance and to identifying the best severity conditions to optimise HWP in sustainable biorefineries.
Keywords :
Document type :
Journal articles
Domain :

https://hal.inrae.fr/hal-03320504
Contributor : <NAME> <>
Submitted on : Monday, August 16, 2021 - 9:16:00 AM
Last modification on : Wednesday, August 25, 2021 - 12:01:50 PM

### Citation

<NAME>, <NAME>, <NAME>, <NAME>, <NAME>, et al.. Evaluating polymer interplay after hot water pretreatment to investigate maize stem internode recalcitrance. Biotechnology for Biofuels, BioMed Central, 2021, 14 (1), ⟨10.1186/s13068-021-02015-8⟩. ⟨hal-03320504⟩

Record views


text:
# Improved Lipschitz Approximation of $H$-perimeter minimizing boundaries

created by monti on 28 Nov 2016
modified by stefani on 04 Jan 2018

[BibTeX]

Published Paper

Inserted: 28 nov 2016
Last Updated: 4 jan 2018

Journal: Journal de Mathématiques Pures et Appliquées
Volume: 108
Number: 3
Pages: 372-398
Year: 2017
Doi: https://doi.org/10.1016/j.matpur.2017.04.002

ArXiv: 1612.00263 PDF

Abstract:

We prove two new approximation results of H-perimeter minimizing boundaries by means of intrinsic Lipschitz functions in the setting of the Heisenberg group $H^n$ with $n\ge2$. The first one is an improvement of $[19]$ and is the natural reformulation in $H^n$ of the classical Lipschitz approximation in $R^n$. The second one is an adaptation of the approximation via maximal function developed by De Lellis and Spadaro $[11]$.


text:
Solved

# How to replace with single quote ?

Posted on 2011-03-17
499 Views
The following expression replace a
forward slash with two single quotes

i want only to one single quote

item_name.replace(/\\/g,"\'");
0
Question by:PeteEngineer

LVL 3

Accepted Solution

CombatGold1 earned 100 total points
Instead of \' see if specifying the single-quote's hexadecimal reference works, which would be \0x27, or the octal reference \047.
0

LVL 16

Assisted Solution

sjklein42 earned 100 total points
Your code seems to work fine:

(The code actually replaces backslashes \ , not forward slashes / .  Is that what you meant to say?)

<script>
var item_name = 'abc\\def'
item_name = item_name.replace(/\\/g,"\'");
</script>

0

LVL 74

Assisted Solution

käµfm³d   👽 earned 100 total points
Perhaps you mean you want to replace a series of one-or-more slashes with just one single quote?
item_name.replace(/\\+/g,"\'");

0

LVL 3

Assisted Solution

grouper15 earned 100 total points
can you send the value of item_name you are having problem with
0

LVL 82

Assisted Solution

leakim971 earned 100 total points
No need to escape the simple quote inside the double quote
item_name.replace(/\\/g,"'");

0

## Featured Post

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…


text:
# Count of common multiples of two numbers in a range in C++

C++Server Side ProgrammingProgramming

We are given two numbers A and B. Also provided two numbers START and END to define a range of numbers. The Ath tile has paint white and Bth tile has paint black. If the tile is painted both black and white then it turns grey. The goal is to find the total number of grey tiles .

We will do this by traversing numbers from START to END and for each number we will check if the number is multiple of both A and B. If yes increment count.

Let’s understand with examples.

Input

START=10 END=20 A=3 B=6

Output

Common multiples of A and B ( grey tiles ): 2

Explanation

Numbers 12, 18 are multiples of 3 and 6.

Input

START=1 END=100 A=10 B=11

Output

Common multiples of A and B ( grey tiles ): 0

Explanation

No common multiple of 10 and 11 in range.

## Approach used in the below program is as follows

• We take an integers START and END as range variables.

• We take A and B as two variables.

• Function countGrey(int start, int end, int a, int b) takes range variables, a, b and returns the count of multiples of a and b.

• Take the initial variable count as 0 for such numbers.

• Traverse range of numbers using for loop. i=start to i=end

• If i%a==0 && i%b==0. Then ‘i’ is multiple of both a and b.

• At the end of all loops count will have a total numbers which are multiples of ‘a’ and ‘b’

• Return the count as result.

## Example

Live Demo

#include <bits/stdc++.h>
using namespace std;
int countGrey(int start, int end, int a, int b){
int count = 0;
for (int i = start; i <= end; i++){
if(i%a==0 && i%b==0) //tile is grey
{ count++; }
}
return count;
}
int main(){
int START =10, END = 30;
int A=4, B=3;
cout <<"Common multiples of A and B ( grey tiles ): "<<
countGrey(START,END, A, B);
return 0;
}

## Output

If we run the above code it will generate the following output −

Common multiples of A and B ( grey tiles ): 2
Published on 31-Oct-2020 04:54:32


text:
# Measure and classify an angle

A line that has one defined endpoint is called a ray and extends endlessly in one direction. A ray is named after the endpoint and another point on the ray e.g.

$\overset{\rightarrow }{AB}$

The angle that is formed between two rays with the same endpoint is measured in degrees. The point is called the vertex

The vertex is written as

$\measuredangle CAB$

In algebra we used the coordinate plane to graph and solve equations.  You can plot lines, line segments, rays and angles in a coordinate plane.

In the coordinate plane above we have two rays

$\overset{\rightarrow }{BA}\: \: and\: \: \overset{\rightarrow }{BD}$

That form an angle with the vertex in point B.

You can use the coordinate plane to measure the length of a line segment. Point B is at (-2, -2) and C (1. -2). The distance between the two points is 1 - (-2) = 3 units.

Angles can be either straight, right, acute or obtuse.

An angle is a fraction of a circle where the whole circle is 360°. A straight angle is the same as half the circle and is 180° whereas a right angle is a quarter of a circle and is 90°.

You measure the size of an angle with a protractor.

Two angles with the same measure are called congruent angles. Congruent angles are denoted as

$\angle A\cong \angle B$

Or could be shown by an arc on the figure to indicate which angles that are congruent.

Two angles whose measures together are 180° are called supplementary e.g. two right angles are supplementary since 90° + 90° = 180°.

Two angles whose measures together are 90° are called complementary.

$m\angle A+m\angle B=180^{\circ}$

$m\angle C+m\angle D=90^{\circ}$

## Video lesson

Measure the size of the angle


text:
Lemma 20.11.4. Let $X$ be a ringed space. Let $\mathcal{U} : U = \bigcup _{i \in I} U_ i$ be a covering. Let $\mathcal{O}_\mathcal {U} \subset \mathcal{O}_ X$ be the image presheaf of the map $\bigoplus j_{p!}\mathcal{O}_{U_ i} \to \mathcal{O}_ X$. The chain complex $K(\mathcal{U})_\bullet$ of presheaves of Lemma 20.11.3 above has homology presheaves

$H_ i(K(\mathcal{U})_\bullet ) = \left\{ \begin{matrix} 0 & \text{if} & i \not= 0 \\ \mathcal{O}_\mathcal {U} & \text{if} & i = 0 \end{matrix} \right.$

Proof. Consider the extended complex $K^{ext}_\bullet$ one gets by putting $\mathcal{O}_\mathcal {U}$ in degree $-1$ with the obvious map $K(\mathcal{U})_0 = \bigoplus _{i_0} (j_{i_0})_{p!}\mathcal{O}_{U_{i_0}} \to \mathcal{O}_\mathcal {U}$. It suffices to show that taking sections of this extended complex over any open $W \subset X$ leads to an acyclic complex. In fact, we claim that for every $W \subset X$ the complex $K^{ext}_\bullet (W)$ is homotopy equivalent to the zero complex. Write $I = I_1 \amalg I_2$ where $W \subset U_ i$ if and only if $i \in I_1$.

If $I_1 = \emptyset$, then the complex $K^{ext}_\bullet (W) = 0$ so there is nothing to prove.

If $I_1 \not= \emptyset$, then $\mathcal{O}_\mathcal {U}(W) = \mathcal{O}_ X(W)$ and

$K^{ext}_ p(W) = \bigoplus \nolimits _{i_0 \ldots i_ p \in I_1} \mathcal{O}_ X(W).$

This is true because of the simple description of the presheaves $(j_{i_0 \ldots i_ p})_{p!}\mathcal{O}_{U_{i_0 \ldots i_ p}}$. Moreover, the differential of the complex $K^{ext}_\bullet (W)$ is given by

$d(s)_{i_0 \ldots i_ p} = \sum \nolimits _{j = 0, \ldots , p + 1} \sum \nolimits _{i \in I_1} (-1)^ j s_{i_0 \ldots i_{j - 1} i i_ j \ldots i_ p}.$

The sum is finite as the element $s$ has finite support. Fix an element $i_{\text{fix}} \in I_1$. Define a map

$h : K^{ext}_ p(W) \longrightarrow K^{ext}_{p + 1}(W)$

by the rule

$h(s)_{i_0 \ldots i_{p + 1}} = \left\{ \begin{matrix} 0 & \text{if} & i_0 \not= i \\ s_{i_1 \ldots i_{p + 1}} & \text{if} & i_0 = i_{\text{fix}} \end{matrix} \right.$

We will use the shorthand $h(s)_{i_0 \ldots i_{p + 1}} = (i_0 = i_{\text{fix}}) s_{i_1 \ldots i_ p}$ for this. Then we compute

\begin{eqnarray*} & & (dh + hd)(s)_{i_0 \ldots i_ p} \\ & = & \sum _ j \sum _{i \in I_1} (-1)^ j h(s)_{i_0 \ldots i_{j - 1} i i_ j \ldots i_ p} + (i = i_0) d(s)_{i_1 \ldots i_ p} \\ & = & s_{i_0 \ldots i_ p} + \sum _{j \geq 1}\sum _{i \in I_1} (-1)^ j (i_0 = i_{\text{fix}}) s_{i_1 \ldots i_{j - 1} i i_ j \ldots i_ p} + (i_0 = i_{\text{fix}}) d(s)_{i_1 \ldots i_ p} \end{eqnarray*}

which is equal to $s_{i_0 \ldots i_ p}$ as desired. $\square$

In your comment you can use Markdown and LaTeX style mathematics (enclose it like $\pi$). A preview option is available if you wish to see how it works out (just click on the eye in the toolbar).


text:
Detection of Transition Times from Single-particle-tracking Trajectories

# Detection of Transition Times from Single-particle-tracking Trajectories

Takuma Akimoto Department of Physics, Tokyo University of Science, Noda, Chiba 278-8510, Japan    Eiji Yamamoto Graduate School of Science and Technology, Keio University, Yokohama, Kanagawa 223-8522, Japan
July 15, 2019
###### Abstract

In heterogeneous environments, the diffusivity is not constant but changes with time. It is important to detect changes in the diffusivity from single-particle-tracking trajectories in experiments. Here, we devise a novel method for detecting the transition times of the diffusivity from trajectory data. A key idea of this method is the introduction of a characteristic time scale of the diffusive states, which is obtained by a fluctuation analysis of the time-averaged mean square displacements. We test our method in silico by using the Langevin equation with a fluctuating diffusivity. We show that our method can successfully detect the transition times of diffusive states and obtain the diffusion coefficient as a function of time. This method will provide a quantitative description of the fluctuating diffusivity in heterogeneous environments and can be applied to time series with transitions of states.

The mean square displacement (MSD) is one of the most popular observables for quantifying the diffusivity. In Brownian motion, the MSD increases linearly with time, and the diffusivity can be quantified by the slope of the MSD, i.e., the diffusion coefficient. The diffusion coefficient is determined by the surrounding environment including the viscosity of the medium and the properties of the diffusing particle, e.g., the shape of the Brownian particle. When there are no fluctuations in the properties of the surrounding environment and the diffusing particle, no intrinsic differences arise between the diffusivities for short-time and long-time measurements except for fluctuations of the diffusivity due to the finite measurement times.

In heterogeneous environments such as amorphous materials and living cells, diffusion often becomes anomalous; that is, the MSD does not increase linearly with time Scher and Montroll (1975); Golding and Cox (2006); Manzo et al. (2015). The local diffusivities in these environments are highly heterogeneous. These heterogeneities are sometimes static or fluctuating. For example, the charge transport in amorphous materials Scher and Montroll (1975) as well as the diffusion of proteins on DNA Granéli et al. (2006); Wang et al. (2006) can be modeled by a quenched trap model, where a random walker jumps in static random energy landscape Bouchaud and Georges (1990). In other words, the characteristic time scale of a change in the energy landscape is much longer than that of random walkers. On the other hand, in supercooled liquids, mobile and immoblie particles are distributed in space, and the diffusive properties (mobile and immobile properties) will change with time, i.e., dynamic heterogeneity Yamamoto and Onuki (1998a, b); Richert (2002). Moreover, transmembrane proteins Sergé et al. (2008); Weron et al. (2017) and membrane-bound proteins on biological membranes Yamamoto et al. (2017) exhibit a temporally heterogeneous diffusivity. In these systems, the diffusivity for short-time measurements is intrinsically different from that for long-time measurements.

One of the most important issues in heterogeneous environments is to uncover the local diffusivity from single-particle trajectories. However, there is a crucial difficulty in extracting the local diffusivity in both spatially and temporally heterogeneous environments. In particular, one cannot know the boundaries of regions with the same diffusivities and transition times when the diffusive states change in spatially and temporally heterogeneous environments, respectively. In previous studies, maximum likelihood estimators were proposed to determine the dynamic changes of the diffusivity Montiel et al. (2006); Koo and Mochrie (2016), where the key idea is to detect the transition times when the diffusivity changes drastically. However, an empirical parameter is necessary to implement the method.

The detection of the transition times is also important in state-transition processes, e.g., channel gating Wang et al. (2016), the conformational transition of proteins Chung et al. (2012), the rotation of F1-ATPase Noji et al. (1997), the fluorescence of quantum dots Stefani et al. (2009), and nanopore sensing of single molecules Howorka and Siwy (2009). A method for detecting transition times using only trajectories without prior knowledge and empirical parameters is desired in time-series analysis.

Here, we devise an estimation method for characterizing the short-time diffusivity from trajectory data without knowing the transition times of the diffusive states. In our method, there are no parameters that are determined empirically. Thus, our method can be applied when many single-particle-tracking trajectories are obtained. We show that our method can successfully detect the transition times of the diffusivity and estimate the local diffusivity in the (overdamped) Langevin equation with a fluctuating diffusion coefficient.

We assume that there are many trajectories for the same system and that the system can be described by the Langevin equation with a fluctuating diffusivity (LEFD):

 dr(t)dt=√2D(t)w(t), (1)

where is the position of a particle at time , is -dimensional white Gaussian noise with and , and is the diffusion coefficient at time , which is a stochastic process independent of . Although we do not assume any condition on , i.e., the diffusion coefficient may be non-Markov and depend on the position , we assume that the variance of is sufficiently large. In particular, it is much greater than the variance of the diffusion coefficients obtained by the time-averaged MSD defined by Eq. (2) when the measurement time is the same as the characteristic time scale of the diffusive state.

In our setting, we do not know

1. the number of diffusive states and

2. the time scales of the diffusive states.

This is because we do not know the transition times when a diffusive state changes in single-particle-tracking trajectories. This is one of the most difficult issues when estimating the fluctuating diffusivity. To overcome this difficulty, we apply a fluctuation analysis of the time-averaged MSDs to obtain a characteristic time scale of the diffusive states. The time-averaged MSD is defined as

 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯δ2(Δ;t)=1t−Δ∫t−Δ0{r(t′+Δ)−r(t′)}2dt′. (2)

To characterize the fluctuations in the time-averaged MSDs, we use the relative standard deviation (RSD) of the time-averaged MSDs, defined as

 Σ(t;Δ)≡√⟨[¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯δ2(Δ;t)−⟨¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯δ2(Δ;t)⟩]2⟩⟨¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯δ2(Δ;t)⟩, (3)

as a function of the measurement time ( is fixed). This type of quantity is widely used to investigate the ergodic property He et al. (2008); Deng and Barkai (2009) as well as the characteristic time of the system Akimoto et al. (2011); Miyaguchi and Akimoto (2011); Uneyama et al. (2012, 2015); Miyaguchi et al. (2016). In fact, the RSD analysis provides the longest relaxation time in the reptation model, which is a model of entangled polymers Uneyama et al. (2012, 2015).

When is a stationary stochastic process, i.e., the characteristic time of the stochastic process is finite, the general formula for the RSD is derived as Uneyama et al. (2015)

 Σ2(t;Δ)≈2t2∫t0ds(t−s)ψ1(s), (4)

where is the normalized correlation function of the diffusion coefficient, i.e., . Thus, if the relaxation time of the system is (roughly speaking, the correlation function decays as ), the asymptotic form of the RSD becomes

 Σ2(t;Δ)≈⎧⎨⎩ψ1(0)(t≪τ),2t∫∞0dvψ1(v)(t≫τ). (5)

Therefore, is obtained by the crossover time from the plateau to the decay in the RSD. In particular, when the correlation function decays exponentially, the crossover time in the RSD is given by . From many single-particle-tracking trajectories, one can calculate the time-averaged MSDs. Taking the ensemble average of the time-averaged MSDs gives us the RSD. In this way, one can obtain the characteristic time scale of from single-particle-tracking trajectories.

Here, we devise a novel method to detect the changes in states from a single-particle-tracking trajectory. First, we define the time-averaged diffusion coefficient (TDC) at time by

 D(t;Δ,T)≡∫t+T−Δt{r(t′+Δ)−r(t′)}2dt′2dΔ(T−Δ). (6)

There are two parameters, and , in the TDC. We set as the minimal time step of the trajectory; thus, it is not necessary to tune this parameter. On the other hand, we have to tune the parameter by introducing a tuning parameter as . Since is of the same order as the system’s characteristic time, can be smaller than one. In what follows, we use .

Second, using the effective diffusion coefficient , which is obtained by the ensemble average of the time-averaged MSD, i.e., , we define the crossing points as the points at which the TDC crosses , i.e., and or and , satisfying , where is the time step of the trajectories (see Fig. LABEL:LEFD_two_statesA). Note that the crossing points are not exact points representing changes in the diffusive states because different diffusive states coexist in a time window of . Therefore, we define the transition time as . The term is not exact when the threshold is not at the middle of two successive diffusive states. If only one transition occurs in the time interval , which is a physically reasonable assumption, the transition times represent the points of changes in the diffusive states. Note that some transition times of the diffusive states will be still missing.

To correct the transition times obtained above, we test whether successive diffusive states are significantly different. Since we know the transition times of the diffusive states, we can estimate the diffusion coefficient in the time interval : the diffusion coefficient of the th diffusive state is given by

 ¯¯¯¯¯Di≡∫ti+1−Δti{r(t′+Δ)−r(t′)}2dt′2dΔ(ti+1−ti−Δ). (7)

Since we consider a situation that is sufficiently large (), fluctuations of can be approximated as a Gaussian distribution by the central limit theorem. According to a statistical test, the th and th states can be considered as the same state if there exists such that both the and states satisfy

 D−σkZ≤¯¯¯¯¯Dk≤D+σkZ, (8)

where is the variance of the TDC with the time window and the diffusion coefficient , which is given by , and is determined by the level of statistical significance, e.g., when the -value is 0.05. Therefore, the transition times can be corrected if the two successive diffusion states are the same. We repeat this procedure: Eq. (7) will be calculated again after correcting the transition times , and the above test will be repeated to correct the transition times.

Furthermore, one can improve the transition times by changing the thresholds around the transition times. The detailed procedure and flowchart of our method are given in the Supplemental Material SM ().

Here, we test our method with the trajectories of three different LEFD models, where the number of diffusive states is two, three, and uncountable. The crossover times in the RSD are finite for all models.

In the Langevin equation with the two-state diffusivity, Fig. 1B shows the diffusion coefficient obtained by our method. Almost all diffusive states can be classified into two states according to the condition (8) with . Moreover, the deviations in the transition times from the actual transition times are within 0.25. Thus, we successfully extract the underlying diffusion process from a single trajectory after obtaining the characteristic time scale of the diffusive states.

We introduce different relaxation times in the two sojourn-time distributions (we use the exponential distribution for both sojourn-time distributions) and examine the effects of the tuning parameter. Figure 2 shows the TDCs for different tuning parameters , , and 0.01, corresponding to , 1.6, and 0.16, respectively. As clearly seen, when the tuning parameter is small, the fluctuations in the TDC become large. Therefore, inaccurate transition times may be detected when is too small. On the other hand, the actual transition times may not be detected when is too large. In fact, the transition times around cannot be detected in the case of the green dotted line (). As a result, the tuning parameter can be set to or between 0.1 and 0.01.

Next, we analyze the LEFD with the three-state diffusivity. The sojourn-time distributions are exponential distributions, and their relaxation times are the same in each state (). For the three-state LEFD, one can obtain several diffusive states from a single trajectory by our method after calculating the crossover time in the RSD using many trajectories. Figure 3 shows the diffusion coefficient obtained by our method, where we revised the threshold using the procedures described in the Supplemental Material SM (). As shown in Fig. 3A, the transition times are correctly detected. Moreover, almost all diffusive states belong to the three diffusive states using , and the distribution of the estimated diffusion coefficients has three peaks corresponding to the exact diffusion coefficient (see Fig. 3B).

Finally, we apply our method to a diffusion process with an uncountable number of diffusive states. In particular, we use the annealed transit time model (ATTM) Massignan et al. (2014); Akimoto and Yamamoto (2016). The ATTM was proposed to describe heterogeneous diffusion in living cells Massignan et al. (2014); Manzo et al. (2015). The diffusion process is described by the LEFD where is coupled to the sojourn time. When the sojourn time is , the diffusion coefficient is given by . Here, we assume that the sojourn-time distribution follows an exponential distribution . One can obtain by the RSD analysis Akimoto and Yamamoto (2016).

Figure 4A shows the diffusion coefficient obtained by our method. Because the variance of is not large, the transition times are not correctly detected compared with the other two models. However, the transition times for the highly diffusive states can be detected correctly. Moreover, Fig. 4B shows the relation between the obtained diffusion coefficient and the sojourn times, which exhibits a power-law relation . Therefore, our method can also be applied to systems with an uncountable number of diffusive states.

Diffusivity changes with time in temporally/spatially heterogeneous environments such as cells and supercooled liquids. It is difficult to estimate such a fluctuating diffusivity from single-particle trajectories because one does not have information about the transition times when the diffusivity changes. In this paper, we have proposed a new method for detecting the transition times from single trajectories. Our method is based on a fluctuation analysis of the time-averaged MSD to extract information on the characteristic time scale of the system. We have applied this method to three different diffusion processes, i.e., the LEFD with two states, the LEFD with three states, and the ATTM, which has an uncountable number of diffusive states. Our method successfully extracts the transition times of the diffusivities and estimates the fluctuating diffusion coefficients in the three models. Since our method can be conducted with single-particle trajectories, the application will be useful and of importance in experiments. Furthermore, a slight modification of this method will be also applied to the time series of state-transition processes.

E.Y. was supported by an MEXT (Ministry of Education, Culture, Sports, Science and Technology) Grant-in-Aid for the “Building of Consortia for the Development of Human Resources in Science and Technology.”

## References

• Scher and Montroll (1975) H. Scher and E. W. Montroll, Phys. Rev. B 12, 2455 (1975).
• Golding and Cox (2006) I. Golding and E. C. Cox, Phys. Rev. Lett. 96, 098102 (2006).
• Manzo et al. (2015) C. Manzo, J. A. Torreno-Pina, P. Massignan, G. J. Lapeyre, M. Lewenstein,  and M. F. <NAME>, Phys. Rev. X 5, 011021 (2015).
• Granéli et al. (2006) A. Granéli, C. C. Yeykal, R. B. Robertson,  and E. C. Greene, Proc. Natl. Acad. Sci. USA 103, 1221 (2006).
• Wang et al. (2006) Y. M. Wang, R. H. Austin,  and E. C. Cox, Phys. Rev. Lett. 97, 048302 (2006).
• Bouchaud and Georges (1990) J. Bouchaud and A. Georges, Phys. Rep. 195, 127 (1990).
• Yamamoto and Onuki (1998a) R. Yamamoto and A. Onuki, Phys. Rev. Lett. 81, 4915 (1998a).
• Yamamoto and Onuki (1998b) R. Yamamoto and A. Onuki, Phys. Rev. E 58, 3515 (1998b).
• Richert (2002) R. Richert, J. Phys. Cond. Matt. 14, R703 (2002).
• Sergé et al. (2008) A. Sergé, N. Bertaux, <NAME>,  and D. Marguet, Nat. Methods 5, 687 (2008).
• Weron et al. (2017) A. Weron, K. Burnecki, E. J. Akin, L. Solé, M. Balcerek, M. <NAME>,  and D. Krap, Sci. Rep. 7, 5404 (2017).
• Yamamoto et al. (2017) E. Yamamoto, T. Akimoto, A. C. Kalli, K. Yasuoka,  and M. S. P. Sansom, Sci. Adv. 3, e1601871 (2017).
• Montiel et al. (2006) D. Montiel, H. Cang,  and H. Yang, J. Phys. Chem. B 110, 19763 (2006).
• Koo and Mochrie (2016) P. K. Koo and S. G. J. Mochrie, Phys. Rev. E 94, 052412 (2016).
• Wang et al. (2016) S. Wang, R. Vafabakhsh, W. F. Borschel, T. Ha,  and C. G. Nichols, Nat. Struct. Mol. Biol. 23, 31 (2016).
• Chung et al. (2012) H. S. Chung, <NAME>, J. <NAME>,  and W. A. Eaton, Science 335, 981 (2012).
• Noji et al. (1997) H. Noji, R. Yasuda, M. Yoshida,  and K. Kinosita Jr, Nature 386, 299 (1997).
• Stefani et al. (2009) F. D. Stefani, J. P. Hoogenboom,  and E. Barkai, Phys. Today 62, 34 (2009).
• Howorka and Siwy (2009) S. Howorka and Z. Siwy, Chem. Soc. Rev. 38, 2360 (2009).
• He et al. (2008) Y. He, S. Burov, R. Metzler,  and E. Barkai, Phys. Rev. Lett. 101, 058101 (2008).
• Deng and Barkai (2009) W. Deng and E. Barkai, Phys. Rev. E 79, 011112 (2009).
• Akimoto et al. (2011) T. Akimoto, E. Yamamoto, K. Yasuoka, Y. Hirano,  and M. Yasui, Phys. Rev. Lett. 107, 178103 (2011).
• Miyaguchi and Akimoto (2011) T. Miyaguchi and T. Akimoto, Phys. Rev. E 83, 062101 (2011).
• Uneyama et al. (2012) T. Uneyama, T. Akimoto,  and T. Miyaguchi, J. Chem. Phys. 137, 114903 (2012).
• Uneyama et al. (2015) T. Uneyama, T. Miyaguchi,  and T. Akimoto, Phys. Rev. E 92, 032140 (2015).
• Miyaguchi et al. (2016) T. Miyaguchi, T. Akimoto,  and E. Yamamoto, Phys. Rev. E 94, 012109 (2016).
• (27) See Supplementary Material for the detailed procedures and flowchart of our method.
• Massignan et al. (2014) P. Massignan, <NAME>, <NAME>, <NAME>, <NAME>,  and G. <NAME>, Phys. Rev. Lett. 112, 150603 (2014).
• Akimoto and Yamamoto (2016) T. Akimoto and E. Yamamoto, J. Stat. Mech. 2016, 123201 (2016).
You are adding the first comment!
How to quickly get a good reply:
• Give credit where it’s due by listing out the positive aspects of a paper before getting into which changes should be made.
• Be specific in your critique, and provide supporting evidence with appropriate references to substantiate general statements.
• Your comment should inspire ideas to flow and help the author improves the paper.

The better we are at sharing our knowledge with each other, the faster we move forward.
The feedback must be of minimum 40 characters and the title a minimum of 5 characters


text:
## Stream: new members

### Topic: rings from subtype

#### <NAME> (Feb 28 2021 at 08:00):

Is something along the lines of the code below available?

import algebra.ring.basic

variables {R : Type*} [comm_semiring R]

variables {p : R → Prop} (p0 : p 0) (p1 : p 1)
(padd : ∀ {a b : R}, p a → p b → p (a + b))
(pmul : ∀ {a b : R}, p a → p b → p (a * b))

section pR

variable (p)

def pR : Type* := {r : R // p r}

end pR

instance comm_semiring : comm_semiring (pR p) := sorry

#### <NAME> (Feb 28 2021 at 08:06):

You know, what you've written is basically the constructor for a subring: docs#subring. Then we know that a subring of a commutative ring is itself a commutative ring: docs#subring.to_comm_ring.

#### <NAME> (Feb 28 2021 at 08:09):

Oh, I see, you want the semiring version, but that exists too: docs#subsemiring.to_comm_semiring

#### <NAME> (Feb 28 2021 at 08:10):

Ah, Heather, thank you very much! I did not know about any of these!

I will take a look: the semi issue may not be too relevant for me, I was just creating a template, to fit it later to what I exactly needed!
Already the comm_ring one is a great start!

Thanks!

#### <NAME> (Feb 28 2021 at 17:49):

Continuing this conversation, what I would like is to talk about the subsemiring of non-negative elements of an ordered ring R. The exact assumptions on the initial ordered rings are possibly flexible, but I would certainly like this to work when R is a comm_ring with a compatible order, possibly with no zero divisors. The most basic setup would be ℤ and ℕ, but I would like something that works simultaneously also for ℚ and ℚ≥0 and ℝ and ℝ≥0.

Hence, is what's below already in mathlib? Is there a simpler way to get Lean to realize all the repetitions in the statements/proofs?

Thanks!

import ring_theory.subring

section Rnnoneg

variables (R : Type*) [ordered_semiring R]

/--  The subtype of non-negative elements of R. -/
def pR : subsemiring R :=
{ carrier := {r : R | 0 ≤ r},
one_mem' := by simp only [set.mem_set_of_eq, zero_le_one],
mul_mem' := begin
rintros x y (x0 : 0 ≤ x) (y0 : 0 ≤ y),
exact mul_nonneg x0 y0,
end,
zero_mem' := rfl.le,
rintros x y (x0 : 0 ≤ x) (y0 : 0 ≤ y),
end }

/--  The non-negative elements come with a partial order. -/
def popR : partial_order (pR R) :=
{ le := (≤),
lt := (<),
le_refl := λ _, le_rfl,
le_trans := λ _ _ _, le_trans,
lt_iff_le_not_le := λ _ _, lt_iff_le_not_le,
le_antisymm := λ _ _, le_antisymm }

/--  ... and they form an ordered semiring. -/
instance : ordered_semiring (pR R) :=
rintros a ⟨b, b0 : 0 ≤ b⟩ ⟨c, c0 : 0 ≤ c⟩ bc,
injection bc with hbc,
simpa using hbc,
end,
rintros ⟨a, a0 : 0 ≤ a⟩ b ⟨c, c0 : 0 ≤ c⟩ ac,
injection ac with hac,
simpa using hac,
end,
rintros ⟨a, a0 : 0 ≤ a⟩ ⟨b, b0 : 0 ≤ b⟩ (ab : a ≤ b) ⟨c, c0 : 0 ≤ c⟩,
end,
rintros ⟨a, a0 : 0 ≤ a⟩ ⟨b, b0 : 0 ≤ b⟩ ⟨c, c0 : 0 ≤ c⟩ (hbc : a + b ≤ a + c),
change b ≤ c,
end,
zero_le_one := zero_le_one,
mul_lt_mul_of_pos_left := λ _ _ _, mul_lt_mul_of_pos_left,
mul_lt_mul_of_pos_right := λ _ _ _, mul_lt_mul_of_pos_right,
..(infer_instance : semiring (pR R)),
..(infer_instance : partial_order (pR R)) }

end Rnnoneg

#### <NAME> (Feb 28 2021 at 17:55):

I'd expect an instance like docs#subtype.partial_order or something that you could use for at least some of these.

#### <NAME> (Feb 28 2021 at 17:56):

Indeed: this seems to work!

def popR : partial_order (pR R) := by apply_instance

#### <NAME> (Feb 28 2021 at 18:29):

Does your ordered_semiring instance actually use any properties of the subsemiring you chose?

#### <NAME> (Feb 28 2021 at 18:29):

Or does it work on an arbitrary sub_semiring

#### <NAME> (Feb 28 2021 at 18:29):

If the latter, then mathlib ought to have provided it for you, and you should PR it!

#### <NAME> (Feb 28 2021 at 18:33):

I will take a look at this. most of these properties are simply checked on a subset of the choices, so they should hold no matter what. I will check later that there are no hidden issues.

Thanks for the comments! As usual, I always learn a lot!

#### <NAME> (Feb 28 2021 at 19:07):

Eric, glancing at the lemmas, you are right that the properties in the ordered_semiring instance above are true since they are true for any subtype of an ordered_semiring: you simply apply the property of the bigger type to the terms of the smaller one.

How does one go about "saying this in Lean"?

#### <NAME> (Feb 28 2021 at 19:08):

You should be stating that result for all subsemirings

#### <NAME> (Feb 28 2021 at 19:08):

Since it doesnt apply to all subtypes

#### <NAME> (Feb 28 2021 at 19:09):

Note that sometimes properties of the bigger one can't always be transferred to the smaller one

#### <NAME> (Feb 28 2021 at 19:10):

But when they can, a common approach is to define things like docs#function.injective.semiring

#### <NAME> (Feb 28 2021 at 19:10):

Do we have docs#function.injective.ordered_semiring?

#### <NAME> (Feb 28 2021 at 19:10):

Ok, this seems like it would take some time: I will take a look at this function.injective.semiring, but probably tomorrow!

Thanks!

#### <NAME> (Feb 28 2021 at 19:11):

The link docs#function.injective.ordered_semiring does not work, so probably not!

#### <NAME> (Feb 28 2021 at 19:15):

I assume we have docs#function.injective.preorder?

Hmm, also no

#### <NAME> (Mar 01 2021 at 04:30):

I am trying to understand how this works. Is the code below what you had in mind, in the case of a partial order?

def function.injective.partial_order [partial_order α] (f : β → α) (hf : injective f) :
partial_order β :=
{ le := λ x y, f x ≤ f y,
lt := λ x y, f x < f y,
le_refl := λ x, rfl.le,
le_trans := λ a b c, le_trans,
lt_iff_le_not_le := λ a b, lt_iff_le_not_le,
le_antisymm := λ a b ab ba, hf (le_antisymm ab ba) }

#### <NAME> (Mar 01 2021 at 04:59):

I tried to extend this, but I am getting stuck: why does the proof below not work?

def function.injective.ordered_semiring [ordered_semiring α]
[has_zero β] [has_one β] [has_add β] [has_mul β]
(f : β → α) (hf : injective f) (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y) :
ordered_semiring β :=
intros a b c bc,
refine hf ((add_right_inj (f a)).mp _),
have abc : f a + f b = f a + f c := (add a b).symm.trans ((congr_arg f bc).trans (add a c)),
convert abc,
-- produces two goals.  My understanding is that Lean is not picking up what the various + symbols mean
-- but I am not sure whether this is really the case, nor how to fix it!
sorry,
end,
zero_le_one := sorry,
mul_lt_mul_of_pos_left := sorry,
mul_lt_mul_of_pos_right := sorry,
.. hf.partial_order f,
.. hf.semiring f zero one add mul }

#### <NAME> (Mar 01 2021 at 05:18):

I don't know what's going on exactly but most of the hypotheses can be bundled into docs#ring_hom. Why aren't you using semi_ring \b?

#### <NAME> (Mar 01 2021 at 06:30):

It seems to me that semiring_hom requires \b to already be a semiring, whereas I would like to prove that \b is an ordered semiring using this result. Am I misunderstanding your suggestion?

#### <NAME> (Mar 01 2021 at 06:33):

Actually, Lean seems to already know that \b is a semiring, since the last row of the proof above works. Maybe I should focus on trying to get lean to work out the semiring assumption on \b explicitly?

#### <NAME> (Mar 01 2021 at 06:39):

If I try

add_left_cancel := begin
haveI : semiring β := hf.semiring f zero one add mul,
let fr : ring_hom β α :=
{ to_fun := f,
map_one' := begin
convert one,
_,
end,
map_mul' := _,
map_zero' := _,

I run into the issue, I think, that Lean now has two 1s on β, one from the assumption has_one and one from the instance semiring β and I do not know how to convince it that they are the same.

#### <NAME> (Mar 01 2021 at 06:44):

Try adding add := (+) etc to your original version

#### <NAME> (Mar 01 2021 at 06:45):

That way lean will use the notation from the has_add argument

#### <NAME> (Mar 01 2021 at 07:12):

Hmm, it gets me to the same stage:

def function.injective.ordered_semiring [ordered_semiring α]
[has_zero β] [has_one β] [has_add β] [has_mul β]
(f : β → α) (hf : injective f) (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y) :
ordered_semiring β :=
intros a b c bc,
refine hf ((add_right_inj (f a)).mp _),
have abc : f a + f b = f a + f c := (add a b).symm.trans ((congr_arg f bc).trans (add a c)),
convert abc,
sorry,
sorry,
end,
zero_le_one := sorry,
mul_lt_mul_of_pos_left := sorry,
mul_lt_mul_of_pos_right := sorry,
.. hf.partial_order f,
.. hf.semiring f zero one add mul }

#### <NAME> (Mar 01 2021 at 07:33):

Does refl solve those goals?

#### <NAME> (Mar 01 2021 at 07:34):

Perhaps after using convert ... using 1

Or 2

#### <NAME> (Mar 01 2021 at 07:38):

refl does not work saying that it fails to unify

#### <NAME> (Mar 01 2021 at 07:39):

convert abc using 1 produces

⊢ f a + f b = f a + f b

and

f a + f c = f a + f c

as subgoals, but again refl fails to unify them.

#### <NAME> (Mar 01 2021 at 07:39):

convert abc using 2 gives the same goals as convert abc

#### <NAME> (Mar 01 2021 at 07:47):

I am really sorry about the confusion: I had a variables {α β : Type*} [semiring α] floating around, so the two add instances had been artificially introduced by me.
:face_palm:

#### <NAME> (Mar 01 2021 at 07:49):

Indeed, this now works:

def function.injective.ordered_semiring [ordered_semiring α]
[has_zero β] [has_one β] [has_add β] [has_mul β]
(f : β → α) (hf : injective f) (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y) :
ordered_semiring β :=
{ add_left_cancel := λ a b c bc,
-- [still to finish]
}

#### <NAME> (Mar 01 2021 at 08:18):

Finally, this works!

def function.injective.ordered_semiring [ordered_semiring α]
[has_zero β] [has_one β] [has_add β] [has_mul β]
(f : β → α) (hf : injective f) (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y) :
ordered_semiring β :=
change f (c + a) ≤ f (c + b),
end,
le_of_add_le_add_left := λ a b c (ab : f (a + b) ≤ f (a + c)), begin
end,
zero_le_one := begin
change f 0 ≤ f 1,
rw [zero, one],
exact zero_le_one,
end,
mul_lt_mul_of_pos_left := begin
intros a b c ab c0,
change f (c * a) < f (c * b),
rw [mul, mul],
apply mul_lt_mul_of_pos_left ab _,
rwa ← zero,
end,
mul_lt_mul_of_pos_right := begin
intros a b c ab c0,
change f (a * c) < f (b * c),
rw [mul, mul],
apply mul_lt_mul_of_pos_right ab _,
rwa ← zero,
end,
.. hf.partial_order f,
.. hf.semiring f zero one add mul }

#### <NAME> (Mar 01 2021 at 09:05):

I now have a bunch of proofs for the results below. Are people interested in having them in mathlib?

def function.injective.preorder [preorder α] (f : β → α) (hf : injective f) :
preorder β :=
{ ... }

lemma function.injective.preorder.mono [preorder α] (f : β → α) (hf : injective f) :
@monotone β α (hf.preorder f) _ f :=
λ a b ab, ab

def function.injective.partial_order [partial_order α] (f : β → α) (hf : injective f) :
partial_order β :=
{ ... }

[has_zero β] [has_one β] [has_add β] [has_mul β]
(f : β → α) (hf : injective f) (zero : f 0 = 0)
(add : ∀ x y, f (x + y) = f x + f y) :
{ ... }

[has_zero β] [has_one β] [has_add β] [has_mul β]
(f : β → α) (hf : injective f) (zero : f 0 = 0)
(add : ∀ x y, f (x + y) = f x + f y) :
{ ... }

def function.injective.ordered_semiring [ordered_semiring α]
[has_zero β] [has_one β] [has_add β] [has_mul β]
(f : β → α) (hf : injective f) (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y) :
ordered_semiring β :=
{ ... }

#### <NAME> (Mar 01 2021 at 09:07):

I can't see why not, we have a precedent for those definitions for other typeclasses

#### <NAME> (Mar 01 2021 at 09:08):

Ok, and should they all go in the same file? Probably algebra.ring.basic?

#### <NAME> (Mar 01 2021 at 09:08):

They can't go there, because the ordering classes don't exist yet

#### <NAME> (Mar 01 2021 at 09:09):

Try to put each in the same file as the typeclass they implement is defined

#### <NAME> (Mar 01 2021 at 09:10):

Ok, good suggestion!

#### <NAME> (Mar 01 2021 at 09:16):

You don't need injectivity to pull back a preorder and the pullback is already there

#### <NAME> (Mar 01 2021 at 09:18):

Kevin, thanks! I had split the preorder from the partial_order and did not think back about the assumptions!

#### <NAME> (Mar 01 2021 at 09:19):

docs#preorder.lift

#### <NAME> (Mar 01 2021 at 09:22):

Thanks Rémy! I see that also partial_order.lift exists: great!

#### <NAME> (Mar 01 2021 at 09:24):

I am down to what is below. Anything else that is already in mathlib?

def function.injective.ordered_add_comm_monoid [ordered_add_comm_monoid α]
[has_zero β] [has_one β] [has_add β] [has_mul β]
(f : β → α) (hf : injective f) (zero : f 0 = 0)
(add : ∀ x y, f (x + y) = f x + f y) :
{ ... }

[has_zero β] [has_one β] [has_add β] [has_mul β]
(f : β → α) (hf : injective f) (zero : f 0 = 0)
(add : ∀ x y, f (x + y) = f x + f y) :
{ ... }

def function.injective.ordered_semiring [ordered_semiring α]
[has_zero β] [has_one β] [has_add β] [has_mul β]
(f : β → α) (hf : injective f) (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y) :
ordered_semiring β :=
{ ... }

#### <NAME> (Mar 01 2021 at 09:25):

It's annoying that the naming convention is different between partial_order.lift and function. Injective.semiring

#### <NAME> (Mar 01 2021 at 09:25):

Use library_search to find out?

#### <NAME> (Mar 01 2021 at 09:26):

library_search is often my first attempt, but I could not find any of these...

#### <NAME> (Mar 01 2021 at 09:27):

Did it find partial_order.lift?

#### <NAME> (Mar 01 2021 at 09:29):

You raise a good point:

def function.injective.partial_order [partial_order α] (f : β → α) :
partial_order β :=
by library_search

says

library_search failed.

#### <NAME> (Mar 01 2021 at 09:30):

Of course it does

#### <NAME> (Mar 01 2021 at 09:30):

docs#partial_order.lift requires injectivity

#### <NAME> (Mar 01 2021 at 09:30):

For ordered add comm monoid you have an unneeded mul on beta

#### <NAME> (Mar 01 2021 at 09:30):

This also fails:

def function.injective.partial_order [partial_order α] (f : β → α) (hf : injective f):
partial_order β :=
by library_search

#### <NAME> (Mar 01 2021 at 09:31):

And a 1 and in the second one too

#### <NAME> (Mar 01 2021 at 09:32):

Thanks for the linting! I cleared unnecessary hypotheses: now only the doc-strings are missing!

#### <NAME> (Mar 01 2021 at 09:33):

import ring_theory.subring

variables {α β : Type*}

open function

/-- Pullback an ordered_add_comm_monoid under an injective map. -/
(f : β → α) (hf : injective f) (zero : f 0 = 0)
(add : ∀ x y, f (x + y) = f x + f y) :
show f (c + a) ≤ f (c + b), by simp [add, add_le_add_left ab (f c)],
..partial_order.lift f hf,

/-- Pullback an ordered_cancel_add_comm_monoid under an injective map. -/
(f : β → α) (hf : injective f) (zero : f 0 = 0)
(add : ∀ x y, f (x + y) = f x + f y) :
{ le_of_add_le_add_left := λ a b c (ab : f (a + b) ≤ f (a + c)),

/-- Pullback an ordered_semiring under an injective map. -/
def function.injective.ordered_semiring [ordered_semiring α]
[has_zero β] [has_one β] [has_add β] [has_mul β]
(f : β → α) (hf : injective f) (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y) :
ordered_semiring β :=
{ zero_le_one := show f 0 ≤ f 1, by  simp [zero, one, zero_le_one],
mul_lt_mul_of_pos_left := λ  a b c ab c0, show f (c * a) < f (c * b),
begin
rw [mul, mul],
refine mul_lt_mul_of_pos_left ab _,
rwa ← zero,
end,
mul_lt_mul_of_pos_right := λ a b c ab c0, show f (a * c) < f (b * c),
begin
rw [mul, mul],
refine mul_lt_mul_of_pos_right ab _,
rwa ← zero,
end,
..hf.semiring f zero one add mul }

#lint

lint is happy!

#### <NAME> (Mar 01 2021 at 09:54):

Can you generate function.injective.ordered_add_comm_monoid from to_additive and function.injective.ordered_comm_monoid?

#### <NAME> (Mar 01 2021 at 11:03):

I think that I managed to get lean to produce the additive version with the proof of the multiplicative ones. I have the issue now that lint complains about the doc-strings missing from the two automatically generated definitions.

How do I provide doc-strings for the [to_additive] stuff?

PR #6489

#### <NAME> (Mar 01 2021 at 11:15):

Like that: [to_additive name_for_to_additive_version "Docstring for to_additive version"]

#### <NAME> (Mar 01 2021 at 11:15):

and the name can most often be omitted. The linter will tell you to remove it if it is the same as the automatically generated one.

#### <NAME> (Mar 01 2021 at 11:19):

Rémy, thank you very much! I will update the PR. I will wait to see if the linter complains about the autogenerated name, although I imagine that I would want the autogenerated name anyway!

#### <NAME> (Mar 01 2021 at 11:50):

I don't think that naming these after function.injective is a good idea if you want consistency, because it's not always a requirement

#### <NAME> (Mar 01 2021 at 11:51):

I am happy to give them a different name. I was simply minimizing the changes from

https://leanprover-community.github.io/mathlib_docs/algebra/ring/basic.html#function.injective.semiring

since I was trying to learn at the same time what this all meant

#### <NAME> (Mar 01 2021 at 11:52):

perhaps partial_order.comap?

#### <NAME> (Mar 01 2021 at 11:52):

What seems to work well with this name is that you can eat the function.injective part with the assumption that the function is injective. This may not seem like a great deal to you, but I am still not entirely accustomed to dot-notation!

#### <NAME> (Mar 01 2021 at 11:53):

No I see that, but like I said you won't get consistent naming that way unless you want function.injective.preorder even though that one doesn't take a function.injective argument

#### <NAME> (Mar 01 2021 at 11:54):

Ah, sorry, I think that the part of the thread that talked about partial_orders ended when I was told that partial_order.lift was already a thing!

#### <NAME> (Mar 01 2021 at 11:54):

since <NAME>'s original complaint was about lack of consistency in the naming

#### <NAME> (Mar 01 2021 at 11:54):

The partial order one exists already and is partial_order.lift. There is also preorder.lift, linear_order.lift. I suggest keeping those names because they describe well what those lemmas do and using class_name.lift

#### <NAME> (Mar 01 2021 at 11:54):

The final PR only talks about ordered_stuff_ring/monoid.

#### <NAME> (Mar 01 2021 at 11:55):

Those came later, and apparently were written without knowing about the *.lift lemmas

#### <NAME> (Mar 01 2021 at 11:55):

So, should the new ones that I PRed contain lift in them?

#### <NAME> (Mar 01 2021 at 11:56):

e.g. ordered_comm_monoid.lift, instead of function.injective.ordered_comm_monoid?

#### <NAME> (Mar 01 2021 at 11:57):

That looks good to me

#### <NAME> (Mar 01 2021 at 11:57):

Looking at the new lemmas, they seem to differ from the *.lift family in that they already expect the domain to have a one and mul

#### <NAME> (Mar 01 2021 at 11:58):

I can certainly change the three names (+2) to be of this form: class_name.lift where class_name is going to be ordered_[...].

#### <NAME> (Mar 01 2021 at 11:59):

The point of partial_order.lift for example is to define a <= induced by the <= on the codomain, so we don't assume any structure on the domain a priori

#### <NAME> (Mar 01 2021 at 12:00):

When there are more operations, I suppose it becomes a question of which operations you want to pull back and which you expect to already exist

#### <NAME> (Mar 01 2021 at 12:03):

In this case there is the issue that I would not want to say that the 0 ring is a subring of any other ring, since for me a ring map needs to take 1 to 0 1 (what a lapsus!)... so I would not be happy to define 1 and 0 from the map.

#### <NAME> (Mar 01 2021 at 12:05):

As far as "algebraic structures" go, though assuming add, mul, 0 and 1 seems pretty basic. In fact, you might even get away with not assuming 0, maybe...

#### <NAME> (Mar 01 2021 at 12:06):

Ah, except that it is there because of autogeneration from the assumption of 1, right? So, to remove 0 you would need to not use to_additive (which is what I was going to do anyway, until Eric suggested that I could take advantage of to_additive).

#### <NAME> (Mar 01 2021 at 12:11):

Hmm, not so sure about not needing 0: should pnat be an ordered_subsemiring of nat?

I would say not...

#### <NAME> (Mar 01 2021 at 12:47):

<NAME> said:

I don't think that naming these after function.injective is a good idea if you want consistency, because it's not always a requirement

I agree, but I think that @Damiano Testa should continue to use function.injective.ordered_cancel_comm_monoid in their PR, and then someone can rename all of them at once later

#### <NAME> (Mar 05 2021 at 10:02):

So the conclusion of this thread is that you can now do:

section Rnnoneg

variables (R : Type*) [ordered_semiring R]

/--  The subtype of non-negative elements of R. -/
def pR : subsemiring R :=
{ carrier := {r : R | 0 ≤ r},
one_mem' := zero_le_one,
mul_mem' := λ x y, mul_nonneg,
zero_mem' := rfl.le,
add_mem' := λ x y (x0 : 0 ≤ x) y0, add_nonneg x0 y0, }

/--  ... and they form an ordered semiring. -/
instance : ordered_semiring (pR R) := infer_instance

end Rnnoneg

right?

#### <NAME> (Mar 05 2021 at 10:03):

Yes, I think we tested this on the toric branch of LTE this morning, and it works

#### <NAME> (Mar 05 2021 at 10:15):

You better use all the other ordering classes too to make the scope creep of the PR worthwhile :laughing:

#### <NAME> (Mar 05 2021 at 11:12):

I will try to use as many of these as possible! If needed, I will artificially prove lemmas about ordered_semi_canonical_monoids, just to use the appropriate typeclass!

#### <NAME> (Mar 05 2021 at 11:14):

In any case, I confirm that one of the new instances is already in use in the toric branch!

#### <NAME> (Mar 05 2021 at 17:09):

Continuing with the instance galore, are the instances below in mathlib?

The proofs are straightforward, but I was wondering if I have simply been unable to find them, or whether there are reasons why having them would cause issues.

Thanks!

instance ring_hom.to_algebra {R S : Type*} [comm_semiring R] [comm_semiring S] (f : R →+* S) :
algebra R S :=

instance : algebra ℝ≥0 ℝ := nnreal.to_real_hom.to_algebra

instance : semimodule ℝ≥0 ℝ := by apply_instance

instance {R S : Type*} [comm_semiring R] [comm_semiring S] [algebra R S] [semimodule S M] :
semimodule R M :=

(In case you are wondering, the apply_instance in the third line above is a consequence of the previous ones, otherwise I could not find it in mathlib.)

#### <NAME> (Mar 05 2021 at 17:31):

ring_hom.to_algebra already exists (with that name)

#### <NAME> (Mar 05 2021 at 17:36):

Good on the naming front, not so good on the search front!

#### <NAME> (Mar 05 2021 at 19:18):

Ok, so does it make sense to PR the instances below?

instance : algebra ℝ≥0 ℝ := nnreal.to_real_hom.to_algebra

instance : semimodule ℝ≥0 ℝ := by apply_instance

instance {R S : Type*} [comm_semiring R] [semiring S] [algebra R S] [semimodule S M] :
semimodule R M :=
{ smul := λ a b, algebra_map R S a • b,
one_smul := λ a, by simp only [one_smul, ring_hom.map_one],
mul_smul := λ x y m, by simp [(•), mul_smul ((algebra_map R S) x) ((algebra_map R S) y) m],
smul_add := λ r m n, smul_add ((algebra_map R S) r) m n,
smul_zero := λ r, smul_zero ((algebra_map R S) r),
add_smul := λ a b m, by simp [(•), add_smul ((algebra_map R S) a) ((algebra_map R S) b) m],
zero_smul := λ m, by simp only [ring_hom.map_zero, zero_smul]}

instance pro [module ℝ M] : semimodule ℝ≥0 M := by apply_instance

#### <NAME> (Mar 05 2021 at 19:26):

Nr 1 looks good, nr 2 is by apply_instance so it is redundant, nr 3 should be a def, because the type class search can not determine S from the goal, so it will go crazy; nr 4 looks good (but the proof will have to change to use the def from nr 3).

#### <NAME> (Mar 05 2021 at 19:27):

nr 2 is by apply_instance only after nr 1 is in: that does not matter, right?

#### <NAME> (Mar 05 2021 at 19:28):

Right, as soon as nr 1 is in mathlib, nr 2 is redundant

#### <NAME> (Mar 05 2021 at 19:30):

Better?

instance : algebra ℝ≥0 ℝ := nnreal.to_real_hom.to_algebra

variables {N : Type*} [add_comm_monoid N]

def semimodule.of_algebra (R S : Type*) [comm_semiring R] [semiring S] [algebra R S]
[semimodule S N] :
semimodule R N :=
{ smul := λ a b, algebra_map R S a • b,
one_smul := λ a, by simp only [one_smul, ring_hom.map_one],
mul_smul := λ x y m, by simp [(•), mul_smul ((algebra_map R S) x) ((algebra_map R S) y) m],
smul_add := λ r m n, smul_add ((algebra_map R S) r) m n,
smul_zero := λ r, smul_zero ((algebra_map R S) r),
add_smul := λ a b m, by simp [(•), add_smul ((algebra_map R S) a) ((algebra_map R S) b) m],
zero_smul := λ m, by simp only [ring_hom.map_zero, zero_smul]}

instance [semimodule ℝ N] : semimodule ℝ≥0 N := semimodule.of_algebra ℝ≥0 ℝ

#### <NAME> (Mar 05 2021 at 19:36):

That last one looks dangerous to me

#### <NAME> (Mar 05 2021 at 19:37):

Oh sorry, didn't scroll down

#### <NAME> (Mar 05 2021 at 19:38):

I don't think semimodule.of_algebra is a great idea, that looks like something docs#is_scalar_tower is intended to solve

#### <NAME> (Mar 05 2021 at 19:39):

I would also like to have

instance ist [semimodule ℝ N] : is_scalar_tower ℝ≥0 ℝ N :=
{ smul_assoc := λ a b c, show (a.val • b) • c = a • b • c, by { rw smul_assoc a.val b c, congr } }

#### <NAME> (Mar 05 2021 at 19:41):

I thing docs#restrict_scalars might be related too

(deleted)

#### <NAME> (Mar 05 2021 at 19:44):

Eric, I am looking at your suggestions: they do look very close to what I want. (Although so far I have not been able to make them work "as is".)

#### <NAME> (Mar 05 2021 at 19:47):

Can you give two concrete examples for N for your last instance?

#### <NAME> (Mar 05 2021 at 19:48):

You mean two ℝ-modules N? Like some actual real vector spaces? Or am I misunderstanding what you are asking?

#### <NAME> (Mar 05 2021 at 19:49):

In toric I am trying to convert all the time between a vector space and a cone inside it, so I like to take "non-negative" multiples of vectors. This is the reason why I would like to have this instance.

(I just added a proof of the is_scalar_tower instance.)

#### <NAME> (Mar 05 2021 at 19:57):

My claim is that the semimodule instance should appear automatically if you define the scalar_tower one

#### <NAME> (Mar 05 2021 at 19:57):

Eg, docs#pi.semimodule for the module fin 3-> R

#### <NAME> (Mar 05 2021 at 19:58):

Will inherit all module structures that R has

#### <NAME> (Mar 05 2021 at 19:59):

If I understand you correctly, and I swap the last two like this:

instance ist [semimodule ℝ N] : is_scalar_tower ℝ≥0 ℝ N :=
{ smul_assoc := λ a b c, show (a.val • b) • c = a • b • c, by { rw smul_assoc a.val b c, congr } }

instance [semimodule ℝ N] : semimodule ℝ≥0 N := semimodule.of_algebra ℝ≥0 ℝ

then, is_scalar_tower wants a has_scalar ℝ≥0 N assumption that it can't find.

#### <NAME> (Mar 05 2021 at 20:00):

I think my claim is that all concrete N you care about should be providing that is_scalar_tower instance

#### <NAME> (Mar 05 2021 at 20:01):

So in abstract situations you should just have it as a typeclass assumption

#### <NAME> (Mar 05 2021 at 20:01):

so, in the toric branch, this is a lemma that does not work without that instance and does with it:

lemma pointed_of_nnreal {ι : Type*} [module ℝ M] {v : ι → M} (bv : is_basis ℝ v) :
pointed ℝ (submodule.span ℝ≥0 (set.range v)) :=
pointed_of_is_basis_is_inj (is_inj_nonneg.pR_ocr ℝ) bv

#### <NAME> (Mar 05 2021 at 20:02):

I might take a look later. Can you give a github line permalink?

#### <NAME> (Mar 05 2021 at 20:02):

It is probably a little cryptic, but you can see the \Rmodule assumption on M which does not automatically get a nnreal is_scalar_tower.

#### <NAME> (Mar 05 2021 at 20:03):

would telling you where to find it in lean-liquid be ok?

#### <NAME> (Mar 05 2021 at 20:06):

The lemma begins on line 575, the instances are before it.

(deleted)

#### <NAME> (Mar 05 2021 at 20:41):

Lines 559 to 573 should be removed, and replaced with hypotheses for the lemma on line 575

#### <NAME> (Mar 05 2021 at 20:45):

That is, assume [semimodule ℝ≥0 N]

#### <NAME> (Mar 05 2021 at 20:47):

I can certainly assume those instances, instead of proving them in general, but the situation with ℕ and ℤ is that those instances are there automatically (e.g. the lemmas on 537 and 543).

#### <NAME> (Mar 05 2021 at 20:51):

I think that Lean also wants me to assume

[algebra ℝ≥0 ℝ]
[semimodule ℝ≥0 M]
[is_scalar_tower ℝ≥0 ℝ M]

and then says that it cannot prove the result. Although, it is getting late, so I may be doing something silly!

#### <NAME> (Mar 05 2021 at 21:02):

It seems that making these assumptions creates new instances for what should already be there and then Lean gets stuck on using them and does not find a compatibility among them. Or maybe, this is what I think at the moment...

#### <NAME> (Mar 05 2021 at 21:04):

The first of those three assumptions should be a global instance

#### <NAME> (Mar 05 2021 at 21:04):

You should indeed assume the other two

#### <NAME> (Mar 05 2021 at 21:06):

Indeed, what is below works!

instance : algebra ℝ≥0 ℝ := nnreal.to_real_hom.to_algebra

lemma pointed_of_nnreal {ι : Type*} [module ℝ M] [semimodule ℝ≥0 M] [is_scalar_tower ℝ≥0 ℝ M]
{v : ι → M} (bv : is_basis ℝ v) :
pointed ℝ (submodule.span ℝ≥0 (set.range v)) :=
pointed_of_is_basis_is_inj (is_inj_nonneg.pR_ocr ℝ) bv

#### <NAME> (Mar 05 2021 at 21:07):

Why do you think that algebra => semimodule and then the nnreal instances are not good? I am not objecting, I am just trying to understand what goes wrong.

#### <NAME> (Mar 05 2021 at 21:09):

I think the key observation is that instead of trying to construct the second module structure to be consistent with the first, you just assume that someone else constructed them in a suitable way

#### <NAME> (Mar 05 2021 at 21:12):

Ok, to me, this seems a different convention than what happens with ℕ and ℤ. However, I can see that maybe ℕ gets treated differently than ℝ. Is this the case?

#### <NAME> (Mar 05 2021 at 21:15):

In any case, if you think that the instance below should go into mathlib, I can PR it (or feel free to do it yourself!), although I am going to bed now, so it will be at some other point!

instance : algebra ℝ≥0 ℝ := nnreal.to_real_hom.to_algebra

#### <NAME> (Mar 05 2021 at 21:17):

That instance definitely belongs in mathlib IMO

#### <NAME> (Mar 05 2021 at 21:24):

I would put it in data/real/nnreal, but there is no import algebra.algebra.basis: it seems too much to import a file simply to use algebra for this instance, though...

#### <NAME> (Mar 05 2021 at 21:31):

N, Z, and Q are special because there are typeclasses for which every instance has an associated algebra - semiring, ring, and division_ring

#### <NAME> (Mar 05 2021 at 21:37):

I can see that, although in the case of division ring, you should also assume char_zero. Anyway, being the initial object of a "natural" category seems like a good place to draw the line!

#### <NAME> (Mar 05 2021 at 23:33):

But all three of those algebra (and semimodule) instances cause nasty non-defeq typeclass diamonds

#### <NAME> (Mar 05 2021 at 23:34):

Eg, a prod of two add_comm_monoids is a nat-module in two ways; by distributing the smul to the components, and by repeated addition

#### <NAME> (Mar 05 2021 at 23:38):

And it only gets worse, a product (M x N) x (P x Q) has 5 nat-module structures, all pairwise non-defeq

#### <NAME> (Mar 06 2021 at 05:16):

Eric, thank you for taking the time to explain the arguments in favour and against these instances!

PR #6560

#### <NAME> (Mar 06 2021 at 08:10):

Now, I guess you'll want \C to inherit that structure too...

#### <NAME> (Mar 06 2021 at 08:19):

Well, I have been working with ordered things, so I will let \C be for the moment... even though Scott was adding orders on \C! :upside_down:

#### <NAME> (Mar 06 2021 at 08:23):

I think docs#complex.algebra_over_reals should be changed to copy across any algebra structure on R, not just R itself

#### <NAME> (Mar 06 2021 at 10:47):

Attempted in #6562

#### <NAME> (Mar 06 2021 at 11:41):

Oooh, I see that this PR is also spraling... I hope that it will be easier than the other instance explosion.

#### <NAME> (Mar 06 2021 at 11:42):

But your observation that ℕ and ℤ are treated specially is salient, as that's where most of the pain in that PR is coming from

#### <NAME> (Mar 06 2021 at 11:45):

Much to my surprise, CI passes already!

#### <NAME> (Mar 06 2021 at 12:00):

I really find these conversations very useful! Thank you for explaining the "Lean translation" of "initial objects in a category".

And I am happy that this is also helpful for the development of the API that you are carrying forward!

Of course, in maths I am also used to making any ring R special/initial, by considering the category of all R-algebras. I can accept that this may not have the status of a "global" instance in Lean.

#### <NAME> (Mar 06 2021 at 12:18):

And thank you for teaching me some category theory words to describe the lean!

#### <NAME> (Mar 11 2021 at 01:05):

<NAME> said:

Now, I guess you'll want \C to inherit that structure too...

As of just now, you should find an algebra ℝ≥0 ℂ instance

Last updated: May 15 2021 at 23:13 UTC


text:
RUS  ENG JOURNALS   PEOPLE   ORGANISATIONS   CONFERENCES   SEMINARS   VIDEO LIBRARY   PACKAGE AMSBIB
 General information Latest issue Archive Impact factor Subscription License agreement Submit a manuscript Search papers Search references RSS Latest issue Current issues Archive issues What is RSS

 F<NAME>. i Prilozhen.: Year: Volume: Issue: Page: Find

 Funktsional. Anal. i Prilozhen., 2015, Volume 49, Issue 1, Pages 49–61 (Mi faa3183)

Systems of Polynomial Equations Defining Hyperelliptic $d$-Osculating Covers

A. Treibichab

a Universit'e d'Artois, Laboratoire de Math'ematique de Lens
b Universidad de la República del Uruguay, Regional Norte

Abstract: Let $X$ denote a fixed smooth projective curve of genus $1$ defined over an algebraically closed field $\mathbb{K}$ of arbitrary characteristic $\boldsymbol{p}\neq2$. For any positive integer $n$, we consider the moduli space $H(X,n)$ of degree-$n$ finite separable covers of $X$ by a hyperelliptic curve with three marked Weierstrass points. We parameterize $H(X,n)$ by a suitable space of rational fractions and apply it to studying the (finite) subset of degree-$n$ hyperelliptic tangential covers of $X$. We find a polynomial characterization for the corresponding rational fractions and deduce a square system of polynomial equations whose solutions parameterize these covers. Furthermore, we also obtain nonsquare systems parameterizing hyperelliptic $d$-osculating covers for any $d>1$.

Keywords: finite separable covers, hyperelliptic curves, Weierstrass points

DOI: https://doi.org/10.4213/faa3183

Full text: PDF file (218 kB)
References: PDF file   HTML file

English version:
Functional Analysis and Its Applications, 2015, 49:1, 40–49

Bibliographic databases:

UDC: 517.9

Citation: A. Treibich, “Systems of Polynomial Equations Defining Hyperelliptic $d$-Osculating Covers”, Funktsional. Anal. i Prilozhen., 49:1 (2015), 49–61; Funct. Anal. Appl., 49:1 (2015), 40–49

Citation in format AMSBIB
\Bibitem{Tre15} \by A.~Treibich \paper Systems of Polynomial Equations Defining Hyperelliptic $d$-Osculating Covers \jour Funktsional. Anal. i Prilozhen. \yr 2015 \vol 49 \issue 1 \pages 49--61 \mathnet{http://mi.mathnet.ru/faa3183} \crossref{https://doi.org/10.4213/faa3183} \zmath{https://zbmath.org/?q=an:06485784} \elib{http://elibrary.ru/item.asp?id=23421403} \transl \jour Funct. Anal. Appl. \yr 2015 \vol 49 \issue 1 \pages 40--49 \crossref{https://doi.org/10.1007/s10688-015-0081-4} \isi{http://gateway.isiknowledge.com/gateway/Gateway.cgi?GWVersion=2&SrcApp=PARTNER_APP&SrcAuth=LinksAMR&DestLinkType=FullRecord&DestApp=ALL_WOS&KeyUT=000351307000004} \scopus{http://www.scopus.com/record/display.url?origin=inward&eid=2-s2.0-84925004450}


text:
# Capacitor

A capacitor is a passive two-terminal electrical component used to store energy electrostatically in an electric field. The forms of practical capacitors vary widely, but all contain at least two electrical conductors (plates) separated by a dielectric (i.e., insulator). Capacitors are widely used as parts of electrical circuits in many common electrical devices. Unlike a resistor, a capacitor does not dissipate energy. Instead, a capacitor stores energy in the form of an electrostatic field between its plates.

Capacitance is expressed as the ratio of the electric charge (Q) on each conductor to the potential difference (V) between them. The SI unit of capacitance is the farad (F). Typical capacitance values range from about 1 pF (10-12 F) to about 470uF (10-6 F).

## Current–voltage relationship

Unlike the resistor, the current voltage relationship of a capacitor is time dependent

$$I(t) = C {dV(t) \over dt}$$

where I is the current in amperes (often shortened to "amps"), V is the potential difference in volts, and C is the capacitance (measured in Farads).

## Capacitor Transient Response

When the switch is first closed, the voltage across the capacitor (assumed fully discharged) is zero volts; thus, it first behaves as though it were a short-circuit. Over time, the capacitor voltage will rise to equal battery voltage, ending in a condition where the capacitor behaves as an open-circuit. Current through the circuit is determined by the difference in voltage between the battery and the capacitor divided by the resistance of R.

Thus the voltage of the capacitor at time 0 is

$$V_c(0) = 0$$

Using KCL, the current through the resistor is the same as that of the capacitor

$${V_o - V_c(t) \over R} = {C {dV_c(t) \over dt}}$$

Rearranging the equation we obtain the following differential equation

$${dV_c(t) \over dt} + {V_c(t) \over RC} - {V_o \over RC} = 0$$

This differential equation has 3 terms, the first derivative of a function, the function itself (with a constant as multiplier) and a constant. The general solution to this type of differential equation has the following form

$$V_c(t) = K_1 e ^ {-{t \over RC}} + K_2$$

where K1 and K2 are constants. To solve for the constants, first we substitute Vc at time 0

\begin{align} V_c(0) = K_1 + K_2 &= 0 \\ K_1 &= - K_2 \end{align}

We rewrite eq 5 in terms of K2

$$V_c(t) = K_2 ( 1 - e ^ {-{t \over RC}})$$

At time infinity, Vc is charged to Vo. The exponent term also tends to 0, allowing for us to solve for K2

\begin{align} V_c(\infty) = K_2 ( 1 - 0 ) &= V_o \\ K_2 &= V_o \end{align}

And we arrive at the voltage of the capacitor

$$V_c(t) = V_o ( 1 - e ^ {-{t \over RC}})$$

Using the same steps, the voltage of a discharging capacitor initially charged at Vo is

$$V_c(t) = V_o e ^ {-{t \over RC}}$$

From eq 9 and 10, we can obtain a universal time constant formula for both charging and discharging

$$change = (f-s)( 1 - e ^ {-{t \over RC}})$$
where
• change is the capacitor voltage change
• f is the capacitor voltage at infinity
• s is the initial voltage of the capacitor

## Capacitors in AC circuits

We can use Ohm's law to describe the relationship of voltage vs current for a capacitor in an AC circuit. Instead of R (resistance) we use (Z) impedance

$$V = IZ$$

Impedance, the vector sum of reactance and resistance, describes the phase difference and the ratio of amplitudes between sinusoidally varying voltage and sinusoidally varying current at a given frequency. The reactance (X) and impedance (Z) of a capacitor are respectively

$$X = -{1 \over {\omega C}} = -{1 \over { 2\pi fC}}$$ $$Z = -{1 \over {j\omega C}} = -{j \over {\omega C}} = -{j \over { 2\pi fC}}$$

where j is the imaginary unit and ω and f is the angular frequency and frequency respectively of the sinusoidal signal. The −j phase indicates that the AC voltage V lags the AC current by 90° unlike the resistor where both the V and I are in phase.

Impedance decreases with increasing capacitance and increasing frequency. This implies that a higher-frequency signal or a larger capacitor results in a lower voltage amplitude per current amplitude — an AC "short circuit" or AC coupling. Conversely, for very low frequencies, the reactance will be high, so that a capacitor is nearly an open circuit in AC analysis.

## Capacitors in Parallel

Capacitors in a parallel configuration each have the same applied voltage. Their capacitances add up.

$$C_{eq} = C_1 + C_2 + ... + C_n$$

## Capacitors in Series

Connected in series, the total voltage difference from end to end is apportioned to each capacitor according to the inverse of its capacitance. The entire series acts as a capacitor smaller than any of its components.

$${1 \over C_{eq}} = {1 \over C_1} + {1 \over C_2} + ... + {1 \over C_n}$$

With advertising revenues falling despite increasing numbers of visitors, we need your help to maintain and improve this site, which takes time, money and hard work. Thanks to the generosity of our visitors who gave earlier, you are able to use this site at no charge.

If you have benefited from this site and are able, please give \$10 via Paypal. It will allow us continue into the future. It only takes a minute. Thanks!


text:
class cirq.google.XmonStepResult(stepper: cirq.google.sim.xmon_stepper.Stepper, qubit_map: Dict, measurements: Dict[str, numpy.ndarray])[source]

Results of a step of the simulator.

qubit_map
A map from the Qubits in the Circuit to the the index
of this qubit for a canonical ordering. This canonical ordering is
used to define the state (see the state_vector() method).
measurements
A dictionary from measurement gate key to measurement
results, ordered by the qubits that the measurement operates on.
__init__(stepper: cirq.google.sim.xmon_stepper.Stepper, qubit_map: Dict, measurements: Dict[str, numpy.ndarray]) → None[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

 bloch_vector_of(qubit) Returns the bloch vector of a qubit in the state. density_matrix_of(qubits) Returns the density matrix of the state. dirac_notation(decimals) Returns the state vector as a string in Dirac notation. sample(qubits, repetitions) Samples from the wave function at this point in the computation. sample_measurement_ops(measurement_ops, …) Samples from the system at this point in the computation. set_state_vector(state, numpy.ndarray]) Updates the state of the simulator to the given new state. simulator_state() Returns the simulator_state of the simulator after this step. state_vector() Return the wave function at this point in the computation.


text:
### 数学代写|黎曼几何代写Riemannian geometry代考|MTH 3022

statistics-lab™ 为您的留学生涯保驾护航 在代写黎曼几何Riemannian geometry方面已经树立了自己的口碑, 保证靠谱, 高质且原创的统计Statistics代写服务。我们的专家在代写黎曼几何Riemannian geometry代写方面经验极为丰富，各种代写黎曼几何Riemannian geometry相关的作业也就用不着说。

• Statistical Inference 统计推断
• Statistical Computing 统计计算
• (Generalized) Linear Models 广义线性模型
• Statistical Machine Learning 统计机器学习
• Longitudinal Data Analysis 纵向数据分析
• Foundations of Data Science 数据科学基础

## 数学代写|黎曼几何代写Riemannian geometry代考|Frobenius’ Theorem

In this section we prove Frobenius’ theorem about vector distributions.
Definition 2.33 Let $M$ be a smooth manifold. A vector distribution $D$ of rank $m$ on $M$ is a family of vector subspaces $D_{q} \subset T_{q} M$, where $\operatorname{dim} D_{q}=m$ for every $q$.

A vector distribution $D$ is said to be smooth if, for every point $q_{0} \in M$, there exists a neighborhood $O_{q_{0}}$ of $q_{0}$ and a family of smooth vector fields $X_{1}, \ldots, X_{m}$ such that
$$D_{q}=\operatorname{span}\left{X_{1}(q), \ldots, X_{m}(q)\right}, \quad \forall q \in O_{q_{0}}$$
Definition 2.34 A smooth vector distribution $D$ (or rank $m$ ) on $M$ is said to be involutive if there exists a local basis of vector fields $X_{1}, \ldots, X_{m}$ satisfying (2.38), and smooth functions $a_{i j}^{k}$ on $M$, such that
$$\left[X_{i}, X_{k}\right]=\sum_{j=1}^{m} a_{i j}^{k} X_{j}, \quad \forall i, k=1, \ldots, m$$
Exercise 2.35 Prove that a smooth vector distribution $D$ is involutive if and only if for every local basis of vector fields $X_{1}, \ldots, X_{m}$ satisfying (2.38) there exist smooth functions $a_{i j}^{k}$ such that (2.39) holds.

Definition 2.36 A smooth vector distribution $D$ on $M$ is said to be flat if for every point $q_{0} \in M$ there exists a local diffeomorphism $\phi: O_{q_{0}} \rightarrow \mathbb{R}^{n}$ such that $\phi_{*, q}\left(D_{q}\right)=\mathbb{R}^{m} \times{0}$ for all $q \in O_{q_{0}}$.

Theorem 2.37 (Frobenius Theorem) A smooth distribution is involutive if and only if it is flat.

Proof The statement is local, hence it is sufficient to prove the statement on a neighborhood of every point $q_{0} \in M$.

## 数学代写|黎曼几何代写Riemannian geometry代考|An Application of Frobenius’ Theorem

Let $M$ and $N$ be two smooth manifolds. Given vector fields $X \in \operatorname{Vec}(M)$ and $Y \in \operatorname{Vec}(N)$ we define the vector field $X \times Y \in \operatorname{Vec}(M \times N)$ as the derivation
$$(X \times Y) a=X a_{y}^{1}+Y a_{x}^{2},$$
where, given $a \in C^{\infty}(M \times N)$, we define $a_{y}^{1} \in C^{\infty}(M)$ and $a_{x}^{2} \in C^{\infty}(N)$ as follows:
$$a_{y}^{1}(x):=a(x, y), \quad a_{x}^{2}(y):=a(x, y), \quad x \in M, y \in N .$$
Notice that, if we denote by $p_{1}: M \times N \rightarrow M$ and $p_{2}: M \times N \rightarrow N$ the two projections, we have
$$\left(p_{1}\right){}(X \times Y)=X, \quad\left(p{2}\right){}(X \times Y)=Y .$$
Exercise 2.40 Let $X{1}, X_{2} \in \operatorname{Vec}(M)$ and $Y_{1}, Y_{2} \in \operatorname{Vec}(N)$. Prove that
$$\left[X_{1} \times Y_{1}, X_{2} \times Y_{2}\right]=\left[X_{1}, X_{2}\right] \times\left[Y_{1}, Y_{2}\right]$$
We can now prove the following result, which is important when dealing with Lie groups (see Chapter 7 and Section 17.5).

## 数学代写|黎曼几何代写Riemannian geometry代考|Cotangent Space

In this section we introduce covectors, which are linear functionals on the tangent space. The space of all covectors at a point $q \in M$, called cotangent space, is in algebraic terms simply the dual space to the tangent space.

Definition 2.42 Let $M$ be an $n$-dimensional smooth manifold. The cotangent space at a point $q \in M$ is the set
$$T_{q}^{} M:=\left(T_{q} M\right)^{}=\left{\lambda: T_{q} M \rightarrow \mathbb{R}, \lambda \text { linear }\right}$$
For $\lambda \in T_{q}^{*} M$ and $v \in T_{q} M$, we will denote by $\langle\lambda, v\rangle:=\lambda(v)$ the evaluation of the covector $\lambda$ on the vector $v$.

As we have seen, the differential of a smooth map yields a linear map between tangent spaces. The dual of the differential gives a linear map between cotangent spaces.

Definition 2.43 Let $\varphi: M \rightarrow N$ be a smooth map and $q \in M$. The pullback of $\varphi$ at point $\varphi(q)$, where $q \in M$, is the map
$$\varphi^{}: T_{\varphi(q)}^{} N \rightarrow T_{q}^{} M, \quad \lambda \mapsto \varphi^{} \lambda,$$
defined by duality in the following way:
$$\left\langle\varphi^{} \lambda, v\right\rangle:=\left\langle\lambda, \varphi_{} v\right\rangle, \quad \forall v \in T_{q} M, \forall \lambda \in T_{\varphi(q)}^{} N .$$ Example 2.44 Let $a: M \rightarrow \mathbb{R}$ be a smooth function and $q \in M$. The differential $d_{q} a$ of the function $a$ at the point $q \in M$, defined through the formula $$\left\langle d_{q} a, v\right):=\left.\frac{d}{d t}\right|{t=0} a(\gamma(t)), \quad v \in T{q} M,$$
where $\gamma$ is any smooth curve such that $\gamma(0)=q$ and $\gamma(0)=v$, is an element of $T_{q}^{} M$. Indeed, the right-hand side of $(2.43)$ is linear with respect to $v$.

## 数学代写|黎曼几何代写Riemannian geometry代考|Frobenius’ Theorem

D_{q}=\operatorname{span}\left{X_{1}(q), \ldots, X_{m}(q)\right}, \quad \forall q \in O_{q_{0}}D_{q}=\operatorname{span}\left{X_{1}(q), \ldots, X_{m}(q)\right}, \quad \forall q \in O_{q_{0}}

[X一世,Xķ]=∑j=1米一个一世jķXj,∀一世,ķ=1,…,米

## 数学代写|黎曼几何代写Riemannian geometry代考|An Application of Frobenius’ Theorem

(X×是)一个=X一个是1+是一个X2,

(p1)(X×是)=X,(p2)(X×是)=是.

[X1×是1,X2×是2]=[X1,X2]×[是1,是2]

## 数学代写|黎曼几何代写Riemannian geometry代考|Cotangent Space

T_{q}^{} M:=\left(T_{q} M\right)^{}=\left{\lambda: T_{q} M \rightarrow \mathbb{R}, \lambda \text { 线性}\正确的}T_{q}^{} M:=\left(T_{q} M\right)^{}=\left{\lambda: T_{q} M \rightarrow \mathbb{R}, \lambda \text { 线性}\正确的}

⟨披λ,在⟩:=⟨λ,披在⟩,∀在∈吨q米,∀λ∈吨披(q)ñ.例 2.44 让一个:米→R是一个平滑的函数并且q∈米. 差速器dq一个功能的一个在这一点上q∈米, 通过公式定义

⟨dq一个,在):=dd吨|吨=0一个(C(吨)),在∈吨q米,

## 有限元方法代写

tatistics-lab作为专业的留学生服务机构，多年来已为美国、英国、加拿大、澳洲等留学热门地的学生提供专业的学术服务，包括但不限于Essay代写，Assignment代写，Dissertation代写，Report代写，小组作业代写，Proposal代写，Paper代写，Presentation代写，计算机作业代写，论文修改和润色，网课代做，exam代考等等。写作范围涵盖高中，本科，研究生等海外留学全阶段，辐射金融，经济学，会计学，审计学，管理学等全球99%专业科目。写作团队既有专业英语母语作者，也有海外名校硕博留学生，每位写作老师都拥有过硬的语言能力，专业的学科背景和学术写作经验。我们承诺100%原创，100%专业，100%准时，100%满意。

## MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。


text:
# Automatic size parenthesis

I am writing a math paper and I have a lot of complicated expressions some with fractions or absolute values, some with normal symbols some with larger symbols etc. So when I use \left( or \right) for parenthesis, they are too big a lot of times (They have other issues of spacing as well which is handled in the mathtools package. But the size is still a problem).

Of course one way out is to manually enter \Big, \big etc. but this becomes problematic as then it is very difficult to be consistent across the document (For e.g. in one formula I use \Big and 20 pages later I use \bigg as I have completely forgotten that I used \Big earlier on).

So is there a way to write a macro that will check the size of the input and then put brackets as either (), \big( \big), \Big( \Big), \bigg( \bigg) or \Bigg( \Bigg)?. Any help would be appreciated!

Edit: See this code for a sample problem

\documentclass{amsart}
\usepackage{mathtools}

\DeclarePairedDelimiter\paren{\lparen}{\rparen}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}

\begin{document}

The parentheses and absolute value are too big
$\int\abs*{\partial_{\alpha '}\frac{1}{Z_{\alpha '}}}^2 \text{ and } \int\paren*{\partial_{\alpha '}\frac{1}{Z_{\alpha '}}}^2$

compared to
$\int\abs[\Big]{\partial_{\alpha '}\frac{1}{Z_{\alpha '}}}^2 \text{ and } \int\paren[\Big]{\partial_{\alpha '}\frac{1}{Z_{\alpha '}}}^2$

\end{document}

• Anyway it should be \bigl( and \bigr). AFAIK, there are no automatically calculating algorithms other than \left and \right. What you see there are the drawbacks of such algorithms. About consistency: you should always get the parenthesis which looks right. There's not a consistency issue imo. – Moriambar Apr 13 '17 at 20:12
• I still think there should be a way to do this. I mean if I could get a handle on the size of the input, then I could just write an if then else code which does this job. Latex definitely calculates these sizes, though I don't know how to access them or what they are called. Having such a code makes life infinitely simpler and elegant as compared to manually entering. – Siddhant Apr 13 '17 at 21:17
• left and right calculate the sizes by creating a subformula, around which they wrap (as far as I understand). Unfortunately, the subformula includes all of the sub elements (how is LaTeX gonna know if something is too high or too low to be comprised in parentheses?) This yields unwanted results, such as the limits of a sum to be comprised by the parentheses, which in turn make the parentheses too big – Moriambar Apr 13 '17 at 21:20
• Have you seen the solutions here? tex.stackexchange.com/q/360996/117534. Otherwise, please give an example of when and how \left( and \right) are not satisfactory. – Troy Apr 14 '17 at 6:51
• I saw the answers. All automatic sizing of () have the same height as that of \left( \right), in all the posts that I have ever seen. – Siddhant Apr 14 '17 at 16:35

The (La)TeX way to typeset autoscaled delimiters is \left and \right. mathtools package provides the \DeclarePairedDelimiter command which corrects their spacing a bit, but still uses them in background
• \bigl, \biggl and similar command for left (i.e. Opening) delimiters
• \bigr, \biggr and such for right (i.e. closing) delimiters


text:
Sensitivity

Definition

Let $f: \{-1,1\}^n \to \{-1,1\}$ be a Boolean function. The local sensitivity of $f$ at point $x$, often denoted $s_f(x)$, is defined as

 $s_f(x) = \#\{y \mid f(x) \neq f(y), |x-y|=1 \}.$

In words, it is the number of neighbors of $x$ on which $f$ changes its value from $f(x)$.

The sensitivity of the function $f$, often denoted $s(f)$, is the maximum over the local sensitivity:

 $s(f) = \max \{s_f(x) \mid x \in \{-1,1\}^n \}.$

Properties

• The expected value of the local sensitivity is equal to the total influence: $\mathbb{E}[s_f] = \mathrm{Inf}(f)$ [1].

References

1. <NAME>, Analysis of Boolean functions, Proposition 27 in section 2.3