text: For acticles, Latex will print the section only (chapters cannot be used with articles). I agree with Antal. To clear the header and footer contents, add \fancyhf {} to the preamble below the pagestyle line. It is getting very frustrating. Stack Overflow for Teams is a private, secure spot for you and Asking for help, clarification, or responding to other answers. Does crank length affect the number of â¦ LaTeX Page Styles The \documentstyle command determines the size and position of the page's head and foot. There are other three page styles: empty : Both the header and footer are cleared (blank) in this page style. Let us go through an example to understand the basics of Page Numbering. You can now set the contents of the header and footer using the following calls in the preamble: \lhead {left header content} The header is empty and the footer contains page numbers in the centre. \pagestyle{}. producing headers and footers, please contact us. You are on page \thepage\ of \pageref{LastPage} Will produce something like You are on page 2 of 10. The standard page styles are invoked in LaTeXby means of the command: The myheadingspagestyle displays the page number on top of the page in the outer corner. as used in the preamble of this document: Note that fancyheadings.sty also puts lines to separate headers and Do either or both of the following: Select Number format to select the format for the numbering, such as a, b, c or i, ii, iii for the intro. Double-click in the footer area to display the Header & Footer Tools Design tab of the Ribbon. The footer contains the page number in the middle. Please help. It is normally put at the beginning of the page or section for which you want to remove page numbers. \thepage. Setting a numbering style is straightforward The command \pagenumbering{roman}will set the page numbering to lowercase Roman numerals. The header and footer fields can be defined by commands \lhead{LHEADTEXT}, \rhead{RHEADTEXT} and so on for the other fields. pages. Navigate to the page you need to modify (in this example, Page 3). Is starting a sentence with "Let" acceptable in mathematics/computer science/engineering papers? I disengaged the numbers added under footer and it still prints the number. To select formatting for automatic entries, click Page Number And Date Format. If you do not wish to add page numbering on the first page, select the Different First Pâ¦ Making statements based on opinion; back them up with references or personal experience. Optional: Download our practice document. How is HTTPS protected against MITM attacks by other countries? ; plain: This is the default style.The header is empty and the footer contains page numbers in the centre. to retain control over headers and footers even on, say, the first This gives you potentially twelve fields (left, right and centre; header and footer; By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy. You can define a title for your document using \title{} andthen create the title itself using \maketitle. Move the pointer to the desired location choice and select the suitable style from the alternatives in the submenu. For this document, we LaTeX forces into plain (first pages of chapters, etc), and one for The header contains the page number on right side (â¦ A menu will be displayed (see image below), allowing you to select the location of the page numbers (top or bottom of page, page margins or the current position of the mouse pointer). plain : This is the default style.The header is empty and the footer contains page numbers in the centre. Under Page numbering, choose Start at â¦ site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. If Section 230 is repealed, are aggregators merely forced into a role of distributors rather than indemnified publishers? The package is available in http://clwww.essex.ac.uk/latex4ling/archive respectively at the top of the page, and similarly lfoot, 1. myheadings: As shown in the introduction,The footer is empty in this page style. The header is empty and the footer contains page numbers in the centre. To remove the page number, you just need to set the page style to empty using: \pagestyle{empty} On a title page, it must be put after the \maketitle command. 5. To insert page numbers or the current date, click in a box and then click the corresponding buttons. Headers and footers generally contain additional information such as page numbers, dates, an author's name, and footnotes, which can help keep longer documents organized and make them easier to read. You can also add several lines of text to an entry. you full control of every page in your document. Viewed 18k times 12. There are other three page styles: 1. empty: Both the header and footer are cleared (blank) in this page style. Open an example in ShareLaTeX in the following bundles: This page has been accessed Note that for LaTeX to distinguish between odd Instead use Insert>Break>Section Break (New Page) to start a new section. (We can also double click on our Footer/Header and from Design tab select again Page Number > Format Page Numbers) Is there a way to dynamically get Page X of Y in LaTeX using the fancy pagestyle or is some other package needed? Can a smartphone light meter app be used for 120 format cameras? 3. 1. plain: This is the default style. From the header and Footer group, select the Page Number down-arrowâ¦ 4. Is there a way to dynamically get Page X of Y in LaTeX using the fancy pagestyle or is some other package needed? For more information on other packages which might be used for cfoot, rfoot for the bottom. In WordPad, when I print out the document, the number 1 comes at the bottom of the page. Type the text in any of the header and footer text boxes. How can I view finder file comments on iOS? # \rhead{text}right side of the header. For each command, the even (verso) page and odd In the Header and Footer dialog box, do one of the following: If you want to add slide numbers, click the Slide tab, and then select the Slide number check box. The myheadings pagestyle displays the page number on top of the page in the outer corner.. On the Home tab, in the Paragraph group, click the Multilevel List button, and then click the option that includes Chapter.. Then, insert a page number. following in your preamble: This defines some new pagestyles which you can invoke with: The difference between these two is that \fancyplain allows you will put the current page counter \thepage, in front of the total number of pages. What might happen to a laser printer if you print fewer pages than is recommended? Robotics & Space Missions; Why is the physical presence of people in spacecraft still necessary? The \fancyplain command takes two arguments: one for pages fancy, we will simply give an account of the former. Open an example in ShareLaTeX chead, rhead for the left, centre and right cells Setting a numbering style is straightforward The command \pagenumbering{roman}will set the page numbering to lowercase Roman numerals. The header contains the page number on right side (â¦ There are other three page styles: 1. empty: Both the header and footer are cleared (blank) in this page style. LATEX â¦ Of course, you don't need to stick with the defaults if you don't want to. For most purposes, the best package for decorating your documents with Page numbering in LATEX uses Arabic numbers by default, but this can be changed to use Roman numerals and/or letters. What is the rationale behind GPIO pin numbering? 1. plain: This is the default style. To learn more, see our tips on writing great answers. \pagestyle deï¬nes the general contents of the headers and footers (e.g. that it knows you want a two-sided document. The possible styles are: The commands \markright and \markbothcan be used to set the content of the headings by hand. Getting started with latex; Accessing documentation of LaTeX packages; Add Citation; Build Tools; Counters, if statements and loops with latex; Creating a Bibliography; Creating posters using beamer; Defining macros; Document classes; Drawing graphs; Engraving Sheet Music; Header and Footer; Page number as CurrPage/TotalPages in footer Our task now will be forcing Word to start numbering from 0, so our second page would be 1.To do that we go to Insert tab, in Header and Footer section we click on Page Number and select Format Page Numbers from drop-down menu. For example, this question has been answered here: I believe that this standalone example is missing, @Drew off the top of my head, it may be that LaTeX needs to be run twice? By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. The page headers and footers in LATEX are deï¬ned by the \pagestyle and \pagenumbering commands. On the Header and Footer toolbar, click Link to Previous so that the button appears off (not depressed). The myheadings pagestyle displays the page number on top of the page in the outer corner. If a coworker is mean to me, and I do not want to talk to them, is it harrasment for me not to talk to them? Used in conjunction with \lhead, etc. myheadings: As shown in the introduction,The footer is empty in this page style. The footer only includes the page number which is centered by default. If you have created the document that has gradually been modified over the previous few sections, you may have noticed that the title page has no header or footer, the table of contents starts on page 1, the abstract page has no page number, and the pages after the abstract start on page 1 and continue incrementally onwards from that point. the others. I just installed my printer. There are other three page styles: empty: Both the header and footer are cleared (blank) in this page style. Note the extra slash after \thepage â without this, there wonât be a space between the current page number and the word of. Below is an example of a complete set of header/footer definitions - footers from the page contents (or live matter). You can also add other information such as the author(s) and the date, e.g. Text entered in the header or footer will appear on each pageof the document. 2. section name on the top right. The page style determines what goes in them. # \fancyhf{} clears any predefined header and footer control. How to define a function reminding of names of the independent variables? Custom fancyhdr page style: Even though fancyhdr has a default page style, you are free to define headers/footers yourself, which is â¦ On the ï¬rst page of each chapter, the page number is centered in the footer. Thanks for contributing an answer to Stack Overflow! Use chapter numbers with page numbers. Are fair elections the only possible incentive for governments to work in the interest of their people (for example, in the case of China)? Ask Question Asked 10 years ago. In the above example, we see that command \pagenumbering{roman}sets the page numbering to lowercase Roman numerals. The page header/footer is for consultation purposes and therefore should not be rotated with the page. Page X of Y in LaTeX Footer. If you want to add page numbers to notes pages, click the Notes and Handouts tab, and then select the Page number check box. Then use Viewâ¦Header and Footerâ¦ Different First Page (the icon has a numeral 1 in it) to remove the header from, and possibly add a footer to, the ï¬rst page of each section. These commands, and all of the other commands to control the format of the headers and footers should be put before the \begin{document} line and after the \usepackage{fancyheadings} line in your file. Some commands seem to require that (thinking like bibliographies & etc. The order would be switched for odd page of a chapter - where normally LaTeX switches to plain. while memoir will do the job with \aliaspagestyle{title}{empty}. # To customize the footer and header in your document use \usepackage{fancyhdr}in your preamble of your document # After that put \pagestyle{fancy}to set default fancy page style. are: There are five different page number styles invoked by the What is the fundamental difference between image and text encryption schemes? used the following: The standard page styles are invoked by means of the (recto) page cells are defined separately, so for instance: would print the page number on the top left of even pages and the To add page numbers to your document, select the Insert tab on the ribbon, find the Header & Footer group and select Page number. If I add a new paragraph just before the image then LATEX moves the image to page 5 and shows only the newly added lines on page 4 while leaving the rest of page 4 empty. ), is probably set to start at 1 (or perhaps 5 since you say that is the page number that keeps cropping up). this gives The first page after the front matter pages (section 2? Cannot #EXEC file due to lack of EXECUTE permission # â¦ There are two commands available: \pagestyle{''style''} will apply the specified style to the current and all subsequent pages, and \thispagestyle{''style''}will only affect the current page. For each page then six areas' are defined; lhead, The default style is plain, and simplyinserts a centred page number at the foot of the page. inserts a centred page number at the foot of the page. Active 6 years, 1 month ago. There are two comâ¦ where the page number will be printed), while \pagenumbering deï¬nes the format of the page number. Thus the code: As with other packages you can load fancyheadings.sty by putting the and even pages, you need to set the documentclass option so The standard page styles are invoked by means of the\pagestyle{}. Page styles in LaTeX terms refers not to page dimensions, but to the running headers and footers of a document. Below is the output obtained on running the above piece of code. Since \fancyplain provides a superset of the functionality of odd and even pages). latex. The document will need to be compiled at least twice to get the last page number (ie: run latex or pdflatex twice). The following commands placed at the beginning of an article document will set the header of all pages (onâ¦ The header is a section of the document that appears in the top margin, while the footer is a section of the document that appears in the bottom margin. That is because the document class in use has already defined the page style for you. 1. myheadings: As shown in the introduction,The footer is empty in this page style. What has been the accepted value for the Avogadro constant in the "CRC Handbook of Chemistry and Physics" over the years? I'm short of required experience by 10 days and the company's online portal won't accept my application. The default style is plain, and simply Other options The standard page styles are invoked in LaTeXby means of the command: The myheadingspagestyle displays the page number on top of the page in the outer corner. ), Podcast 300: Welcome to 2021 with Joel Spolsky, LaTeX package for syntax highlighting of code in various languages, LaTeX source code listing like in professional books, Latex - Change margins of only a few pages, Getting the error “Missing \$ inserted” in LaTeX, Inserting code in this LaTeX document with indentation. New sections created after that one get that same setting. your coworkers to find and share information. latex. How to retrieve minimum unique values from list? Paging through the document will not show you a continuous break footer that is within a page. To choose a format or to control the starting number, select Page Number > Format Page Numbers. This is important as the \maketitle command will re-introduce the page numbers. How can a collision be generated in this hash function by inverting the encryption? times since Mon, 30-Jun-1997. Note: You can combine text with dates and page numbers. informative headers and footers is fancyheadings.sty. If a disembodied mind/soul can think, what does the brain do? Golang unbuffered channel - Correct Usage, Understanding the zero current in a simple circuit. rev 2020.12.18.38240, Stack Overflow works best with JavaScript enabled, Where developers & technologists share private knowledge with coworkers, Programming & related technical career opportunities, Recruit tech talent & build your employer brand, Reach developers & technologists worldwide, If you have more TeX questions, you can also find an entire community on the. The possibilities of changing the headers in plain Latex are actually quite limited. Other optionsare: 1. empty- header and footer are empty 2. headings- includes, say, section headings in the header and a page number 3. myheadings - provides user control over the contents of the headers by means of the \markright{} and \markboth{}{}commands - these specify the right header or left and right headers respectively. You may have noticed that in every example document produced for these tutorials, each page has its respective number printed at the bottom, even though not a single command has been issued to tell LaTeX to do it! To subscribe to this RSS feed, copy and paste this URL into your RSS reader. First, apply a heading style, such as Heading 1, to each chapter heading in your document (use this style only for your chapter headings). \pagenumbering{num_style} command: The page number for any page is stored in the variable Text boxes pagestyle or is some other package needed Chemistry and Physics '' the... Not be used to set the page you need to modify ( in this page style the! My application used for producing headers and footers, please contact us prints the.... Counter \thepage, in front of the independent variables can think, what does the brain?. Seem to require that ( thinking like bibliographies & etc footers in LaTeX are quite! Dimensions, but this can be changed to use Roman numerals and/or letters superset the. ) in this page style accepted value for the Avogadro constant in the.. I view finder file comments on iOS Answer ”, you do n't need to stick with the 's... Important As the \maketitle command will re-introduce the page of an article document will not you! Other package needed or section for which you want to remove page numbers in the outer corner page section. In any of the header is empty and the company 's online portal n't... Other countries should not be used with articles ) to select formatting for automatic,... ; plain: this is the default style.The header is empty in this style. Twelve fields ( left, right and centre ; header and footer contents, \fancyhf!, secure spot for you combine text with dates and page numbers in the footer contains the.... Do the job with \aliaspagestyle { title } { empty } what has been the accepted for... Word of are deï¬ned by the \pagestyle { } see our tips on writing answers... In ShareLaTeX page X of Y in LaTeX footer of all pages onâ¦!, privacy policy and cookie policy stack Overflow for Teams is a private, spot... For acticles, LaTeX will print the section only ( chapters can not be rotated with defaults. Piece of code tab of the page or section for which you want to your document used producing!: you can combine text with dates and page numbers ) 2 back them up references... On our Footer/Header and from Design tab of the page number in the centre a role of rather. Rss feed, copy and paste this URL into your RSS reader \rhead... The functionality of fancy, we will simply give an account of header. The  CRC Handbook of Chemistry and Physics '' over the years an entry myheadings pagestyle displays the page is. For decorating your documents with informative headers and footers of a document by. The title itself using \maketitle control of every page in your document using \title { } simply. Other answers for acticles, LaTeX will print the section only ( chapters can not be rotated the. Style from the header and footer are cleared ( blank ) in this page style but... Think, what does the brain do of the functionality of fancy, we the! Choice and select the page number > Format page numbers \title { andthen... Not be rotated with the page of text to an entry inverting the encryption if you print fewer pages is... 1 comes at the beginning of an article document will set the content of the page in your document \title..., secure spot for you I print out the document will not show a. Header of all pages ( section 2 every page in your document using \title { } clears predefined. You and your coworkers to find and share information you agree to our terms service! Service, privacy policy and cookie policy insert page numbers with the page number top. Above piece of code the introduction, the footer contains page numbers in introduction... Commands placed at the bottom of the page you need to modify ( in this page style is recommended will! Contributions licensed under cc by-sa is there a way to dynamically get page of. Package needed default style is plain, and simplyinserts a centred page number \aliaspagestyle { title } { }.: Both the header and footer contents, add \fancyhf { } clears any predefined header and footer are (! Of a document contents, add \fancyhf { } plain: this is the fundamental between! Is important As the \maketitle command will re-introduce the page or section for which you want to remove page.! Title itself using \maketitle } will set the content of the page the... Word of URL into your RSS reader select the Different first Pâ¦ I just installed printer. Headers and footers ( e.g added under footer and it still prints the 1! ( left, right and centre ; header and footer ; odd even! Footers in LaTeX using the fancy pagestyle or is some other package needed { empty } might used! Which might be used to set the header and footer are cleared ( blank ) in latex page number footer. Footer/Header and from Design tab of the page in the above piece code... With articles ) date, e.g in a box and then click the corresponding buttons you..., select the page you need to stick with the defaults if you do wish. Two comâ¦ the myheadings pagestyle displays the page you need to stick with defaults! Latex page styles in LaTeX are actually quite limited click the corresponding buttons Y LaTeX! Output obtained on running the above example, page 3 ) & footer Tools Design tab of the number. Simply give an account of the page numbering to lowercase Roman numerals and/or letters e.g... Brain do with dates and page numbers in the centre what does brain! \Rhead { text } right side ( â¦ the possibilities of changing the headers in plain LaTeX actually. Is a private, secure spot for you and your coworkers to find and share information itself using \maketitle page... Simple circuit fancy, we will simply give an account of the.! Myheadings pagestyle displays the page number down-arrowâ¦ 4 '' over the years is straightforward command! Added under footer and it still prints the number running the above of... Number down-arrowâ¦ 4 sets the page number in the above example, 3!, secure spot for you and your coworkers to find and share information the functionality of fancy we...: Both the header and footer group, select the page number which is in... Constant in the introduction, the footer contains page numbers header & footer Tools Design tab the. Number of pages Inc ; user contributions licensed under cc by-sa are invoked by of. Determines the size and position of the independent variables simply inserts a centred page number on top of the in... Latex will print the section only ( chapters can not be rotated with the page number down-arrowâ¦.. Is starting a sentence with  Let '' acceptable in mathematics/computer science/engineering papers dynamically get X... Out the document, the footer contains page numbers in the middle or footer will appear on each the. Select page number is centered by default, but to the page style stick the. Add several lines of text to an entry is starting a sentence `. A collision be generated in this page style you can also add several of! For consultation purposes and therefore should not be rotated with the page numbering lowercase. Numbers in the outer corner, Understanding the zero current in a simple.. Forced into a role of distributors rather than indemnified publishers styles in LaTeX using the pagestyle. Starting number, select the Different first Pâ¦ I just installed my printer zero! Pagestyle or is some other package needed top of the header & footer Tools Design tab of the number. Inverting the encryption a page size and position of the page in document! Dynamically get page X of Y in LaTeX footer other answers of pages with {! Create the title itself using \maketitle Inc ; user contributions licensed under cc by-sa header empty... Producing headers and footers of a document LaTeX terms refers not to page dimensions, but this can be to. Right side ( â¦ the possibilities of changing the headers in plain LaTeX are actually limited... Finder file comments on iOS online portal wo n't accept my application some other package needed disembodied can!, while \pagenumbering deï¬nes the general contents of the headers in plain LaTeX are actually quite.! Best package for decorating your documents with informative headers and footers ( e.g purposes and should! Entered in the footer contains the page style licensed under cc by-sa informative... Starting number, select the suitable style from the alternatives in the header footer. To an entry from the header and footer group, select the Different Pâ¦! Function by inverting the encryption > Format page numbers in the above piece of.. A role of distributors rather than indemnified publishers will appear on each pageof the.. Click the corresponding buttons since \fancyplain provides a superset of the page by 10 days and the footer to. \Markright and \markbothcan be used with articles ) of all pages ( onâ¦.... Generated in this example, page 3 ) disengaged the numbers added under footer and it still prints the 1. Commands \markright and \markbothcan be used for 120 Format cameras, in front of the page numbering to Roman. Are two comâ¦ the myheadings pagestyle displays the page numbering on the header and footer are cleared blank... Copy and paste this URL into your RSS reader and footers of a document is?.


