text:
User talk:Strebe

Welcome to Wikimedia Commons, Strebe!

-- 04:14, 15 August 2011 (UTC)

Babel user information
 en This user is a native English speaker.
 ja-3 この利用者は高度なレベルの日本語を理解します。
Users by language

Hi I would like to use your world map projections in this book: http://www.tandf.net/books/details/9781138922976/ Is this possible? SSJJPP

Certainly. Feel free to send me an e-mail using the “Email this user” link at the bottom of this page. Strebe (talk) 02:00, 25 March 2015 (UTC)

Maps

Hello, I noticed your nice maps (projections). I'm myself writing down some GIS cartographic tutorials, and I'm interested to know :

• where to download this 'skin', is it a GIS file ?
• which software do you use ?
• have you some specific understanding of geographic projections ? (I'm myself looking for a good projection for Mainland China)

Cheer, Yug (talk) 20:28, 10 September 2011 (UTC)

Apologies for missing your posting. I use Geocart for my maps. The base image comes with the software. I wrote Geocart, so I know quite a bit about map projections. What kind of map do you need to make of China? Strebe (talk) 05:53, 9 December 2011 (UTC)

File:HEALPix projection SW.jpg

I can't agree with your comment "Not a line drawing; subject is photographic data; does not contain significant compression artifacts." about File:HEALPix projection SW.jpg. Technically, it does contain line drawing, and is not really photographic data. However, the main problem is not the classification, :-) but the fact that while the original indeed does not contain significant compression artifacts, the thumbnailed images do show quite noticeable ringing artifacts (they are well seen in the illustration to en:HEALPix). Could you please recreate and upload a PNG version, if SVG is impossible? (And, after all, this "Blue Marble summer month composite" has nothing to do with the projection, so why not to take something general from Category:Blank SVG maps of the world and make a pure SVG? I think, it could be much cleaner and more usable.) — Mikhail Ryazanov (talk) 03:16, 9 December 2011 (UTC)

Thanks for your note. The ringing is from the downsampling applied by Wikimedia to create the thumbnail. The same thing would happen with a PNG of the same size. The data is indeed photographic—or at least, contains the same order of complexity of photographic data across the land areas: It’s NASA Blue World satellite imagery. A PNG would be much larger in file size to no benefit, so I do not understand why you prefer PNG. The reason for using the image is because it is used uniformly across the Wikipedia pages that display map projections. It is an informative image, and using the same image makes comparison much easier. I have no software for creating SVGs, so that is not a project I can work on. I can produce PDFs, including line art for those, but PDF is not a format supported by Wikimedia Commons. Strebe (talk) 06:09, 9 December 2011 (UTC)
I have converted the image to PNG to show you that PNGs do not suffer from ringing artifacts (check it in the article). The file size after direct conversion was ~3 times larger than of JPEG, partially due to JPEG compression artifacts; if created directly it would be probably only about twice larger (it is not "much", in my opinion :-) ). If you can produce PDF with vector grid, it can be easily converted to SVG by, for example, Inkscape. (In principle, Commons allow PDF upload, but for some reason it renders in JPEG only.) If you don't want to bother with conversions, could you please upload one PDF as an example, so that I can try to convert it to SVG? — Mikhail Ryazanov (talk) 07:26, 12 December 2011 (UTC)
You are correct; the PNG and JPG downsample differently. It’s odd that Wikimedia Commons uses different window functions for PNG vs. JPG downsampling. Clearly the PNG file is “softer”, and while I do prefer the look of the PNG downsampling, the JPG downsampling preserves more detail. Anyway, I can create a PDF image easily enough when I get time. Strebe (talk) 04:56, 13 December 2011 (UTC)
SVG version here. Strebe (talk) 03:27, 19 December 2011 (UTC)
Great! :-) I've experimented with it a little bit and found that black grid is much more contrast over snow and sand (and has approximately the same contrast everywhere else as the original light-gray), plus it's more consistent with the boundary color (which is a part of the grid). What do you think? (The recolored version is uploaded over your file, you can revert it after comparison...) — Mikhail Ryazanov (talk) 08:51, 21 December 2011 (UTC)
Thanks for the comments. I prefer the original color scheme. The thumbnail image in the article looks better with the black graticule as per your modification, but in the full-scale image, the graticule overwhelms everything. I do not think the outer boundary’s line color and weight need to match the graticule; that is not cartographic convention and in my opinion does not add any clarity. Also, all the other map projection articles use the original color scheme. I think consistency is important. The original color scheme was discussed publicly before creating the images so that the many needs could be balanced. Strebe (talk) 11:47, 21 December 2011 (UTC)
Yes, consistency is important. :-) I asked because if these maps are to be replaced with SVGs, it would be better to use good colors for all of them. Could you point me at the previous discussion?
Regarding that "the graticule overwhelms everything" — I thought, it was the main subject of these images. After all, the projection of a regular grid is more revealing than that of some complicated shapes. Figures in the main article en:Map projection suggests that this is indeed the case (and, for example, looking at "A two-point equidistant projection of Asia" illustration there I can barely see what is going on, because the grid is almost invisible).
Mikhail Ryazanov (talk) 15:36, 24 December 2011 (UTC)
We anticipated the need for actual maps, as opposed to just a caricature of the graticule. If the only need were for a thumbnail, then the images might legitimately be only a graticule, or possibly a graticule with a vector coastline. There would be no need for 2,000-pixel-wide satellite images. In most articles on map projections, the thumbnails are at 450 pixels in width, clearly showing the graticule as well as useful land-cover detail. It is true that the thumbnails are smaller in the article on en:Map projection, and it is true that the graticule is difficult to see on the two-point equidistant map of Asia. Yet it is not clear to me how helpful the graticule itself is in that image (actually, it is not even clear to me how relevant the image is to the article). In any case, the rationale is that you can always click on the thumbnail image to see whichever details are most relevant to you, the reader.
Also, most many projection articles include a Tissot indicatrix diagram in addition to the standardized imagery. (See, for example, en:Mollweide projection.) In my opinion that is a much better way to handle demonstrating the graticule and geometric relationships of the projection.
The discussion happened here and was announced on each map projection page whose image would be replaced. I see that I did not include an announcement on the HEALPix Talk page since it that article had no image originally. Strebe (talk) 18:02, 24 December 2011 (UTC)
Well, I see that in the "discussion" you basically showed only one variant, and there was just one reply "Good step", before the discussion slipped to the cutoff of Mercator projection. :-) No real discussion about the color scheme, not even anyone mentioned JPEG problems...
Anyway, if the real purpose was to show the landscape map in different projection, then your colors are quite good. And I totally agree that Tissot diagrams are indeed much more useful in articles about projection. Unfortunately, I haven't seem them there — probably because there are actually very few of them. Could you make such diagrams for the other projections? (And I'm going to revert the HEALPix to your original colors.) — Mikhail Ryazanov (talk) 03:08, 26 December 2011 (UTC)
All right, well, I am tired of this discussion. I am not responsible for how other people did or did not respond. I am not responsible for Wikimedia’s inconsistent thumbnail generation of JPEG vs PNG. I improved the images in 38 Wikipedia articles. I added images to pages that had none at all, including HEALPix. I announced the plans in advance on all the pages that had images that I was replacing. No one objected. It was a lot of work. If someone else wants to step up to help improve the situation, they are more than welcome to. Until someone else does, I infer that not many people care anyway, so it makes no sense for me to put even more effort into it, particularly if the only reward is to receive complaints and demands for yet more work. Strebe (talk) 05:39, 29 December 2011 (UTC)

Author of Geocart

Are you Daniel “daan” Strebe, one of Geocart author? If so, why do you chose to not license it freely? 171.229.90.177 11:56, 3 January 2012 (UTC)

Because it was a gigantic amount of work? Strebe (talk) 23:30, 3 January 2012 (UTC)

Yes, you are. Where did you find the formulas? Perhaps one of the sources is An Album of Map Projections? Refereced (talk) 06:05, 19 January 2012 (UTC)

Snyder’s “Album of Map Projections” was an early source. So was his “Flattening the Earth” and “Map Projections—A Working Manual”. Maling’s “Coordinate Systems and Map Projections.” Plus dozens and dozens of professional papers. And that’s just for the projection formulæ. Many of them can’t be used as-is for serious work because they contain singularities or numerically problematic regions. Strebe (talk) 08:24, 19 January 2012 (UTC)

Can you give me the formulas for 4 random projections? 1.55.108.57 08:29, 19 January 2012 (UTC)

“Can”? Yes. “Will”? What is this about? Strebe (talk) 09:34, 19 January 2012 (UTC)

Ellipsoidal projection in Geocart

Does Geocart support ellipsoidal projection or does it support only spherical projection? 171.229.112.37 06:28, 24 January 2012 (UTC)

See here please. Thank you kindly for your interest. Strebe (talk) 07:04, 24 January 2012 (UTC)

Strebe 1995 projection

