text:
# slama.dev

## History Of Changes

Vim , released 28. 7. 2020, updated 26. 6. 2022

In this post, we’ll talk about how history of changes is implemented in Vim (compared to other editors), how to make it persistent, why the <u> + <C-r> combination isn’t doing it justice and what are some plugins you can use to improve your workflow!

### Implementations

Most editors keep a linear history of changes made to a given file, meaning that you can only move forward and backward in time. While simple to implement, it isn’t an ideal solution – what if you undoed some changes, made new ones and only after realized that the previous changes were actually the ones you wanted to keep?

This uncommon problem is impossible to deal with using a linear history of changes. Vim, however, offers an elegant solution – instead of storing changes in a linear manner, it stores them in a tree. This means that information about changes made never gets lost (only gets stored in a separate branch) and the problem from the previous paragraph is just a matter of switching from one branch to another.

Imagine the following scenario: you’re editing a file; you make changes, then undo them, then you make some more changes. The history will look like this (numbers signify the various states of the file after you made changes):

      2
/
0---1---3 (we are here)

Using <u> and <C-r> will move you forward/backward in a linear fashion (meaning that you will only move between states 0, 1 and 3). We need more advanced commands to traverse the entire tree.

One way we could do this is based on the relative time a given change was made. To move relative to the current time, use the earlier and later commands:

:earlier {duration}{unit}
:later   {duration}{unit}

where duration is an integer and unit is s/h/m/d for second/hour/minute/day.

You can also use the commands to move based on chronological order of the changes made:

:earlier {num}
:later   {num}

will move the file to num changes before, based on when they were made. This solves our problem from the previous section, since you can use earlier (possibly repeatedly) to switch back to the branch that you decided was actually the one you wanted to keep.

Last way to use the commands is to move based on writes to file:

:earlier {num}f
:later   {num}f

will change the state of the file to num writes to file before.

### Persistent history

When working frequently on the same files for a prolonged period of time, it can be quite useful to make the history of changes persistent, so that closing the file won’t discard the history of changes. Luckily, Vim has you covered – you can enable persistent history by adding set undofile to your .vimrc.