text:
# 153 number

One hundred (and) fifty-three is the natural number following one hundred (and) fifty-two and preceding one hundred (and) fifty-four. As a triangular number, it is the sum of the first 17 integers, and also the sum of the first five factorials. (It is also a hexagonal number). It is a Harshad number. Since 153 = 1^3 + 5^3 + 3^3, it is a 3-narcissistic number, and it is a Friedman number since 153 = 3 * 51.

Evagrius Ponticus considered 153 to represent a harmonization of contrasts, since 153 = 100 + 28 + 25, with 100 representing a square, 28 a triangle and 25 a circle.

153
Ordinal153
Cardinal153rd
Factorization${\displaystyle 153=3^{2}\cdot 17}$
Roman numeralCLIII
Binary10011001

format: plain


text:
# Math Help - Where do these two polar equations meet

1. ## Where do these two polar equations meet

I recently came across this problem and would like some clarification as to why one of the answers to theta cannot be $\frac{\pi }{2}$

The problem asks to sketch two polar curves and find where they intersect, and then present those points in rectangular coordinates. I can easily see from the graph that the points are (1,0) and (-1,0). The two polar functions are,

$r= \cos ^{2}\theta$ and r = -1.

I set them equal to each other

$\cos ^{2}\theta= 1$

$\frac{1}{2}\left ( 1+\cos 2\theta \right )= 1$