Please upload this (the Strebe 1995 projection formulas here. 113.190.110.1 13:05, 25 January 2012 (UTC)

These formulæ describe the Strebe 1995 projection, which is equal-area. φ means latitude; λ means longitude. The plane coordinates are x and y.

{\displaystyle {\begin{aligned}x&={\frac {2D}{k_{g}}}\cos \varphi _{p}\sin \lambda _{p}\\y&=k_{g}D\sin \varphi _{p}\\k_{g}&=1.35\\D&={\sqrt {\frac {2}{1+\cos \varphi _{p}\cos \lambda _{p}}}}\\\sin \varphi _{p}&={\frac {2\sin ^{-1}{\frac {{\sqrt {2}}y_{e}}{2}}+ry_{e}}{\pi }}\\\lambda _{p}&={\frac {\pi x_{e}}{4r}}\\r&={\sqrt {2-y_{e}^{2}}}\\x_{e}&=2k_{g}{\frac {\lambda (1+\cos \theta )}{\sqrt {4\pi +\pi ^{2}}}}\\y_{e}&=2{\frac {{\sqrt {\pi }}\sin \theta }{k_{g}{\sqrt {4+\pi }}}}\\{\text{where }}\theta {\text{ is solved iteratively:}}\\\theta +\sin \theta \cos \theta +2\sin \theta &={\frac {1}{2}}\left(4+\pi \right)\sin \varphi \\\end{aligned}}}

Strebe (talk) 03:26, 15 February 2012 (UTC)

It is equal area maping projection. the length of polar is half than equator. See This,[1]

File:Ecker II projection SW.jpg

--무소속 (talk) 07:54, 16 March 2012 (UTC)

Are you asking for an image? Formulæ? What do you want this for? Strebe (talk) 19:56, 16 March 2012 (UTC)
I want image --23:11, 16 March 2012 (UTC)
You gave a link to an image. Is there something wrong with that image? Strebe (talk) 23:15, 16 March 2012 (UTC)
I want Image like File:Ecker IV projection SW.jpg. --58.29.48.106 23:29, 16 March 2012 (UTC)
I want to. --무소속 (talk) 03:20, 26 March 2012 (UTC)
Done Strebe (talk) 04:04, 23 July 2012 (UTC)

File:Mollweide projection SW.jpg

 File:Mollweide projection SW.jpg has been listed at Commons:Deletion requests so that the community can discuss whether it should be kept or not. We would appreciate it if you could go to voice your opinion about this at its entry. If you created this file, please note that the fact that it has been proposed for deletion does not necessarily mean that we do not value your kind contribution. It simply means that one person believes that there is some specific problem with it, such as a copyright issue. Please remember to respond to and – if appropriate – contradict the arguments supporting deletion. Arguments which focus on the nominator will not affect the result of the nomination. Thank you!

Kabyst (talk) 08:19, 14 September 2012 (UTC)

Request for Ordnance Survey grid projection

Note incomplete map outline at top left

Hi Strebe,

I came across your map projections and am fascinated by your work. I wondered if you could help me with an illustration I made to help readers understand the UK Ordnance Survey grid reference system, please:

http://commons.wikimedia.org/wiki/File:Ordnance_Survey_National_Grid.svg

I superimposed in green an outline of Great Britain which I found (I'm not sure if it's correct), but think it would be much better if the rest of Western Europe in the top-left grid could be shown.

Might you be willing to contribute a bit of your time to render in SVG format at any scale an outline of the land masses in the projection Ordnance Survey maps use? Alternatively, I will most appreciate a list of vertices which can be joined by straight lines, or quadratic Bézier or cubic curves.

cmglee (talk) 21:30, 22 February 2015 (UTC)

Hello cmglee. I posted this: [2]. However, for reasons I don’t know, the outline varies slightly from the one you posted in these ways:
• I had to scale the map left-right by 0.998 in order to match your image. I believe this is a flaw in your image.
• The coastline does not match precisely in northeast Scotland and Cornwall, and to a lesser extent, eastern Ireland. I do not know the source of the discrepancy. I used vector data from WGS 84 coordinates and performed a Molodensky 3-parameter conversion, which might account for it, but the discrepancy seems larger than I would expect from that cause. Strebe (talk) 00:02, 23 February 2015 (UTC)
Thank you very much for your speedy response, Strebe. I've removed redundant Inkscape tags and attributes, and rescaled it to fit in my graphic. As the polylines are in parts, I couldn't shade the landmasses a solid colour, so just used an outline. You're right, there are flaws in my image as I traced the gridlines by hand and superimposed another map I found on Commons. Nevertheless, I think it's sufficient to illustrate the Ordnance Survey grid reference system. Thanks again, cmglee (talk) 23:21, 25 February 2015 (UTC)

Karavaisky vii map projection

Hi i was wondering if you can help me adapt a fictional continent that i made in the indian ocean to fit the karavaisky 7 world map projection?

Hello User:Drax90. Probably. Message me privately, please. Strebe (talk) 04:11, 31 January 2016 (UTC)

how to contact you ? i don't have any idea, do you have alternatehistory account? i could send it there

Hello User:Drax90. There is an "Email this user" link at the bottom of this page. I assume it works. Thanks. Strebe (talk) 20:08, 17 March 2016 (UTC)

Hello Strebe i hsve sent you the map request on wikipedia page

A barnstar for you!

 The Photographer's Barnstar Thanks for adding images such as the current featured one. RotubirtnoC (talk) 03:00, 10 February 2016 (UTC)
Many thanks, RotubirtnoC! I’m glad people have found this series useful and beautiful. Strebe (talk) 07:45, 14 February 2016 (UTC)

Hello User:Drax90. On April 24th, I responded to your e-mail by sending my response to your Hotmail account. Did you not receive my response? Strebe (talk) 06:31, 6 May 2016 (UTC)

i have seen your message, and i have changed my adress now for contact, it seems you didn't understand my request so i'll repeat it again: this map is in karavaisky 7 projection already, but the fictional continent i made is not adapted to it, so i wanted if someone could change it to look like its part of the karavaisky 7 projection Best regards — Preceding unsigned comment added by Drax90 (talk • contribs) 08:08, 10 May 2016 (UTC)

~~

Hi. I noticed you reverted the cat I added to this image. For the first few weeks of its existence, WikiProject Category:Women in Red used it as its logo. But no worries if you think we shouldn't include the cat. --Rosiestep (talk) 16:53, 17 June 2016 (UTC)

Makes perfect sense, Rosiestep. I restored the categorization. Thanks! Strebe (talk) 22:45, 17 June 2016 (UTC)

Response

Strebe, unfortunately I can't receive that message you sent, so if you could simply copy it here on this user talk page

Thank you Drax90 (talk)

Drax90, I need to be able to conduct a dialogue without it being so cumbersome and public. If you have an e-mail address you can give me that works, then please send it via Wikimedia’s “Email this user” feature, and I will send you an e-mail directly. Strebe (talk) 05:27, 22 June 2016 (UTC)


text:
# Aligning a structure to another¶

We use align.alignto to align a structure to another.

Last executed: May 18, 2021 with MDAnalysis 1.1.1

Last updated: June 26, 2020 with MDAnalysis 1.0.0

Minimum version of MDAnalysis: 1.0.0

Packages required:

Optional packages for molecular visualisation:

Note

MDAnalysis implements RMSD calculation using the fast QCP algorithm ([The05]) and a rotation matrix R that minimises the RMSD ([LAT09]). Please cite ([The05]) and ([LAT09]) when using the MDAnalysis.analysis.align module in published work.

[1]:

import MDAnalysis as mda
from MDAnalysis.analysis import align
from MDAnalysis.tests.datafiles import CRD, PSF, DCD, DCD2
import nglview as nv

The test files we will be working with here are trajectories of a adenylate kinase (AdK), a phosophotransferase enzyme. ([BDPW09]) The trajectories sample a transition from a closed to an open conformation.

[2]:

adk_open = mda.Universe(CRD, DCD2)

[3]:

adk_closed = mda.Universe(PSF, DCD)

Currently, the proteins are not aligned to each other. The difference becomes even more obvious when the closed conformation is compared to the open. Below, we set adk_open to the last frame and see the relative positions of each protein in a merged Universe.

[4]:

adk_open.trajectory[-1] # last frame
nv.show_mdanalysis(merged)

## Aligning a structure with align.alignto¶

alignto (API docs) aligns the mobile AtomGroup to the target AtomGroup by minimising the root mean square deviation (RMSD) between particle positions (please see the linked notebook for an explanation of RMSD). It returns (old_rmsd, new_rmsd). By default (match_atoms=True), it will attempt to match the atoms between the mobile and reference structures by mass.

[5]:

rmsds = align.alignto(adk_open,  # mobile
select='name CA', # selection to operate on
match_atoms=True) # whether to match atoms
print(rmsds)

(21.712154435976014, 6.817293751703919)

However, you may want to align to a structure that where there is not a clear match in particle mass. For example, you could be aligning the alpha-carbons of an atomistic protein to the backbone beads of a coarse-grained structure. Below, we use the somewhat contrived example of aligning 214 alpha-carbons to the first 214 atoms of the reference structure. In this case, we need to switch match_atoms=False or the alignment will error.

[6]:

rmsds = align.alignto(adk_open.select_atoms('name CA'),  # mobile
select='all', # selection to operate on
match_atoms=False) # whether to match atoms
print(rmsds)

(18.991465038265208, 16.603704620787127)

When we align structures, positions are set temporarily. If we flip to the first frame of adk_open and back to the last frame, we can see that it has returned to its original location.

[7]:

adk_open.trajectory[0] # set to first frame
adk_open.trajectory[-1] # set to last frame

You can save the aligned positions by writing them out to a PDB file and creating a new Universe.

[8]:

align.alignto(adk_open, adk_closed, select='name CA')
nv.show_mdanalysis(mda.Universe('aligned.pdb'))

/Users/lily/anaconda3/envs/mda-user-guide/lib/python3.7/site-packages/MDAnalysis/coordinates/PDB.py:864: DeprecationWarning: Using the last letter of the segid for the chainID is now deprecated and will be changed in 2.0. In 2.0, the chainID attribute will be used if it exists, or a placeholder value.
"exists, or a placeholder value.", DeprecationWarning)

## References¶

[1] Oliver Beckstein, Elizabeth J. Denning, Juan R. Perilla, and Thomas B. Woolf. Zipping and Unzipping of Adenylate Kinase: Atomistic Insights into the Ensemble of Open↔Closed Transitions. Journal of Molecular Biology, 394(1):160–176, November 2009. 00107. URL: https://linkinghub.elsevier.com/retrieve/pii/S0022283609011164, doi:10.1016/j.jmb.2009.09.009.

[2] Richard J. Gowers, Max Linke, Jonathan Barnoud, Tyler J. E. Reddy, Manuel N. Melo, Sean L. Seyler, Jan Domański, David L. Dotson, Sébastien Buchoux, Ian M. Kenney, and Oliver Beckstein. MDAnalysis: A Python Package for the Rapid Analysis of Molecular Dynamics Simulations. Proceedings of the 15th Python in Science Conference, pages 98–105, 2016. 00152. URL: https://conference.scipy.org/proceedings/scipy2016/oliver_beckstein.html, doi:10.25080/Majora-629e541a-00e.

[3] Pu Liu, Dimitris K. Agrafiotis, and Douglas L. Theobald. Fast determination of the optimal rotational matrix for macromolecular superpositions. Journal of Computational Chemistry, pages n/a–n/a, 2009. URL: http://doi.wiley.com/10.1002/jcc.21439, doi:10.1002/jcc.21439.

[4] Naveen Michaud-Agrawal, Elizabeth J. Denning, Thomas B. Woolf, and Oliver Beckstein. MDAnalysis: A toolkit for the analysis of molecular dynamics simulations. Journal of Computational Chemistry, 32(10):2319–2327, July 2011. 00778. URL: http://doi.wiley.com/10.1002/jcc.21787, doi:10.1002/jcc.21787.