The <.> command is nice, as it takes you back to the line that was last changed. You can also just <u> and <C-r>` (like I do, although I shouldn’t), but the former is far more elegant 🙂.

### Plugins

If the commands and techniques mentioned above weren’t enough for you, there are a number of plugins that make it easy to view and traverse the graph. I’ve personally used UndoTree and found it quite nice, but there are other alternatives (like Mundo, for example). Give them a try and see for yourself!


text:
### 同面异面环加成中分子轨道的对称性和简并性

1. 中山大学化学系
• 收稿日期:1984-06-03 修回日期:1985-02-27 发布日期:1985-08-15

### SYMMETRY AND DEGENERACY OF MOs IN SUPRA-ANTARA CYCLOADDITIONS

Chen Zhixing; Zhang Yala

1. Chemistry Department, Zhongshan University, Guangzhou
• Received:1984-06-03 Revised:1985-02-27 Published:1985-08-15

Abstract: The [2_s+n_a] system can have C_2 symmetry (Fig.1) rather than local C_2 and local σ as described in Ref.4. For the [m_s +n_a] cycloaddition with m>2, the reaction system is no doubt unsymmetrical, the special symmetry of the MOs obtained by the HMO model is due to oversimplification. Bond angles are not concerned in the HMO method. Thus, if the m_s component is regarded as a straight carbon skeleton, the system will be of C_2 symmetry, which is shown in Fig.1 with the m_s in place of the ethylene. Correlation diagrams of [m_s+n_a] canbe constructed from the MO energies and special symmetries of the initial and the final states. For [m_s+m_a] reaction, the eigenvalue problem is equivalent to that of two identical systems with straight carbon chains (Fig.3). Therefore, double degeneracy holds for all MOs throughout the reaction (Fig.4).

format: plain


text:
• Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started! # Multiple Scripting Languages With Identical User-work Old topic! Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic. 4 replies to this topic ### #1taylorsnead Members - Reputation: 139 Like 0Likes Like Posted 09 August 2012 - 02:53 AM I am attempting to make a system that would allow a user (in C++) to bind classes to their scripting language of choice, then compile the script and run it. The primary language I am using for any scripting needs is Squirrel, but I want to be able to switch languages at runtime (possibly with an enum), and using the same code, bind to, say, Python. I was thinking of doing it by having a class for each language's Class (eg. has Var, Func, Prop, Bind, etc, functions for binding) and a class for it's Script (eg. Compile and Run functions), then instantiating those runs through the Subsystem (which changes based on the enum to a child class with creation methods), which passes back a Class* pointer or Script* pointer, but I'd prefer it to be implicit. Like this: [source lang="cpp"]void BindPlayer(){ scriptLang = "Squirrel"; // SClass is for ScriptClass, the parent top class, not for Squirrel specifics SClass<Player> pclass; pclass.Var("TestVar", &Player::TestVar); // Bind other vars/funcs/props pclass.Bind("Player"); Script scr; scr.Compile("TestPlayer.nut"); scr.Run(); scriptLang = "Python"; // Do the bind again, same code. Script scrp; scrp.Compile("TestPlayer.py"); scrp.Run();}[/source] How feasible is this method; if at all, how exactly would I go about the implicit creation via another class? If that method wouldn't work well, then what would? Sponsor: ### #2Ashaman73 Crossbones+ - Reputation: 11945 Like 0Likes Like Posted 09 August 2012 - 03:13 AM Supporting multiple languages should not be a technical problem at all, when using some kind of clean interface and binding. Something like this: [source lang="cpp"]class ScriptInterface{ startNewCall( string pName); addParam(int pIntParam); addParam(string pStringParam); ScriptResult executeCall();}class ScriptSquirrel : ScriptInterface{// implement script binding etc.}class ScriptFactory { ScriptInterface createNewScriptInterface( String pLanguage) ;}[/source] But the practical benefit could be lower than expected when mixing languages, because most scripting languages runs in its own VM including all data. Ashaman ### #3Hodgman Moderators - Reputation: 42086 Like 0Likes Like Posted 09 August 2012 - 03:16 AM I'm working on a similar system, so I hope it's feasible I manually reflect on my bindable classes like: class Test1 { public: eiBind(Test1); int DoStuff() { return 0; } private: int m_stuff; }; eiBindClass( Test1 ) eiBeginMethods() eiBindMethod( DoStuff ) eiEndMethods() eiBeginData() eiBindData( m_stuff ) eiEndData() eiEndBind(); And then to bind it to a specific scripting VM, I can fetch the above info with const TypeBinding& b = ReflectTest1(); Which gives me structures like typedef void (FnTask)( void* obj, void* args, uint argSize ); struct DataBinding { const char* name; memptr memvar; uint offset, size; Type type; }; struct MethodBinding { const char* name; FnTask* task; const DataBinding* args; uint argCount; }; struct TypeBinding { const DataBinding* data; uint dataCount; const MethodBinding* method; uint methodCount; }; Edited by Hodgman, 09 August 2012 - 03:19 AM. ### #4taylorsnead Members - Reputation: 139 Like 0Likes Like Posted 09 August 2012 - 07:49 PM I understand both of your concepts. I tried to implement both. For the first (Ashaman73) concept, I did it like so: [source lang="cpp"]//SClass has Var, Func, Prop, and Bind functions without implementations//SqClass is a child and implements the functions for squirrel//ScriptSystem::NewClass() returns a pointer to a child SqClass or eg. LuaClass, based on mLang (set by SetLang();ScriptSystem::SetLang("Squirrel");SClass$Player# & scp = ScriptSystem::NewClass<Player>();scp.Var("Health", &Player::mHealth);scp.Bind("Player");Script& sqs = ScriptSystem::NewScript();sqs.Compile("Test.nut");sqs.Run();[/source]
Now, this should basically work, except that if I want to, say, shut off the Squirrel VM and launch the Lua VM, I have to rebind those classes. Using something closer to the other given concept (Hodgman), I'd be able to bind once, and it should keep a list of the classes to be bound in ScriptSystem (Since then the SClass holds actual data), then on VM binding (called just before script launching begins), it would take the data from all SClass instances in the list, using it to create VM specific Classes, binding their members and vars, then binding the actual class (Also, then it's easy to remove them from the bind list). The only problem is, I can't really figure out how I should manage the structures to use for data containment, and later usage for binding to the specific VM.
I was thinking something like this:
[source lang="cpp"]struct VarData{ string label; void* ref;};struct ClassData{ vector $VarData# vars;};struct SClass{ template$class T, typename V# void Var(string label, V T::*val) { VarData newvar; newvar.label = label; newvar.ref = val; data.vars.push_back(newvar); } void Bind(string label); ClassData data;};[/source]
But, the problem is about using that given data later.
[source lang="cpp"]Class $Player# cls;for(int i=0; i$ play.data.vars.size(); ++i){ cls.Var(play.data.vars[i].label, play.data.vars[i].ref); RootTable().Bind("NameHere", cls);}[/source] ("<>" are replaced by "\$#", the code block doesnt like those characters, for some reason)
Something like that for Squirrel, except I can't use the void pointer directly, so would I use a different type for storage, or how can I cast to the correct type for this situation? I'm just not really sure how I'd approach it.

Edited by taylorsnead, 09 August 2012 - 07:55 PM.

### #5taylorsnead  Members   -  Reputation: 139

Like
0Likes
Like

Posted 02 September 2012 - 01:41 PM

I'm going to bump this, because I still haven't figured it out, and I'm still trying to implement it. I'm able to make a system for multiple languages, but it then forces the programmer to rebind their classes for each language. So, I was attempting to do something like what Hodgman suggested, but I don't really know how I'd reaccess the data later, since it would be a solely automatic grabbing and using of the data and I can't store a type as a variable so that it's known what type to bind it as. Once I can have the data grabbed later on in a separate function with the correct type and stuff, then I can have an easily extensible system to add new languages that work with no changes to existing binding code. Maybe it would be better to bind one language (eg. Squirrel) and use its dynamic typing to create a binding system there that routes back to C++, allowing someone to bind their classes in either Squirrel or C++?

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS


text:
Free Version
Moderate

# Second Fundamental Theorem with Properties of Definite Integrals

APCALC-PHGBKE

Evaluate the derivative:

$$\frac { d }{ dx } \left( \int _{ x }^{ 5}{ t^{3}dt } \right)$$

A

$\cfrac{1}{4}(5^{4}-x^{4})$

B

$-\cfrac{x^{4}}{4}$

C

${ x }^{ 3 }$

D

$-{ x }^{ 3 }$


text:
# Probability problem

1. Mar 4, 2005

### Niels

I'm trying to learn probability on my own and I'm stuck.

My multiple-variable-calculus is not so strong so the following problem got me stuck.

I have density function

f(x,y) = x^2 + xy/3 for 0<x<1; 0<y<2 otherwise 0

And I need to calculate Prob(X > Y). X and Y are random variables.

I know how to do Prob(X <= 0.5) etc.

Also would be nice if someone could explain Prob(Y < 1/2 and X < 1/2) and
Prob(X+Y < 1)

Thanks
/Niels

2. Mar 4, 2005

### hypermorphism

Just to make sure, this is just integrating over all values of Y, such that X <= 0.5, which is a rectangle.

Similarly, this is an integration of the density function over the region where Y < 1/2 and X < 1/2. This is a square of sidelength 1/2 with one corner at the origin. It is a double integral that can be written as:
$$\int_0^{\frac{1}{2}} \int_0^{\frac{1}{2}} f(x,y) dy dx$$
Do you know how to find P(X<1/2 OR Y<1/2) ?
If you cannot picture the region, rewrite it in a friendlier form; ie., Y < -X + 1. You're then integrating the density function for all points below the line y = -x + 1. This integral can be written:
$$\int_0^1 \int_0^{-x+1} f(x,y) dy dx$$
So your original problem, P(Y<X) is just the set of points below the line y=x.

Last edited: Mar 4, 2005
3. Mar 4, 2005

### Niels

thank you!

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook


text:
## 90.20 The cotangent complex of a morphism of ringed spaces

The cotangent complex of a morphism of ringed spaces is defined in terms of the cotangent complex we defined above.

Definition 90.20.1. Let $f : (X, \mathcal{O}_ X) \to (S, \mathcal{O}_ S)$ be a morphism of ringed spaces. The cotangent complex $L_ f$ of $f$ is $L_ f = L_{\mathcal{O}_ X/f^{-1}\mathcal{O}_ S}$. We will also use the notation $L_ f = L_{X/S} = L_{\mathcal{O}_ X/\mathcal{O}_ S}$.

More precisely, this means that we consider the cotangent complex (Definition 90.18.2) of the homomorphism $f^\sharp : f^{-1}\mathcal{O}_ S \to \mathcal{O}_ X$ of sheaves of rings on the site associated to the topological space $X$ (Sites, Example 7.6.4).

Lemma 90.20.2. Let $f : (X, \mathcal{O}_ X) \to (S, \mathcal{O}_ S)$ be a morphism of ringed spaces. Then $H^0(L_{X/S}) = \Omega _{X/S}$.

Proof. Special case of Lemma 90.18.6. $\square$

Lemma 90.20.3. Let $f : X \to Y$ and $g : Y \to Z$ be morphisms of ringed spaces. Then there is a canonical distinguished triangle

$Lf^* L_{Y/Z} \to L_{X/Z} \to L_{X/Y} \to Lf^*L_{Y/Z}[1]$

in $D(\mathcal{O}_ X)$.

Proof. Set $h = g \circ f$ so that $h^{-1}\mathcal{O}_ Z = f^{-1}g^{-1}\mathcal{O}_ Z$. By Lemma 90.18.3 we have $f^{-1}L_{Y/Z} = L_{f^{-1}\mathcal{O}_ Y/h^{-1}\mathcal{O}_ Z}$ and this is a complex of flat $f^{-1}\mathcal{O}_ Y$-modules. Hence the distinguished triangle above is an example of the distinguished triangle of Lemma 90.18.8 with $\mathcal{A} = h^{-1}\mathcal{O}_ Z$, $\mathcal{B} = f^{-1}\mathcal{O}_ Y$, and $\mathcal{C} = \mathcal{O}_ X$. $\square$

Lemma 90.20.4. Let $f : (X, \mathcal{O}_ X) \to (Y, \mathcal{O}_ Y)$ be a morphism of ringed spaces. There is a canonical map $L_{X/Y} \to \mathop{N\! L}\nolimits _{X/Y}$ which identifies the naive cotangent complex with the truncation $\tau _{\geq -1}L_{X/Y}$.

Proof. Special case of Lemma 90.18.10. $\square$

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


text:
## Question 11.103

A pump is located near the edge of the horizontalplatform shown.The nozzle at A discharges water with an initialvelocity of 25 ft/s at an angle with the vertical. Determine therange of values of the height h for which the water enters theopening BC.

I tried to solve this problem but results I am getting are notrealistic ( pump should be located below the surface ). Any helpwould be apprecited!


text:
## Journal of the Mathematical Society of Japan

### A second main theorem of Nevanlinna theory for meromorphic functions on complete Kähler manifolds

Atsushi ATSUJI

#### Abstract

We show that a second main theorem of Nevanlinna theory holds for meromorphic functions on general complete Kähler manifolds. It is well-known in classical Nevanlinna theory that a meromorphic function whose image grows rapidly enough can omit at most two points. Our second main theorem implies this fact holds for meromorphic functions on general complete Kähler manifolds.

#### Article information

Source
J. Math. Soc. Japan Volume 60, Number 2 (2008), 471-493.

Dates
First available in Project Euclid: 30 May 2008

http://projecteuclid.org/euclid.jmsj/1212156659

Digital Object Identifier
doi:10.2969/jmsj/06020471

Zentralblatt MATH identifier
1145.32008

Mathematical Reviews number (MathSciNet)
MR2421985

#### Citation

ATSUJI, Atsushi. A second main theorem of Nevanlinna theory for meromorphic functions on complete Kähler manifolds. J. Math. Soc. Japan 60 (2008), no. 2, 471--493. doi:10.2969/jmsj/06020471. http://projecteuclid.org/euclid.jmsj/1212156659.

#### References

• A. Atsuji, Nevanlinna theory via stochastic calculus, J. Funct. Anal., 132 (1995), 473–510.
• A. Atsuji, A second main theorem of Nevanlinna theory for meromorphic functions on complex submanifolds in $\ce^n$, submitted.
• R. F. Bass, Probabilistic Techniques in Analysis., Springer, New York, 1995.
• J. R. Baxter and G. A. Brosamler, Energy and the law of iterated logarithm, Math. Scand., 38 (1976), 115–136.
• I. Chavel, Isoperimetric inequalities, Cambridge tracts in mathematics 145, Cambridge university press, Cambridge 2001.
• B. Davis, Picard's theorem and Brownian motion, Trans. Amer. Math. Soc., 213 (1975), 353–361.
• B. Davis, Brownian motion and analytic functions, Ann. Prob., 7 (1979), 913–932.
• R. E. Green and H. Wu, Embedding of open Riemannian manifolds by harmonic functions, Ann. Inst. Fourier, 25 (1975), 215–235.
• P. A. Griffiths, Entire holomorphic mappings in one and several complex variables, Ann. Math. Stud., 85, Princeton University Press, Princeton, 1976.
• W. K. Hayman, Meromorphic functions, Oxford Mathematical Monographs Clarendon Press, Oxford, 1964.
• W. K. Hayman, Subharmonic functions, 2, Academic press, London-San Diego, 1989.
• N. Ikeda and S. Watanabe, Stochastic differential equations and diffusion processes, Second edition, North-Holland Mathematical Library, 24, North-Holland Publishing Co., Amsterdam; Kodansha, Ltd., Tokyo, 1989.
• K. Ito and H. P. McKean, Diffusion processes and their sample paths, Springer-Verlag, Berlin-New York, 1974.
• A. Kasue, Applications of Laplacian and Hessian comparison theorems, Geometry of Geodesics and Related Topics, Adv. Stud. Pure Math., 3 (1984), 333–386.
• H. Kumura, On the intrinsic ultracontractivity for compact manifolds with boundary, Kyushu J. Math., 57 (2003), 29–50.
• P. Li, On the structure of complete Kähler manifolds with nonnegative curvature near infinity, Invent. Math., 99 (1990), 579–600.
• Y. C. Lu, Holomorphic mappings of complex manifolds, J. Diff. Geom., 2 (1968), 299–312.
• J. Noguchi and T. Ochiai, Geometric function theory in several complex variables, Translations of Mathematical Monographs, 80, Amer. Math. Soc., Providence, RI, 1990.
• W. Stoll, Value distribution on parabolic spaces, Lecture Notes in Math., 600, Springer-Verlag, Berlin-New York, 1977.
• M. Tsuji, Potential theory in modern function theory, Maruzen, Tokyo, 1959.
• J. Vauthier, Processus projeté, Comparaison avec une diffusion, C. R. Acad. Sci. Paris Sér. A–B, 285 (1977), A569–A571.
• H. Wu, Mappings of Riemann surfaces (Nevanlinna theory), Entire Functions and Related Parts of Analysis, Proc. Sympos. Pure Math., Amer. Math. Soc., Providence, R.I., 1966, 480–532.


text:
# What is the derivative of sin^-1 * (5x)?

May 3, 2017

$\frac{\mathrm{dy}}{\mathrm{dx}} = \frac{5}{\sqrt{1 - 25 {x}^{2}}}$

#### Explanation:

$y = {\sin}^{- 1} \left(5 x\right)$

$\implies 5 x = \sin y$

differentiate$\text{ " wrt" } y$

$5 \frac{\mathrm{dx}}{\mathrm{dy}} = \cos y$

$\frac{\mathrm{dx}}{\mathrm{dy}} = \cos \frac{y}{5}$

$\implies \frac{\mathrm{dy}}{\mathrm{dx}} = \frac{5}{\cos} y$

we need to rewrite this in terms of the original variable $x$

now:

${\sin}^{2} y + {\cos}^{2} y = 1$

$\implies \cos y = \sqrt{1 - {\sin}^{2} y}$

$\implies \cos y = \sqrt{1 - {\left(5 x\right)}^{2}}$

$\therefore \cos y = \sqrt{1 - 25 {x}^{2}}$

$\frac{\mathrm{dy}}{\mathrm{dx}} = \frac{5}{\sqrt{1 - 25 {x}^{2}}}$


text:
# Browser Performance

In this post we’ll go over the topic of browser performance. We’ll cover tools and techniques to identify, measure and improve performance on the client side of web applications.

Assumptions. Our tests use the Chrome browser, which means the tools likely only make sense for this specific browser (general techniques are agnostic). All the screenshots are taken either on a Linux machine running Gnome or the latest MacOS, though it should be relatively similar to Chrome in other platforms. The Chrome version used is v80.

## Analyzing Performance

### FPS Meter

This widget tracks the number of frames per second. To enable it,

In the … icon menu, click on Show console drawer:

In the Rendering tab, check the box FPS meter:

And it should looks like this:

The yellow bar represents 60 FPS, which is the threshold under which the page might look sluggish. The bar chart on the right is a histogram view of the visible line chart. The bars at the bottom represent low FPS and on the top high FPS. The number on the top are the range (max/min FPS).

Initially the numbers will be low because the is not previous data, since it only measure FPS when the page re-renders. To prime the data you need to manually trigger many visual updates, say resizing the window or specific actions on your application:

### Flame Chart

The flame chart is a very useful visualization to understand performance. It allows identifying expensive functions at a glance (long bars) and dive in into sub-functions quickly.

To use this, download and open (locally) the on_click.html example. Click on the “Performance” tab. Click the record button. Click the “Click Me” button on the page. After some number is displayed, click on Stop on the recording. We should get a chart similar to the one below:

Flame chart view

We can see the area chart at the top which is an overview of the processing happening below. The y-axis in that chart is amount of CPU.

The second chart is the flame chart. It has the bars corresponding to function calls (e.g. Event:click) and below that are the functions that were called. We see a generic Function Call because we used a anonymous arrow function like below:

Another thing to notice is that if we zoom enough, we see what looks like multiple calls of the expensive() function but in our code it is a single continuous function. I’m not sure why Chrome does that, but I’m assuming it has to do with the garbage collection kicking in.

There are other interesting alternative views at the bottom. The doughnut chart gives a breakdown on types of work being done. In our case it’s just a mix of scripting and idle:

The Call Tree view is great for the details. It allows looking at specific call chains and how much each is contributing. In our example, we can see Event: click is an expensive operation but it’s the expensive() function that is the culprit (based on the Self time):

To find specific bottlenecks the Bottom-Up view might be more interesting. If the Call Tree shows a nested tree from the root, the Bottom-up view shows the internal nodes but sorted by Self Time:

Performance Metrics

When we record a trace that includes a page load, it also includes some standard metrics like First contentful paint (FCP). The definition of some them are here [4].

It’s possible to write our own events that show up in Timings. We just need to add markers and  measure duration using the performance API [6]:

Then it shows up in the Timeline row:

The result of performance.measure() contains useful information:

### Network

When we first open the Network tab, it immediately starts recording the network activity, but since we want a full-scan of the page requests, let’s stop it, clear the data, start recording again, reload the page and then stop recording to get a report.

The sample below is from imdb.com:

Network tracing for imdb.com

Similar to the performance tab, this view provides a timeline which we can zoom in. The table below lists all network requests performed by the browser, including static resources like images, JavaScript files and async requests to fetch more data.

We can filter by request type at the top:

Here we could look for oversized images (though unlikely you’ll need to show a gigantic high-resolution image by default – so look into sending a thumbnail with a link to the larger image) or slow async requests.

Async requests are of type XHR (XmlHttpRequest), so we can filter by that:

the bars on the last column give an indication of not only the time a request took, but the dependencies. Sometimes an async request doesn’t start until a specific one finishes. If we hover over the bar of the render request, we see:

It has a nice breakdown on the timings, including DNS lookup and SSL latency (authentication). It also includes queuing time, the amount of time waiting TTFB, and then the content download.

The queuing indicates that the request was ready to go, but needed to wait on some other dependency or due to browser limits. Usually there’s a limit of active XHRs per domain the browser can have (<10) [7].

TTFB means “Time to first byte” – this means that the time it takes to start receiving data. This is indicative of the time the server took processing.

Content download is the time spend getting the resource/data. It’s correlated with the size of the data, network bandwidth/speed.

## Measuring Performance

### Duration from start

The performance API keeps track of specific events in the page loading lifetime, so we can measure durations compared to a specific point in time.

performance.now() [9] provides the timestamp since the page started to load (in rough terms – see this more precise definition).

Side note: browsers purposefully reduce the precision of these APIs to protect against attacks that rely on high-precision timing information [10].

### Custom Durations

As we mentioned in an earlier in measurement.js, we can measure durations. By using performance.mark() and performance.measure() [5].

Benchmarking

We can use the APIs above to create simple benchmarks.

Before we start: always beware of over-optimizing code! You might end up spending a lot of time to improve performance against a specific benchmark, browser or even JavaScript engine version. That’s part of the reason V8 retired the benchmark tool Octane.

That said, if you identify some code in the critical path that executes the same operation on the order of millions of times, it might be worth optimizing it. One example is changing from array methods like forEach() and reduce() to pure for-loops. We can perform several runs of the same function and get the average. I opted for using a random number generator to avoid any optimization related to caching.

The function generated an array with 10 million random floats and calculates the sum. It then runs the code 10 times. The results follow:

• for loop 12ms
• reduce 156ms
• forEach: 208ms

On Firefox it yields

• for loop 40ms
• reduce 48ms
• forEach 64ms

We can see a for loop is ~92% and ~16% faster than reduce on Chrome and Firefox respectively. Some takeaways:

• It’s highly browser-dependent! Don’t over-optimize code for one browser.
• Although the relative gains are substantial, the absolute improvements are only 100ms for an array of 10 million items – how practical is this? The creation and allocation of the array probably takes more time than this.
• This is pure computation, so no DOM access is needed, so consider using Web Workers

## Techniques

Here we discuss some techniques to improve performance. The first two are general purpose optimizations but we include here for completeness.

### Reduce Algorithmic Complexity

Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.

Before optimizing code, we should consider optimizing algorithm. This means reducing the big-O complexity. In a recent project, we found several wins by identifying hidden O(n^2) code and converted them to O(n).

We often need to make this tradeoff: to improve speed of code (computation) we have to use more memory. This is actually how we improved the O(n^2) to O(n): by keeping a look-up hash table for fast access.

In JavaScript a quick look-up table can be implemented via Object, or ES6 Map and Set. Other techniques involve caching (memoization).

In [8] Addy Osmani and Mathias Bynens suggest that if you’re sending large JSON payload via the network, it’s better to send them JSON-encoded instead of JavaScript objects literals:

Because the JSON grammar is much simpler than JavaScript’s grammar, JSON can be parsed more efficiently than JavaScript

### Reduce CSS selector complexity

In [17], Lewis suggests reducing the complexity of CSS selectors such as

to

The reason being:

Roughly 50% of the time used to calculate the computed style for an element is used to match selectors (…)

### Use Flexbox

In [18] Lewis suggests that flexbox is more efficient than other layouting alternatives such as float positioning. One caveat made in the article is that is node widely supported. As of 2020 however, that doesn’t seem the case anymore.

### Avoid reading DOM properties right after mutating them

In [18] Lewis explains that the Layout phase happens after the JavaScript runs:

This means that changing a DOM property and reading it afterwards, requires the browser to block and perform the layout before reading the new value. If possible, make the read before the write.

### Avoid some advanced CSS effects

This is more of a tradeoff between performance and design. In [19] Lewis mentions that properties such as box-shadow can be expensive.

It’s unclear however which specific CSS properties are expensive.

### Use Layers (but sparingly)

In [19] Lewis suggests creating layers for elements that are updated very often, to avoid these updates from causing updates in the rest of the page. One way to force the creation of a layer is:

These should only be created if there’re clear improvements in performance, since like indexes in databases, they come with memory and management cost.

### Use requestAnimationFrame()

Since JavaScript’s main thread is used for rendering, running expensive function might cause the UI to freeze. In order to prioritize the rendering, we can schedule expensive functions to run we can use requestAnimationFrame(). According to [3]:

When visual changes are happening on screen you want to do your work at the right time for the browser, which is right at the start of the frame. The only way to guarantee that your JavaScript will run at the start of a frame is to use requestAnimationFrame

In [20], Lewis provides a more specific case for the use of requestAnimationFrame(): on scroll input handlers since they block the UI.

There’s one caveat however: Input handlers execute before requestAnimationFrame(), so if it makes style changes and then we read it in requestAnimationFrame, we run into the problem described in Avoid reading DOM properties right after mutating them.

### Web Workers

As we discussed previously, web workers run in a separate thread, which prevents your application from freezing because the main thread is blocked. To understand why this happens, it’s important to know the basics of how the JavaScript execution model works.

The major caveat is that web workers don’t have access to the DOM but they do have I/O access (like XHR).

### Web Assembly

It’s possible to use lower level languages like C++ and Rust and run them on the browser by compiling them to an intermediate representation called Web Assembly (WASM).

This guide explains how to compile Rust code to Web Assembly, package it as an npm package and execute it on the browser via Webpack. I’ve tried myself and the process is relatively straightforward.

Portability. Web Assembly’s official website [14] claims it is portable across different platforms.

Existing libraries. One of the major selling points of Web Assembly is being able to run existing libraries written in languages like C/C++. In [11] PSPDFKit’s team showcase their port of a PDF renderer that previously had to be done on the server and now can be done by shipping the binary as wasm. They perform some benchmark, getting mixed results in terms of performance but had several follow-up with browser vendors and were able to improve their performance (though no subsequent analysis was available in the post).

Web Assembly’s website [13] lists other use cases.

Performance. The main benefit I can see for starting a project from scratch in say, C++ or Rust, would be performance over JavaScript. JS vs WASM’s site [12] provides a set of computations in JavaScript and wasm compiled from C++. The results are not promising: in most cases Javascript is faster.

### GPU via WebGL

WebGL (Web Graphics Library) is a JavaScript library available in most browsers, with the main purpose of rendering 2D and 3D graphics. But because it has access to the GPU (JavaScript doesn’t have direct access), it’s can be used for heavy but highly parallelizable computations such as Machine Learning [16].

If your application requires this sort of processing, WebGL can be an interesting idea.

## Conclusion

This was another of the notes on Web Development. The other notes are listed in the Related Posts section below.

In this post we covered a wide variety of tools and techniques regarding performance of client-side applications. We didn’t delve into much detail, but hopefully some of the links will serve as starting pointers for further research.

For me it was particularly interesting to learn more about Web Assembly and I’m interested in studying it further, especially with Rust.

## References

[1] Get Started With Analyzing Runtime Performance
[2] Rendering Performance
[3] Optimize JavaScript Execution
[4] User-centric performance metrics
[5] User Timing API
[6] StackOverflow: Using performance.mark() with Chrome dev tools performance tab
[7] StackOverflow: How many concurrent AJAX (XmlHttpRequest) requests are allowed in popular browsers?
[8] The cost of parsing JSON
[9] MDN: performance.now()
[10] Github w3c/hr-time: Reducing the precision of the DOMHighResTimeStamp resolution
[11] A Real-World WebAssembly Benchmark
[12] JS vs WASM
[13] WebAssembly: Use Cases
[14] WebAssembly: Portability
[15] Donald Knuth: Structured Programming with go to Statements
[16] TensorFlow.js: Machine Learning for the Web and Beyond
[17] Reduce the Scope and Complexity of Style Calculations
[18] Avoid Large, Complex Layouts and Layout Thrashing
[19] Simplify Paint Complexity and Reduce Paint Areas

## Related Posts

• Notes on JavaScript Interpreters – This post focuses on the detail of Chrome’s V8 interpreter. The relationship with performance is that understanding how JavaScript code is executed (e.g. event loop model, JIT) can give us insight on how to optimize it.
• Web workers – is a browser feature that allows running code outside of the main thread. This can speed up computation as long as no DOM access is needed.
• Notes on how browsers work – provides a basic overview on the stages of executing a web page, from downloading HTML and Javascript, executing the scripts, constructing the DOM tree and laying out the page. Understanding these steps might give insights on how to better optimize the app.
• Notes on Javascript Memory Profiling in Google Chrome – memory is related to performance because memory and CPU are the major bounded resources your app has to deal with. Not taking care of memory (e.g. memory leaks) could also exhaust the memory available for the execution engine to make the CPU-Memory tradeoffs we mentioned above.

# Observable

Observable is a web-first interactive notebook for data analysis, visualization, and exploration [1].

It was created by Mike Bostock, the creator of d3.js, which we discussed previously way back in 2014 [2]. At some point, Mike stepped down from d3.js to focus on a new library called d3.express, which he presented in 2017 during the OpenVis conference [3] and was still in the makes. d3.express eventually got renamed to Observable.

I’ve been experimenting with Observable and in this post I’ll cover some of my learnings while trying to build two visualizations.

One of the benefits of notebooks like Observable is to co-locate code with its output. This makes it much easier to explain code because in addition to markdown comments, we can modify the code and see the results in real-time. This means that a lot of the documentation of APIs available in Observable are notebooks themselves. For these reasons, this post consists of a series of links to notebooks with high-level comments.

Before we start, some assumptions I’m making are familiarity with imperative programming and the basics of JavaScript.

## What is Observable?

Why Observable – this notebook explains the motivation behind Observable and how it works at a high level:

An Observable notebook consists of reactive cells, each defining a piece of state. Rather than track dependencies between mutable values in your head, the runtime automatically extracts dependencies via static analysis and efficiently re-evaluates cells whenever things change, like a spreadsheet

Five-Minute Introduction – provides a hands-on approach of the many topics, some of which we’ll cover in more detail in this post:

• Real-time evaluation of JavaScript snippets
• Cell references
• Markdown
• HTML/DOM display
• Promises
• Generators
• Views
• Importing from other notebooks

Let’s start by delving into the details of JavaScript snippets and cell references.

## Observable vs. JavaScript

Observable’s not JavaScript – in this notebook Bostock explains the differences between JavaScript and Observable. Some notes I found interesting from that notebook:

• A cell is composed by a cell name and an expression:
• [cell name] = [expression]

It can be simple statements like 1 + 2, or multi-line statements like

• The value of  cell_name can be used in other cells, but by default is read-only.
• Each cell can only have one  cell_name  assignment. In other words, it can only “export” one variable. It’s possible to cheat by exporting an object. Note that because curly brackets are used to denote code blocks, we need to wrap an object literal with parenthesis:

• Cells can refer to other cells in any part of the code – Observable builds a dependency DAG to figure out the right order. This also means dependencies cannot be circular. How Observable Runs explains this in more details.
• Constructs like async functions (await) and generators (yield) have special behavior in a cell. We’ll expand in the Generators section below.
• Cells can be mutated if declared with a qualifier (mutable). We’ll expand in the Mutability section below.

## Mutability

Introduction to Mutable State – cells are read-only by default but Observable allows changing the value of a cell by declaring it mutable. When changing the value of the cell elsewhere, the mutable keyword also must be used.

It’s important to note that the cell is immutable, but if the cell is a reference to a value, say an Object, then the value can be mutated. This can lead to unexpected behavior, so  I created a notebook, Mutating references, to highlight this issue.

## Markdown

Markdown summary – is a great cheat sheet of Markdown syntax in Observable. I find the Markdown syntax in Observable verbose which is not ideal given text is so prevalent in notebooks:

mdHello World
More cumbersome still is typing inline code. Because it uses backticks, It has to be escaped:

mdHello \code\

To be fair, most code will be typed as cells, so this shouldn’t be too common. It supports LaTeX via KaTeX which is awesome. KaTeX on Observable contains a bunch of examples.

## Generators

Generators are a JavaScript construct that allows a function to yield the execution back to the caller and resume from where it stopped when it’s called again. We talked about this in the Async Functions in JavaScript post.

Introduction to Generators explains how generators can be used in Observable. The combination of generators and delays (via promises) is a great mechanism to implement a ticker, which is the base of animation. Here’s a very simple way to define a ticker in Observable (remember that Promises are awaited without extra syntax):

## Views

Introduction to Views explains what views are and how to construct one from scratch. I like this recommendation:

If there is some value that you would like the user to control in your notebook, then usually the right way to represent that value is as a view.

Views are thus convenient ways to expose parameters via buttons and knobs such as text inputs, dropdowns and checkboxes.

I ran into a problem when using checkbox with labels in it, like the cell below:

It does not yield true/false as I wanted. This notebook, Checkbox, discusses the problem and offers a solution. This is an example where great but imperfect abstractions make it hard to understand when something doesn’t work. It’s worth learning about how viewof is implemented behind the scenes.

In one of my experiments I needed to synchronize a view and a ticker. Bostock provides a neat abstraction in his Synchronized Views notebook.

## Importing from other notebooks

Introduction to Imports shows how easy it is to import cells from other notebooks.

It also shows that it’s possible to override the value of some of the cells in that notebook:

This is neat, because the chart cell depends on the data, and by allowing overriding data, it allows parameterizing chart. In other words, we import chart as a function as opposed to a value (the result of chart(data)).

Versioning. When importing a notebook we always import the most recent version, which means it could potentially break if the notebook’s contract changes. The introduction above mentions the possibility of specifying the version when importing but didn’t provide an example on how to do so.

My strategy so far has been to clone a notebook if I’m really concerned about it changing, but that means one has to manually update / re-fork if they want to sync with the upstream changes.

## React Hooks

I’m used to write UI components with React and luckily Jed Fox created a notebook which I forked into this React Notebook which allowed me to use React Hooks to write a view.

## Conclusion

I really like Observable and am looking forward to add implement more data visualizations in it. I experimented with 2 animations so far: a simplistic Solar System model and a spinning Globe.

One natural question that crossed my mind is whether I should have written this whole post as an Observable notebook. In the end I decided to stick with an old-school static post for two reasons:

• Consistency: Observable only supports JavaScript, so if I’m writing a post about Python I’d need to fallback to a post, and I wouldn’t want to have a mix of both.
• Durability: Observable has a lot of potential but it’s still mostly experimental and I’m not sure I can rely on it sticking around for a long time.

## References

• Introduction
• Mutability
• Markdown
• Views
•  Importing
• Integration

### Other

[1] Observable – Why Observable?
[2] Introduction to d3.js
[3] OpenViz Conf – 2017
[4] Async Functions in JavaScript

# Notes on JavaScript Interpreters

In a previous post, Notes on how browsers work, we studied the high-level architecture of a browser, specifically the Rendering Engine. We used the following diagram,

In this post we’ll focus on the JavaScript interpreter part. Different browsers use different implementations of the interpreters. Firefox uses SpiderMonkey, Chrome uses V8, Safari uses JavaScriptCore, Microsoft Edge uses Chakra, to name a few. V8 is also used as a standalone interpreter, most notably by Node.js.

These interpreters usually comply to one of the versions of the ECMAScript, which is a standardization effort of the JavaScript language. ECMA-262 is the document with the specification. As it happens with other languages, from their first inception, design flaws are identified, new development needs arise, so the language spec is always evolving. For that reason, there are a few versions of ECMAScript. Most browsers support the 5th edition, also known as ES5.

There’s already the 7th edition (as of 2016), but it takes time for browsers to catch up. Because of that, JavaScript programs that are capable of translating newer specs into ES5 were created, such as Babel. The advantage of using this technique, also known as transpiling, is that developers can use newer versions of the step, such as ES6, without depending on browser support. Disadvantages include the extra complexity by adding a new step in the deployment process and it makes harder to debug since it’s hard to map errors that happen in the transformed code back to the original source.

Section 8.4 of the ECMA-262 describes the execution model of JavaScript:

A Job is an abstract operation that initiates an ECMAScript computation when no other ECMAScript computation is currently in progress. A Job abstract operation may be defined to accept an arbitrary set of job parameters.

Execution of a Job can be initiated only when there is no running execution context and the execution context stack is empty. A PendingJob is a request for the future execution of a Job. A PendingJob is an internal Record whose fields are specified in Table 25. Once execution of a Job is initiated, the Job always executes to completion. No other Job may be initiated until the currently running Job completes. However, the currently running Job or external events may cause the enqueuing of additional PendingJobs that may be initiated sometime after completion of the currently running Job.

MDN’s Concurrency model and Event Loop [2] describes this spec in a more friendly way. As in other programming environments such as C and Java, we have two types of memory available: the heap and the stack. The heap is the general purpose memory and the stack is where we keep track of scopes for example when doing function calls.

In JavaScript we also have the message queue, and for each message in the queue there is an associated function to be executed.

JavaScript Execution Model

### The event loop

The execution model is also called the event loop because of the high-level working of this model:

When the stack is empty, the runtime processes the first message from the queue. While executing the corresponding function, it adds an initial scope to the stack. The function is guaranteed to execute “atomically”, that is, until it returns. The execution might cause new messages to be enqueued, for example if we call

The callback passed as the first argument to setTimeout() will be enqueued, not stacked. On the other hand, if we have a recursive function, such as a factorial:

The recursive calls should all go to the same stack, so they will be executed to completion, that is until the stack is empty. The calls provided to setTimeout() will get enqueued and be executed only after the value of the factorial gets printed.

In fact, using setTimeout() is a common trick to control the execution order of functions. For example, say that function A called B and B calls another function C. If B calls C normally, then C will have to finish before B returns, as the sample code below:

In case we want to finish executing A first, then B can call C using setTimeout(C, 0), because then it will be enqueued, and then both A and B will finish until a new message is processed from the queue, as the code below:

### Web Workers

We discussed Web Workers in a previous post, in which we mentioned that it’s a separate thread that shares no memory with the main thread. In fact, according to [2], it has its own stack, heap and queue. It doesn’t violate the execution model of the main thread because communications must be done via a publisher/subscriber API, which means communicating between two threads is subject to the queueing.

### V8

Beyond the spec, each JavaScript engine is free to implement feature the way they want. V8’s architecture is described in their wiki page [3], so we can study some of its key components.

#### Fast Property Access

In JavaScript, structures like Object can be mutated (added and removed properties) in runtime. Implementing them as hashtables can lead to performance problems when accessing properties of these structures. Compare that to compiled languages like Java in which instances of a class can be allocated with all its members in a single chunk of memory and accessing properties of objects consists in adding an offset to the object’s pointer.

V8 optimizes the Object allocation by creating hidden classes. It makes use of the fact that properties are mutated in the same pattern. For example in

In this case, we always insert the property x and then y. V8 starts with an empty class C0 when the object is first created. When x is assigned, it creates another class C1 with property x and that points to C0. When y is assigned, it creates yet another class C2 with property y that point to C1.

When the Point constructor is finished, it will be an instance of C2. It has to instantiate 3 objects one from C0, then C1, then C2.

Accessing property y is an adding an offset operation, while accessing property x is two offset operations, but still fast than a table lookup. Other instances of Point will share the same class C2. If for some reason we have a point with only x set, then it will be an instance of class C1. This sharing of structures resembles the persistent data structures that we studied previously.

Another interesting property of this method is that it doesn’t need to know in advance whether the code has indeed a pattern in mutating objects. It’s sort of a JIT compilation.

#### Dynamic Machine Code Generation

According to [3]:

V8 compiles JavaScript source code directly into machine code when it is first executed. There are no intermediate byte codes, no interpreter.

#### Efficient Garbage Collection

We wrote about V8’s memory management in a previous post.

### Conclusion

In this post we revisited a bit of the history of JavaScript and ECMAScript. We also studied the event loop model that is part of the spec and finally saw some aspects of one of the JavaScript engines, V8.

### References

• [1] ECMAScript 2016 – Language Specification
• [2] MDN: Concurrency model and Event Loop
• [3] V8 – Design Elements

# Emacs Lisp Introduction

Richard Stallman is an american programmer and software freedom activist. He graduated from Harvard magna cum laude in Physics and started his PhD in Physics at MIT, but after about one year, he decided to focus on programming at the MIT AI Laboratory. There, he developed several softwares, including Emacs, which we’ll talk about in this post.

Emacs is named after Editor MACroS, since it was originally a macro editor for another editor, called TECO.

I’ve been using emacs since 2005, but never took the time to learn about elisp, which is the emacs dialect of Lisp and which emacs uses to implement a lot of its functions and the way it allows users to extend it.

In this post we’ll cover the basics of the elisp language. Most of if was based in the “Introduction to Programming in Emacs Lisp” by Robert Chassell and the Emacs Lisp Manual.

### Setting up the environment

In the following sessions we’ll have a lot of examples, so let’s setup an environment to run them.

Interpreter. For an interactive way to test the code snippets, we can use the elisp interpreter, integrated with emacs, called ielm. To open it, just run M-x ielm.

Running from a text file. An alternative to using the interpreter is by evaluating the code in a given region. To do that, select a region and run eval-last-sexp (C-x C-e).

Now, let’s cover some of the basic aspects of emacs lisp.

### Basics

List Centered. Lisp stands for list processing and as this suggests, it is highly centered on lists. Usually we use lists to perform the evaluation of some expression (which is also referred to form). One common expression is a function call. In this case, the first element of the list is the function and the other elements are parameters to the function. For example, we can call the function max:

(max 3 4) ;; returns 4

Similarly, for operators, we first provide the operator and then the parameters, so the For example, to add two numbers:

(+ 2 3)

We can see then that for arithmetic expressions we use the prefix (polish) notation, instead of the infix notation as in languages such as C++, Python and Haskell.

To use a elisp list to represent an actual list, we use the single quote.

'(1 2 3)

Printing. For simple cases, printing can be handy. On elisp we can use the function message. Run the following in the interpreter or run eval-last-sexp with that text selected:

(message "hello world")

This will print out the hello world string in the messages buffer, which can be viewed by running switch-to-buffer command (M-x b) and going to the *Messages* buffer.

Comments. In elisp, comments are inline and start after a semi-colon (unless it’s part of a string): ;.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This is a way to emphasize a comment
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(message "hello; world")  ; simple inline comment
; will print hello; world

### Variables

As in other languages, elisp has variables. But in elisp, variable names can contain symbols that wouldn’t be allowed as in some more common languages like +,-,*.

That is possible because in elisp we don’t have in-fix notation, so a variable named a+b is not ambiguously mistaken by a plus b, which has to be defined as (+ a b)

To set a variable you can use the set function:

(set 'x '(1 2))

We quote both elements because we want their literal and not to evaluate them. In most of the cases, we want the left hand side of the assignment to be a literal (representing the variable), so we use the shortcut setq:

(setq x '(1 2)) ;; Equivalent to (set 'x '(1 2))

Another option is to use defvar. The difference between defvar and setq is that defvar won’t set the variable again if it was already defined.

(setq x '(1 2))
(defvar x '(3 4)) ;; x still holds (1 2)

When we use set/setq/defvar, we create a variable in the global scope. To restrict variables to a local scope, we can use the let.

(let (a (b 5))
(setq a 3)
(+ a b)
) ;; returns 8

For this function, the first argument is a list of the variables which will be in the local scope. You can initialize a variable with a value by providing a pair (variable value) like we did with b above.

To indicate that a variable should not be changed, we can use the defconst macro. Note that it doesn’t actually prevent from overriding with setq though.

Another form of setting variable is using the special form defcustom. The first three parameters are the same of defvar. In addition, we can provide a documentation string as the fourth parameter and following are any number of arguments in the form

<keyword>:<value>

Common examples of keywords are type, option and group.

The type can have a different set of values such as string, integer, function, etc.

A custom group represents a series of custom variables and or other custom groups. Thus, one can organize groups in a tree hierarchy. When specifying the group keyword, we can provide an existing group such as applications, or define our own.

Let’s define our custom group for learning purposes:

(defgroup my-custom-group nil
"This is my first custom group"
:group 'applications
)

In the definition above, we’re creating a group called my-custom-group. The second argument is the list of custom variables in the group, which in our case is empty. The third argument is a description of the group and then there’s a list of key-value pairs, as in defcustom. In the example above, we’re making our new group a subgroup of the existing applications group.

Now, let’s create a custom variable in that group:

(defcustom my-custom-var nil
"This is my first custom variable."
:type 'string
:group 'applications)

Let’s add these definitions to our init file (e.g. .emacs or .emacs.d/init.el) and re-open emacs.

We can browse the custom variables by typing M-x customize to go the *Customize Apropos* buffer. In this buffer, there’s the option to search for variable names or groups. Let’s search for my-custom-variable in the search box:

Figure 1: Searching for my-custom-var (click to enlarge)

We can edit its value by changing from nil in the yellow box above. Let’s put an arbitrary string, such as "some-value" and then hit the [Save for future sessions] button.

This should change the init file with something like:

(custom-set-variables
'(my-custom-variable "some-value")
)

### List Manipulation: cons, car and cdr

One distinct trait of Lisp and Emacs is their alternative naming conventions. For example, what most people refer to copy and paste, emacs uses kill and yank.

Lisp, on its merit, has two important list functions curiously named car and cdr. The function car stands for Contents of the Address part of the Register and cdr for Contents of the Decrement part of the Register.

The car function will retrieve the first element of the list and cdr will get the remaining part of it.

(car '(1 2 3)) ;; 1
(cdr '(1 2 3)) ;; (1 2 3)

Another important function with a more intuitive meaning is cons, a short for constructor. It takes an element and a list, and preprends the element to the list and returns a new list:

(cons 1 (2 3)) ;; (1 2 3)

For those familiar with Haskell, cons is like the (:) operator, car is head and cdr is tail.

### Conditionals

In elisp we can use the if special form, which can take 2 or 3 arguments.

(if <condition> <then clause> <optional else clause>

The first argument is a predicate. A predicate is anything that after evaluated returns true or false. In elisp, both nil and the empty list are considered false. Anything else is true.

If the condition evaluates to true, the second argument is evaluated and returned. If it’s false and the third argument is provided, it will evaluate it and return. If it’s false and the third argument is not provided, it will just return false (nil).

Let’s do a dummy example. Suppose we have an existing variable x and we want to print a message depending on whether it’s negative:

(if (> x 0)
(message "x is positive")
(message "x is negative")
)

Block of code. If besides printing a message we want to do some calculations, we would need to evaluate multiple statements, but the second argument of if takes a single one. To solve this, we can use the progn function, which will combine a list of statements into a single one.

In our example above, if besides printing a message in case the number is negative, we wanted to set x to positive, we could do something like:

(if (> x 0)
(message "x is positive")
(progn
(message "x is negative")
(setq x (* -1 x))
)
)

### Loops

We can use a loop with the while function. It takes a predicate as the first argument and one ore more arguments which will be executed while the predicate evaluates to true. Another simple example:

;; Print numbers from 0 to 9
(let ((x 0))
(while (< x 10)
(message (number-to-string x))
(setq x (+ x 1))
)
)

For the example above, we can alternatively use the dotimes function, which executes a series of statements an specified number of times, much like a for in other languages.

(dotimes (x 10 nil)
(message (number-to-string x))
)

It takes two or more parameters. The first is a list of three elements, the first element will represent the counter (which starts at 0), the second is the number of repetitions and the third is executed after the loop is over. The other parameters are evaluated in the loop.

Another handy function is the dolist, which will iterate through a list for us. For example:

(dotimes (elem '("a" "b" "c") nil)
(message elem)
)

It takes two or more parameters, the first is a list of three elements: a variable which will contain the an element at each iteration; the list to be iterated on; an expression to be evaluated when finishing the loop. The other parameters are the body of the loop.

### Functions

To define a function, we can use the special defun form.

(defun add (a b)
"This simple function adds to numbers"
(+ a b)
)

It takes several arguments. The first one is the name of the function, the second is a list representing the parameters of that function, the third, optional, is a string describing what the function does. The remaining arguments are executed and we evaluate a function and the last evaluated argument is returned.

Anonymous functions. W can also create an anonymous (lambda). The example above would be done as:

(setq add (lambda (a b)
(+ a b)
))

But this time we need to call this function through funcall. This is because at runtime, add can potentially have any type (not necessarily a function), so we might not know it can be invoked as a function.

(funcall add 3 4)

Recursion. We can also define a function in terms of itself to implement recursion. The classical factorial example can be done as:

(defun factorial (n)
"Computes the factorial of n"
(if (<= n 1)
1
(* n (factorial (- n 1)))
)
)

Commands. Within emacs, it’s handy to ask for the input parameters from the user. For that we can use the interactive option. Using the example above, we can ask the input for the factorial function:

(defun printFactorial (n)
(interactive "n")
(message (number-to-string (factorial n)))
)

To run this, first execute execute-extended-command and then execute printFactorial. After hitting enter, you’ll be prompted to input a number, which will feed the function printFactorial.

### Conclusion

In this post, we’ve learned a bit about elisp. In future posts, we’ll cover some of the API emacs provides for extending it.

Robert Chassell mentions that “Introduction to Programming in Emacs Lisp” is a book for non-programmers, but he digs into functions definitions and implementation details that would be uninviting for people learning how to program.

### References

[1] An Introduction to Programming in Emacs Lisp
[2] Emacs Lisp Reference Manual (v 24.3)
[3] Customization Types

# An Introduction to Agda

Per Martin-Löf is a Swedish logician, philosopher and mathematician statistician. Since 1970 he has been mainly publishing on logic.

Martin-Löf has been active in developing intuitionistic type theory as a constructive foundation of mathematics and his work on type theory has influenced computer science.

He completed his PhD program under supervision of Andrei Kolgomorov and is currently Professor at Stockholm University, being a member of the Royal Swedish Academy of Sciences.

In this post we’ll talk about assisted theorem proving, more specifically using a tool named Agda, which has it’s syntax based on Haskell and the engine is based on the Per Martin-Löf’s intuitionistic type theory.

We’ll first talk about the basic concepts such as assisted theorem proving and dependent type theory and then present a very brief introduction to Agda based on a tutorial from Ulf Norell and James Chapman [3].

### Assisted Theorem Proving

We can classify theorem proving in the following categories:

1) Manual
2) Manual with machine support
3) Interactive
4) Automated

(1) is the oldest, most known and widely used method by mathematicians. (2) Since the introduction of computers, we now can have machines to verify syntax and make manual proofs less error prone. (3) We can also write proofs in a way the machine understands so that it can perform some logical deductions steps for us. (4) In the last extreme case, we can let the machine do all the job and find proofs by itself.

### Dependent Types

Basically speaking, dependent type is a type that depends on a value. In typed programming languages we can have a type like vector T, representing a vector containing elements of type T, but in a dependent type language we could also have vector T n, representing vectors with elements of type T and length n. We’ll see an example for this type in the next section using Agda.

### Agda

Agda is a dependent type language based on intuitionistic type theory, introduced by Martin-Löf. It was first implemented by Catarina Coquand (who is married to Thierry Coquand, which inspired the Coq tool, another famous assisted proof tool). Later it was rewritten as Agda 2 by Ulf Norell, one of the authors of the tutorial we’re going to follow.

#### Installing

The first thing we want to do before starting is to get Agda running. This can be done using the cabal package manager from Haskell:

> cabal install Agda

On Mac, this will install some binaries to ~/Library/Haskell. We want to use some of those binaries, so let’s include in our bin path:

export PATH="$HOME/Library/Haskell/bin:$PATH"

Agda has a very good integration with Emacs. On Mac we can make use of that integration in Aquamacs. To set up the right configuration into the .emacs file, we can now run:

> agda-mode setup

#### Main Concepts

Latex and Unicode. Agda uses makes use of unicode characters to make the code more readable and accepts LaTeX syntax to define them. For example, we can input \rightarrow which will be transformed into the → character. Also there are shortcuts to avoid typing a lot (for example \r is expanded to \rightarrow)

Delimiters. Agda is very flexible in naming, by only considering very few characters as delimiter (including space, parenthesis and curly brackets). This means we can have names like :<a*, but then we have to be careful in adding space whenever we need to separate two variables.

Modules and name convention. Agda files have the extension .agda. For our tutorial, let’s create one called basic.agda. The first thing we want to do is to define the module, which is used to manage namespaces. By convention, the module name has to match the file name, so we write:

module basic where

Data Types. Our basic working blocks will be types and we can define them by data types, which have syntax similar to data types in Haskell. For example, we can model the boolean type, which we call Bool. In the following code we have the type named Bool which is a subset of Set (pre-defined) and we provide two constructors, both being of the type Bool.

data Bool : Set where
true : Bool
false : Bool

In the same manner we can define the set of natural numbers. Since it’s impossible to explicitly define all value like we did for booleans, we do so by defining a function suc recursively, which takes a Nat and returns its successor, like in the following example:

-- Natural numbers
data Nat : Set where
zero : Nat
suc  : Nat -> Nat

Note that we are saying the constructor suc represents a function that receives a Nat and return a Nat, but we are not providing the implementation for it.

So let’s write some functions to work with the Nat type. More specifically, addition and multiplication.

Functions. In Agda, when we write a function surrounded by underscores, like _+_, we’re defining a function that takes two arguments using infix notation. Let’s define the addition operation:

-- Addition
_+_ : Nat -> Nat -> Nat
zero  + m = m
suc n + m = suc (n + m)

Note how we define everything in terms of the basic elements from Nat, that is, zero and suc, we have no notion of values. This is important because if we want to encode proofs as programs, we have to be generic and ‘value agnostic’. In this function we pattern match on different values of the first argument: If it’s zero, we are in the base case. Otherwise, the first argument must be a successor of some another value n, so we do recursion on n until it hit the base case.

Multiplication is analogous, but here we use the _+_ operator to define the second matched pattern:

-- Multiplication
_*_ : Nat -> Nat -> Nat
zero  * m = zero
suc n * m = m + n * m

The code above will cause an error because Agda requires strictly different priorities for different operators.

We can attribute some random values to these operators using infixl, which takes a priority value and a function. The higher the value, the higher the priority. Since we want multiplication to have higher priority than addition we can assign a higher number for it, for example:

-- Defining priority
infixl 6 _*_
infixl 4 _+_

Parametrized types. We can define a type that depends on other types, like parametrized types in Haskell or templates in C++. In this tutorial, we’ll create a list of elements of a given type A, as in the following data type:

-- Definition of a list with parametrized type
data List (A : Set) : Set where
-- empty operator
[] : List A
-- append operator
_::_ : A -> List A -> List A

Let’s write the map function over List. Differently from Haskell, Agda doesn’t perform type inference by default, so we need to explicitly provide the types when defining/calling a function that depends on other types. In the following example, the types A and B must be provided as parameters:

map1 : (A : Set) -> (B : Set) -> (A -> B) -> List A -> List B
map1 A B f [] = []
map1 A B f (x :: xs) = f x :: map1 A B f xs

We have the following syntax sugar to combine two or more types that are subset of the same type:

(A : Set) -> (B : Set) is equivalent to (A B : Set)

Implicit Types. We have the option to make types implicit and let Agda figure out the right one. The syntax is to use curly brackets instead of parenthesis:

map2 : {A B : Set} -> (A -> B) -> List A -> List B
map2 f [] = []
map2 f (x :: xs) = f x :: map2 f xs

Dependent Types. So far the types and operations we discussed so far don’t seem to show the real power of dependent types. So let’s define a new version of List, enhanced with the length of the list, which we’ll then call Vector:

data Vec (A : Set) : Nat -> Set where
[]   : Vec A zero
-- Make the length type implicit
_::_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n)

Here we have two parameters when defining the data type, Nat -> Set. Notice also how when defining the list recursively we update the value n properly.

One nice thing about this is that in defining a head function, we don’t need to handle the empty case as long as we restrict the type of non-empty lists:

-- Doesn't need to check for empty lists. Restriction is encoded in
-- the function type!
head : {A : Set}{n : Nat} -> Vec A (suc n) -> A
head (x :: xs) = x

Proofs as types. We are now going to write an example on how to use dependent types to encode proofs ( as types.

Let’s start by defining data types to represent the two possible values of a boolean. Note that we don’t specify constructors here.

data False : Set where
data True  : Set where

Now we define a function to convert a boolean values into these types:

isTrue : Bool -> Set
isTrue true = True
isTrue false = False

Let’s, for instance, define a function to be use as predicate, in this case, the < operator:

-- Definition of the < operator
_<_ : Nat -> Nat -> Bool
_ < zero = false
zero  < suc n = true
suc m < suc n = m < n

We will need the following function, that returns the length of a list, in our final example:

-- Definition of the length function
length : {A : Set} -> List A -> Nat
length [] = zero
length (x :: xs) = suc (length xs)

Finally, we can now write a sample function that encodes a predicate as a type. In the following example, the function lookup accepts one member of the family of predicates in which n less than the size of the list is a true statement.

-- Function that looks up the i-th element in a list
-- param 1: list
-- param 2: look up index
-- param 3: proof
lookup : {A : Set}(xs : List A)(n : Nat) -> isTrue (n < length xs) -> A
lookup [] n ()
lookup (x :: xs) zero p = x
lookup (x :: xs) (suc n) p = lookup xs n p

This concludes our brief introduction to Agda syntax and dependent types. In following posts we’ll learn more about writing proofs and have Agda to perform logical derivations for us.

### Conclusion

I have close to zero knowledge in formal systems. I’ve been exposed briefly to it by reading parts of Gödel, Escher and Bach and the subject sounds very interesting. I based most of the content of this post in a few introductory tutorials [3-6], but I still didn’t get a good grasp of the power of systems like Agda.

I was initially interested in learn Coq but due to some problems in setting it up, I ended up looking for alternatives and found Agda. It seems that Coq is based on Ocaml and Agda is based on Haskell and since I’ve been focused in learning Haskell, it was a pleasant surprise. Agda has also has a good integration with Emacs, which is my favorite editor, so this was a plus.

### References

[1] Per Martin-Löf – Wikipedia
[2] Proof Assistant – Comparison of Systems – Wikipedia
[3] Dependently Typed Programming in Agda – Ulf Norell and James Chapman
[4] Interactive Theorem Proving, Lecture Notes 0 – Anton Setzer
[5] Interactive Theorem Proving, Lecture Notes 1 – Anton Setzer
[6] Interactive Theorem Proving, Lecture Notes 2 – Anton Setzer


text:
# Exercise 12.4 Algebraic-Expressions -NCERT Solutions Class 7

Go back to  'Algebraic Expressions'

## Chapter 12 Ex.12.4 Question 1

Observe the patterns of digits made from line segments of equal length. You will find such segmented digits on the display of electronic watches or calculators.

(a)

(b)

(c)

If the number of digits formed is taken to be n, the number of segments required to form n digits is given by the algebraic expression appearing on the right of each pattern. How many segments are required to form $$5, 10, 100$$ digits of the kind,

### Solution

What is known?

The patterns of digits made from line segments of equal length

What is unknown?

Number of segments required to form $$5, 10, 100$$ digits of the kind, ,

Reasoning:

This question is very easy like simply put the value of n in the pattern formulae and you can easily find out the number of segments.

Steps:

Putting value of $$n=5, 10$$ and $$100$$ in the pattern formulae.

$$({\rm{i}})\quad 5n + 1$$ \begin{align}5 \times 5 + 1 & = 25 + 1\\& = 26\\5 \times 10 + 1 & = 50 + 1\\& = 51\\5 \times 100 + 1 & = 500 + 1\\& = 501\end{align}

$${\rm{(ii)}}\quad 3n + 1$$ \begin{align}3 \times 5 + 1 & = 15 + 1\\& = 16\\3 \times 10 + 1 &= 30 + 1\\& = 31\\3 \times 100 + 1 & = 300 + 1\\& = 301\\\end{align}

$$( {{\rm{iii}}}) \quad 5n + 2$$  \begin{align}\\5 \times 5 + 2 & = 25 + 2\\&= 27\\5 \times 10 + 2 & = 50 + 2\\& = 52\\5 \times 100 + 2 & = 500 + 2\\& = 502\\\end{align}

 S. No. Symbol Digit’s Number Pattern’s Formulae No. of. Segments (i) $$5$$ $${\rm{5 n + 1}}$$ 26 $$10$$ 51 $$100$$ 501 (ii) $$5$$ $${\rm{3}}\,{\rm{n + 1}}$$ 16 $$10$$ 31 $$100$$ 301 (iii) $$5$$ $${\rm{5 n + 2}}$$ 27 $$10$$ 52 $$100$$ 502

## Chapter 12 Ex.12.4 Question 2

Use the given algebraic expression to complete the table of number patterns.

 S. No. Expression Terms 1st 2nd 3rd 4th 5th ... 10th … 100th … (i) $$2n – 1$$ $$1$$ $$3$$ $$5$$ $$7$$ $$9$$ - $$19$$ - - - (ii) $$3n+2$$ $$5$$ $$8$$ $$11$$ $$14$$ - - - - - - (iii) $$4n + 1$$ $$5$$ $$9$$ $$13$$ $$17$$ - - - - - - (iv) $$7n + 20$$ $$27$$ $$34$$ $$41$$ $$48$$ - - - - - - (v) $$n^2 +1$$ $$2$$ $$5$$ $$10$$ $$17$$ - - - - $$10,001$$ -

### Solution

What is known?

Different algebraic expressions and the terms.

What is unknown?

Some terms of the given algebraic expression.

Reasoning:

This question is very simple put the value of n in the given algebraic expression and you can easily find out the unknown terms.

Steps:

Putting value of $$n = 5, 10$$ and $$100$$

(i) $$2n – 1$$

\begin{align}2 \times 100 - 1 & = 200 - 1\\& = 199\end{align}

(ii) $$3n+2$$

\begin{align}3 \times 5 + 2 & = 15 + 2\\ & = 17\\\ 3 \times 10 + 2&=30+ 2\\ &= 32 \\ 3 \times 100 + 2 & = 300 + 2\\& = 302\\\end{align}

(iii) $$4n+1$$

\begin{align}4 \times 5 + 1& = 20 + 1\\&= 21\\ 4 \times 10 + 1&= 40 + 1\\ & = 41\\4 \times 100 + 1&= 400 + 1\\ & = 401\end{align}

(iv) $$7n+2$$

\begin{align}7 \times 5 + 20 & = 35 + 20\\&= 55\\7 \times 10 + 20 & = 70 + 20\\&= 90\\7 \times 100 + 20 & = 700 + 20\\&= 720\end{align}

(v) $$n^2+1$$

\begin{align}5 \times 5 + 1 & = 25 + 1\\& = 26\\10 \times 10 + 1 & = 100 + 1\\& = 101\\100 \times 100 + 1 & = 10000 + 1\\& = 10001\end{align}

Complete table is:

 S.No. Expression Terms 1st 2nd 3rd 4th 5th ... 10th … 100th … (i) $$2n – 1$$ $$1$$ $$3$$ $$5$$ $$7$$ $$9$$ - $$19$$ - $$199$$ - (ii) $$3n + 2$$ $$5$$ $$8$$ $$11$$ $$14$$ $$17$$ - $$32$$ - $$302$$ - (iii) $$4n + 1$$ $$5$$ $$9$$ $$13$$ $$17$$ $$21$$ - $$41$$ - $$401$$ - (iv) $$7n + 20$$ $$27$$ $$34$$ $$41$$ $$48$$ $$55$$ - $$90$$ - $$720$$ - (v) $$n^2 + 1$$ $$2$$ $$5$$ $$10$$ $$17$$ $$26$$ - $$101$$ - $$10,001$$ -

Related Sections
Related Sections


text:
#### Volume 22, issue 2 (2022)

 Recent Issues
 The Journal About the Journal Editorial Board Editorial Interests Subscriptions Submission Guidelines Submission Page Policies for Authors Ethics Statement ISSN (electronic): 1472-2739 ISSN (print): 1472-2747 Author Index To Appear Other MSP Journals
The topological slice genus of satellite knots

### Peter Feller, Allison N Miller and Juanita Pinzón-Caicedo

Algebraic & Geometric Topology 22 (2022) 709–738
##### Abstract

We present evidence supporting the conjecture that, in the topological category, the slice genus of a satellite knot $P\left(K\right)$ is bounded above by the sum of the slice genera of $K$ and $P\left(U\right)$. Our main result establishes this conjecture for a variant of the topological slice genus, the $ℤ$–slice genus. Notably, the conjectured upper bound does not involve the algebraic winding number of the pattern $P\phantom{\rule{-0.17em}{0ex}}$. This stands in stark contrast with the smooth category, where, for example, there are many genus 1 knots whose $\left(n,1\right)$–cables have arbitrarily large smooth $4$–genera. As an application, we show that the $\left(n,1\right)$–cable of any knot of $3$–genus 1 (eg the figure-eight or trefoil knot) has topological slice genus at most 1, regardless of the value of $n\in ℕ$. Further, we show that the lower bounds on the slice genus coming from the Tristram–Levine and Casson–Gordon signatures cannot be used to disprove the conjecture.

We have not been able to recognize your IP address 34.231.21.105 as that of a subscriber to this journal.
Online access to the content of recent issues is by subscription, or purchase of single articles.

or by using our contact form.


text:
# Revision history [back]

There are inbuilt software managers such as dnfdragora (which is historically known as being bad), Yumex (outdated), Synaptic or GNOME Software (the one most use). I tend to prefer command line tools; they are a lot easier than you think!

Most of the time, when I want to install something, it's just a simple:

dnf search whateverSoftware # make sure it's here!

dnf install whateverSoftware

Want to remove?

dnf remove whateverSoftware

There's a great guide here: https://fedoraproject.org/wiki/DNF

It's really, really simple to use the command line most of the time. Look up a video tutorial if you are struggling; chances are millions of people have already struggled with it and have posted how to do it. Or post it here, we'd be glad to help you out.

Hope that helps.

There are inbuilt GUI software managers such as dnfdragora (which is historically known as being bad), Yumex (outdated), Synaptic or GNOME Software (the one most use). I tend to prefer command line tools; they are a lot easier than you think!

Most of the time, when I want to install something, it's just a simple:

dnf search whateverSoftware # make sure it's here!

dnf install whateverSoftware

Want to remove?

dnf remove whateverSoftware

There's a great guide here: https://fedoraproject.org/wiki/DNF

It's really, really simple to use the command line most of the time. Look up a video tutorial if you are struggling; chances are millions of people have already struggled with it and have posted how to do it. Or post it here, we'd be glad to help you out.

Hope that helps. helps.


text:
From non-linear least squares to weighted linear least squares

Given an overdetermined linear system $$A \in \mathbb{R}^{m \times n}$$, $$b \in \mathbb{R}^{m \times 1}$$. And a non-linear function $$f(x)$$. Given a non-linear least squares: $$e^* = \min_g \left\lVert f(A g) - {b}\right\rVert_2^2,$$ where the function $$f(x)$$ is applied element-wise. What would be the best weight $$W$$ depending on $$b$$ for a weighted linear least squares $$\hat{e} = \min_g \left\lVert W A g - W b\right\rVert_2^2,$$ such that $$\min{|e^* - \hat{e}|}$$.


text:
# Suppose

Suppose you know that the length of a line segment is 15, x2=6, y2=14 and x1= -3. Find the possible value of y1. Is there more than one possible answer? Why or why not?

Correct result:

y11 =  26
y12 =  2

#### Solution:

Our quadratic equation calculator calculates it.

${y}_{12}={q}_{2}=2$

We would be pleased if you find an error in the word problem or inaccuracies and send it to us. Thank you!

Showing 1 comment:
Matematik
we make circle k with centre S(x2,y2) and radius r = 15 . Then we make vertical line x= -3 . It make two intersections with circle k thus solutions are two: y11,y12.

Tips to related online calculators
For Basic calculations in analytic geometry is a helpful line slope calculator. From coordinates of two points in the plane it calculate slope, normal and parametric line equation(s), slope, directional angle, direction vector, the length of segment, intersections the coordinate axes etc.
Looking for help with calculating roots of a quadratic equation?
Do you have a linear equation or system of equations and looking for its solution? Or do you have quadratic equation?
Do you want to convert length units?
Pythagorean theorem is the base for the right triangle calculator.

#### You need to know the following knowledge to solve this word math problem:

We encourage you to watch this tutorial video on this math problem:

## Related math problems and questions:

• Prove
Prove that k1 and k2 are the equations of two circles. Find the equation of the line that passes through the centers of these circles. k1: x2+y2+2x+4y+1=0 k2: x2+y2-8x+6y+9=0
• Intersections 3
Find the intersections of the circles x2 + y2 + 6 x - 10 y + 9 = 0 and x2 + y2 + 18 x + 4 y + 21 = 0
• Trapezoid 15
Area of trapezoid is 266. What value is x if bases b1 is 2x-3, b2 is 2x+1 and height h is x+4
• Curve and line
The equation of a curve C is y=2x² -8x+9 and the equation of a line L is x+ y=3 (1) Find the x co-ordinates of the points of intersection of L and C. (2) Show that one of these points is also the stationary point of C?
• Sphere equation
Obtain the equation of sphere its centre on the line 3x+2z=0=4x-5y and passes through the points (0,-2,-4) and (2,-1,1).
• Find the 15
Find the tangent line of the ellipse 9 x2 + 16 y2 = 144 that has the slope k = -1
Which of the points belong function f:y= 2x2- 3x + 1 : A(-2, 15) B (3,10) C (1,4)
• Non linear eqs
Solve the system of non-linear equations: 3x2-3x-y=-2 -6x2-x-y=-7
• Sphere from tree points
Equation of sphere with three point (a,0,0), (0, a,0), (0,0, a) and center lies on plane x+y+z=a
• Square area
Complete the table and then draw each square. Provide exact lengths. Describe any problems you have. Side Length Area Square 1 1 unit2 Square 2 2 units2 Square 3 4 units2
• Distance problem 2
A=(x,2x) B=(2x,1) Distance AB=√2, find value of x
• Find the 5
Find the equation of the circle with center at (1,20), which touches the line 8x+5y-19=0
• Ellipse
Ellipse is expressed by equation 9x2 + 25y2 - 54x - 100y - 44 = 0. Find the length of primary and secondary axes, eccentricity, and coordinates of the center of the ellipse.
• Three points
Three points A (-3;-5) B (9;-10) and C (2;k) . AB=AC What is value of k?
• Find x 2
Find x, y, and z such that x³+y³+z³=k, for each k from 1 to 100. Write down the number of solutions.


text:
# memo_has_moved_text();Dimensions of Affine Deligne–Lusztig Varieties: A New Approach via Labeled Folded Alcove Walks and Root Operators

Elizabeth Milićević, Department of Mathematics & Statistics, Haverford College, 370 Lancaster Avenue, Haverford, PA, USA, Petra Schwer, Department of Mathematics, Karlsruhe Institute of Technology, EnglerstraÃe 2, 76133 Karlsruhe, Germany and Anne Thomas, School of Mathematics & Statistics, Carslaw Building F07, University of Sydney NSW 2006, Australia

Publication: Memoirs of the American Mathematical Society
Publication Year: 2019; Volume 261, Number 1260
ISBNs: 978-1-4704-3676-6 (print); 978-1-4704-5403-6 (online)
DOI: https://doi.org/10.1090/memo/1260
Published electronically: November 7, 2019
MSC: Primary 20G25; Secondary 05E10, 20F55, 51E24.

View full volume PDF

View other years and numbers:

Chapters

• 1. Introduction
• 2. Preliminaries on Weyl groups, affine buildings, and related notions
• 3. Labelings and orientations, galleries, and alcove walks
• 4. Dimensions of galleries and root operators
• 5. Affine Deligne–Lusztig varieties and folded galleries
• 6. Explicit constructions of positively folded galleries
• 7. The varieties $X_x(1)$ in the shrunken dominant Weyl chamber
• 8. The varieties $X_x(1)$ and $X_x(b)$
• 9. Conjugating to other Weyl chambers
• 10. Diagram automorphisms
• 11. Applications to affine Hecke algebras and affine reflection length

### Abstract

Let $G$ be a reductive group over the field $F=k((t))$, where $k$ is an algebraic closure of a finite field, and let $W$ be the (extended) affine Weyl group of $G$. The associated affine Deligne–Lusztig varieties $X_x(b)$, which are indexed by elements $b \in G(F)$ and $x \in W$, were introduced by Rapoport (2000). Basic questions about the varieties $X_x(b)$ which have remained largely open include when they are nonempty, and if nonempty, their dimension. We use techniques inspired by geometric group theory and combinatorial representation theory to address these questions in the case that $b$ is a pure translation, and so prove much of a sharpened version of Conjecture 9.5.1 of Görtz, Haines, Kottwitz, and Reuman (2010). Our approach is constructive and type-free, sheds new light on the reasons for existing results in the case that $b$ is basic, and reveals new patterns. Since we work only in the standard apartment of the building for $G(F)$, our results also hold in the $p$-adic context, where we formulate a definition of the dimension of a $p$-adic Deligne–Lusztig set. We present two immediate applications of our main results, to class polynomials of affine Hecke algebras and to affine reflection length.

References


text:
A library for formatting numbers according to the metric system

# Pymetro

Pymetro is a python library that allows you to incorporate scientific notations using symbols into your program. It provides functions that force a specific notation on a variable as specified by the user and includes a function that automatically formats any given numbers to a standard index form. Note that all of the returns given by any functions in this module are Strings.

# Usage

## Manual

To use Pymetro, it is first imported to the Python workspace like any other library as:

>> import pymetro

You can then call one of the many functions provided in order to format the desired number. For manual formatting functions, the function is called from the library and provided with either an integer or a float. The following is an example of raising the number 2314.124 to a notation of kilo:

>> pymetro.kilo(2314.124)
2.314124k

You can also specify the number of digits after the decimal point by providing another integer to the function representing the number of places required after the decimal point:

>> pymetro.kilo(2314.124, 3)
2.314k

If no integer is provided to specify the rounding place, the function would simply default to not rounding the number at all.

## Auto

The auto function on the other hand automatically formats the number based on the standard index form, to illustrate, these are the results of passing two different numbers into the auto function:

>> pymetro.auto(2145.235)
2.145235k
>> pymetro.auto(0.032523)
32.523m

As you can see, both numbers were automatically formatted to the recommended notation. This is helpful when the user cannot predict what numbers are going to be generated or inputted in their program. Similarly, the auto function is also capable of accepting a specific number of integers following the decimal point to round, the result is as follows:

>> pymetro.auto(2145.235, 3)
2.145k
>> pymetro.auto(0.032523, 2)
32.52m

# Functions

Notation Symbol Function
Atto a atto()
Femto f femto()
Pico p pico()
Nano n nano()
Micro µ micro()
Milli m milli()
Kilo k kilo()
Mega M Mega()
Giga G giga()
Tera T tera()
Peta peta peta()
Exa E exa()
Zetta Z zetta()
Yotta Y yotta()

## Project details

Uploaded source
Uploaded py3


text:
# Answer the following question. Student while observing a slide of leaf section observed many stomata on the upper surface. He thought he has placed slide upside down - Biology

Short Note

Student while observing a slide of leaf section observed many stomata on the upper surface. He thought he has placed slide upside down. Teacher confirmed it is rightly placed. Explain.

#### Solution

1. In a dicot leaf, stomata are generally absent on the upper epidermis but are present on the lower epidermis. Thus, the student must have thought that he has placed slide upside down.
2. According to teacher, the section was placed rightly, thus the given section must be of monocot leaf.
3. It is because in monocot leaf stomata are present on both upper and lower epidermis.
Concept: Anatomy of Root, Stem and Leaf
Is there an error in this question or solution?

#### APPEARS IN

Balbharati Biology 11th Standard Maharashtra State Board
Chapter 8 Plant Tissues and Anatomy
Exercise | Q 2. (H) | Page 95


text:
## Dynamic influence maximization

21 May 2021, 20:48 (edited 28 Dec 2021)NeurIPS 2021 PosterReaders: Everyone
• Keywords: Influence maximization, submodular maximization, dynamic algorithm
• TL;DR: Near optimal algorithm/hardness for dynamic influence maximization
• Abstract: We initiate a systematic study on {\em dynamic influence maximization} (DIM). In the DIM problem, one maintains a seed set $S$ of at most $k$ nodes in a dynamically involving social network, with the goal of maximizing the expected influence spread while minimizing the amortized updating cost. We consider two evolution models. In the {\em incremental model}, the social network gets enlarged over time and one only introduces new users and establishes new social links, we design an algorithm that achieves $(1-1/e-\epsilon)$-approximation to the optimal solution and has $k \cdot\mathsf{poly}(\log n, \epsilon^{-1})$ amortized running time, which matches the state-of-art offline algorithm with only poly-logarithmic overhead. In the fully dynamic model, users join in and leave, influence propagation gets strengthened or weakened in real time, we prove that under the Strong Exponential Time Hypothesis (SETH), no algorithm can achieve $2^{-(\log n)^{1-o(1)}}$-approximation unless the amortized running time is $n^{1-o(1)}$. On the technical side, we exploit novel adaptive sampling approaches that reduce DIM to the dynamic MAX-k coverage problem, and design an efficient $(1-1/e-\epsilon)$-approximation algorithm for it. Our lower bound leverages the recent developed distributed PCP framework.
• Supplementary Material: pdf
• Code Of Conduct: I certify that all co-authors of this work have read and commit to adhering to the NeurIPS Statement on Ethics, Fairness, Inclusivity, and Code of Conduct.
13 Replies


text:
# Dispersion and Scattering of Light

## Dispersion

Light can also disperse. The index of refraction depends on the wavelength. We don’t have the capability of sending a perfectly monochromatic light into an optical fiber, therefore there will be some dispersion of light. This also has implications for optical fibers. We must pick materials for optical fibers that do not absorb in the near IR, the popular wavelength for telecommunications. In general terms as the index of refraction increases the wavelength decreases. For example, n for blue light is larger than n for red light. A blue photon has an energy of about 3 eV, vs 1.5 eV on the red side of the spectrum.

Dispersion is defined as

$\frac {dn(\lambda)}{d\lambda}\,\!$

If you send white light into a material the material will respond differently to each wavelength of light. Therefore the angle of deflection will be slightly different for each color. This explains how a prism makes a rainbow. White light passes from air into the glass and becomes decomposed into each color.

## Raleigh Scattering

Plane glass is an amorphous material with no crystalline structure. This prevents various refractive processes from occurring that would ruin its transparency. This is why optical fibers are made with amorphous materials. Light can be scattered in any inhomogeneous medium, that is, if there are fluctuations in the refractive index. Amorphous materials tend to be inhomogeneous.

Here is a light beam I0 that is coming from the left towards a scattering center.

$\rightarrow{I_0} \star \rightarrow{\theta}\,\!$

The expression for Rayleigh scattering is given by:

$I_s (\theta)\propto I_0 \; \frac{V^2} {\lambda^4} ( 1 + cos^2 \theta)\,\!$

where:

$R\,\!$ is the distance to the particle or scattering center
$\theta\,\!$ is the scattering angle
$V\,\!$ is the volume of the scattering particle

It is valid for small spherical scattering particles of volume V with a diameter less than 1/10 of λ of incident light.

The scattering particles (scattering centers) can be as small as a single molecule

Scattering depends on the angle but it is not an all or nothing relationship. The intensity of the beam going straight vs θ at 90 degrees exhibits a factor of 2 difference because of the $( 1 + cos^2 \theta)\,\!$ expression. Otherwise there would be much more effect from the angle.

Since Rayleigh scattering is proportional to $\frac{1}{\lambda^4}\,\!$ scattering is larger for blue light than for red light. For a given angle of scattering the blue light will be scatter 16x as much as the red. This is the reason the sky is blue.

Blue light from the sun is scattered more than red so the sky is blue during the day. At sunset the angle of light is very low and the blue light is scattered away completely leaving only the less scattered red.