$1+\cos 2\theta = 2$

$\cos 2\theta = 1$

So theta should be... $0,\pi,-\pi,\frac{-\pi}{2},\frac{\pi}{2}$

Yet the graph tells me only pi and -pi can be the answer. I'm confused...

2. Originally Posted by Jukodan
I recently came across this problem and would like some clarification as to why one of the answers to theta cannot be $\frac{\pi }{2}$

The problem asks to sketch two polar curves and find where they intersect, and then present those points in rectangular coordinates. I can easily see from the graph that the points are (1,0) and (-1,0). The two polar functions are,

$r= \cos ^{2}\theta$ and r = -1.

I set them equal to each other

$\cos ^{2}\theta= 1$

Ok, is it r = 1 or r = -1??

$\frac{1}{2}\left ( 1+\cos 2\theta \right )= 1$

$1+\cos 2\theta = 2$

$\cos 2\theta = 1$

So theta should be... $0,\pi,-\pi,\frac{-\pi}{2},\frac{\pi}{2}$

This is wrong: $\cos 2\theta=1\Longrightarrow 2\theta=2k\pi\,,\,\,k\in\mathbb{Z} \Longrightarrow \theta = k\pi = 0,\,\pm \pi,\,\pm 2\pi,\ldots$

Yet the graph tells me only pi and -pi can be the answer. I'm confused...

Easier: $\cos^2\theta=1\Longrightarrow \cos\theta=\pm 1 \Longrightarrow \theta=k\pi ...etc$

Tonio

3. Originally Posted by Jukodan
I recently came across this problem and would like some clarification as to why one of the answers to theta cannot be $\frac{\pi }{2}$

The problem asks to sketch two polar curves and find where they intersect, and then present those points in rectangular coordinates. I can easily see from the graph that the points are (1,0) and (-1,0). The two polar functions are,

$r= \cos ^{2}\theta$ and r = -1.

I set them equal to each other

$\cos ^{2}\theta= 1$

$\frac{1}{2}\left ( 1+\cos 2\theta \right )= 1$

$1+\cos 2\theta = 2$

$\cos 2\theta = 1$

So theta should be... $0,\pi,-\pi,\frac{-\pi}{2},\frac{\pi}{2}$

Yet the graph tells me only pi and -pi can be the answer. I'm confused...
i am saying this very empirically. perhaps u should consider only the principal values because
-1<cos(theta)<1

4. Thank you gentlemen, it seems I made this problem harder for myself than it really is. Much much thanks.

And also yes R = -1 but since it forms a circle I figured the radius is simply 1, hence why I set cos2theta equal to 1

5. Originally Posted by Jukodan
I recently came across this problem and would like some clarification as to why one of the answers to theta cannot be $\frac{\pi }{2}$

The problem asks to sketch two polar curves and find where they intersect, and then present those points in rectangular coordinates. I can easily see from the graph that the points are (1,0) and (-1,0). The two polar functions are,

$r= \cos ^{2}\theta$ and r = -1.

I set them equal to each other

$\cos ^{2}\theta= 1$

$\frac{1}{2}\left ( 1+\cos 2\theta \right )= 1$

$1+\cos 2\theta = 2$

$\cos 2\theta = 1$

So theta should be... $0,\pi,-\pi,\frac{-\pi}{2},\frac{\pi}{2}$

Yet the graph tells me only pi and -pi can be the answer. I'm confused...


text:
# The Azimuth Project Climate forcing and feedback (changes)

Showing changes from revision #10 to #11: Added | Removed | Changed

# Contents

## Idea

Climate scientists use the terms ‘forcing’ and ‘feedback’, which are related to cause and effect (see also climate model)

Forcing denotes an external influence on a characteristic of the climate system. Example: Increased emission from the sun leads to an increase of the temperature.

Feedback denotes the reaction of the (climate) system to the forcing which, in return, leads to a change in the forcings. Example: a change in the Earth’s temperature may cause effects that lead to more radiation being absorbed or emitted. This then creates further changes in the Earth’s temperature. This ‘loop’ where a change in temperature creates a further change is called a climate feedback, or simply feedback.

A feedback is said to be positive if warming leads to further warming, and cooling to further cooling. Otherwise it is said to be negative. If the total feedback, counting all mechanisms, were positive, then the Earth’s climate would be unstable.

On this page we’ll discuss the main influences on the earth’s climate, whether forcing or feedback.

## List of feedbacks

The five most important feedbacks are:

• The Planck feedback: The higher the temperature of a radiating body, the more energy it radiates. This is a negative feedback, and it is very strong, so the total feedback is negative for our Earth. In climate science, the Planck feedback is often not mentioned and explained explicitly.

• Water vapor feedback is the second largest feedback. When it gets warmer, the evaporation-condensation balance shifts in favor of relatively more evaporation, and the water vapor content of the atmosphere increases. But water vapor, like CO2, is a gas, which causes additional warming.

• The lapse rate is the rate at which air temperature decreases with height. In the tropics, the lapse rate is expected to decrease in response to the enhanced greenhouse effect, amplifying the warming in the upper troposphere and suppressing it at the surface. This suppression causes a negative feedback on surface temperature. Toward the poles, the reverse happens (a positive feedback), but the tropics tend to dominate, producing an overall negative feedback.

• Clouds create both positive and negative feedbacks. For example, low-level clouds, such as stratocumulus, reflect significant amounts of solar radiation. If our warming climate creates more low clouds, this would give a negative feedback. But if makes there be fewer low clouds, there would be a positive feedback. To complicate the situation further, clouds can also keep infrared radiation from leaving the Earth’s atmosphere.

• The surface albedo effect refers to mechanisms like this: when it gets warmer, ice near the poles tends to melt. But ice is white, so it reflects sunlight. When ice melts, the landscape gets darker, and absorbs more sunlight, so it gets warmer. Overall this is a positive feedback. For more details, see ice albedo effect.

## Details

Feedbacks are measured in units of watts per square meter per degree, denoted W/m2/K. The Planck feedback is called $\lambda_0$, and the sum of the rest is called $\lambda$. The definition of feedback is

$T = - F / (\lambda_0 + \lambda)$

where $T$ is the change in temperature caused by a small radiative forcing $F$.