[5] Hai Nguyen, David A Case, and Alexander S Rose. NGLview–interactive molecular graphics for Jupyter notebooks. Bioinformatics, 34(7):1241–1242, April 2018. 00024. URL: https://academic.oup.com/bioinformatics/article/34/7/1241/4721781, doi:10.1093/bioinformatics/btx789.

[6] Douglas L. Theobald. Rapid calculation of RMSDs using a quaternion-based characteristic polynomial. Acta Crystallographica Section A Foundations of Crystallography, 61(4):478–480, July 2005. 00127. URL: http://scripts.iucr.org/cgi-bin/paper?S0108767305015266, doi:10.1107/S0108767305015266.

format: plain


text:
# Suppose that β is an acute angle and sec β = 11 . 3. How to do the following?

## (a) Find the exact value of: (i) cosec β, (ii) cot β. (b) Show that $c o$${\sec}^{2}$ β − ${\cot}^{2}$ β = 1.

May 19, 2018

cosec b = 1.0039
cot b = 0.0888

#### Explanation:

$\sec b = 11.3$ -->
$\cos b = \frac{1}{11.3} = 0.0885$. Find sin b.
${\sin}^{2} b = 1 - {\cos}^{2} b = 1 - 0.0078 = 0.9921$
$\sin b = 0.9960$
cosec b = $\frac{1}{\sin b} = 1.0039$
$\cot b = \cos \frac{b}{\sin b} = \frac{0.0085}{0.9960} = 0.0888$

$\cos e {c}^{2} b - {\cot}^{2} b = 1.0078 - 0.0078 = 1$. Proved


text:
# Solve the following :

Question:

A bullet of mass $m$ moving at a speed $v$ hits a ball of mass $M$ kept at rest. A small part having mass $m$ breaks from the ball and sticks to the bullet. The remaining ball is found to move at a speed of $v_{1}$ in the direction of bullet. Find the velocity of the bullet after the collision.

Solution:

Use C.O.L.M,

$m v=\left(m^{\prime}+m\right) V_{2}+\left(M+m^{\prime}\right) V_{1}$

$V_{2}=\frac{m v-\left(M-m^{\prime}\right) V_{1}}{\left(m^{\prime}+m\right)}$


text:
# Rowspace(B) subset of Rowspace(A) when rank(A) > rank(B)

Suppose A and B are two mxn matrices such that rank (A) > rank (B) , then I have to prove that rowspace of B is a subset of rowspace of A.

What I tried was using property of 'Simplified Span Method' , i.e. Finding reduced row echelon form after using vectors as rows of matrix, that the final rref has linearly independent non zero rows. So A will have more linearly independent vectors than B as rank(A) > rank(B). But I do not know how to proceed if these vectors are different i.e.

Suppose n is 6, so maximum possible cardinal number for a subset of mxn matrices is 6 and A contains 3 of these and B contains 2 and the other one is left out. In this case, rowspace of B will not be a subset of rowspace of A.

• It's not hard to find two $3\times3$ matrices $A,B$ such that the rank of $A$ is 2, the rank of $B$ is 1, but the rowspace of $B$ is not a subset of the rowspace of $A$. – Gerry Myerson Feb 19 '17 at 10:27
• Did you mean in your question to ask how to disprove? – Maciej Caputa Feb 19 '17 at 10:39
• The question asked to prove or disprove the fact, I completely ignored that. 😅 – Quark Feb 19 '17 at 10:41

This statement is not correct and can be disproved by a counter example as you mentioned.

Let $A$ and $B$ be a $3$ by $3$ matrices with $$Rowspace(A) = span\left\{<1,0,0>,<0,1,0>\right\}$$ and $$Rowspace(B) = span\left\{<0,0,1>\right\}$$

Hence $Rank(A) > Rank(B)$, but $Rowspace(B) \not\subset Rowspace(A)$

However, following statement is true.

$$A, B \in M_{m,n}(\mathbb{R}) : rank(A) = m\ \wedge\ rank(A) > rank(B) \implies Rowspace(B) \subseteq Rowspace(A)$$

This can be read as:

Let $A$ and $B$ be m by n matrices with real entries. If rowspace of A spans $\mathbb{R}^m$ ($dim(Rowspace(A)) = m$) and $rank(A) > rank(B)$ then rowspace of B is a proper subset of rowspace of A.


text:
# Hartree–Fock theory#

With the state of the system being described by a single Slater determinant, the Hartree–Fock wave function is given as that which minimizes the electronic energy in a variational sense with respect to variations in the spin orbitals. It represents a cornerstone in quantum chemistry and provides total electronic energies that are within 1% of the exact results and a wide range of molecular properties that are within 5–10% accuracy. Moreover, the Hartree–Fock method serves as starting points for the formulation of many other, more accurate, wave function methods as well as the Kohn–Sham formulation of density functional theory.

## Hartree–Fock equation#

In the Hartree–Fock approximation, the many-electron wave function takes the form of a Slater determinant

$\begin{split} | \Phi \rangle = \frac{1}{\sqrt{N!}} \begin{vmatrix} \psi_{1}(\mathbf{r}_1) & \cdots & \psi_{N}(\mathbf{r}_1) \\ \vdots & \ddots & \vdots \\ \psi_{1}(\mathbf{r}_N) & \cdots & \psi_{N}(\mathbf{r}_N) \\ \end{vmatrix} \end{split}$

where $$\psi_i$$ are the single-electron wave functins known as spin orbitals. The Hartree–Fock energy and the associated state is found by minimizing the energy functional

$E_\mathrm{HF} = \min_{\psi} E[\psi]$

under the constraint that the spin orbitals remain orthonormal. Here, $$\psi$$ collectively refers to the entire set of $$N$$ spin orbitals. Such a contrained minimization is conveniently performed by means of the technique of Lagrange multipliers.

### Lagrangian#

In Hartree–Fock theory, we introduce the real-valued Lagrangian

$L[\psi] = E[\psi] - \sum_{i,j=1}^N \varepsilon_{ji} \big( \langle \psi_i | \psi_j \rangle - \delta_{ij} \big)$

and search for the set of spin orbitals, $$\psi$$, that results in a first variation that vanishes

$\delta L = 0$

Expressing the energy as the expectation value of the electronic Hamiltonian with respect to a Slater determinant and using the general expressions for matrix elements, we arrive at

\begin{align*} \delta L & = \sum_{i=1}^N \langle \delta \psi_i | \hat{h} | \psi_i \rangle + \sum_{i,j=1}^N \big( \langle \delta \psi_i \psi_j | \hat{g} | \psi_i \psi_j\rangle - \langle \delta \psi_i \psi_j | \hat{g} | \psi_j \psi_i\rangle - \varepsilon_{ji} \langle \delta \psi_i | \psi_j \rangle \big) + \mbox{complex conjugate} \\ &= \sum_{i=1}^N \langle \delta \psi_i | \big( \hat{f} | \psi_i \rangle - \sum_{j=1}^N \varepsilon_{ji} | \psi_j \rangle \big) + \mbox{complex conjugate} \end{align*}

where we have introduced the one-electron Fock operator

$\hat{f} = \hat{h} + \sum_{j=1}^N \big( \hat{J}_j - \hat{K}_j \big)$

with