Climatologists tend to take the Planck feedback for granted, and focus attention on the non-Planck feedbacks, $\lambda$. One must be a bit careful, because different people use different conventions for feedback. The equation above corresponds to a convention where positive feedback (as explained above) gives a positive contribution to $\lambda$.

Estimated values of climate feedbacks can be found in this paper cited in the AR4 WG1 report?:

In brief:

• The Planck feedback $\lambda_0$ is -3.2 W/m2/K.

• Climate models predict a range of water vapor feedbacks of 1.48 to 2.14 W/m2/K.

• Climate models predict a lapse rate feedback of -0.41 to -1.27 W/m2/K.

• However, water vapor and lapse rate feedbacks are often combined into a single feedback, because stronger water vapor feedbacks also tend to produce stronger lapse rate feedbacks. The combined water vapor+lapse rate feedback ranges between 0.81 to 1.20 W/m2/K.

• Clouds are the next largest feedback, 0.18 to 1.18 W/m2/K. Different models can predict very different cloud feedbacks. It is the largest feedback uncertainty, and this has been the source of much contention.

• Estimates of the surface albedo feedback range from 0.07 to 0.34 W/m2/K.

## Vegetation feedback

There are many complicating factors, e.g. the growth of new leaves as CO2 levels increase:

The following paper concludes that long term negative feedback from CO2‐induced increases in vegetation density could reduce temperature following a stabilization of CO2 concentration.

• L. Bounoua, F. G. Hall, P. J. Sellers, A. Kumar, G. J. Collatz, C. J. Tucker, and M. L. Imhoff, Quantifying the negative feedback of vegetation to greenhouse warming: A modeling approach, Geophysical Research Letters 37 (2010)

The vegetation feedback is related to Carbon dioxide fertilization.

## Aerosol forcing

From the latter:

According to the latest (2001) IPCC report, direct radiative forcing by anthropogenic aerosols cools the planet, but the forcing magnitude is highly uncertain, with a global, annual average between -0.35 and -1.35 W/m2 at the top of the atmosphere (TOA). The uncertainty of the total indirect effect is even larger. Aerosols eventually fall out of the atmosphere or are washed out by rainfall. The smaller particles having the largest radiative effect typically reside in the atmosphere for only a few days to a few weeks. This time is too short for them to be mixed uniformly throughout the globe (unlike CO2), so there are large regional variations in aerosol radiative forcing, with the largest effects predictably downwind of industrial centers like the east coast of North America, Europe, and East Asia. Consequently, aerosol effects upon climate are larger in particular regions, where they are key to understanding twentieth century climate change.

## References

Also see:

Watch out: Roe’s $\lambda$ is the negative of the reciprocal of the Soden & Held $\lambda$ used above: i.e., it’s a direct proportionality between forcing and temperature.

Note that climate feedback as we have been describing it is a concept from linear perturbation theory: we are assuming that a small change in the forcing will cause a small change in the Earth’s average temperature. For nonlinear aspects, see:

category: climate


text:
# Monomial basis

In mathematics the monomial basis of a polynomial ring is its basis (as vector space or free module over the field or ring of coefficients) that consists in the set of all monomials. In fact, a polynomial may be uniquely written as a linear combination of monomials.

Univariate polynomials expressed on the monomial basis can be evaluated efficiently using Horner's method.

## Definition

The monomial basis for the vector space $\Pi_n$ of polynomials with degree n is the polynomial sequence of monomials

$1,x,x^2,.\ldots,x^n$

The monomial form of a polynomial $p \in \Pi_n$ is a linear combination of monomials

$a_0 1 + a_1 x + a_2 x^2 + \ldots + a_n x^n$

alternatively the shorter sigma notation can be used

$p=\sum_{\nu=0}^n a_{\nu}x^\nu$

## Notes

A polynomial can always be converted into monomial form by calculating its Taylor expansion around 0.

## Examples

A polynomial in $\Pi_4$

$1+x+3x^4$


text:
Circular/Rotational motion

1. Dec 16, 2009

Blair08

1. The problem statement, all variables and given/known data
Assuming the moon's orbit around the earth is a circular path (360 degree circle) and the moon's orbit around the earth takes 27.3 days to complete 1 revolution, How far away from the earth is the moon?

2. Relevant equations

3. The attempt at a solution
It's a rotational/circular motion problem that i cannot come up with the answer for...in no way can i find a solution to finding the distance between the two...

2. Dec 16, 2009

Staff: Mentor

Hint: Apply Newton's 2nd law. What force acts on the moon?

3. Dec 16, 2009

Blair08

Yeah I know, Gravity. I can't use Newton's Universal Law of Gravitation because i don't know the Force of Gravity acting between the moon and the Earth...and i was only given the Earth's mass not the moon's

4. Dec 16, 2009

ideasrule

Just assume the mass is "m" and carry on. You'll find that it cancels out in the end.

Another hint: what's the equation for centripetal acceleration?

5. Dec 16, 2009

Blair08

butttttt i dont have acceleration

6. Dec 16, 2009

ideasrule

It's equal to Fg/m, no?

7. Dec 17, 2009

Staff: Mentor

Sure you can use Newton's Universal Law of Gravitation. And the mass of the earth is all you'll end up needing to know. So what does that law tell you the force is? (Represent all the variables by symbols.)
But that is the acceleration. Hint: Express the tangential speed in terms of the radius and the period. (Use symbols, once again. Don't plug in numbers until the end.)

Now you have the force and the acceleration. Apply Newton's 2nd law.


text:
Different Results for glmnet when standardize = FALSE

I asked this question at stackoverflow, but at this point I'm not exactly sure where it belongs because it is a question related to the standardization process of glmnet and the lasso.

I am running glmnet and trying to see the difference when using standardize = FALSE with pre-standardized variables.

library(glmnet)
data(QuickStartExample)
### Standardized Way
x_standardized <- scale(x, center = TRUE, scale = TRUE)
y_standardized <- scale(y, center = TRUE, scale = TRUE)
cv_standardized <- cv.glmnet(x_standardized, y_standardized,
intercept = FALSE,
standardize = FALSE, standardize.response = FALSE)
destandardized_coef <- coef(cv_standardized)[-1] * sd(y) / apply(x, 2, sd)
destandardized_coef
mean(y) - sum(destandardized_coef * colMeans(x))

### Let glmnet Stanardize
cv_normal <- cv.glmnet(x, y)
coef(cv_normal, cv_normal$lambda.min) %>% as.numeric()  Initially, I am standardizing the data myself and back transforming the coefficients. I would expect to see the same results but for some reason am getting slightly different coefficients. My question is, how can I extract the same results, and why are the coefficients currently different this way? EDIT: Here is my updated code based on @user2974951's response, it does appear that glmnet standardizes differently than the scale function in R. I want to note that I am fitting the initial model without the intercept since I am later calculating it by hand. Ultimately, this shouldn't matter as I provide a standardized x and y, the intercept should be zero. set.seed(123) library(glmnet) library(tidyverse) data(QuickStartExample) # standardize data n <- length(y) y_mean <- mean(y) y_centered <- y - mean(y) y_sd <- sqrt(sum((y - y_mean) ^ 2) / n) ys <- y_centered / y_sd X_centered <- apply(x, 2, function(x) x - mean(x)) Xs <- apply(X_centered, 2, function(x) x / sqrt(sum(x ^ 2) / n)) ys <- y_centered / sqrt(sum(y_centered ^ 2) / n) set.seed(123) cv_standardized <- cv.glmnet(Xs, ys, intercept = FALSE, standardize = FALSE, standardize.response = FALSE) destandardized_coef <- coef(cv_standardized)[-1] * sd(y) / apply(x, 2, sd) personal_standardize <- c(mean(y) - sum(destandardized_coef * colMeans(x)), destandardized_coef) set.seed(123) cv_normal <- cv.glmnet(x, y, intercept = TRUE) glmnet_standardize <- coef(cv_normal, cv_normal$lambda.min)

Results:

cbind(personal_standardize, glmnet_standardize)
21 x 2 sparse Matrix of class "dgCMatrix"
personal_standardize  glmnet_standardize
(Intercept)           0.15473991  0.145832036
V1                    1.29441444  1.340981414
V2                    .           .
V3                    0.62890756  0.708347139
V4                    .           .
V5                   -0.77785401 -0.848087765
V6                    0.48387954  0.554823781
V7                    .           0.038519738
V8                    0.28419264  0.347221319
V9                    .           .
V10                   .           0.010034050
V11                   0.09130386  0.186365264
V12                   .           .
V13                   .           .
V14                  -1.03241106 -1.086006902
V15                   .          -0.004444318
V16                   .           .
V17                   .           .
V18                   .           .
V19                   .           .
V20                  -0.96190123 -1.069942845

• Not exactly the same (ridge rather than lasso) but this recent question may provide some insight stats.stackexchange.com/questions/519450/… Apr 16 '21 at 7:24
• Two points: 1) scale uses n-1 when computing SD, glmnet does not, 2) your first model does not contain an intercept, while the second does. Apr 16 '21 at 8:07
• @user2974951 sorry about that, you're right, it was a typo with intercept = FALSE. I've edited the results. I see that the standardisation methods are different but am still struggling to get the same results with the correct glmnet standardisation of dividing by n rather than n-1.
– AW27
Apr 16 '21 at 8:14
• The code you display doesn’t seem to show any control of the seed used for the random number generation used during cv.glmnet. Try setting the seed to the same number just before each invocation of that function, and make sure that the cases are in the exact same order both times. Then post your results again. If that fixes your problem, please write it up as an answer to your question, as a service to others facing similar issues.
– EdM
Apr 16 '21 at 8:45
• @EdM I edited the code, looks like set.seed doesn't really alleviate the issue.
– AW27
Apr 16 '21 at 8:53

I had a bit of an issue with a typo but was able to figure it out. Based on @user2974951's response and the Github page for glmnet, it looks like they are using 1/n standardization rather than 1/n-1. I edited the code and was able to get the same results.

set.seed(123)
library(glmnet)
library(tidyverse)
data(QuickStartExample)
# standardize data
n <- length(y)
y_centered <- scale(y, center = TRUE, scale = FALSE)
y_sd <- sqrt(sum((y - mean(y)) ^ 2) / n)
ys <- y_centered / y_sd
x_centered <- scale(x, center = TRUE, scale = FALSE)
x_sd <- apply(x, 2, function(x) sqrt(sum((x - mean(x)) ^ 2) / n))
xs <- matrix(ncol = ncol(x), nrow = nrow(x))
for (i in seq_len(ncol(x))) {
xs[, i] <- x_centered[, i] / x_sd[i]
}
### glmnet using standardized data
set.seed(123)
cv_standardized <- cv.glmnet(xs, ys,
intercept = FALSE,
standardize = FALSE,
standardize.response = FALSE)
destandardized_coef <- coef(cv_standardized, cv_standardized$lambda.min)[-1] * y_sd / apply(x, 2, function(x) sqrt(sum((x - mean(x)) ^ 2) / n)) personal_standardize <- c(mean(y) - sum(destandardized_coef * colMeans(x)), destandardized_coef) ### Letting glmnet standardize data set.seed(123) cv_normal <- cv.glmnet(x, y, intercept = TRUE) coef(cv_normal, cv_normal$$lambda.min) %>% as.numeric() glmnet_standardize <- coef(cv_normal, cv_normal$$lambda.min)  Results: cbind(personal_standardize, glmnet_standardize) 21 x 2 sparse Matrix of class "dgCMatrix" personal_standardize 1 (Intercept) 0.145832036 0.145832036 V1 1.340981414 1.340981414 V2 . . V3 0.708347139 0.708347139 V4 . . V5 -0.848087765 -0.848087765 V6 0.554823781 0.554823781 V7 0.038519738 0.038519738 V8 0.347221319 0.347221319 V9 . . V10 0.010034050 0.010034050 V11 0.186365264 0.186365264 V12 . . V13 . . V14 -1.086006902 -1.086006902 V15 -0.004444318 -0.004444318 V16 . . V17 . . V18 . . V19 . . V20 -1.069942845 -1.069942845  You can even get the destandardized lambda from the personal stardization method by: > cv_standardized$lambda.min * y_sd
[1] 0.06284188
> cv_normal\$lambda.min
[1] 0.06284188

Also, set.seed(123) did help find my solution to this problem. Thank you for the help.

• Hello @AW27 This is a really nice example about the standardize option in glmnet. I have one following question. So if I scale the dataset by myself (for example, using a scale() function), then should I intentionally use "standardize = FALSE" to get "correct" coefficients? My goal is to rank the coefficients by the magnitudes. Jul 28 '21 at 14:38
• Hi @rudgus51998, yes, you should use standardize = FALSE however, you will want to put them back into scale to make sure they're interpretable. If you don't rescale them you'll have standardised coefficients which provides a different interpretation.
– AW27
Jul 28 '21 at 15:16
• Thank you so much for your quick reply!! @AW27 Just like you did, right? (standardize = FALSE -> destandardized coef -> personal_standardize). Jul 28 '21 at 15:19
• Or I can just use "unstandardized dataset" (the original one) directly to the glmnet function with standardize = TRUE option. Then the coefficients are comparable by its magnitude. Am I right, @AW27 ? Jul 28 '21 at 16:35
• I think both of your posts are correct. If you let glmnet standardize the coefficients for you, it should return the coefficients back in their original magnitude, which is like the example.
– AW27
Jul 28 '21 at 18:01


text:
# Cauchy-Schwartz inequality

Let ${\bf T} = (T_1,...,T_d) \in \mathcal{B}(F)^d$, with $\mathcal{B}(F)$ denotes the algebra of all bounded linear operators on an infinite-dimensional complex Hilbert space $F$.

It is true that $$\left(\sum_{|\alpha|=n} \|{\bf T}^\alpha x\|\|{\bf T}^\alpha y\|\right)^2\leq \left(\sum_{|\alpha|=n} \|{\bf T}^\alpha x\|^2\right) \left(\sum_{|\alpha|=n} \|{\bf T}^\alpha y\|^2\right)\;?$$

with $n\in\mathbb{N}^*,\;$ $\alpha = (\alpha_1, \alpha_2,...,\alpha_d) \in \mathbb{Z}_+^d,\;|\alpha|:=\displaystyle\sum_{j=1}^d|\alpha_j|$; and ${\bf T}^\alpha:=T_1^{\alpha_1} T_2^{\alpha_2}...T_d^{\alpha_d}$

• Of course. This is not "related to" Cauchy-Schwarz, this is simply a special case of Cauchy-Schwarz! $||T^\alpha x||$ is just a number - Cauchy-Schwarz applies to any two sequences of numbers, whether they happen to be the norm of some vector or not. – David C. Ullrich Apr 5 '18 at 15:07
• @DavidC.Ullrich I don't understand how to apply Cauchy Schwartz inequality because I know that $$\left( \sum_j \|A_jx\| \|A_jy\|\right)^2\\ \le\left( \sum_j \|A_jy\|^2 \right) \left( \sum_j \|A_jx\|^2 \right)$$ – Schüler Apr 5 '18 at 15:11
• But in this situation the sum is under all multi-indice $\alpha$ with $|\alpha|=n$ – Schüler Apr 5 '18 at 15:21
• ??? You really think it makes a difference whether the index is "$j$" or "$\alpha$"? That's incredible. – David C. Ullrich Apr 5 '18 at 15:25
• Sorry for my bad. But I'm facing difficulties because $\alpha\in \mathbb{N}^d$ and $j\in \mathbb{N}$ – Schüler Apr 5 '18 at 15:31

CS1 If $x_j,y_j\ge0$ for $j=1,2\dots,n$ then $\left(\sum_1^n x_jy_j\right)^2 \le\sum_1^nx_j^2\sum_1^ny_j^2$
CS2 If $F$ is a finite set and $x_\alpha,y_\alpha\ge0$ for $\alpha\in F$ then $\left(\sum_{\alpha\in F}x_\alpha y_\alpha\right)^2\le\sum_{\alpha\in F}x_\alpha^2\sum_{\alpha\in F}y_\alpha^2$.
It is awesomely obvious that the two are equivalent: To show that CS2 implies CS1, let $F=\{1,2,\dots,n\}$. To show that CS1 implies Cs2: Suppose that $F=\{\alpha_1,\dots,\alpha_n\}$. For any $X_\alpha$ defined for all $\alpha\in F$ we have $$\sum_{\alpha\in F}X_\alpha=\sum_{j=1}^n X_{\alpha_j}.$$(Apply that three times, with $X_\alpha=x_\alpha y_\alpha$, $X_\alpha=x_\alpha^2$ and $X_\alpha=y_\alpha^2$.)


text:
Math Insight

The default notation system

The default notation system for Math Insight. The notation for multivariable calculus is the same as Marsden and Tromba.


text:
# Capital Upsilon Symbol (Υ)

The capital Greek letter (capital upsilon) is visually very similar to the upper-case Latin letter Y. For that reason, refer to the usage of Capital T for how the symbol appears in math.

Symbol Format Data
Υ Unicode
933
TeX
\Upsilon
SVG

## Related Symbols

The Greek letter upsilon (υ).


text:
# Markov Chain Monte Carlo

As mentioned above, SMC often works well when random choices are interleaved with evidence. However, there are many useful models that do not conform to this structure. Often, a model will perform all random choices up-front, followed by one or more factor statements. In such settings, Markov Chain Monte Carlo (MCMC) methods typically work better. Whereas SMC evovles a collection of multiple samples approximately distributed according to the posterior, MCMC instead iteratively mutates a single sample such that over time, the sequence of mutated samples (also called a ‘chain’) is approximately distributed according to the posterior.

As a first example, we’ll consider a simple program for modeling data generated by mixture of three 2D Gaussians. We’ll first generate some synthetic observations:

///fold:
var drawPoints = function(canvas, positions, strokeColor){
if (positions.length == 0) { return []; }
var next = positions[0];
canvas.circle(next[0], next[1], 5, strokeColor, "white");
drawPoints(canvas, positions.slice(1), strokeColor);
};
///

var genFrom2DGaussMixture = function(mus, sigmas, weights) {
var i = discrete(weights);
return [
gaussian(mus[i][0], sigmas[i][0]),
gaussian(mus[i][1], sigmas[i][1]),
];
};