\begin{align*} \hat{J}_j | \psi_i \rangle & = \Big[ \int \frac{e^2 |\psi_j(\mathbf{r}')|^2}{4\pi\varepsilon_0 |\mathbf{r} - \mathbf{r}'|} d^3\mathbf{r}' \Big] | \psi_i \rangle \\ % \hat{K}_j | \psi_i \rangle & = \Big[ \int \frac{e^2 \psi_j^\dagger(\mathbf{r}')\psi_i(\mathbf{r}')}{4\pi\varepsilon_0 |\mathbf{r} - \mathbf{r}'|} d^3\mathbf{r}' \Big] | \psi_j \rangle \end{align*}

Since the first-order variation in the Lagrangian is required to vanish for general variations in the spin orbitals, we have shown that the Hartree–Fock solution is given by

$\hat{f} | \psi_i \rangle - \sum_{j=1}^N \varepsilon_{ji} | \psi_j \rangle = 0$

This equation is known as the Hartree–Fock equation and it to be solved for the spin orbitals and the associated Lagrange multipliers. We note that the matrix elements of the Fock operator equal the multipliers

$f_{ki} = \langle \psi_k | \hat{f} | \psi_i \rangle = \sum_{j=1}^N \varepsilon_{ji} \langle \psi_k | \psi_j \rangle = \varepsilon_{ki}$

### Canonical form#

Apart from a trivial overall phase factor, unitary transformations among the occupied orbitals are shown to leave the Hartree–Fock wave function unchanged. We introduce a unitary transformation that diagonalizes the Hermitian Fock matrix

$f' = \langle \overline{\psi}' | \hat{f} | \overline{\psi}' \rangle = U^\dagger \langle \overline{\psi} | \hat{f} | \overline{\psi} \rangle U = U^\dagger f U$

We have here adopted the compact overline notation of orbitals. In this basis of canonical spin orbitals, the Hartree–Fock equation takes the form

$\hat{f} | \psi_i \rangle = \varepsilon_{i} | \psi_i \rangle$

which we recognize as an eigenvalue equation introducing the orbital energies, $$\varepsilon_{i}$$, as the eigenvalues of the Fock operator. With an infinite number of solutions to the Hartree–Fock equation, the Hartree–Fock ground state is given by employing the $$N$$ spin orbitals with lowest orbital energies in the Slater determinant.

#### In AO basis#

The spatial parts of the spin orbitals, or molecular orbitals (MOs), are expanded as linear combination of atomic orbitals (LCAO). In the basis of spin atomic orbitals, the Fock matrix becomes block diagonal

$\begin{split} \mathbf{F} = \begin{pmatrix} \mathbf{F}^{\alpha\alpha} & \mathbf{0} \\ \mathbf{0} & \mathbf{F}^{\beta\beta} \end{pmatrix} \end{split}$

Using the bar notation to distinguish $$\alpha$$- and $$\beta$$-spin atomic orbitals, we get

\begin{align*} F_{\mu\nu} & = F^{\alpha\alpha}_{\mu\nu} = h_{\mu\nu} + \sum_{\gamma\delta} \Big( D_{\gamma\delta}(\mu\nu|\gamma\delta) - D^\alpha_{\gamma\delta}(\mu\delta|\gamma\nu) \Big) \\ F_{\bar{\mu}\bar{\nu}} & = F^{\beta\beta}_{\mu\nu} = h_{\mu\nu} + \sum_{\gamma\delta} \Big( D_{\gamma\delta}(\mu\nu|\gamma\delta) - D^\beta_{\gamma\delta}(\mu\delta|\gamma\nu) \Big) \\ F_{\mu\bar{\nu}} & = F_{\bar{\mu}\nu} = 0 \end{align*}

where

\begin{align*} D_{\gamma\delta} &= D^\alpha_{\gamma\delta} + D^\beta_{\gamma\delta} \\ D^\alpha_{\gamma\delta}& = \sum_{j=1}^{N_\alpha} \big[c_{\gamma j}^\alpha\big]^* c_{\delta j}^\alpha ; \quad D^\beta_{\gamma\delta} = \sum_{j=1}^{N_\beta} \big[c_{\gamma j}^\beta\big]^* c_{\delta j}^\beta \\ \end{align*}

The canonical Hartree–Fock equation thereby takes the form

$\mathbf{F C} = \mathbf{S C} \boldsymbol{\varepsilon} \, ,$

where $$\mathbf{S}$$ is the overlap matrix and $$\boldsymbol{\varepsilon}$$ is a diagonal matrix collecting the orbital energies.

## Hartree–Fock energy#

For a given density $$\mathbf{D}$$, the Hartree–Fock energy becomes equal to

$E_\mathrm{HF} = \frac{1}{2} \mathrm{tr} \big[ (\mathbf{h} + \mathbf{F}) \mathbf{D} \big] + V^\mathrm{n-n} \, ,$

where $$V^\mathrm{n-n}$$ is the nuclear repulsion energy.

## Koopmans’ theorem#

The orbital energies of occupied and unoccupied orbitals, respectively, equal

\begin{align*} \varepsilon_i & = \langle \psi_i |\hat{f} | \psi_i \rangle = \langle \psi_i |\hat{h} | \psi_i \rangle + \sum_{j\neq i}^N \big( \langle \psi_i | \hat{J}_j | \psi_i \rangle - \langle \psi_i | \hat{K}_j | \psi_i \rangle \big) \\ \varepsilon_a & = \langle \psi_a |\hat{f} | \psi_a \rangle = \langle \psi_a |\hat{h} | \psi_a \rangle + \sum_{j=1}^N \big( \langle \psi_a | \hat{J}_j | \psi_a \rangle - \langle \psi_a | \hat{K}_j | \psi_a \rangle \big) \end{align*}

where the cancellation between Coulomb and exchange terms for $$j=i$$ has been used in the former case. It thus appears as if $$\varepsilon_i$$ relates to the energy of an electron interacting with $$(N-1)$$ other electrons, whereas $$\varepsilon_a$$ relates to the energy of an electron interacting with $$N$$ other electrons. In accordance with these observations, it is readily shown from the expressions for matrix elements that

\begin{align*} \mathrm{IP} &= E_i^{N-1} - E_\mathrm{HF}^N = - \varepsilon_i \qquad (\textsf{ionization potential}) \\ \mathrm{EA} &= E_\mathrm{HF}^N - E_a^{N+1} = - \varepsilon_a \qquad (\textsf{electron affinity}) \end{align*}

where, in the frozen orbital approximation, $$E_i^{N-1}$$ is the energy of the system after the removal of the electron in spin orbital $$i$$ and $$E_a^{N+1}$$ is the energy of the system after the addition of an electron in spin orbital $$s$$.

## Brillouin’s theorem#

Based on the expressions for matrix elements, we find

$\langle \Phi_\mathrm{HF} | \hat{H} | \Phi_i^a \rangle = \langle \psi_i | \hat{f} | \psi_a \rangle = 0$

which shows that there is no coupling between the Hartree–Fock ground state and singly excited determinants. This result is known as the Brillouin theorem.

## SCF procedure#

Due to the summation over occupied spin orbitals that expresses the effective electron interactions, the Fock operator depends on its eigenfunctions and the canonical Hartree–Fock equation is therefore solved iteratively by means of a self-consistent field (SCF) procedure as illustrated in Fig. 17.

### Rothaan–Hall scheme#

In the following, we will consider the spin-restricted formulation where $$\alpha$$- and $$\beta$$-spin orbitals have identical spatial parts. We also restrict the situation to the common case of a closed-shell system such that

\begin{align*} N_\alpha & = N_\beta = \frac{1}{2} N \\ D^\alpha_{\gamma\delta} & = D^\beta_{\gamma\delta} = \frac{1}{2} D_{\gamma\delta} = \sum_{j=1}^{N/2} c_{\gamma j}^* c_{\delta j} \end{align*}

Note

When referring to closed-shell systems it is customary to refer to the density matrix as that for either of the spin components.

import veloxchem as vlx
import numpy as np

# Writing your own SCF program#

Let us implement the presented Hartree–Fock SCF procedure. We will use the water molecule as an example and, as reference, we will first compute the Hartree–Fock energy using the built-in compute method in VeloxChem.

## Setting up the system#

mol_str = """
O    0.000000000000        0.000000000000        0.000000000000
H    0.000000000000        0.740848095288        0.582094932012
H    0.000000000000       -0.740848095288        0.582094932012
"""

norb = vlx.MolecularBasis.get_dimensions_of_basis(basis, molecule)
nocc = molecule.number_of_electrons() // 2
V_nuc = molecule.nuclear_repulsion_energy()

print('Number of contracted basis functions:', norb)
print('Number of doubly occupied molecular orbitals:', nocc)
print(f'Nuclear repulsion energy (in a.u.): {V_nuc : 14.12f}')

Number of contracted basis functions: 24
Number of doubly occupied molecular orbitals: 5
Nuclear repulsion energy (in a.u.):  9.343638157670

## Reference calculation#

Let us first perform an reference calculation using the restricted closed-shell SCF driver in VeloxChem.

scf_drv = vlx.ScfRestrictedDriver()
scf_drv.compute(molecule, basis)

print(f'Final HF energy: {scf_drv.get_scf_energy() : 12.8f} Hartree')

Final HF energy: -76.02698419 Hartree

## Getting integrals in the AO basis#

# overlap matrix
overlap_drv = vlx.OverlapIntegralsDriver()
S = overlap_drv.compute(molecule, basis).to_numpy()

# one-electron Hamiltonian
kinetic_drv = vlx.KineticEnergyIntegralsDriver()
T = kinetic_drv.compute(molecule, basis).to_numpy()

nucpot_drv = vlx.NuclearPotentialIntegralsDriver()
V = -nucpot_drv.compute(molecule, basis).to_numpy()

h = T + V

# two-electron Hamiltonian
eri_drv = vlx.ElectronRepulsionIntegralsDriver()
g = np.zeros((norb, norb, norb, norb))
eri_drv.compute_in_mem(molecule, basis, g)

## Orthogonalization of the AO basis#

In order to use the np.linalg.eigh function from NumPy to solve the Hartree–Fock equation, we first retrieve an orthogonal AO (OAO) basis by means of a non-unitary transformation matrix $$\mathbf{X}$$ such that

$| \overline{\chi^\mathrm{OAO}} \rangle = | \overline{\chi} \rangle \mathbf{X}$

and

$\mathbf{S}^\mathrm{OAO} = \mathbf{X}^\dagger \mathbf{S X} = \mathbf{I}$

In the absence of linear dependencies in the AO basis, the overlap matrix is symmetric (and positive-definite) and it can first be diagonalized by a unitary transformation

$\mathbf{U}^{\dagger} \mathbf{S U} = \boldsymbol{\sigma}$

where $$\boldsymbol{\sigma}$$ is a diagonal matrix collecting the eigenvalues. It is then straightfoward to contruct explicit forms of $$\mathbf{X}$$. There exist two common choices

\begin{align*} \mathbf{X} = \mathbf{U} \boldsymbol{\sigma}^{-\frac{1}{2}} \mathbf{U}^\dagger \qquad & \textsf{symmetric, or Löwdin} \\ \mathbf{X} = \mathbf{U} \boldsymbol{\sigma}^{-\frac{1}{2}} \qquad & \textsf{canonical} \end{align*}

We can readily verify that both expression satisfy $$\mathbf{X}^\dagger \mathbf{S X} = \mathbf{I}$$. The expression for the associated transformation of MO coefficients is determined from the relation

$| \overline{\phi} \rangle = | \overline{\chi} \rangle \mathbf{C} = | \overline{\chi^\mathrm{OAO}} \rangle \mathbf{X}^{-1} \mathbf{C}$

We identify

$\mathbf{C}^\mathrm{OAO} = \mathbf{X}^{-1} \mathbf{C}$

or

$\mathbf{C} = \mathbf{X C}^\mathrm{OAO}$
# symmetric transformation
sigma, U = np.linalg.eigh(S)
X = np.einsum('ik,k,jk->ij', U, 1/np.sqrt(sigma), U)

## Solving the Hartree–Fock equation#

For a given Fock matrix, we solve the Hartree–Fock equation by the following steps:

1. transform the Fock matrix to the OAO basis

2. diagonalize the Fock matrix

3. transform the MO coefficients back to AO basis

def get_MO_coeff(F):

F_OAO = np.einsum('ki,kl,lj->ij', X, F, X)
epsilon, C_OAO = np.linalg.eigh(F_OAO)
C = np.einsum("ik,kj->ij", X, C_OAO)

return C

## SCF iterations#

We form an initial guess for the density based on the core Hamiltonian and thereafter enter the SCF iterations. As a measure of convergence, we adopt the norm of the occupied–virtual block of the Fock matrix in MO basis. It is convenient to scatter the elements of this block into the format of a vector and which we refer to as the error vector. During the course of the SCF iterations, we form a sequence of error vectors, $$\mathbf{e}_i$$.

max_iter = 50
conv_thresh = 1e-4

# initial guess from core Hamiltonian
C = get_MO_coeff(h)

print("iter      SCF energy    Error norm")

for iter in range(max_iter):

D = np.einsum('ik,jk->ij', C[:, :nocc], C[:, :nocc])

J = np.einsum('ijkl,kl->ij', g, D)
K = np.einsum('ilkj,kl->ij', g, D)
F = h + 2*J - K

E = np.einsum('ij,ij->', h + F, D) + V_nuc

# compute convergence metric
F_MO = np.einsum('ki,kl,lj->ij', C, F, C)
e_vec = np.reshape(F_MO[:nocc, nocc:], -1)
error = np.linalg.norm(e_vec)

print(f'{iter:>2d}  {E:16.8f}  {error:10.2e}')

if error < conv_thresh:
print('SCF iterations converged!')
break

C = get_MO_coeff(F)

iter      SCF energy    Error norm

 0      -68.84975229    2.23e+00
1      -69.95937641    1.79e+00
2      -73.34743276    1.74e+00
3      -73.46688910    1.36e+00
4      -74.74058933    1.29e+00
5      -75.55859127    7.91e-01
6      -75.86908635    4.86e-01
7      -75.97444165    2.74e-01
8      -76.00992921    1.60e-01
9      -76.02143957    8.99e-02
10      -76.02519173    5.15e-02
11      -76.02640379    2.92e-02
12      -76.02679653    1.67e-02
13      -76.02692347    9.45e-03
14      -76.02696455    5.38e-03
15      -76.02697784    3.06e-03
16      -76.02698213    1.74e-03
17      -76.02698352    9.89e-04
18      -76.02698397    5.63e-04
19      -76.02698412    3.20e-04
20      -76.02698416    1.82e-04
21      -76.02698418    1.04e-04
22      -76.02698418    5.89e-05
SCF iterations converged!

# Convergence acceleration#

## Direct inversion iterative subspace#

The Rothaan–Hall scheme suffer from poor numerical convergence and in practice some version of convergence acceleration is adopted. In the method of direct inversion of the iterative subspace (DIIS) [Pul80, Pul82, Sel93] information is used from not only the present but also previous iterations to form an averaged effective one-electron Hamiltonian, or Fock matrix, according to

$\mathbf{F}_n^\mathrm{DIIS} = \sum_{i=1}^n w_i \mathbf{F}_i$

where $$\mathbf{F}_i$$ is the Fock matrix generated in SCF iteration $$i$$, $$n$$ is present iteration, and the weights, $$w_i$$, are to be determined. To guarantee that the one-electron Hamiltonian is preserved in the effective Fock operator, we impose the condition

$\sum_{i=1}^n w_i = 1$

Under the assumption of a strict linearity between Fock matrices and error vectors, the averaged error vector would read

$\mathbf{e}_n^\mathrm{DIIS} = \sum_{i=1}^n w_i \mathbf{e}_i$

As the molecular orbitals change from one iteration to the next, this is not strictly the case but it is a good approximation. We can then determine the weights by minimizing the squared norm of the averaged error vector under the imposed constraint. The squared norm becomes equal to

$\| \mathbf{e}_n^\mathrm{DIIS} \|^2 = \sum_{i,j=1}^n w_i B_{ij} w_j ; \quad B_{ij} = \langle \mathbf{e}_i | \mathbf{e}_j \rangle$

and the constrained minimization is achieved by introducing a Lagrangian

$L = \| \mathbf{e}_n^\mathrm{DIIS} \|^2 - 2\lambda \Big( \sum_{i=1}^n w_i - 1 \Big)$

where the factor of $$-2$$ multiplying the Lagrange multiplier $$\lambda$$ is a mere convention as to arrive at an explicit matrix equation of the form

$\begin{split} \begin{pmatrix} B_{11} & \cdots & B_{1n} & -1 \\ \vdots & \ddots & \vdots & \vdots \\ B_{n1} & \cdots & B_{nn} & -1 \\ -1 & \cdots & -1 & 0 \end{pmatrix} \begin{pmatrix} w_1 \\ \vdots \\ w_n \\ \lambda \end{pmatrix} = \begin{pmatrix} 0 \\ \vdots \\ 0 \\ -1 \end{pmatrix} \end{split}$

We solve this equation for the weights, $$w_i$$, and then determine the averaged Fock matrix, $$\mathbf{F}_n^\mathrm{DIIS}$$, and error vector, $$\mathbf{e}_n^\mathrm{DIIS}$$, which are both kept in storage for subsequent SCF iterations.

def get_DIIS_fock(F_mats, e_vecs):

n = len(e_vecs)

# build DIIS matrix
B = -np.ones((n + 1, n + 1))
B[n, n] = 0

for i in range(n):
for j in range(n):
B[i,j] = np.dot(e_vecs[i], e_vecs[j])

b = np.zeros(n + 1)
b[n] = -1

w = np.matmul(np.linalg.inv(B), b)

F_ave = np.zeros((norb, norb))
evec_ave = np.zeros(nocc * (norb - nocc))
for i in range(n):
F_ave += w[i] * F_mats[i]
evec_ave += w[i] * e_vecs[i]

F_mats[-1] = F_ave
e_vecs[-1] = evec_ave

return F_ave

## SCF iterations#

In principle, the only needed modification in the SCF module to implement the DIIS scheme is a replacement of the original Fock matrix with the weighted averaged counterpart before the determination of the new MO coefficients. But it is also required to save Fock matrices and error vectors from previous SCF iteration. In practice, however, this extra storage requirement does not severely hamper applications, and in particular so as an optimum stabilitity in the DIIS scheme is experienced with the use of information from a limited number (about 10) of the previous iterations.

e_vecs = []
F_mats = []

# initial guess from core Hamiltonian
C = get_MO_coeff(h)

print("iter      SCF energy    Error norm")

for iter in range(max_iter):

D = np.einsum('ik,jk->ij', C[:, :nocc], C[:, :nocc])

J = np.einsum('ijkl,kl->ij', g, D)
K = np.einsum('ilkj,kl->ij', g, D)
F = h + 2*J - K
F_mats.append(F)

E = np.einsum('ij,ij->', h + F, D) + V_nuc

# compute convergence metric
F_MO = np.einsum('ki,kl,lj->ij', C, F, C)
e_vecs.append(np.reshape(F_MO[:nocc, nocc:], -1))
error = np.linalg.norm(e_vecs[-1])

print(f'{iter:>2d}  {E:16.8f}  {error:10.2e}')

if error < conv_thresh:
print('SCF iterations converged!')
break

F = get_DIIS_fock(F_mats, e_vecs)

C = get_MO_coeff(F)

iter      SCF energy    Error norm

 0      -68.84975229    2.23e+00
1      -69.95937641    1.79e+00
2      -75.55244086    7.92e-01
3      -75.98441968    2.55e-01
4      -76.01359974    1.37e-01
5      -76.02627504    3.17e-02
6      -76.02602152    3.75e-02
7      -76.02686952    1.26e-02
8      -76.02697700    3.01e-03
9      -76.02698332    8.67e-04
10      -76.02698394    5.41e-04
11      -76.02698416    1.39e-04
12      -76.02698418    5.89e-05
SCF iterations converged!


text:
LIFT

# Chapter 6: LIFT #

I may remark that the curious transformations many formulae can undergo, the unsuspected and to a beginner apparently impossible identity of forms exceedingly dissimilar at first sight, is I think one of the chief difficulties in the early part of mathematical studies. I am often reminded of certain sprites and fairies one reads of, who are at one’s elbows in one shape now, and the next minute in a form most dissimilar.

When you believe in a thing, believe in it all the way, implicitly and unquestionable.

— Walt Disney

As seen in Chapter 5, recursive specifications often lead to algebraic equations encoding a generating function of interest. Right now we need to solve these algebraic equations to extract coefficients and determine counting sequences, however this can be difficult (and sometimes impossible). In this chapter we construct a powerful algebraic tool to determine coefficients from algebraic equations without solving them.

Lagrange Implicit Function Theorem (LIFT): Let $D$ be an integral domain containing the rational numbers (for instance, the rational numbers itself, the real numbers, polynomials with rational coefficients, etc.). If $G(u)$ is a formal power series in $D[[u]]$ such that the constant term $G(0)$ is invertible in $D$ then there is a unique element $R \in D[[z]]$ with $R(0)=0$ such that $$z=\frac{R(z)}{G(R(z))}.$$ Furthermore, if $F(u)$ is any formal power series in $D[[u]]$ then $$[z^n] F(R(z)) = \frac{1}{n} \left[u^{n-1}\right] F^\prime(u)G(u)^n$$ for all $n \geq 1.$

This statement of LIFT is written in a very general way in order to apply as broadly as possible. It is often applied in the special case when $F(z)=z,$ where it gives the following.

Corollary: If $R\in D[[z]]$ has no constant term and satisfies $$z = \frac{R(z)}{G(R(z))}$$ for some power series $G \in D[[u]]$ whose constant term is invertible in $D$ then $$[z^n]R(z) = \frac{1}{n}\left[u^{n-1}\right]G(u)^n.$$
Example: As seen previously, a nonempty planar rooted tree is a vertex followed by a sequence of nonempty planar rooted trees. If $\mathcal{T}$ is the class of nonempty planar rooted trees then $$\mathcal{T} = \mathcal{Z} \times \text{SEQ}(\mathcal{T})$$ so that $$T(z) = \frac{z}{1-T(z)}$$ and thus $$z = \frac{T(z)}{G(T(z))}$$ where $G(u) = (1-u)^{-1}.$ LIFT and the Negative Binomial Theorem then imply $$[z^n] T(z) = \frac{1}{n}\left[u^{n-1}\right] (1-u)^{-n} = \frac{1}{n} (-1)^{n-1} \binom{-n}{n-1} = \frac{1}{n} \binom{2n-2}{n-1},$$ rederiving a result previously determined by a long computation in a single line.

## A Proof of LIFT #

Many proofs of LIFT for convergent series use tools from complex analysis. Because we want to apply LIFT over general integral domains (for instance, when working with multivariate generating functions in the next chapter) we cannot use such techniques, but we can use tools from analysis to motivate the formal constructions used in our proof. Interestingly, even though LIFT is a statement about power series the most convenient method of proof uses arguments about Laurent series.

Let $D$ be an integral domain containing the rational numbers and let $F(z) = \sum_{n \geq \kappa} f_nz^n$ be a formal Laurent series in $D((z)).$ The residue of $F(z)$ is the coefficient $$\text{res}(F) = \left[z^{-1}\right]F(z) = f_{-1}.$$ We define the formal derivative of a Laurent series analogously to the formal derivative of a power series, $$\frac{d}{dz} F(z) = F^\prime(z) = \sum_{n \geq \kappa} nf_n z^{n-1}.$$ We begin by establishing some technical results that will be used in our proof of LIFT.

Lemma 1: The derivative $F^\prime$ satisfies $\text{res}(F^\prime)=0$ for any Laurent series $F.$
Proof of Lemma 1
We have $\displaystyle \left[z^{-1}\right]F^\prime(z) = \left[z^{-1}\right]\sum_{n \geq \kappa} nf_n z^{n-1} = 0 \cdot f_0 = 0.$
Lemma 2: For any Laurent series $F,G \in D((z)),$ $$[z^{-1}]F^\prime(z)G(z) = -[z^{-1}]F(z)G^\prime(z).$$
Proof of Lemma 2
The product rule implies that $$\left(F(z)G(z)\right)^\prime = F^\prime(z)G(z) + F(z)G^\prime(z),$$ so the stated identity follows from Lemma 1.

Let $G(z)$ be a non-zero formal power series with no constant term. If $F(z)$ is any formal power series then we proved in Chapter 4 that the composition $F(G(z))$ is a well-defined formal power series. In fact, if $$F(z) = f_{-r}z^{-r} + f_{-r+1}z^{-r+1} + \cdots$$ is any formal Laurent series then the composition $$F(G(z)) = \underbrace{f_{-r}G(z)^{-r} + \cdots + f_{-1}G(z)^{-1}}_{\text{finite sum}} + \sum_{n\geq0} f_nG(z)^n$$ is a well-defined Laurent series, since the first term is a (possibly empty) finite sum of Laurent series and the second term is the composition of $G(z)$ with a formal power series.

Change of Variables Lemma: Let $D$ be an integral domain containing $\mathbb{Q},$ let $F(u)$ be a formal Laurent series in $D((u)),$ and let $B(z)$ be a formal power series in $D[[z]]$ such that $$B(z) = b_kz^k + b_{k+1}z^{k+1} + \cdots$$ for some $k>0$ with $b_k$ is invertible in $D.$ Then $$[z^{-1}]F(B(z))B^\prime(z) = k \; [u^{-1}]F(u).$$
Proof of Change of Variables Lemma

First, suppose that $F(u)=u^r$ for some integer $r.$

• If $r \neq -1$ then the right-hand side of the claimed equality is $[u^{-1}]u^r = 0.$ Similarly, the left-hand side of the claimed equality is $$[z^{-1}]B(z)^rB^\prime(z) = [z^{-1}] \left(\frac{1}{r+1} B(z)^{r+1}\right)^\prime=0$$ by Lemma 1, where we note $1/(r+1)$ exists because $D$ contains $\mathbb{Q}.$ Thus, the claimed equality holds.

• If $r=-1$ then the right-hand side of the claimed equality is $k[u^{-1}]u^{-1}=k$ while the left-hand side is $[z^{-1}]B(z)^{-1}B^\prime(z).$ Write $$B(z) = b_kz^k \; \underbrace{\left( 1 + \frac{b_{k+1}}{b_k}z + \cdots \right)}_{H(z)}$$ for a power series $H$ with constant coefficient $1,$ so that \begin{aligned} B(z)^{-1} &= b_k^{-1}z^{-k}H(z)^{-1} \\[+3mm] B^\prime(z) &= b_k z^{k}H^\prime(z) + k b_k z^{k-1}H(z). \end{aligned} The left-hand side of the claimed equality is thus \begin{aligned} [z^{-1}]B(z)^{-1}B^\prime(z) &= [z^{-1}] \left( H(z)^{-1}H^\prime(z) + k z^{-1} \right) \\[+3mm] &= [z^{-1}] \left( H(z)^{-1}H^\prime(z) \right) + k. \end{aligned} The residue $[z^{-1}] \left( H(z)^{-1}H^\prime(z) \right)=0$ because $H(z)^{-1}$ and $H^\prime(z)$ are formal power series, so $[z^{-1}]B(z)^{-1}B^\prime(z) = k$ and the claimed equality holds.

Having proved the claimed equality when $F(u)=u^r$ we now establish the general case. If $F(u) = \sum_{\ell \geq N}f_\ell u^\ell$ then \begin{aligned} [z^{-1}]F(B(z))B’(z) &= [z^{-1}]\left(\sum_{\ell \geq N} f_\ell B(z)^\ell B^\prime(z)\right) \\[+4mm] &= \sum_{\ell \geq N} f_\ell \cdot [z^{-1}] \left(B(z)^\ell B^\prime(z)\right) \\[+4mm] &= \sum_{\ell \geq N} k f_\ell \cdot [u^{-1}] u^\ell \\[+4mm] &= k [u^{-1}]F(u), \end{aligned} as desired. Note that the third equality in this chain follows from the version of the result with $F(u)=u^\ell$ established above.

We now assume the hypotheses in the statement of LIFT and complete its proof in two steps, using the Change of Variables Lemma.

### Step 1: Existence and Uniqueness #

We first prove that there is a unique $R \in D[[z]]$ such that $R(z) = zG(R(z)).$ Let $$R(z) = \sum_{\ell \geq 0}r_\ell z^\ell \qquad\qquad G(u) = \sum_{k \geq 0}g_ku^k,$$ so that $r_0 = [z^0]zG(R(z)) = 0.$ For any $n \geq 1$ we want to find a coefficient \begin{aligned} r_n &= [z^n]zG(R(z)) \\[+2mm] &= [z^{n-1}]\sum_{k \geq 0} g_k \left(\sum_{\ell \geq 1} r_\ell z^\ell \right)^k \\[+5mm] &= [z^{n-1}]\sum_{k=0}^{n-1} g_k \left(\sum_{\ell \geq 1} r_\ell z^\ell \right)^k \\[+5mm] &= \sum_{k=0}^{n-1} g_k \left(\sum_{|(\ell_1,\dots,\ell_k)| = n-1} r_{\ell_1} \cdots r_{\ell_k}\right), \end{aligned} where the final sum is over $k$-tuples of positive integers summing to $n-1.$ This is a complicated expression, but it implies that there is a series $R(z)$ solving the stated equation whose coefficients $r_n$ are uniquely determined inductively by a polynomial expression in $g_0,\dots,g_{n-1},r_0,\dots,r_{n-1}.$ We also note that $r_1=g_0$ is invertible in $D.$

### Step 2: Coefficients #

Let $P(u) = uG(u)^{-1}.$ If we set $u = R(z)$ then $$z = R(z)G(R(z))^{-1} = uG(u)^{-1} = P(u)$$ so the substitution $z=P(u)$ is the inverse substitution to $u = R(z).$ In particular, if we define $H(u) = P(u)^{-n}F^\prime(u)$ then $H(R(z)) = z^{-n} F^\prime(R(z)).$

Now, if $n\geq1$ then \begin{aligned} [z^n]F(R(z)) &= [z^{-1}]z^{-1-n}F(R(z)) \\[+2mm] &= \frac{-1}{n} [z^{-1}] \left( z^{-n} \right)^\prime F(R(z)) &&\text{Def. of \left(z^{-n}\right)^\prime} \\[+2mm] &= \frac{1}{n} [z^{-1}] z^{-n} \left(F(R(z))\right)^\prime &&\text{Lemma 2} \\[+2mm] &= \frac{1}{n} [z^{-1}] z^{-n} F^\prime(R(z))R^\prime(z) &&\text{Chain Rule} \\[+2mm] &= \frac{1}{n} [z^{-1}] H(R(z))R^\prime(z). \end{aligned} Since $R(z) = r_1z + \cdots$ and $r_1 \neq 0,$ the Change of Variables Lemma applies with $k=1,$ giving \begin{aligned} [z^n]F(R(z)) &= \frac{1}{n}[u^{-1}]H(u) \\[+2mm] &= \frac{1}{n}[u^{-1}]P(u)^{-n}F^\prime(u) \\[+2mm] &= \frac{1}{n}[u^{-1}]u^{-n}G(u)^nF^\prime(u) \\[+2mm] &= \frac{1}{n}[u^{n-1}]G(u)^nF^\prime(u), \end{aligned} as claimed.

Remark: There are many proofs of LIFT, some analytic (applying to convergent series), some algebraic, and even some that are combinatorial.

## Examples #

Having gone through the long algebraic argument establishing LIFT once, we will now make great use of it throughout the rest of the notes. We end with a couple more examples.

Example: Fix a positive integer $r.$ Find the number of rooted planar trees where every node has either 0 or exactly $r$ children.

The combinatorial description of the class $\mathcal{T}$ under consideration directly yields the construction $$\mathcal{T} = \mathcal{Z} \times \left(\epsilon + \mathcal{T}^r\right),$$ so that $$T(z) = z\left(1+T(z)^r\right),$$ and thus $$z = \frac{T(z)}{G(T(z))}$$ where $G(u) = 1+u^r.$ LIFT and the binomial theorem then imply that the number of such trees with $n$ nodes is \begin{aligned} [z^n]T(z) &= \frac{1}{n}[u^{n-1}]\left(1+u^r\right)^n \\[+3mm] &= \begin{cases} 0 &\text{ if r doesn’t divide n-1} \\[+2mm] \frac{1}{n}\binom{n}{\frac{n-1}{r}} &\text{ if r divides n-1.} \end{cases} \end{aligned}

Sometimes the combinatorial specification of a class must be slightly modified in order to find an equation of the form where LIFT can be applied.

Example: The class $\mathcal{F}$ of rooted planar $5$-ary trees satisfies the specification $$\mathcal{F} = \epsilon + \mathcal{Z} \times \mathcal{F}.$$ Find a formula for the number of elements of $\mathcal{F}$ of size $n.$

This specification gives the algebraic equation $$F(z) = 1 + zF(z)^5,$$ however this is not in the form where we can apply LIFT. The problem is that we have constructed $\mathcal{F}$ with an element of size $0,$ so $F(0) \neq 0.$ To correct this, we let $S(z) = F(z) - 1$ be the generating function for the number of elements in $\mathcal{F}$ of size at least $1.$ Then $$z = \frac{S(z)}{(1+S(z))^5} = \frac{S(z)}{G(S(z))},$$ where $G(u) = (1+u)^5,$ so if $n \geq 1$ then LIFT implies $$[z^n]F(z) = [z^n]S(z) = \frac{1}{n}[u^{n-1}] (1+u)^{5n} = \frac{1}{n}\binom{5n}{n-1}.$$

Problem 1: The famous Lambert W function $W(z)$ (which has a huge number of applications) is defined by the equation $W(z)e^{W(z)} = z.$ Use LIFT to prove that $$W(z) = \sum_{n \geq 1} \frac{(-n)^{n-1}}{n!} z^n.$$

Problem 2: Suppose that $R\in D[[z]]$ has no constant term and satisfies $$z = \frac{R(z)}{G(R(z))}$$ for some power series $G \in D[[u]]$ whose constant term is invertible in $D.$

(a) Prove that $$[z^n]R(z)^k = \frac{k}{n}\left[u^{n-k}\right]G(u)^n$$ for any positive integer $n$ and natural number $k.$

(b) Prove that $$[z^n]\frac{R(z)^k}{1-zG^\prime(R(z))} = \left[u^{n-k}\right] G(u)^n$$ for any positive integer $n$ and natural number $k.$

Problem 3: Show that if $T(z)$ is a formal power series in $D[[z]]$ satisfying $T(z)=z\exp(T(z))$ and $c$ is any invertible constant in $D$ then $$[z^n]\exp(cT(z)) = \frac{c(c+n)^{n-1}}{n!}.$$ Hint: Use the fact that the formal exponential satisfies $\exp((a+b)z) = \exp(az)\exp(bz)$ for any $a,b \in D$ together with the general form of LIFT.

Problem 4: Let $a,b,$ and $a+b$ be invertible in $D.$ Prove Abel’s extension of the binomial theorem, $$(a+b)(a+b+n)^{n-1} = \sum_{k=0}^n \binom{n}{k}a(a+k)^{k-1}b(b+n-k)^{n-k-1},$$ by calculating the coefficient of $z^n$ in $\exp((a+b)T(z))$ in two different ways, where $T$ satisfies $T(z)=z\exp(T(z)).$


text:
# The product of two consecutive even integers is 624. How do you find the integers?

Jun 18, 2018

See a solution process below:

#### Explanation:

First, let's call the first number: $x$

Then the next consecutive even integer would be: $x + 2$

Therefore their product in standard form would be:

$x \left(x + 2\right) = 624$

${x}^{2} + 2 x = 624$

${x}^{2} + 2 x - \textcolor{red}{624} = 624 - \textcolor{red}{624}$

${x}^{2} + 2 x - 624 = 0$

We can factor this as:

(x + 26)(x - 24) = 0

Now, we can solve each term on the left side of the equation for $0$:

Solution 1:

$x + 26 = 0$

$x + 26 - \textcolor{red}{26} = 0 - \textcolor{red}{26}$

$x + 0 = - 26$

$x = - 26$

Solution 2:

$x - 24 = 0$

$x - 24 + \textcolor{red}{24} = 0 + \textcolor{red}{24}$

$x - 0 = 24$

$x = 24$

If the first number is $- 26$ then the second number is:

$- 26 + 2 = - 24$

$- 26 \cdot - 24 = 624$

If the first number is 24 then the second number is:

$24 + 2 = 26$

$24 \cdot 26 = 624$

There are two solutions to this problem:

$\left\{- 26 , - 24\right\}$; $\left\{24 , 26\right\}$


text:
Limited access

After soccer practice, Coach Miller goes to the roof of the school to retrieve the errant soccer balls. The height of the school is $3.5\text{ m}$. He kicks a soccer ball which leaves the roof with a horizontal velocity, but no vertical velocity.

Ignoring air resistance, which of the following values indicates how much horizontal velocity is needed for the ball to reach the soccer field located $22\text{ m}$ from the school?

A

$26\text{ m/s}$

B

$23\text{ m/s}$

C

$21\text{ m/s}$

D

$18\text{ m/s}$

Select an assignment template


text:
# Coverage Analysis¶

## Verifying Test Quality¶

The purpose of coverage analysis is to verify the thoroughness of a test suite. For example, unit tests are used to validate the implementation of detailed design objects through comprehensive testing. Coverage analysis checks that the testing is, indeed, comprehensive by executing instrumented unit tests which records the complete execution path through the code and then calculating metrics indicative of the coverage achieved during execution.

Coverage analysis examines the output of a code instrumented to record every line executed, every conditional branch taken, and every block executed. It then generates metrics on:

• Percent of statements executed
• Percent of methods (and/or functions) executed
• Percent of conditional branches executed
• Percent of a method’s (and/or function’s) entry/exit branches taken.

The metrics give a general idea of the thoroughness of the unit tests. The most valuable aspect of most web-based coverage analysis tools is the color-coded report where the statements not exercised and the branches not taken are vividly evident. The color-coded coverage holes clearly show the developer where unit tests need improvement.

Using the coverage analysis reports, the LSST DM developer should determine code segments which have not been adequately tested and should then revise the unit test suite as appropriate. Coverage analysis reports should be generated in concert with the routine automated CI testing.

## DM Coverage Analysis Metrics¶

Refer to Code Coverage Analysis, by Steve Cornett, for a discussion of coverage metrics and to Minimum Acceptable Code Coverage, also by Steve Cornett, for the companion discussion on determining ‘good-enough’ overall test coverage.

A specific metric for lines of code executed and/or metric for branch conditionals executed is expected to be defined for Construction.

## Using Coverage Analysis Tools¶

### C++¶

LSST scons builds will automatically instrument all object and link modules with coverage counters when invoked with:

scons profile=gcov

This passes --coverage to all compile and link builds; this is equivalent to -fprofile-arcs -ftest-coverage on compile and -lgcov on link.

Executing the instrumented program causes coverage output to be accumulated. For each instrumented object file, the associated files .gcda and .gcno are created in the object file’s directory. Successive runs add to the .gcda files resulting in a cumulative picture of object coverage.

Use one of the following tools to create the coverage analysis reports to verify that your unit testing coverage is adequate. Editor’s preference is for either ggcov or tggcov since only the local source files are processed; see below for details.

#### gcov¶

gcov is the original coverage analysis tool delivered with the GNU C/C++ compilers. The coverage analysis output is placed in the current directory. The analysis is done on all source and include files to which the tool is directed so be prepared for reports on all accessed system header files if you use gcov.

Use the following to generate coverage analysis on the LSST <module>/src directory:

cd <module>
scons profile=gcov
gcov -b -o src/ src/*.cc src.gcov >& src_gcov.log

#### ggcov¶

ggcov is an alternate coverage analysis tool to gcov which uses a GTK+ GUI. ggcov uses the same profiling data generated from a GCC instrumented code but uses its own analysis engine.

Use the following to bring up the ggcov GUI:

cd <module>
scons profile=gcov
ggcov -o src/

#### tggcov¶

tggcov is the non-graphical interface to ggcov.

tggcov creates its output files in the same directory as the source files are located. It creates analysis files for only the local source files (i.e. not the system files).

Use the following for a comprehensive coverage analysis. Output files will be in src/*.cc.tggcov:

cd <module>
scons profile=gcov
tggcov -a -B -H -L -N -o src/ src

#### gcov output files in git directories¶

gcov coverage output files should be identified as non-git files to avoid the git warning about untracked files. In order to permanently ignore all gcov output files, add the extensions .gcno and .gcda, to the .gitignore file.

### Python¶

Note

No recommendations have been made for Python coverage analysis tools. The following are options to explore when time becomes available.

#### Coverage.py¶

Coverage.py, written by Ned Batchelder, is a Python module that measures code coverage during Python execution. It uses the code analysis tools and tracing hooks provided in the Python standard library to determine which lines are executable and which have been executed.

#### figleaf¶

figleaf, written by Titus Brown, is a Python code coverage analysis tool, built somewhat on the model of Ned Batchelder’s Coverage.py module. The goals of figleaf are to be a minimal replacement of Coverage.py that supports more configurable coverage gathering and reporting.

### Java¶

No options have been researched.

## Python & C++ Test Setup¶

DM developers frequently use the Python unittest framework to exercise C++ methods and functions. This scenario still supports the use of the C++ coverage analysis tools.

As usual, the developer instruments the C++ routines for coverage analysis at compilation time by building with scons profile=gcov. The C++ routines generated from the pybind11 source are also instrumented. Later when a Python unittester invokes an instrumented C++ routine, the coverage is recorded into the well-known coverage data files <src>.gcda and <src>.gcno. Post-processing of the coverage data files is done by the developer’s choice of C++ coverage analysis tool.


text:
# [texhax] reference to complete bibtex-listing

Uwe Lück uwe.lueck at web.de
Tue Jun 17 11:55:42 CEST 2008

... to be sure, if the bibliography chapter has a number which you want
to refer to, the trick may not be dirty enough; in this case one needs to
know what chapter macro you are using (it won't be standard LaTeX)
-- Uwe.

>Date: Tue, 17 Jun 2008 01:20:57 +0200
>From: Uwe Lück <uwe.lueck at web.de>
>
>At 07:56 06.06.08, Peter Dziedzic wrote:
>>I want to make reference with \ref{} to my complete
>>bibtex-bibliogrpahy-chapter.
>[...]
>>i want to reference to the whole chapter and i dont know how can i do it.
>
>nice request; dirty trick, working at my test:
>
>     \renewcommand{\refname}{References\label{refref}}
>
>... to be referred to by \pageref{refref}
>
>!? Uwe.


text:
Citations:hyperslab

English citations of hyperslab

• 2010 Yannis Kopsinis et al, "Online Sparse System Identification and Signal Reconstruction using Projections onto Weighted $\ell_1$ Balls" arXiv
The algorithm develops around projections onto the sequence of the generated hyperslabs as well as the weighted ${\displaystyle \ell _{1}}$  balls.


text:
MathSciNet bibliographic data MR344439 30A32 Bajpai, S. K. On regions of $\alpha$$\alpha$-convexity for starlike functions. Proc. Amer. Math. Soc. 44 (1974), 365–368. Article

For users without a MathSciNet license , Relay Station allows linking from MR numbers in online mathematical literature directly to electronic journals and original articles. Subscribers receive the added value of full MathSciNet reviews.


text:
# Autofill a table based on the input provided in a userform

Good morning,

I have the following code:

Option Explicit

Private Sub CommandButton1_Click()
Dim LastRowA As Long, LastRowB As Long, LastRowC As Long, lastrowD As Long, LastrowE As Long,
LastrowF As Long, LastrowG As Long, LastrowH As Long, LastrowI As Long, LastrowK As Long, LastrowL
As Long
Dim ws As Worksheet

Set ws = Sheets("Sheet1")

LastRowA = ws.Range("A" & Rows.Count).End(xlUp).Row + 1 'Finds the last blank row
LastRowB = ws.Range("B" & Rows.Count).End(xlUp).Row + 1
LastRowC = ws.Range("C" & Rows.Count).End(xlUp).Row + 1
lastrowD = ws.Range("D" & Rows.Count).End(xlUp).Row + 1
LastrowE = ws.Range("E" & Rows.Count).End(xlUp).Row + 1
LastrowF = ws.Range("F" & Rows.Count).End(xlUp).Row + 1
LastrowG = ws.Range("G" & Rows.Count).End(xlUp).Row + 1
LastrowH = ws.Range("H" & Rows.Count).End(xlUp).Row + 1
LastrowI = ws.Range("I" & Rows.Count).End(xlUp).Row + 1
LastrowK = ws.Range("K" & Rows.Count).End(xlUp).Row + 1
LastrowL = ws.Range("L" & Rows.Count).End(xlUp).Row + 1

ws.Range("A" & LastRowA).Value = JobID.Text 'Adds the TextBox3 into Col A & Last Blank Row
ws.Range("B" & LastRowB).Value = Surveyor.Text
ws.Range("C" & LastRowC).Value = DateBox.Text
ws.Range("E" & LastrowE).Value = CityBox.Text
ws.Range("F" & LastrowF).Value = PostcodeBox.Text
ws.Range("G" & LastrowG).Value = THPBox.Text
ws.Range("H" & LastrowH).Value = ChamberBox.Text
ws.Range("I" & LastrowI).Value = ORFibreBox.Text
ws.Range("K" & LastrowK).Value = ("=I" & LastrowI & "*5")

End Sub

which helps me to autofill the table columns based on the user form.

The code is valid, but I am wondering how can I write it smarter. Is it possible at all?

Whenever you find yourself writing a block of nearly identical code, I recommend creating a common function that simplifies and isolates that functionality. The advantage is that you now have a single location for the logic and can easily make a change that is consistent for each instance you need to use that logic. In your case, you are repeatedly finding the last row in a column and adding a value to the first empty row in that column. So create a separate routine for that.

You have three tricky parts. The first is that you're not always adding a value. In at least one case, you want to add a formula. For this, I created a simple enumeration type as an optional parameter. The second is you wanted to use the row index in your formula, so that row index value is returned from the function to use if needed. The last tricky bit is adding a value to a column that is completely empty. You can't blindly always add one to the lastRow value because you'll end up skipping that top row. This isn't always a problem since many folks reserve the first row for a column header, but the function takes this into account to be thorough.

Option Explicit

Private Enum DataType
DataValue
FormulaValue
End Enum

Private Sub CommandButton1_Click()
AppendToColumn Sheet1, "A", JobID.Text  'Adds the TextBox3 into Col A & Last Blank Row
AppendToColumn Sheet1, "B", Surveyor.Text
AppendToColumn Sheet1, "C", DateBox.Text
AppendToColumn Sheet1, "E", CityBox.Text
AppendToColumn Sheet1, "F", PostcodeBox.Text
AppendToColumn Sheet1, "G", THPBox.Text
AppendToColumn Sheet1, "H", ChamberBox.Text
Dim lastRowI As Long
lastRowI = AppendToColumn(Sheet1, "I", ORFibreBox.Text)
AppendToColumn Sheet1, "K", ("=I" & lastRowI & "*5"), FormulaValue
End Sub

Private Function AppendToColumn(ByRef ws As Worksheet, _
ByVal columm As Variant, _
ByVal value As Variant, _
Optional ByVal kindOfValue As DataType = DataValue) As Long
'--- copies the given value to the first empty cell in the
'    specified column. the "columm" value can be either numeric
'    or alphabetic. RETURNS the index of the last row
Dim colIndex As Long
Dim lastRow As Long
Dim firstEmptyRow As Long
With ws
'--- quick conversion to make sure we have a numeric column index
colIndex = IIf(IsNumeric(columm), columm, .Cells(1, columm).column)
lastRow = .Cells(.Rows.Count, colIndex).End(xlUp).Row
'--- if the column is completely empty, the first empty row is 1,
'    otherwise it's one row down from the last row
firstEmptyRow = IIf(IsEmpty(.Cells(lastRow, colIndex)), 1, lastRow + 1)
Select Case kindOfValue
Case DataValue
.Cells(firstEmptyRow, colIndex).value = value
Case FormulaValue
.Cells(firstEmptyRow, colIndex).Formula = value
End Select
End With
AppendToColumn = lastRow
End Function

Assuming that you always want the data from a single button press to fall on the same row, you can achieve this functionality with

let ws.[A1].Offset(row-1).Resize(1,10) = _
Array( _
JobID.Text, _
Surveyor.Text, _
DateBox.Text, _
CityBox.Text, _
PostcodeBox.Text, _
THPBox.Text, _
ChamberBox.Text, _
ORFibreBox.Text)
let ws.[K1].Offset(row-1).Formula="=I" & row & "*5"

where you have to row is found in the same way as you had been doing before, with some column that is garunteed not to have a blank. Or, if we assume that column J will always be blank at the time a new row is added, you can do this with

let ws.[A1].Offset(row-1).Resize(1,10) = _
Array( _
JobID.Text, _
Surveyor.Text, _
DateBox.Text, _
CityBox.Text, _
PostcodeBox.Text, _
THPBox.Text, _
ChamberBox.Text, _
ORFibreBox.Text, _
"", _
("=I" & row & "*5"))

That said, you should probably look into making the table into a ListObject. If you do so (CTRL + T while highlighting the table; yes it has headers), you can make your code look like

dim lo as ListObject, _
lr as ListRow

Set lo = ws.[A1].listobject
let lr.Range(1, 1).Resize(1, 11) = _
Array( _
JobID.Text, _
Surveyor.Text, _
DateBox.Text, _


text:
# Math Help - Prove Trig Identity

1. ## Prove Trig Identity

$\frac{cos2x}{sin2x+1} = \frac{1-tanx}{1+tanx}$

Can't seem to prove this one, help please

2. Originally Posted by Raj
$\frac{cos2x}{sin2x+1} = \frac{1-tanx}{1+tanx}$

Can't seem to prove this one, help please
Start by choosing a side.

I choose the right hand side.

Substitute $\tan x = \frac{\sin x}{\cos x}$. Multiply numerator and denominator by $\cos x$.

Now multiply numerator and denominator by $\cos x + \sin x$ and expand.

You should recognise the numerator as $\cos (2x)$. Simplify the denominator to recognise $\sin (2x)$.

3. Substitute . Multiply numerator and denominator by .
Where is the cosx coming from

4. Originally Posted by Raj
Where is the cosx coming from
Did you do the substitution?

If you did it should be perfectly clear where the cos x comes from. You multiply top and bottom by cos x to get rid of the fraction.

You have to actually do each of the suggested steps before you'll see why you do them.


text:
# How to tweak acronym.sty to longtable width format and appearance?

Is it possible to tweak the acronym.sty to accept the same width format as passed to the long table example below?

In other words going from

    %\begin{acronym}[USA]
%\acro{USA}{United States of America}
%\end{acronym}

to

    %\begin{acronym}{@{}p{50pt} p{250pt}} % <-- direct example
%\acro{USA}{United States of America}
%\end{acronym}

The intention is to make the appearance of the acronym list identical to the longtable I am using for nomenclature (see example below). I would like to keep the functionality of the acronym package.

    \begin{longtable}[l]{@{}p{50pt} p{250pt}}
\textsc{Acronym} & \textsc{Description}\\
\textsc{USA} & {United States of America}
\end{longtable}

How to change the format of acronyms? came somewhat close, but I am not near having the necessary know how for tweaking that .sty modification to something looking like the example given above. I am aware that the line spacing and column widths might make things rather complicated. Perhaps it would be simpler to redefine the acronym.sty to use longtable instead?

I am using the classicthesis.sty https://www.ctan.org/pkg/classicthesis with no modifications; i.e. I am tweaking the ClassicThesis.tex.

Suggestions are much appreciated!

• I might suggest switching to the acro package which is very similar but more powerful and (most relevantly) has an option to print the list of acronyms in a longtable environment. – Dai Bowen Sep 11 '16 at 20:44

Having spent a while looking at Gonzalo Medina's answer to the question you link to I think it will at least be very difficult to adapt the acronym package to be used in a longtable.

Instead I'm going to provide one of those annoying answers which tells you how to do what you want in a different package. In this case, the acro package which is not too dissimilar from acronym (same macros for using acronyms, slightly different way of defining them and generally more powerful).

The advantage acro offers is that you can define styles for how the acronym list is printed by

\DeclareAcroListStyle{ThomasStyle}{table}{
table = longtable,
table-spec = | @{} p{50pt} | p{250pt} |
}

The first argument provides a name for the list, the second specifies the general type (i.e. list or table) then this is followed by a key-value list, the table key sets which table-like environment is used and table-spec sets the column types

Then we can set the acronym list to be printed with this style with \acsetup{list-style=ThomasStyle}

This will now print the entire list in a longtable environment with the column specifications given.

\documentclass{article}

\usepackage{acro}

\usepackage{longtable}

\DeclareAcroListStyle{ThomasStyle}{table}{
table = longtable,
table-spec = | @{}p{50pt} | p{250pt} |
}

\acsetup{list-style=ThomasStyle}

\DeclareAcronym{pdf}{
short = pdf,
long = portable document format
}

\begin{document}
This is a \ac{pdf}

\printacronyms
\end{document}

As far as generally switching from acronym to acro, it should be sufficient to replace \acro{shortname}{longname} with \DeclareAcronym{key}{short=shortname,long=longname} for the simplest cases, the \ac{key} macro works in the same manner with both packages.


text:
## 03453660 2 years ago prove: when xz= yz then x=y if z is not equal to zero

1. ParthKohli

This uses certain axioms.

2. ParthKohli

Well... this is itself an axiom.

3. 03453660

yes but how to prove

4. ParthKohli

Divide both sides by $$\rm z$$.

5. 03453660

no no i worked like that but it needs another proof

6. hba

You Mean Geometric Proofs ?

7. akhilnkumar

@ParthKohli seems right. Dividing both the sides by z is possible only when z is not equal to 0. Cuz, any number divided by 0 is not defined. Do reply if you get another proof.

8. hba

Take z inverse operation xz * z^-1 = yz * z^-1 x = y

9. hba

Well Pk is Right

10. vipul92

we can write x/y=z/z so x/y=1 so x=y

11. 03453660

ok man i got the proof wanna share with you guyssssss as xz = yz -----> given xz- yz = 0 (x-y)z = 0 as z is not equal to zero-----> given thus x-y=0 => x=y hence proved thanks to all of you. thanks alot for your time

12. 03453660

@hba ,@vipul92 ,@akhilnkumar ,@ParthKohli