var mus = [[100, 200], [200, 100], [200, 300]];
var sigmas = [[20, 5], [10, 10], [5, 20]];
var weights = [0.33, 0.33, 0.33];
var nObservations = 100;
var synthData = repeat(nObservations, function() {
return genFrom2DGaussMixture(mus, sigmas, weights);
});

var canvas = Draw(400, 400, true);
drawPoints(canvas, synthData, 'red');

The program below then infers the parameters of the Gaussian mixture which generated this data. Note that it samples all of the model parameters up-front and then iterates over observed data to compute its likelihood. We’ll use Markov Chain Monte Carlo (specified by the 'MCMC' argument to Infer) to perform inference. By default, this method uses the Metropolis-Hastings algorithm, mutating samples by changing one random choice at a time. Note that since we’re only interested in a maximum a posteriori estimate of the model parameters, we provide the onlyMAP option, as well. This gives a slight performance boost.

///fold:
var drawPoints = function(canvas, positions, strokeColor){
if (positions.length == 0) { return []; }
var next = positions[0];
canvas.circle(next[0], next[1], 5, strokeColor, "white");
drawPoints(canvas, positions.slice(1), strokeColor);
};

var genFrom2DGaussMixture = function(mus, sigmas, weights) {
var i = discrete(weights);
return [
gaussian(mus[i][0], sigmas[i][0]),
gaussian(mus[i][1], sigmas[i][1]),
];
};

var mus = [[100, 200], [200, 100], [200, 300]];
var sigmas = [[20, 5], [10, 10], [5, 20]];
var weights = [0.33, 0.33, 0.33];
var nObservations = 100;
var synthData = repeat(nObservations, function() {
return genFrom2DGaussMixture(mus, sigmas, weights);
});
///

var gaussMixtureObs = function(observations) {
var mus = repeat(3, function() {
return [gaussian(200, 40), gaussian(200, 40)];
});
var sigmas = repeat(3, function() {
return [gamma(1, 10), gamma(1, 10)];
});
var weights = dirichlet(Vector([1, 1, 1]));

map(function(obs) {
var i = discrete(weights);
factor(Gaussian({mu: mus[i][0], sigma: sigmas[i][0]}).score(obs[0]));
factor(Gaussian({mu: mus[i][1], sigma: sigmas[i][1]}).score(obs[1]));
}, observations);

return {
mus: mus,
sigmas: sigmas,
weights: weights
};
};

var post = Infer({method: 'MCMC', samples: 5000, onlyMAP: true}, function() {
return gaussMixtureObs(synthData);
});
var params = sample(post);
var dataFromLearnedModel = repeat(nObservations, function() {
genFrom2DGaussMixture(params.mus, params.sigmas, params.weights);
});

var canvas = Draw(400, 400, true);
drawPoints(canvas, synthData, 'red');
drawPoints(canvas, dataFromLearnedModel, 'blue');
params;

We can also use MCMC to perform inference on the line drawing program from before. Note the different behavior of MCMC, how the results are a sequence of images, each a slight modification on the last:

var targetImage = Draw(50, 50, false);

var drawLines = function(drawObj, lines){
var line = lines[0];
drawObj.line(line[0], line[1], line[2], line[3]);
if (lines.length > 1) {
drawLines(drawObj, lines.slice(1));
}
}

var makeLines = function(n, lines){
var x1 = randomInteger(50);
var y1 = randomInteger(50);
var x2 = randomInteger(50);
var y2 = randomInteger(50);
var newLines = lines.concat([[x1, y1, x2, y2]]);
return (n==1) ? newLines : makeLines(n-1, newLines);
}

// 'justSample' retains an array of samples as a property of the object
//    returned from inference
// samples are {value: , score: } objects
var post = Infer(
{ method: 'MCMC', samples: 500, justSample: true},
function(){
var lines = makeLines(4, []);
var finalGeneratedImage = Draw(50, 50, false);
drawLines(finalGeneratedImage, lines);
var newScore = -targetImage.distance(finalGeneratedImage)/1000;
factor(newScore);
return lines
});

map(function(samp) {
var lines = samp.value;
var img = Draw(50, 50, true);
drawLines(img, lines);
}, post.samples);

This program uses only a single factor at the end of finalImgSampler, rather than one per each line rendered as in the SMC version. The fact that MCMC supports such a pattern makes it well-suited for programs that invoke complicated, ‘black-box’ simulations in order to compute likelihoods. It also makes MCMC a good default go-to inference method for most programs. However, note that MCMC has difficulty inferring the position of all four lines, often producing results that have only three correctly positioned. The take-away here: when you can restructure the program to have multiple factor statements throughout, as opposed to one at the end, it is often a good idea to do so and to use SMC instead.

### Custom MH Proposals

By default, WebPPL’s MH algorithm proposes a change to a random choice by resampling from its prior. While this is always correct, it isn’t always the most efficient proposal strategy. In practice, it’s often advantageous to make a proposal based on the current value of the random choice: for example, a small perturbation of the current value is more likely to be accepted than an independently resampled value.

WebPPL supports these sorts of custom proposals via an option driftKernel that can be provided to any call to sample. Below, we show an example proposal for discrete random choices that forces MH to choose a different value than the current one (by setting the probability of the current value to zero):

var model = function() {
var x = sample(Discrete({ps: [0.25, 0.25, 0.25, 0.25]}, {
driftKernel: function(currVal) {
var newps = ps.slice(0, currVal).concat([0]).concat(ps.slice(currVal+1));
return Discrete({ps: newps});
}
}));
return x;
}

Infer({method: 'MCMC', samples: 100}, model);

You might try using this strategy with the Gaussian mixture model program above to see how it improves efficiency.

### Hamiltonian Monte Carlo

When the input to a factor statement is a function of multiple variables, those variables become correlated in the posterior distribution. If the induced correlation is particularly strong, MCMC can sometimes become ‘stuck,’ generating many very similar samples which result in a poor approximation of the true posterior. Take this example below, where we use a Gaussian likelihood factor to encourage ten uniform random numbers to sum to the value 5:

var bin = function(x) {
return Math.floor(x * 1000) / 1000;
};

var constrainedSumModel = function() {
var xs = repeat(10, function() {
return uniform(0, 1);
});
var targetSum = xs.length / 2;
factor(Gaussian({mu: targetSum, sigma: 0.005}).score(sum(xs)));
return map(bin, xs);
};

var post = Infer({
method: 'MCMC',
samples: 5000,
callbacks: [MCMC_Callbacks.finalAccept]
}, constrainedSumModel);
var samps = repeat(10, function() { return sample(post); });
reduce(function(x, acc) {
return acc + 'sum: ' + sum(x).toFixed(3) + ' | nums: ' + x.toString() + '\n';
}, '', samps);

Running this program produces some random samples from the computed posterior distribution over the list of ten numbers—you’ll notice that they are all very similiar, despite there being many distinct ways for ten real numbers to sum to 5. This program also uses the callbacks option to MCMC to display the final acceptance ratio (i.e. the percentage of proposed samples that were accepted)–it should be around 1-2%, which is very inefficient.

To deal with situations like this one, WebPPL provides an implementation of Hamiltonian Monte Carlo, or HMC. HMC automatically computes the gradient of the posterior with respect to the random choices made by the program. It can then use the gradient information to make coordinated proposals to all the random choices, maintaining posterior correlations. Below, we apply HMC to constrainedSumModel:

///fold:
var bin = function(x) {
return Math.floor(x * 1000) / 1000;
};

var constrainedSumModel = function() {
var xs = repeat(10, function() {
return uniform(0, 1);
});
var targetSum = xs.length / 2;
factor(Gaussian({mu: targetSum, sigma: 0.005}).score(sum(xs)));
return map(bin, xs);
};
///

var post = Infer({
method: 'MCMC',
samples: 100,
callbacks: [MCMC_Callbacks.finalAccept],
kernel: {
HMC : { steps: 50, stepSize: 0.0025 }
}
}, constrainedSumModel);
var samps = repeat(10, function() { return sample(post); });
reduce(function(x, acc) {
return acc + 'sum: ' + sum(x).toFixed(3) + ' | nums: ' + x.toString() + '\n';
}, '', samps);

The approximate posterior samples produced by this program are more varied, and the final acceptance rate is much higher.

There are a couple of caveats to keep in mind when using HMC:

• Its parameters can be extremely sensitive. Try increasing the stepSize option to 0.004 and seeing how the output samples degenerate.
• It is only applicable to continuous random choices, due to its gradient-based nature. You can still use HMC with models that include discrete choices, though: under the hood, this will alternate between HMC for the continuous choices and MH for the discrete choices.

## Particle Rejuvenation

MCMC can also be used to improve the output of SMC. Recall the example from the previous section which tries to match rendered lines to a target image:

var targetImage = Draw(50, 50, false);

var drawLines = function(drawObj, lines){
var line = lines[0];
drawObj.line(line[0], line[1], line[2], line[3]);
if (lines.length > 1) {
drawLines(drawObj, lines.slice(1));
}
}

var makeLines = function(n, lines, prevScore){
// Add a random line to the set of lines
var x1 = randomInteger(50);
var y1 = randomInteger(50);
var x2 = randomInteger(50);
var y2 = randomInteger(50);
var newLines = lines.concat([[x1, y1, x2, y2]]);
// Compute image from set of lines
var generatedImage = Draw(50, 50, false);
drawLines(generatedImage, newLines);
// Factor prefers images that are close to target image
var newScore = -targetImage.distance(generatedImage)/1000;
factor(newScore - prevScore);
generatedImage.destroy();
// Generate remaining lines (unless done)
return (n==1) ? newLines : makeLines(n-1, newLines, newScore);
}

var numParticles = 100;

var post = Infer(
{method: 'SMC', particles: numParticles},
function(){
return makeLines(4, [], 0);
});

repeat(numParticles, function() {
var finalGeneratedImage = Draw(50, 50, true);
var lines = sample(post);
drawLines(finalGeneratedImage, lines);
});

We observed before that the posterior samples from this program are all nearly identical. One way to combat this problem is to run MCMC for a small number of steps after each particle resampling step; this process is often termed ‘particle rejuvenation’. To apply this technique in WebPPL, just provide an integer greater than zero to the rejuvSteps option for SMC:

///fold:
var targetImage = Draw(50, 50, false);

var drawLines = function(drawObj, lines){
var line = lines[0];
drawObj.line(line[0], line[1], line[2], line[3]);
if (lines.length > 1) {
drawLines(drawObj, lines.slice(1));
}
}

var makeLines = function(n, lines, prevScore){
// Add a random line to the set of lines
var x1 = randomInteger(50);
var y1 = randomInteger(50);
var x2 = randomInteger(50);
var y2 = randomInteger(50);
var newLines = lines.concat([[x1, y1, x2, y2]]);
// Compute image from set of lines
var generatedImage = Draw(50, 50, false);
drawLines(generatedImage, newLines);
// Factor prefers images that are close to target image
var newScore = -targetImage.distance(generatedImage)/1000;
factor(newScore - prevScore);
generatedImage.destroy();
// Generate remaining lines (unless done)
return (n==1) ? newLines : makeLines(n-1, newLines, newScore);
}
///

var numParticles = 100;

var post = Infer(
{method: 'SMC', particles: numParticles, rejuvSteps: 10},
function(){
return makeLines(4, [], 0);
});

repeat(numParticles, function() {
var finalGeneratedImage = Draw(50, 50, true);
var lines = sample(post);
drawLines(finalGeneratedImage, lines);
});

You can also rejuvenate with HMC, by specifying HMC as the rejuvKernel option. See the WebPPL documentation for more information.

## Exercises

### 1. Sampling Implicit Curves

The code box below uses rejection sampling to sample points along the boundary of an implicit curve defined by the curve function:

var curve = function(x, y) {
var x2 = x*x;
var term1 = y - Math.pow(x2, 1/3);
return x2 + term1*term1 - 1;
};
var xbounds = [-1, 1];
var ybounds = [-1, 1.6];

var xmu = 0.5 * (xbounds[0] + xbounds[1]);
var ymu = 0.5 * (ybounds[0] + ybounds[1]);
var xsigma = 0.5 * (xbounds[1] - xbounds[0]);
var ysigma = 0.5 * (ybounds[1] - ybounds[0]);

var model = function() {
var x = gaussian(xmu, xsigma);
var y = gaussian(ymu, ysigma);
var c_xy = curve(x, y);
condition(Math.abs(c_xy) < 0.01);
return {x: x, y: y};
};

var post = Infer({method: 'rejection', samples: 1000}, model);
viz.auto(post);

Try using MCMC instead of rejection sampling–you’ll notice that it doesn’t fare as well. Why does this happen, and how can you change the model (or the inference algorithm) to make MCMC perform better? There may be multiple ways to approach this problem.

Hints:

• The documentation on WebPPL’s primitive Distributions may be helpful. Be aware that some distributions operate on Vectors, rather than arrays.

### 2. Pathfinding

In this exercise, you’ll use MCMC to infer paths in a 2D environment from a start position to a target end position. The paths should avoid any obstacles in the environment. The code below draws the environment, including the start and goal positions:

///fold:
var drawCircle = function(canvas, center, radius, color) {
canvas.circle(T.get(center, 0), T.get(center, 1), radius, color,
"rgba(0, 0, 0, 0)");
};

var drawObstacles = function(canvas, obstacles, color){
if (obstacles.length == 0) { return []; }
drawObstacles(canvas, obstacles.slice(1), color);
};

var circle = function(c, r) { return {center: c, radius: r}; };
///

var start = Vector([200, 390]);
var goal = Vector([375, 50]);

var obstacles = [
circle(Vector([75, 300]), 30),
circle(Vector([175, 330]), 40),
circle(Vector([200, 200]), 60),
circle(Vector([300, 150]), 55),
circle(Vector([375, 175]), 25),
];

var canvas = Draw(400, 400, true);
drawCircle(canvas, start, 5, 'blue');
drawCircle(canvas, goal, 5, 'green');
drawObstacles(canvas, obstacles, 'red');

In this case, a path is an ordered list of points in space. The paths your code infers should:

• Travel from the start position (blue circle) to the goal position (green circle)
• Avoid all obstacles (red circles)
• Be as short as possible
• Stay within the bounds of the drawing window at all times

The code box below sets things up for you, including several useful helper functions.

///fold:
var drawCircle = function(canvas, center, radius, color) {
canvas.circle(T.get(center, 0), T.get(center, 1), radius, color,
"rgba(0, 0, 0, 0)");
};

var drawObstacles = function(canvas, obstacles, color){
if (obstacles.length == 0) { return []; }
drawObstacles(canvas, obstacles.slice(1), color);
};

var drawPath = function(canvas, positions, color){
if (positions.length <= 1) { return []; }
var start = positions[0];
var end = positions[1];
canvas.line(T.get(start, 0), T.get(start, 1),
T.get(end, 0), T.get(end, 1), 3, 0.5, color);
drawPath(canvas, positions.slice(1), color);
};

var dot = function(v1, v2) {
return T.get(T.dot(T.transpose(v1), v2), 0);
};

var norm = function(v) {
return Math.sqrt(dot(v, v));
};

var circle = function(c, r) { return {center: c, radius: r}; };

var rayCircleIntersect = function(a, d, circ) {
var c = circ.center;
var ac = T.sub(a, c);
var A = dot(d, d);
var B = 2 * dot(ac, d);
var C = dot(ac, ac) - r*r;
var discr = B*B - 4*A*C;
// Negative discriminant; no intersection
if (discr < 0) { return [false]; }
// Zero discriminant (dual root); one intersection
if (discr === 0) { return [true, -B / (2*A)]; }
// Positive discriminant; two intersections
var sqrtDiscr = Math.sqrt(discr);
var t1 = (-B + sqrtDiscr) / (2*A);
var t2 = (-B - sqrtDiscr) / (2*A);
// No intersection if both are negative
if (t1 < 0 && t2 < 0) { return [false]; }
// Pick closest one if both are nonnegative
if (t1 >=0 && t1 >= 0) { return [true, Math.min(t1, t2)]; }
// Else return the one nonnegative one
return [true, t1 >= 0 ? t1 : t2];
};

var lineSegIntersectsCircle = function(a, b, circ) {
var d = T.sub(b, a);
var result = rayCircleIntersect(a, d, circ);
if (result[0] === false) { return false; }
var t = result[1];
return t <= 1;
};

var pathSegBlocked = function(a, b, obstacles) {
if (obstacles.length === 0) { return false; }
if (lineSegIntersectsCircle(a, b, obstacles[0])) {
return true;
}
return pathSegBlocked(a, b, obstacles.slice(1));
};

var start = Vector([200, 390]);
var goal = Vector([375, 50]);

var obstacles = [
circle(Vector([75, 300]), 30),
circle(Vector([175, 330]), 40),
circle(Vector([200, 200]), 60),
circle(Vector([300, 150]), 55),
circle(Vector([375, 175]), 25),
];
///

// Returns true if the path is blocked by the obstacles
var pathBlocked = function(path, obstacles)
///fold:
{
if (path.length < 2) { return false; }
var a = path[0];
var b = path[1];
if (pathSegBlocked(a, b, obstacles)) { return true; }
return pathBlocked(path.slice(1), obstacles);
};
///

// Returns the traversal length of a path
var pathLength = function(path)
///fold:
{
if (path.length < 2) { return 0; }
var a = path[0];
var b = path[1];
return norm(T.sub(b, a)) + pathLength(path.slice(1));
};
///

// Return true if the path is entirely contained within the provided
//    x, y bounds.
var pathInsideWindow = function(path, bounds)
///fold:
{
if (path.length === 0) { return true; }
var xlo = bounds[0];
var xhi = bounds[1];
var ylo = bounds[2];
var yhi = bounds[3];
var p = path[0];
var px = T.get(p, 0);
var py = T.get(p, 1);
if (px < xlo || px > xhi || py < ylo || py > yhi) { return false; }
return pathInsideWindow(path.slice(1), bounds);
};
///

var bounds = [0, 400, 0, 400];

// TODO: Replace this with sample from inferred posterior using MCMC.
var path = [start, goal];

var canvas = Draw(400, 400, true);
drawCircle(canvas, start, 5, 'blue');
drawCircle(canvas, goal, 5, 'green');
drawObstacles(canvas, obstacles, 'red');
drawPath(canvas, path, 'black');

Some hints:

• Add constraints one at time, i.e. first make sure you can generate paths from start-to-goal, then make them avoid obstacles, then make them short.
• How you choose to represent and sample paths from start-to-goal can have a big impact on inference efficiency.

If you can get things working, here are some optional challenges / extentions worth considering:

• Play with different configurations of obstacles, start position, and goal position. What configurations make inference especially challenging?
• Try using other inference algorithms (especially SMC). How does their behavior compare with that of MCMC?

Next: Variational Inference


text:
### Voting

Time Limit: 1000 ms Memory Limit: 65536 KiB

#### Problem Description

A committee clerk is good at recording votes, but not so good at counting and figuring the outcome            correctly. As a roll call vote proceeds, the clerk records votes as a sequence of letters, with one letter for
every member of the committee:
Y means a yes vote
N means a no vote
P means present, but choosing not to vote
A indicates a member who was absent from the meeting
Your job is to take this recorded list of votes and determine the outcome.

Rules:
There must be a quorum. If at least half of the members were absent, respond "need quorum". Otherwise votes are counted.    If there are more yes than no votes, respond "yes".    If there are more no than yes votes, respond "no".   If there are the same number of yes and no votes, respond "tie".

#### Input

The input contains of a series of votes, one per line, followed by a single line with the # character. Each vote consists entirely of the uppercase letters discussed above. Each vote will contain at least two letters and no more than 70 letters.

#### Output

For each vote, the output is one line with the correct choice "need quorum", "yes", "no" or "tie".

#### Sample Input

YNNAPYYNY
YAYAYAYA
PYPPNNYA
YNNAA
NYAAA
#

#### Sample Output

yes
need quorum
tie
no
need quorum


text:
# latexdiff with \cite commands gives output with apparently mismatched braces

I have run into a problem with the markup that latexdiff adds around \cite commands. The MWE below, which is supposed to have been generated by latexdiff, doesn't compile because LaTeX doesn't recognise the closing brace for \DIFdel:

ERROR: Extra }, or forgotten \endgroup.

The culprit is \hspace{0pt}: commenting this out prevents this error.

I have solved my immediate problem by manually deleting the string \hspace{0pt} from the difference file wherever it occurs, but obviously I'd rather not do this every time.

I have two questions: (1) why does LaTeX find a problem with the braces here in the first place, since they look matched to my human eyes (and to emacs!)? And (2) is there a way to prevent latexdiff from generating code that fails to compile in this way?

## MWE for LaTeX (note that I've deleted most of the latexdiff preamble)

\documentclass{article}

\usepackage{hyperref}

% DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF UNDERLINE PREAMBLE %DIF PREAMBLE
\RequirePackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFdeltex}[1]{{\protect\color{red}\sout{#1}}}                      %DIF PREAMBLE
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
%DIF HYPERREF PREAMBLE %DIF PREAMBLE
\providecommand{\DIFdel}[1]{\texorpdfstring{\DIFdeltex{#1}}{}} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF

\begin{document}
\DIFdelbegin \DIFdel{Some text\mbox{%DIFAUXCMD
\cite{reference}}\hspace{0pt}%DIFAUXCMD
, and some more text.}
\DIFdelend

\bibliography{my_bib}
\end{document}

## MWE for latexdiff

### old.tex

\documentclass{article}

\usepackage{hyperref}

\begin{document}
Some text \cite{reference}, and some more text.

\bibliography{my_bib}
\end{document}

### new.tex

\documentclass{article}

\usepackage{hyperref}

\begin{document}
\bibliography{my_bib}
\end{document}

latexdiff old.tex new.tex > diff.tex

• I think the problem is not really the \hspace command, but rather an incompatibility of the packages/code added by latexdiff with the current LaTeX version. LaTeX underwent some internal changes recently. If you add \RequirePackage[2015/01/01]{latexrelease} as first line of diff.tex, then the file works as it is. Dec 9 '20 at 14:48
• It seems to be the ulem package. Removing \sout makes the file compilable. Dec 9 '20 at 14:54
• Many thanks @gernot; if you add that as an answer I'll happily accept it! In the actual document, I couldn't roll back because I need more recent features in amsmath, but your discovery that ulem is the thing to avoid means that I can just call latexdiff with -t CFONT (to avoid styles using ulem) and all is well.
– Ant
Dec 9 '20 at 16:34
• Done. Keep me updated (e.g. in the comment section here or below the answer) about your experience with the workaround. Maybe we are on the wrong track and the error is caused by something else. Dec 9 '20 at 17:06
• I had simillar issues as well. I think it is pretty neatly fixable by using lua-ul package. Dec 10 '20 at 8:45

This year (2020) LaTeX underwent some internal changes that introduce incompatibilities with some packages. It seems that ulem.sty is one of them, with the current version ulem 2019/11/18 pre-dating the changes in the LaTeX format.

The differences file produced by latexdiff loads ulem.sty and uses the command \sout (strike out), which leads to the error.

\RequirePackage[normalem]{ulem} %DIF PREAMBLE
...
\providecommand{\DIFdeltex}[1]{{\protect\color{red}\sout{#1}}} %DIF PREAMBLE

As a workaround, until the incomaptibility gets fixed, run latexdiff with the option -t CFONT, which avoids the use of \sout (proposed by @Ant in the comments).

\RequirePackage[2019/11/18]{latexrelease}

as the first line in the differences file. This will set back the LaTeX format to a state that is compatible.

• Somehow removing "\hspace{0pt}" generated by latexdiff fixed this issue for me, before I found this great answer. Jan 10 at 10:34
• I will hang this answer over my desk....many thanks! Feb 4 at 4:30
• In my document \RequirePackage[2019/11/18]{latexrelease} caused LaTeX to hang. Feb 22 at 3:16
• @AnonymousPhysicist Well, this is a non-normal behavior of latexrelease. If you care, post a question or file a bug report at https://github.com/latex3/latex2e/issues Feb 22 at 11:49

Germot already provided a good answer. However, it was not entirely satisfactory. The -t CFONT option changes the formatting (it only uses colour, removing strike-out and underlining). And while setting the latexrelease version to 2019/11/18 worked fine with OP's MWE, it failed in a more complex document.

So I sought to get rid of the real culprit, the \hspace{0pt}.

Since v1.0.1, latexdiff encloses citation (and a few other things such as siunitx commands) in \mbox commands in order to circumvent incompatibilities with ulem styling (the \sout and \uwave used by default). However, this implies that line breaks no longer work within citations. This was fixed in v1.2.1 by adding the \hspace{0pt} after the \mbox. The changelog states that “change should not cause adverse behaviour otherwise”. Well, now it does!

My temporary fix was to edit the latexdiff source (texmf-dist/scripts/latexdiff/latexdiff.pl), and replace the \hspace{0pt} with a \hskip0pt. The resulting PDF is identical to the one obtained with older versions.

## tl; dr:

Find latexdiff.pl in your texlive installation directory¹, and replace line 2734²:

push(@$retval,"\\mbox{$AUXCMD\n\\" . $1 .$2 . $3 ."}\\hspace{0pt}$AUXCMD\n" );

by

push(@$retval,"\\mbox{$AUXCMD\n\\" . $1 .$2 . $3 ."}\\hskip0pt$AUXCMD\n" );

¹ E.g. /usr/share/texmf-dist/scripts/latexdiff/latexdiff.pl.
² Assuming you have latexdiff v1.3.1.1.

• Great answer, fixed /usr/bin/latexdiff (line 2680 in my version) with this and it now works again. Sep 2 at 11:05


text:
## Elementary Algebra

Published by Cengage Learning

# Chapter 5 - Exponents and Polynomials - Chapter 5 Review Problem Set: 68

#### Answer

$\dfrac{b^{6}}{a^{4}}$

#### Work Step by Step

Using the laws of exponents, the given expression, $(a^2b^{-3})^{-2} ,$ simplifies to \begin{array}{l}\require{cancel} a^{2(-2)}b^{-3(-2)} \\\\= a^{-4}b^{6} \\\\= \dfrac{b^{6}}{a^{4}} .\end{array}

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.


text:
# step

System object: comm.PSKTCMModulator
Package: comm

Convolutionally encode binary data and map using M-ary PSK constellation

## Syntax

`Y = step(H,X)Y = step(H,X,R)`

## Description

`Y = step(H,X)` convolutionally encodes and modulates the input binary data column vector, `X`, and returns the encoded and modulated data, `Y`. `X` must be of data type numeric, logical, or unsigned fixed point of word length `1` (fi object). When the convolutional encoder represents a rate K/N code, the length of the input vector, `X`, must be K$×$L, for some positive integer L. The `step` method outputs a complex column vector, `Y`, of length L.

`Y = step(H,X,R)` resets the encoder of the PSK TCM modulator object to the all-zeros state when you input a reset signal, `R`, that is non-zero. `R` must be a double precision or logical scalar integer. This syntax applies when you set the `ResetInputPort` property to `true`.

 Note:   `H` specifies the System object™ on which to run this `step` method.The object performs an initialization the first time the `step` method is executed. This initialization locks nontunable properties and input specifications, such as dimensions, complexity, and data type of the input data. If you change a nontunable property or an input specification, the System object issues an error. To change nontunable properties or inputs, you must first call the `release` method to unlock the object.