text:
# 9.9.9B: Orbital Energies

Orbital energies are not physical properties. They are constructs that arise from our approximate approach to a true multi-electron wavefunction using products of single-electron wavefunctions called atomic orbitals. Nevertheless, a great deal can be learned by considering orbital energies.

Our use of orbital energy level diagrams and the Aufbau principle to create electron configurations is based on the idea that the electrons fill the orbitals in order of increasing orbital energy. The implicit assumption is that the sum of the atomic orbital energies represents the total energy of the molecule. This assumption ignores electron correlation effects that arise when two electrons are in the same orbital. For example, electron configurations exhibit periodic trends in the number of electrons present in the atomic orbitals with the highest principal quantum number, n. These electrons are called valence electrons. The periodic table is arranged so that atoms with the same distributions of valence electrons are arranged in columns. Trends in physical properties track the trends in valence electron configurations and thus are called periodic properties.

We know how to calculate orbital energies from first principles. A single table or orbital energy level diagram that is valid for all elements does not suffice because the orbital energies depend on the electron-electron interactions that in turn depend on the number of electrons in the atom and the orbitals they occupy. Consequently, the orbital energies need to be specified for each element, which can be done most conveniently in graphical form.

The diagram/table reveals general trends as well as exceptions to these trends. A careful examination of the diagram reveals the basis for the electron configuration mnemonics or guides given in most introductory chemistry courses:

1s<2s<2p<3s<3p<4s<3d<4p<5s<4d<5p<6s<4f<5d<6p<7s<5f<6d<7p

For example the 1s orbital is always lowest in energy, followed by the 2s, 2p and 3s orbitals. The 4s is lower than the 3d orbital between elements 7 and 20, so the potassium and calcium electron configurations (Z = 19 and 20, respectively) have electrons in the 4s orbital rather than the 3d, and scandium (Z = 21) has the expected configuration [Ar]4s23d1. For elements with very small and very large atomic numbers, the energies of all orbitals of a given n tend to converge.

Exercise $$\PageIndex{1B}$$

Predict the configurations of K, Sc, Ni, Sb, I and Xe.

The ground-state electron configurations of the elements are listed in Table $$\PageIndex{1}$$. The “exceptions” to the simple mnemonic noted in general chemistry texts are partly a consequence of the inadequacy of a “one-orbital order-fits-all” model. For example, copper has an electron configuration of [Ar]4s1d10. This configuration, which is at odds with the simple mnemonic, would be predicted successfully by the orbital ordering for copper given in an orbital energy diagram.

Table $$\PageIndex{1}$$: The ground-state electron configurations of the elements.
Atomic Symbol
Atomic Number
Configuration
H
1
1s1
He
2
1s2
Li
3
1s2 2s1
Be
4
1s2 2s2
B
5
1s2 2s2 2p1
C
6
1s2 2s2 2p2
N
7
1s2 2s2 2p3
O
8
1s2 2s2 2p4
F
9
1s2 2s2 2p5
Ne
10
1s2 2s2 2p6
Na
11
[Ne] 3s1
Mg
12
[Ne] 3s2
Al
13
[Ne] 3s2 3p1
Si
14
[Ne] 3s2 3p2
P
15
[Ne] 3s2 3p3
S
16
[Ne] 3s2 3p4
Cl
17
[Ne] 3s2 3p5
Ar
18
[Ne] 3s2 3p6
K
19
[Ar] 4s1
Ca
20
[Ar] 4s2
Sc
21
[Ar] 3d1 4s2
Ti
22
[Ar] 3d2 4s2
V
23
[Ar] 3d3 4s2
Cr
24
[Ar] 3d5 4s1
Mn
25
[Ar] 3d5 4s2
Fe
26
[Ar] 3d6 4s2
Co
27
[Ar] 3d7 4s2
Ni
28
[Ar] 3d8 4s2
Cu
29
[Ar] 3d10 4s1
Zn
30
[Ar] 3d10 4s2
Ga
31
[Ar] 3d10 4s2 4p1
Ge
32
[Ar] 3d10 4s2 4p2
As
33
[Ar] 3d10 4s2 4p3
Se
34
[Ar] 3d10 4s2 4p4
Br
35
[Ar] 3d10 4s2 4p5
Kr
36
[Ar] 3d10 4s2 4p6

Even with our best calculations, however, we can’t successfully predict electron configurations for all elements using the ordering of orbital energies. For instance, orbital energy diagrams show that the 3d orbital energies are lower than the 4s orbital energies for all known elements with Z > 20. However, most of the elements in the first transition series have electron configurations with one or two electrons in the 4s orbital. The reason is that the sum of the orbital energies does not adequately describe the total energy of a multielectron system. Configuration interaction produces our best calculated values for the total energies of multi-electron systems, but the cost is that it wipes out the familiar conceptual picture of atomic orbitals and orbital energies.


text:
# Multiple lines of TeX output between btex and etex in METAPOST

As you know, this is how to create labels in METAPOST:

label(btex some text etex, (0,0));

How do I place text on multiple lines -- in this case such that "some" appears on one line, and "text" appears on the next line? Putting "\\" between them doesn't seem to work at all.

Here is the skeleton of my file:

verbatimtex
%&latex
\documentclass[10pt]{article}
\begin{document}
etex
input mp-tool;
beginfig(0);

label(btex some text etex, (0,0));

endfig;
verbatimtex
\end{document}
etex
end

-
Welcome to TeX.SX! Are you using LaTeX to format the labels? Can you make a complete example of your .mp file? (Just with the essential bits) –  egreg Jul 8 '12 at 15:04
@egreg Thanks! I have now pasted the skeleton of my document. Also, I should perhaps mention that I then use "mptopdf" to compile it into a PDF file. –  MayGodBlessKnuth Jul 8 '12 at 15:21

verbatimtex
%&latex
\documentclass[10pt]{article}
\begin{document}
etex
input mp-tool;
beginfig(0);

label(btex \begin{tabular}{@{}c@{}} some \\ text \end{tabular} etex, (0,0));

endfig;
verbatimtex
\end{document}
etex
end

You can also use \begin{tabular}[t] or \begin{tabular}[b] to modify the vertical alignment.

-
Didn't try, but the tabular preamble appears to be missing its closing brace. –  Bruno Le Floch Jul 9 '12 at 12:11
@BrunoLeFloch Thanks, fixed –  egreg Jul 9 '12 at 13:23

format: plain


text:
# News What Alternative kind of Government do you Support?

1. Nov 20, 2004

### Smurf

In this thread everyone get's to express what kind of alternative Government you think we should have?

Rules are:
No arguing for Democracy
No arguing for Republic
No arguing for Fascism
No arguing for Communism

Why:
Because we've tried those before, (except maybe communism according to some, but whatever) and this thread is to find an Alternative, a New Shiny idea of a Government.

http://www.all-science-fair-projects.com/science_fair_projects_encyclopedia/List_of_forms_of_government [Broken]

Last edited by a moderator: May 1, 2017
2. Nov 20, 2004

### Smurf

I personally support http://www.wordlist.org/an/Anarcho-syndicalism.html [Broken].

Last edited by a moderator: May 1, 2017
3. Nov 20, 2004

### loseyourname

Staff Emeritus
Well, that's about exactly the opposite of what I would propose.

Ideally, I would eliminate just about every role of government outside of foreign relations, contract enforcement, currency printing, and national defense, although even here I would like the military to rely more on the production of technology that can be applied to civilian use rather than on taxation and deficit spending. I'd like to see the majority of decisions made locally and see federal government just about completely abolished, sort of a town-hall approach to government, with each municipality deciding for itself how to spend its own money and what rules it will live by. I'd like to see public services provided by private investment and user fees wherever possible, again in lieu of taxation. All taxation that does exist would ideally be applied only to transactions between private entities and public entities, eliminating income and corporate taxes. An important part of privatizing most government functions, and also allowing the market to operate under the best conditions, would be full disclosure of business activities, including expense reports, for all companies, not just those listed on public stock exchanges. I'd probably leave this function to the government as well. This way, we can bring about the only true democracy, one based on the principals of capitalism, where you vote with your dollar, giving it to whoever does the job best, instead of giving half to a public beast that misspends it without repercussion.

4. Nov 20, 2004

### Smurf

Why Capitalism?

5. Nov 20, 2004

### loseyourname

Staff Emeritus
Because when it operates under ideal conditions, it is the only fair system of exchange of goods and services ever devised.

6. Nov 20, 2004

### Smurf

That is simply untrue.
Ever tried in the west? True.
Most Successfull in exploiting the world? True.

But there are a million and one economic systems that have been devised that just havn't been tried yet because they would take power away from the corporations.

7. Nov 20, 2004

### BobG

Interesting list.

Wouldn't doulocracy (rule by slaves) be problematic? What if they outlawed slavery? Or would political candidates sell themselves into slavery to raise campaign funds? (Reminds of the SNL skit about how Dole's resignation from the Senate might affect the Clinton/Dole Presidential campaign :rofl: )

A strumpetocracy (rule by strumpets) or a pornocracy (rule by harlots) would make for an interesting campaign. :tongue2:

I'd lean towards a mesocracy. Better than the stochastic foolocracy we have today.

8. Nov 20, 2004

### wasteofo2

What are ideal conditions for capitalism?

Around the time of the industrial revolution, the government had very few restrictions on buisness. As a result, the wages workers were paid were ridiculously low, children as young as 4 were working to help support their families, there was no reason for buisnesses to spend any extra money to protect their employees from work-related accidents, buisnesses had no accountability for their actions, and thus they took no precautions to protect the environment.

I think you need a strong/fair central government to keep corporations in check. Without government mandating minimum wage, environmental restraints, work place safety etc., corporations have no reason to not exploit people if it'll make them more money.

9. Nov 20, 2004

### loseyourname

Staff Emeritus
Fair competition standards and full disclosure of all business practices.

Sure they do. The only way for any company to remain in existence is for them to sell their product or service. When they operate according to fair competition standards (no collusion, kickbacks, etc., all strictly regulated by an impartial third-party committee that is not politicized) and under full disclosure, they have every reason not to exploit anybody.

I suppose this depends on what you mean by fair. By fair, I mean that this is the least coercive and aggressive of any economic system.

10. Nov 20, 2004

### plover

How do you get companies that see this as in their best interest? The ones we have now fight transparency kicking and screaming.

And how do economies of scale operate? If governmental decisions are all local and but corporate decisions can be global, you'd end up with a kind of corporate feudalism, with your proposed central governments sort of serving the role the church played in medieval feudalism.

11. Nov 20, 2004

### franznietzsche

Technocracy with capitalist economic philosophy (as opposed to socialist).

If your IQ is over 140, you matter, if not, get back to work.

12. Nov 21, 2004

### vanesch

Staff Emeritus
A favorite goes to random technocracy, where people with the right competences in the domain are given political responsability by random choice (lottery). It is actually very close to the actual way of functioning of the European administration. Legislation comes out, but there are no faces on it, no parties on it. It just happens

13. Nov 21, 2004

### vanesch

Staff Emeritus
I'd like to see both, actually. No matter what capitalists (or socialists for that matter) say, a simplistic ideology never works optimally in all circumstances. Some things work better with a capitalist ideology, others with a socialist ideology, and sometimes you'll have to think up another alternative. There's no magic rule that solves all problems in one sentence.

14. Nov 21, 2004

### franznietzsche

I'll rephrase:

Technocracy: But you don't get what you don't earn. Period.

15. Nov 21, 2004

### vanesch

Staff Emeritus
Do you do the same thing to your kids ?

16. Nov 21, 2004

### franznietzsche

If i had kids, yes. They don't get allowances for chores, they do chores because they are alive. They have to learn that nothing is free. If they choose to do extra things for money, then so be it, but nothing in this world is free,and they have to learn that.

I've seen nine year olds with $200 cd players (not so common now that they are cheaper) listening to someofthe fouestl music, becuase their parents just give them what they want. I have a friend who works at best buy and routinely has parents who come and pick things up, at their child's request while the kid is at school so they kid can have it when he gets home. Heck no. You have to earn your keep in this world, and learn to not expect it to be given to you by anyone, the government least of all. Now back to more political territory: Before one of themore vapid liberals trys it, i will jsut say that no, if one is mentallyretarded or parapalegic or otherwise genuinely disabled i don'tthink that they should starve because they cannot function. But a normal healthy person who does nothing but wait to be given something without working, does deserve to starve. 17. Nov 21, 2004 ### vanesch Staff Emeritus Glub ! :yuck: Can you imagine he/she's maybe between a rock and a hard place ? Like after having been beaten up by her man, left alone with 4 children, on the street, of which two are ill and nothing to live off ? Things like that ? 18. Nov 21, 2004 ### franznietzsche I'm speaking in generalities. General rules. You are dealing with exceptions. As i made the point about people genuinely disabled there are exceptions, but the rule is you earn what you get, you don't go to others looking for handouts and freebies just because you're lazy. 19. Nov 21, 2004 ### Smurf Franz, I think it is a common misconcenption that Socialism is going to give people everything for free, I don't know the dictionary definition off the top of my head but I've been called a socialist more often than not and I don't think people should get money for not doing anything either. My socialism is about exceptions. 20. Nov 21, 2004 ### vanesch Staff Emeritus Well, then we agree. But if there is not some form of social coverage organised by the state, there's no way to handle these "exceptions". (that is what a long discussion with Aquamarine was about) It is typically one of the problems that pure, hard capitalism handles badly. However, you'd be surprised what is the fraction of people in "socialist states" according to a typical US view, like many Western European ones who are supported by social wellfare, that are of the "exceptional case". It is true, however, that there is also a fraction based on laziness, or even downright abuse (in that they DO work, undeclared, and get their allowances on top of that, making easily$6000 a month cash). There should be a strong crackdown on that.
But nevertheless, there's more honest misery out there than you think, and it is often not the fault of the people (they just had bad luck for one or another reason, often one of the factors being born in the wrong place).

21. Nov 21, 2004

### franznietzsche

Well, since you bring up bad luck, your example of the woman fleeingher abusive "man," thats not bad luck. Thats the culmination of bad choices. The situation her kids are in, that is bad luck. The situation she's in, is the result of her bad judgement.

You say we agree, in principle. The difference is, and smurf brings this up, is that you want to serve the exceptions first. I do not. The government is a failure when it comes to this sort of thing, because too many people who should not be helped, get helped, and too many people who should not be helped have lobbyists that are far to powerful, and i'msick of it.

My mother works at bank. She has people come in every other week to cash disability checks. More than half are for carpal tunnel syndrome. She has yet to see even one who has any difficulty driving to the bank, opening the door, walking to her desk, signing paper work, or any thing else. Now i'm sure a few might have just been able to conceal genuine pain, but you cannot tell me, a bunch of people, obviously healthy enough to still work, if they can go to the bank on their own they can work, deserve anything from the government.

22. Nov 21, 2004

### Smurf

I think this is an example of the Government's inefficiency in dealing with scammers than the failure of the system in general. We have the same problems in Canada.

23. Nov 21, 2004

### franznietzsche

The government is the system. The failure of the government is the failure of the system.

24. Nov 21, 2004

### Aquamarine

Does the industrial age argument never die?


text:
Secunia Research Community

#### Forum Thread: Missing previous scan history, and no applications found

You are currently viewing a forum thread in the Secunia Community Forum. Please note that opinions expressed here are not of Secunia but solely reflect those of the user who wrote it.

This thread was submitted in the following forum:
PSI

This thread has been marked as locked.
MrMarshallMan Missing previous scan history, and no applications found
8th Sep, 2010 20:18
Ranking: 2
Posts: 2
User Since: 8th Sep, 2010
System Score: N/A
Location: US
I've been using PSI for a while now. I've gotten great use out of it. However, when starting PSI v1.5.0.0 today I got its introductory message:

Welcome to the Secunia PSI 1.0
Thank you for installing the Secunia PSI.
. . .
Please wait while the first scan finishes.

After scanning is complete, no problems are reported. In fact, no software is listed at all! It's as if I've lost all previous PSI history and PSI acts as if there is no software or OS installed on my system.

BTW, closing PSI and starting the scan over doesn't help. If fact, it goes right back to giving me the introductory message and has no history of the previous scan.

Q Has anyone seen this before? Do you know of a fix?
Q Where does PSI store its scanning information? This might help locating a root cause.

System Details
Windows XP - SP3
Secunia PSI v1.5.0.0

Reno Bill RE: Missing previous scan history, and no applications found
9th Sep, 2010 00:05
Score: 4
Posts: 7
User Since: 26th Nov 2008
System Score: N/A
Location: N/A
Last edited on 9th Sep, 2010 00:05
I have exactly the same problem. I also run XP/SP3, PSI V.1.5. Hope someone can offer some suggestions. Thx.
 +1 -0
TiMow RE: Missing previous scan history, and no applications found
9th Sep, 2010 07:27
Score: 737
Posts: 728
User Since: 26th Jun 2009
System Score: N/A
Location: CH
Last edited on 9th Sep, 2010 08:05
Hi MrMarshallMan (and Reno Bill)

As far as I know PSI doesn't store scanning information. When you run a scan it connects to Secunia's servers and compares your installed software versions with those on it's database, and reports any discrepancies at that time.

What you have described, has been reported by other members on the forum before, but could be too time consuming to find the relevant threads - which may or may not have been solved. If I recall the advice was to un- and re- install PSI.

The latest PSI (stable) version is 1.5.0.2 - you may wish to upgrade to this - see link ("Download PSI"), top right of forum page. Although there is a beta version (2.0) also available (from here: http://secunia.com/PSI2SetupBeta.exe)

You could also try: right click PSI tray icon (bottom right of task bar) and click reload interface. To fully exit PSI you also have to right click tray icon and choose exit (clicking the "X" on the PSI window only closes the window). Restart PSI from "All Programs" in Start menu.

TiMow

PS: I have found the following thread link- which also includes links to similar threads - which seem to be solved. I suggest you open the contained links in different tabs and compare advice/solutions.

PS2: The solution does appear to be to upgrade to v.1.5.0.2 - it shouldn't be necessary to uninstall PSI first because the setup.exe for this version has a built in uninstaller. If you would rather uninstall first, though, PSI has an unintall element within the program found here: C:\Program Files\Secunia\PSI\psi.exe. Navigate here using Windows Explorer or Open Folder icon from expanded Secunia PSI entry in Patched tab (Advanced mode).
At the time when this version became available, some users had problems downloading using IE. If you have another browser, I would use that - Firefox and Chrome were both problem free.

--
Computing is not yet a perfect science - it still requires humans.
 +4 -0
This user no longer exists RE: Missing previous scan history, and no applications found
9th Sep, 2010 10:04
Hi,

Do your settings in Internet Explorer match those described in this item of our FAQ?
http://secunia.com/vulnerability_scanning/personal...
 +0 -0
Anthony Wells RE: Missing previous scan history, and no applications found
9th Sep, 2010 13:23
Score: 2514
Posts: 3,399
User Since: 19th Dec 2007
System Score: N/A
Location: N/A

Hi TiMow ,

As I remember from previous discussion , Secunia keeps the last scan data , along with your profile data , on it's servers and presents it to you using the interface of the PSI GUI , each time you open it ; it also keeps a small log file on your PC .

Any changes detected by "program monitoring" (if enabled) are displayed and retained in real time .

I'm sure Emil will correct me where necessary .

Take care

Anthony

--

It always seems impossible until its done.
Nelson Mandela
 +0 -0
Reno Bill RE: Missing previous scan history, and no applications found
9th Sep, 2010 17:51
Score: 4
Posts: 7
User Since: 26th Nov 2008
System Score: N/A
Location: N/A
I upgraded to V.1.5.0.2, and it solved the problem. Thanks for the suggestion.
 +1 -0
Reno Bill RE: Missing previous scan history, and no applications found
9th Sep, 2010 17:55
Score: 4
Posts: 7
User Since: 26th Nov 2008
System Score: N/A
Location: N/A
The only difference from your FAQ settings for IE is that I don't have Secunia listed in the trusted zones, and the box is checked to require server verification. However, since the update I mentioned previously, I have no more problems.

Out of curiosity, what role does IE play with Secunia PSI? I don't use IE, except when required by MS or another program, and it is never open when I run Secunia.
 +1 -0
Anthony Wells RE: Missing previous scan history, and no applications found
9th Sep, 2010 19:06
Score: 2514
Posts: 3,399
User Since: 19th Dec 2007
System Score: N/A
Location: N/A
Last edited on 9th Sep, 2010 19:09
Hello Reno Bill ,

The PSI uses the embedded part of IE to scan your computer and to contact and check with M$updates and check with Secunia databases . It will attempt to use IE when you click on a PSI "solution" button where IE is the essential browser for the download :eg: M$ patches from the M\$ website .

Not having the Secunia sites selected may prevent bits of the PSI not working in the future as per your original post :(( At least you know where to look :))

You do not need to have IE as your default and the PSI will try to use the default wherever possible - or tell you it can't and request permission to use another browser . The "auto-updates" facility in the 2.0 Beta do not select any browser .

Hope that is clear , if not ask .

Anthony

--

It always seems impossible until its done.
Nelson Mandela
 +0 -0
Anthony Wells RE: Missing previous scan history, and no applications found
9th Sep, 2010 19:17
Score: 2514
Posts: 3,399
User Since: 19th Dec 2007
System Score: N/A
Location: N/A

Hello MrMarshallMan ,

How are you doing ; do you need further help ??

Anthony

--

It always seems impossible until its done.
Nelson Mandela
 +0 -0
Reno Bill RE: Missing previous scan history, and no applications found
9th Sep, 2010 20:12
Score: 4
Posts: 7
User Since: 26th Nov 2008
System Score: N/A
Location: N/A
Thanks for the clarification. I like PSI, and use it every couple of months to update programs that don't do it automatically, or which I only use occasionally.
 +0 -0
MrMarshallMan RE: Missing previous scan history, and no applications found
10th Sep, 2010 18:29
Score: 2
Posts: 2
User Since: 8th Sep 2010
System Score: N/A
Location: US
First off let me say thank you to everyone who replied. This forum has got to be the most responsive of any community based help site I've used in a very long time.

Internet Options
I placed https://psi.secunia.com into my list of trusted sites. I also made sure I comply with the listed PSI system requirements.

This didn't help.

Full disclosure: I forgot that I had cleared all entries from my trusted sites this past Monday. I can't remember if secunia.com was listed there originally or not.

This fixed the problem.

Again, thank you. The responses I got here were:
* timely
* courteous and directly answered my questions
* fixed my issue

--
Marshall
Software Engineer

P.s. My apologies for posting a known issue. In my defense, I did a search of the PSI forum to see if anyone had reported this issue before; but I came up with nothing.


text:
Iterate through files in specific directory

While trying to enhance one of my packages, I wondered whether it is possible to iterate through a directory's file list in expl3 (I've read in l3interfaces.pdf that expl3 has some IO facilities, but they seem unable to scan directories).

The use case is the following: I have one main document. This shall include some special files generated with an external application and stored in directories outside the path.

So the question is: How would an expl3 "directory scanner" (I only want to specify the directory) look or do I have to use Lua for this purpose?

• I assume that you specify only the directory? – user31729 Apr 21 '17 at 15:06
• @ChristianHupfer Yes. – TeXnician Apr 21 '17 at 15:06
• Perhaps this helps: tex.stackexchange.com/questions/341578/…. TeX/LaTeX isn't really designed to work with directories – user31729 Apr 21 '17 at 15:15
• @ChristianHupfer Does not sound bad, but I'd rather use a TeXy approach. – TeXnician Apr 21 '17 at 15:17

expl3 is written in tex so is limited to the facilities that tex provides so you can not do this unless you use -shell-escape or luatex.

For example this will typeset a list of tex files in the current directory if that is what ls *.tex generates in your operating system. (probably dir *.tex in windows)

\documentclass{article}

\begin{document}

\def\zzpar{\par}

\openin\zzz="|ls *tex"
\loop
\ifx\tmp\zzpar\else
\par[\expandafter\detokenize\expandafter{\tmp}]%
\fi
\ifeof\zzz\else
\repeat

\end{document}

If I run it I get 105 pages looking like

• How would a version with --shell-escape look like (command line tools or what do you mean)? – TeXnician Apr 21 '17 at 16:05
• @TeXnician added an example – David Carlisle Apr 21 '17 at 16:17
• With miktex you need (only) --enable-pipes and the command should be dir /w/B *.tex (and it stopped for me after 6 pages with a runaway argument: my test folder is a garbage heap -- no orderly numbered zz or yy files -- and sometimes in the dark ages I managed to create a file {foo.tex ...) – Ulrike Fischer Apr 22 '17 at 16:21
• @UlrikeFischer Thanks, it really works well. – TeXnician Apr 22 '17 at 16:54
• @DavidCarlisle I think I'll accept it again as it is now real multi-platform. – TeXnician Apr 22 '17 at 16:54

With TeX Live 2017 an enhanced version of TeXOSQuery will be shipped, which also runs in the restricted shell:

\documentclass{article}
\usepackage{texosquery}

\TeXOSQuery{\result}{-i ; .}

\show\result

\stop

This outputs

> \result=macro:

You can then use standard methods for splitting the \result macro into components.
• @UlrikeFischer You have to use a personal texosquery.cfg file, see tug.org/pipermail/tex-live/2017-April/039884.html – egreg Apr 22 '17 at 16:46


text:
# Solved: A general contractor has submitted two bids for two projects; A and B. The probability of getting project A

#### ByDr. Raju Chaudhari

Feb 25, 2021

A general contractor has submitted two bids for two projects; A and B. The probability of getting project A is 0.60. The probability of getting project B is 0.75. The probability of getting at least one of the projects is 0.85.

a. What is the probability that the contractor will get both projects?
b. Are the events of getting the two projects mutually exclusive? Explain using probabilities.
c. Are the events of getting the two projects independent? Explain using probabilities.
d. If the contractor gets project A, what is the probability that he will get project B?
e. If the contractor gets project B, what is the probability that he will get project A?

#### Solution

Let $A$ be the event of getting project $A$ and $B$ be the event of getting project $B$.

Given that $P(A) = 0.60$, $P(B) = 0.75$ and $P(A\cup B) =0.85$.

a. The probability that the contractor will get both projects is

 \begin{aligned} P(A\cap B) &= P(A) + P(B) - P(A\cup B)\\ &= 0.60+0.75 -0.85\\ &= 0.5 \end{aligned}

b. $P(A\cap B)\neq 0$, the events of getting the two projects are not mutually exclusive.

c. $P(A)\times P(B) = 0.60\times 0.75 = 0.45\neq P(A\cap B)$, the events of getting the two projects are not independent.
d. If the contractor gets project A, the probability that he will get project B is

 \begin{aligned} P(B|A) &=\frac{P(A\cap B)}{P(A)}\\ &= \frac{0.5}{0.60}\\ &= 0.8333 \end{aligned}
e. If the contractor gets project B, the probability that he will get project A is

 \begin{aligned} P(A|B) &=\frac{P(A\cap B)}{P(B)}\\ &= \frac{0.5}{0.75}\\ &= 0.6667 \end{aligned}


text:
# Shortest Proof of Lebesgue Dominated Convergence Theroem ( 5 lines) without using Fatou's lemma

If {$G_n$} is a sequence of bounded measurable functions and $| G_n | \le M$ where M is a positive real number $\lim\limits_{n\mapsto \infty} G_n =F$ on a bounded measurable set E , $\epsilon> 0$ Let $A_n =$ { $x : |G_m(x)-F(x)|<\epsilon$} whenever $m \ge n$

and let $B_n =$ { $x : |G_n(x)-F(x)|<\epsilon$}

Then $A_n\subseteq A_{n+1}\subseteq B_{n+1}\subseteq E , \lim\limits_{n\mapsto \infty} \mu^*( A_n) = \mu^*( E)$ according to see here Then$\lim\limits_{n\mapsto \infty} \mu^*( B_n) =\mu^*( E) , \lim\limits_{n\mapsto \infty} \mu^*( B_n^C) =0$

$B_n$ is measurable so its outer and inner measures are equal

$\lim\limits_{n\mapsto \infty} | \int_{E}(G_n -F) | \le\lim\limits_{n\mapsto \infty}\int_{B_n}|(G_n -F)|+\lim\limits_{n\mapsto \infty}\int_{B_n^C}|(G_n -F)| \le \epsilon M$

The condition that each $G_n$ is bounded by M can be relaxed to uniform integrability of {$G_n$}.

• Are you asking for verification of your proof? – walkar May 5 '16 at 1:30
• Yes .Please do tell if you find a flaw. – ibnAbu May 5 '16 at 1:37
• I haven't seen a proof with outer measures, so I'm not sure. – walkar May 5 '16 at 1:41
• @walkar. $B_n$ is measurable so its outer and inner measures are equal – ibnAbu May 5 '16 at 1:49
• $A_n$ doesn't appear to be well defined. You have it set to an infinitude of (possibly distinct) sets for each choice of $m \geq n$. – Eric Towers May 5 '16 at 1:53

Counterexample: On $(0,1),$ let $f_n(x) = n^2x^n.$ Then each $f_n$ is bounded on $(0,1),$ and $f_n \to 0$ pointwise on $(0,1).$ But $\int_0^1 f_n(x)\, dx = n^2/(n+1) \to \infty,$ while $\int_0^1 0\, dx = 0.$

• Not a counter example.Your $f_n$ is not bounded by any real number nor is your {$f_n$} uniformly integrable. – ibnAbu May 5 '16 at 11:05
• I addressed the result you first claimed, which was in error. So a better comment from you, I think, would have been to admit the error. – zhw. May 5 '16 at 19:23
• I gave a proof of the theorem used in the proof : math.stackexchange.com/questions/1772057/… – ibnAbu May 7 '16 at 18:38

If {$G_n$} is a sequence of bounded measurable functions and $| G_n | \le M$ where M is a positive real number $\lim\limits_{n\mapsto \infty} G_n =F$ on a bounded measurable set E , $\epsilon> 0$ Let $A_n =$ { $x : |G_m(x)-F(x)|<\epsilon$} whenever $m \ge n$

and let $B_n =$ { $x : |G_n(x)-F(x)|<\epsilon$}

Then $A_n\subseteq A_{n+1}\subseteq B_{n+1}\subseteq E , \lim\limits_{n\mapsto \infty} \mu^*( A_n) = \mu^*( E)$ according to see here Then$\lim\limits_{n\mapsto \infty} \mu^*( B_n) =\mu^*( E) , \lim\limits_{n\mapsto \infty} \mu^*( B_n^C) =0$

$B_n$ is measurable so its outer and inner measures are equal

$\lim\limits_{n\mapsto \infty} | \int_{E}(G_n -F) | \le\lim\limits_{n\mapsto \infty}\int_{B_n}|(G_n -F)|+\lim\limits_{n\mapsto \infty}\int_{B_n^C}|(G_n -F)| \le \epsilon M$

The condition that each $G_n$ is bounded by M can be relaxed to uniform integrability of {$G_n$}.

• Your proof is false in many ways. – Michael Mar 24 '17 at 14:04


text:
# Mass of field for small fluctuations

1. Jan 26, 2010

### h0dgey84bc

Hi,

If I have a Lagrangian that looks like $$L=-\frac{1}{2} \partial^a{\phi}\partial_a{\phi}-\frac{1}{2} \mu \phi^2 -\frac{1}{24}\lambda \phi^4$$.
Where $$\lambda>0$$

Then how do I figure out the mass for small fluctuations about $$\phi=0$$ ?

I don't think I really understand what it means for some parameter to represent the mass. I mean without the phi^4 term, it would just lead to KG equation and obviously there $$\mu$$ represents the mass when you find the dispersion relation.
Should I just therefore find the equations of motion, then plug in some superposition type solution to find out the dispersion relation, and thus find a term that I would normally call the mass in a relation of the form $$E^2=P^2+m^2$$? or is there something else to this?

I'm not really sure how to incorporate the phi=0 expansion into this, I was originally thinking just Taylor expand but then I would have expanded about $$\phi(0,\vec(0))$$, as oppose to the trivial $$\phi=0$$ solution.

Thanks for any help

2. Jan 26, 2010

### torquil

I will only comment in the context of classical field theory, because I think it is not necessary to mention detailed aspects of QFT.

I think you already have the correct idea. The mass of the field is determined by its behaviour for small values of the field \phi. This means that you can simply neglect the quadric term.

If you want to actually do a Taylor expansion, you can construct the action integral and do a Taylor expansion with functional derivatives around \phi=0, but the end result will be the same.

Lots of more complicated answers can be given, involving quantization, representation theory of the Lorentz-group, mass renormalization with bare masses and dressed masses, singularities of propagators, and so on. But I believe what I mentioned above is a pretty reasonable definition in the context of classical field theory. If you are interested in more detailed aspects, consult Weinbergs first QFT book.

One thing to watch out for with this kind of approximation. After you have assumed that \phi is small, you have to make sure that the solutions in the approximative theory don't grow to become large.... That would be inconsistent. But in this case, your approximation of small \phi leads to a linear equation of motion, so all is well!

Torquil

Last edited: Jan 26, 2010


text:
# Is there a way to create elements that looks like tags?

How can I style some element that looks like stackoverflow tags?

• Welcome to TeX.SX! This can be easily done with TikZ or alike. Please see the PGF manual and try to construct them. If you encounter any problems, post you code here with your specific question and we try to help you. Like this, it is just a "do-it-for-me"-question which will not find much interest here. – LaRiFaRi Jan 9 '15 at 8:31
• tex does not have "elements" are you asking about a web page (with mathjax style math as on math.stackexchange?) (If so it is off topic for this site) – David Carlisle Jan 9 '15 at 8:43
• tcolorbox could be another solution. – Ignasi Jan 9 '15 at 9:01

Here's another option using tcolorbox:

The code:

\documentclass{article}
\usepackage[many]{tcolorbox}

\definecolor{tagbg}{RGB}{224,234,241}
\definecolor{tagtext}{RGB}{62,109,154}

\newtcbox{\mytag}{
enhanced,
nobeforeafter,
tcbox raise base,
boxrule=0.4pt,
top=1pt,
bottom=1pt,
right=3pt,
left=3pt,
arc=0pt,
outer arc=0pt,
boxrule=0.4pt,
before upper={\vphantom{dlg}},
coltext=tagtext,
colback=tagbg,
colframe=tagtext,
fontupper=\sffamily
}

\begin{document}

\mytag{html}
\mytag{css}
\mytag{alignment}

\end{document}

With \fcolorbox command from the xcolor package you can define a new command \tagbox

\newcommand{\tagbox}[1]{\fcolorbox{LightGray}{LightCyan}{\textsf{#1}}}

Change the colors to the ones you like.

MWE:

\documentclass{article}
\usepackage[svgnames]{xcolor}
\newcommand{\tagbox}[1]{\fcolorbox{LightGray}{LightCyan}{\textsf{#1}}}
\begin{document}
\tagbox{html}
\end{document}

Output:

## EDIT

Just to show that it can be done without tcolorbox.

MWE (colors borrowed from Gonzalo's answer

\documentclass{article}
\usepackage{xcolor}

% colors borrowed from Gonzalo's answer
\definecolor{TagBG}{RGB}{224,234,241}
\definecolor{TagText}{RGB}{62,109,154}

\newcommand{\tagbox}[1]{\fcolorbox{TagText}{TagBG}{\textcolor{TagText}{\textsf{\vphantom{hg}#1}}}}

\begin{document}
\tagbox{html} \tagbox{css} \tagbox{alignment}
\end{document}

Output:


text:
Browse Questions

# The breaking stress of aluminium is $7\times 10^7N/m^2$.Find the maximum length of wire that can be hang with out breaking if density of aluminium is $3\times 10^3Kgm^{-3}$

$\begin{array}{1 1}(A)\;2.83\times 10^3m\\(B)\;2.38\times 10^3m\\(C)\;5.83\times 10^3m\\(D)\;2.67\times 10^3m\end{array}$

The maximum stress is a highest point of wire which is equal to $Sgl_{max}$
Given $S=3\times 10^3kg/m^3$
$Stress_{max}=70\times 10^7$
$l_{max}=\large\frac{7.0\times 10^7}{3\times 10^3\times 9.8}$
$\Rightarrow 2.38\times 10^3m$
Hence (B) is the correct answer.


text:
## ksf-2015-st-14

Given five different positive integers $$a, b, c, d, e$$, we know that $$c : e = b$$, $$a+b = d$$ and $$e - d = a$$.

Question:

Which of the numbers $$a, b, c, d, e$$ is the largest?


text:
# Let $T$ be a theory of Abelian groups where every element has order 2 find complete theory include T

This question is from Marker's book . Let $T$ be a theory of Abelian groups where every element has order 2 . Show that it is not complete . Find $T' \supset T$ a complete theory with the same infinite model as $T$.

I showed it is not complete but i can't find $T'$.I don't want whole answer just give me clue .

• That's a really cute question! – Asaf Karagila Jan 27 '14 at 23:33

Note that every such group $G$ is a vector space over $\Bbb F_2$ (the field of two elements). Add to $T$ the sentences "There are at least $n$ elements in the universe", for every $n\in\Bbb N$. Then $T'$ is the theory of an infinite dimensional vector space over $\Bbb F_2$.


text:
# Tractability of mutual information-augmented ensemble classification algorithms

I am seeking to augment random forest classification using Shannon-Weaver mutual information as a metaheuristic to partition candidate datasets. Specifically, I am trying to determine if such an approach is both tractable and offers an improved convergence time over bruteforce methods and random forest classification on its own without a major reduction in classification.

Suppose we have a collection of data sets, $K$, that contains rows $\{k1, k2, ..., kn\}$. Each of these rows carries an unknown language $L$ in the context of an unknown, uniformly-applied noise function. Our hypothesis is that at least some subset of these data rows share information: that is, for some rows, $I(kx,ky) > 0$ for ${kx,ky} \in K$. Additionally, we hypothesize that multivariate mutual information $I(kx,ky,...) \not= 0$ for some set of multivariate relations. That is, that our graph contains compositions that are more informative in the context of multiply-chained relationships, or contain some XOR-shaped relationship.

If we attempt to bruteforce this space, because mutual information is commutative, we require n-binomial-n time and space. That is to say, to compute the mutual information of all combinations within collection $D$, we require $\sum\limits_{x=1}^n\binom{n}{x}$ time, assuming for simplicity that the comparison of each row is an $O(1)$ operation.

We would then prune output data set using a fixed cutoff value, $v$, retaining only connections where $I(kx,...) > v$. We would then sort this set in descending order of the number of terms and use this to construct an undirected graph, by connecting features that share positive mutual information and forming branches when multivariate mutual information is negative.

The obvious reduction to this complexity, at an error-bound cost in robustness, is to use random forest analysis. I wish to simplify this computation further, by computing the pairspace mutual information for each pair of rows, then using a cutoff value similar to $v$, construct sets that only contain the participating nodes of each of these graphs. These sets would then be fed into our random forest classifier to determine the shape of the graphs, at an expected reduced time for convergence.

Is this approach tractable? Even if so, are there better approaches to the pruning stage of this problem?

-
This question is extremely cross-disciplinary and research level. As a result, I felt this to be the most correct StackExchange for it to live within, ousting even Stats.SE. –  MrGomez Mar 21 '12 at 1:57
It's debatable. you might get some feedback here, but it sounds like you're looking for practical experience with the heuristics, and stats.SE might be slightly better on that front. This might be one of the few instances where simultaneous cross posting isn't a bad thing –  Suresh Venkat Mar 21 '12 at 2:13
@SureshVenkat Thank you. I've done so: stats.stackexchange.com/questions/25039/… –  MrGomez Mar 21 '12 at 21:09
add comment


text:
### Electronic Research Archive

2021, Issue 4: 2791-2817. doi: 10.3934/era.2021014
Special Issues

# Averaging principle on infinite intervals for stochastic ordinary differential equations

• Received: 01 August 2020 Revised: 01 January 2021 Published: 22 February 2021
• 34C29, 60H10, 37B20, 34C27

• In contrast to existing works on stochastic averaging on finite intervals, we establish an averaging principle on the whole real axis, i.e. the so-called second Bogolyubov theorem, for semilinear stochastic ordinary differential equations in Hilbert space with Poisson stable (in particular, periodic, quasi-periodic, almost periodic, almost automorphic etc) coefficients. Under some appropriate conditions we prove that there exists a unique recurrent solution to the original equation, which possesses the same recurrence property as the coefficients, in a small neighborhood of the stationary solution to the averaged equation, and this recurrent solution converges to the stationary solution of averaged equation uniformly on the whole real axis when the time scale approaches zero.

Citation: David Cheban, Zhenxin Liu. Averaging principle on infinite intervals for stochastic ordinary differential equations[J]. Electronic Research Archive, 2021, 29(4): 2791-2817. doi: 10.3934/era.2021014

### Related Papers:

• In contrast to existing works on stochastic averaging on finite intervals, we establish an averaging principle on the whole real axis, i.e. the so-called second Bogolyubov theorem, for semilinear stochastic ordinary differential equations in Hilbert space with Poisson stable (in particular, periodic, quasi-periodic, almost periodic, almost automorphic etc) coefficients. Under some appropriate conditions we prove that there exists a unique recurrent solution to the original equation, which possesses the same recurrence property as the coefficients, in a small neighborhood of the stationary solution to the averaged equation, and this recurrent solution converges to the stationary solution of averaged equation uniformly on the whole real axis when the time scale approaches zero.

 [1] N. N. Bogolyubov, On Some Statistical Methods in Mathematical Physics, Akademiya Nauk Ukrainskoǐ SSR, 1945. (in Russian) [2] N. N. Bogolyubov and Y. A. Mitropolsky, Asymptotic Methods in the Theory of Non-Linear Oscillations, Translated from the second revised Russian edition. International Monographs on Advanced Mathematics and Physics Hindustan Publishing Corp., Delhi, Gordon and Breach Science Publishers, New York, 1961. [3] A stochastic version of center manifold theory. Probab. Theory Related Fields (1989) 83: 509-545. [4] Averaging principle for a class of stochastic reaction-diffusion equations. Probab. Theory Related Fields (2009) 144: 137-177. [5] Averaging principle for nonautonomous slow-fast systems of stochastic reaction-diffusion equations: the almost periodic case. SIAM J. Math. Anal. (2017) 49: 2843-2884. [6] D. N. Cheban, Asymptotically Almost Periodic Solutions of Differential Equations, Hindawi Publishing Corporation, New York, 2009. [7] D. N. Cheban, Global Attractors of Nonautonomous Dynamical and Control Systems, 2$^{nd}$ edition, Interdisciplinary Mathematical Sciences, vol.18, River Edge, NJ: World Scientific, 2015. doi: 10.1142/9297 [8] D. Cheban and J. Duan, Recurrent motions and global attractors of non-autonomous Lorenz systems, Dyn. Syst., 19 (2004), 41–59. doi: 10.1080/14689360310001624132 [9] Periodic, quasi-periodic, almost periodic, almost automorphic, Birkhoff recurrent and Poisson stable solutions for stochastic differential equations. J. Differential Equations (2020) 269: 3652-3685. [10] Ju. L. Dalec'kiǐ and M. G. Kreǐn, Stability of Solutions of Differential Equations in Banach Space, Translated from the Russian by S. Smith. Translations of Mathematical Monographs, Vol. 43. American Mathematical Society, Providence, R.I., 1974. [11] (2014) Stochastic Equations in Infinite Dimensions.2$^{nd}$ edition, Encyclopedia of Mathematics and its Applications, 152. Cambridge University Press. [12] J. Duan and W. Wang, Effective Dynamics of Stochastic Partial Differential Equations, Elsevier Insights. Elsevier, Amsterdam, 2014. doi: 10.1016/B978-0-12-800882-9.00001-9 [13] (2002) Real Analysis and Probability.Revised reprint of the 1989 original. Cambridge Studies in Advanced Mathematics, 74. Cambridge University Press. [14] M. I. Freidlin and A. D. Wentzell, Random Perturbations of Dynamical Systems, Translated from the 1979 Russian original by Joseph Szücs. 3$^rd$ edition. Grundlehren der Mathematischen Wissenschaften [Fundamental Principles of Mathematical Sciences], 260. Springer, Heidelberg, 2012. doi: 10.1007/978-3-642-25847-3 [15] R. Z. Has'minskiǐ, On the principle of averaging the itô's stochastic differential equations, Kybernetika (Prague), 4 (1968), 260–279. (in Russian) [16] Weak averaging of semilinear stochastic differential equations with almost periodic coefficients. J. Math. Anal. Appl. (2015) 427: 336-364. [17] M. A. Krasnosel'skiǐ, V. Sh Burd and Yu. S. Kolesov, Nonlinear Almost Periodic Oscillations, Nauka, Moscow, 1970 (in Russian). [English translation: Nonlinear Almost Periodic Oscillations. A Halsted Press Book. New York etc.: John Wiley & Sons; Jerusalem- London: Israel Program for Scientific Translations. IX, 326 p., 1973] [18] (1943) Introduction to Non-Linear Mechanics.Annals of Mathematics Studies, no. 11. Princeton University Press. [19] (1978) Almost Periodic Functions and Differential Equations.Moscow State University Press. [20] X. Liu and Z. Liu, Poisson stable solutions for stochastic differential equations with Lévy noise, Acta Math. Sin. (Engl. Ser.), In Press. (also available at arXiv: 2002.00395) [21] Almost automorphic solutions for stochastic differential equations driven by Lévy noise. J. Funct. Anal. (2014) 226: 1115-1149. [22] Normal form transforms separate slow and fast modes in stochastic dynamical systems. Phys. A (2008) 387: 12-38. [23] B. A. Ščerbakov, A certain class of Poisson stable solutions of differential equations, Differencial'nye Uravnenija, 4 (1968), 238–243. (in Russian) [24] B. A. Ščerbakov, The comparability of the motions of dynamical systems with regard to the nature of their recurrence, Differencial'nye Uravnenija, 11 (1975), 1246–1255. (in Russian) [English translation: Differential Equations 11 (1975), 937–943]. [25] G. R. Sell, Topological Dynamics and Ordinary Differential Equations, Van Nostrand-Reinhold, 1971. [26] B. A. Shcherbakov, Topologic Dynamics and Poisson Stability of Solutions of Differential Equations, Stiinca, Kishinev, 1972. [27] B. A. Shcherbakov, Poisson Stability of Motions of Dynamical Systems and Solutions of Differential Equations, Știinţa, Chişinǎu, 1985. (in Russian) [28] K. S. Sibirsky, Introduction to Topological Dynamics, Kishinev, RIA AN MSSR, 1970. (in Russian). [English translation: Introduction to Topological Dynamics. Noordhoff, Leyden, 1975] [29] A. V. Skorokhod, Asymptotic Methods in the Theory of Stochastic Differential Equations, Translated from the Russian by H. H. McFaden. Translations of Mathematical Monographs, 78. American Mathematical Society, Providence, RI, 1989. doi: 10.1090/mmono/078 [30] On large deviations in the averaging principle for SDEs with a "full dependence''. Ann. Probab. (1999) 27: 284-296. [31] Weak averaging of stochastic evolution equations. Math. Bohem. (1995) 120: 91-111. [32] Average and deviation for slow-fast stochastic partial differential equations. J. Differential Equations (2012) 253: 1265-1286.
###### 通讯作者: 陈斌, bchen63@163.com
• 1.

沈阳化工大学材料科学与工程学院 沈阳 110142


text:
Journal of Mathematical Physics, Analysis, Geometry 2021, vol. 17, No 2, pp. 216-232   https://doi.org/10.15407/mag17.02.216     ( to contents , go back )

### Some Properties of the Tsallis Relative Operator φ-Entropy

Ismail Nikoufar

Department of Mathematics, Payame Noor University, P.O. Box 19395-3697 Tehran, Iran
E-mail: nikoufar@pnu.ac.ir

Received February 26, 2020, revised March 10, 2021.

Abstract

In this paper, we introduce the notion of the Tsallis relative operator $\varphi$-entropy between two strictly positive operators and verify its properties such as joint convexity, joint subadditivity, and monotonicity. We also give the Shannon type operator inequality and its reverse one satisfied by the Tsallis relative operator $\varphi$-entropy.

Mathematics Subject Classification 2010: 81P45, 15A39, 47A63, 15A42, 81R15
Key words: perspective function, generalized perspective function, Tsallis relative operator entropy, Tsallis relative operator φ -entropy


text:
Invertible Element of Monoid is Cancellable

Corollary to Invertible Element of Associative Structure is Cancellable

Let $\left({S, \circ}\right)$ be a monoid whose identity is $e_S$.

An element of $\left({S, \circ}\right)$ which is invertible is also cancellable.

Proof

By definition of monoid, $\left({S, \circ}\right)$ is an algebraic structure in which $\circ$ is associative.

The result follows from Invertible Element of Associative Structure is Cancellable.

$\blacksquare$


text:
# Difference between revisions of "Number theory"

Main Article
Talk
Related Articles  [?]
Bibliography  [?]
Citable Version  [?]

This editable Main Article is under development and not meant to be cited; by editing it you can help to improve it towards a future approved, citable version. These unapproved articles are subject to a disclaimer.

Number theory is a branch of mathematics devoted primarily to the study of the integers. Any attempt to conduct such a study naturally leads to an examination of the properties of that which integers are made of (namely, prime numbers) as well as the properties of objects made out of integers (such as rational numbers) or defined as generalisations of the integers (such as, for example, algebraic integers).

Integers can be considered either as such or as solutions to equations (diophantine geometry). Some of the main questions are those of distribution: questions, say, on patterns or their absence (in the primes or other sequences) or, more generally, questions on size, number and growth. Such matters are often best understood through the study of analytical objects (e.g., the Riemann zeta function) that encode them in some fashion (analytical number theory). One may also study real numbers in relation to rational numbers, e.g., as approximated by the latter (diophantine approximation).

The older term for number theory is arithmetic; it was superseded by "number theory" in the nineteenth century, though the adjective arithmetical is still fully current. By 1921, T. Heath had to explain: "By arithmetic Plato meant, not arithmetic in our sense, but the science which considers numbers in themselves, in other words, what we mean by the Theory of Numbers."[1] The general public now uses arithmetic to mean elementary calculations, whereas mathematicians use arithmetic as this article shall, viz., as an older synonym for number theory. (The use of the term arithmetic for number theory has regained some ground since Heath's time, arguably in part due to French influence.[2])

## Origins

### The dawn of arithmetic

The first historical find of an arithmetical nature is a fragment of a table: the broken clay tablet Plimpton 322 (Larsa, Mesopotamia, ca. 1800 BCE) contains a list of "Pythagorean triples", i.e., integers $\scriptstyle (a,b,c)$ such that $\scriptstyle a^2+b^2=c^2$. The triples are too many and too large to have been obtained by brute force.

The Plimpton 322 tablet.

The table's outlay suggests[3] that it was constructed by means of what amounts, in modern language, to the identity

$\left(\frac{1}{2} \left(x - \frac{1}{x}\right)\right)^2 + 1 = \left(\frac{1}{2} \left(x + \frac{1}{x}\right)\right)^2,$

which is implicit in routine Old Babylonian exercises[4]. If some other method was used, the triples were first constructed and then reordered by $c/a$, presumably for actual use as a "table", i.e., with a view to applications.

We do not know what these applications may have been, or whether there could have been any; Babylonian astronomy, for example, truly flowered only later. It has been suggested instead that the table was a source of numerical examples for school problems[5][6]. Alternatively, the table could have served to demonstrate a method for solving a problem of interest to one's students or fellow scribes.

While Babylonian number theory - or what survives of Babylonian mathematics that can be called thus - consists of this single, striking fragment, Babylonian algebra (in the secondary-school sense of "algebra") was exceptionally well developed. Iamblichus states that Pythagoras learned mathematics from the Babylonians, and there is no very strong reason to believe otherwise. (Much earlier sources attest to the travels and studies of Thales and Pythagoras in Egypt.)

Pythagoras was a mystic who gave great importance to the odd and the even. Euclid IX 21--34 is very probably Pythagorean; it is very simple material ("odd times even is odd", "if an odd number measures [= divides] an even number, then it also measures [= divides] half of it"), but it is all that is needed to prove that $\scriptstyle \sqrt{2}$ is irrational. The discovery that $\scriptstyle \sqrt{2}$ is irrational is credited to the early Pythagoreans (pre-Theodorus). By revealing (in modern terms) that numbers could be irrational, this discovery seems to have provoked the first foundational crisis in mathematical history; its proof or its divulgation are sometimes credited to Hippasus, who was expelled or split from the Pythagorean sect. It is only here that we can start to speak of a clear, conscious division between numbers (integers and the rationals - the subjects of arithmetic) and lengths (real numbers, whether rational or not).

The Pythagorean tradition spoke also of so-called polygonal numbers and perfect numbers. The study of the latter made some look at the divisors of integers. While square numbers, cubic numbers, etc., are seen now as more natural than triangular numbers, square numbers, pentagonal numbers, etc., the study of the sums of triangular and pentagonal numbers would prove very fruitful in the early modern period (17th to early 19th century).

We know of no clearly arithmetical material in ancient Egyptian or Vedic sources, though there is some algebra in both. Imperial China has left us a single result in arithmetic, namely, the basic statement known as the Chinese remainder theorem to all students of number theory. The result appears as an exercise in Sun Zi's Suan Ching (also known as Sun Tzu's Mathematical Classic; 3rd, 4th or 5th century CE). A sketch of a method of solution is given: Sun Zi finds a number given its residues much as a modern would, though we do not know whether he had a good way of taking an important intermediate step - namely, finding the inverse of a number modulo another. (The earliest full solution known to this last problem is Āryabhaṭa's; see below.)

There is also some numerical mysticism in Chinese mathematics, but, unlike that of the Pythagoreans, it seems to have led nowhere. Like the Pythagoreans' perfect numbers, magic squares have passed from superstition into recreation.

### Plato and Euclid

Aside from a few fragments, the mathematics of Classical Greece is known to us either through the reports of contemporary non-mathematicians or through mathematical works from the early Hellenistic period. In the case of number theory, this means, large and by, Plato and Euclid, respectively.

Plato had a keen interest in mathematics, and distinguished clearly between arithmetic and calculation. (By arithmetic he meant, in part, theorising on number, rather than what arithmetic or number theory have come to mean.) It is through one of Plato's dialogues -- namely, Theaetetus -- that we know that Theodorus had proven that $\scriptstyle \sqrt{3}, \sqrt{5}, \dots, \sqrt{17}$ are irrational. Theaetetus was, like Plato, a disciple of Theodorus's; he worked on distinguishing different kind of inconmensurables, and was thus arguably a pioneer in the study of number systems. (Book X of Euclid is described by Pappus as being largely based on Theaetetus's work.)

... Euclid devoted part of his Elements to prime numbers and divisibility, topics that belong unambiguously to number theory and are basic thereto; in particular, he gave the first known proof of the infinitude of primes ...

### Diophantus

Very little is known about Diophantus of Alexandria; he probably lived in the third century CE, that is, about five hundred years after Euclid. Six out of the thirteen books of Diophantus's Arithmetica survive in the original Greek; four more books survive in an Arabic translation. The Arithmetica is a collection of worked-out problems where the task is invariably to find rational solutions to a system of polynomial equations, usually of the form $\scriptstyle f(x,y)=z^2$ or $\scriptstyle f(x,y,z)=w^2$. Thus, nowadays, we speak of Diophantine equations when we speak of polynomial equations to which rational or integer solutions must be found.

One may say that Diophantus was studying rational points -- i.e., points whose coordinates are rational -- on curves and varieties; however, unlike the Greeks of the Classical period, who did what we would now call basic algebra in geometrical terms, Diophantus did what we would now call basic algebraic geometry in purely algebraic terms. In modern terms, what Diophantus does is to find rational parametrisations of many varieties; in other words, he shows how to obtain infinitely many rational numbers satisfying a system of equations by giving a procedure that can be made into an algebraic expression (say, $\scriptstyle x=f(r,s)$, $\scriptstyle y=g(r,s)$, $\scriptstyle z=h(r,s)$, where $\scriptstyle f$, $\scriptstyle g$ and $\scriptstyle h$ are polynomials or quotients of polynomials).

Diophantus generally seems to prefer procedures that lead to invertible rational parametrisations; when his procedure leads to a non-invertible rational parametrisation (a so-called unirrational parametrisation) it is generally the case that one can show nowadays that no invertible rational parametrisation is possible. However, Diophantus never inverts his parametrisations (or procedures, as he would more likely have seen them). He would have seen the distinction between his invertible and non-invertible rational parametrisations only in so far as the procedures that give the latter make special assumptions, and (arguably) in so far as non-invertible rational parametrisations miss some rational points (very easily found ones in some of Diophantus's examples).

Diophantus also studies the equations of some non-rational curves, for which no rational parametrisation is possible. He manages to find some rational points on these curves -- elliptic curves, as it happens, in what seems to be their first known occurence -- by means of what amounts (in geometrical terms) to a tangent construction. (He also resorts to what could be called a special case of a secant construction.)

While Diophantus is concerned largely with rational solutions, he assumes some results on integer numbers; in particular, he seems to assume that every integer is the sum of four squares, though he never states as much explicitly.

### The Indian school: Āryabhaṭa, Brahmagupta, Bhāskara

... Brahmagupta (628 CE) started the systematic study of indefinite quadratic equations -- in particular, the misnamed Pell equation, in which Archimedes may have first been interested. Later Sanskrit authors would follow, using Brahmagupta's technical terminology. A general method (the cakravāla) for solving Pell's equation was finally found by Jayadeva (cited in the eleventh century; his work is otherwise lost) and Bhāskara (twelfth century).

### Arithmetic in the Islamic golden age

In the early ninth century, the caliph Al-Ma'mun ordered translations of many Greek mathematical works and at least one Sanskrit work (generally presumed to be Brahmagupta's), thus giving rise to the rich tradition of Islamic mathematics. Diophantus's main work, the Arithmetica, was translated into Arabic by Qusta ibn Luqa (820-912). Part of the treatise al-Fakhri (by al-Karajī, 953 - ca. 1029) builds on it to some extent. Al-Karajī's contemporary Ibn al-Haytham knew[7] what would later be called Wilson's theorem, which, arguably, was thus the first clearly non-trivial result on congruences to prime moduli ever known.

Other than a treatise on squares in arithmetic progression by Fibonacci - who lived and studied in north Africa and Constantinople during his formative years, ca. 1175-1200 - no number theory to speak of was done in western Europe while it went through the Middle Ages. Matters started to change in Europe in the late Rennaissance, thanks to a renewed study of the works of Greek antiquity. The key catalyst was the textual emendation and translation into Latin of Diophantus's Arithmetica.

## Subfields

### Analytic number theory

Analytic number theory is generally held to denote the study of problems in number theory by analytic means, i.e., by the tools of calculus. Some would emphasize the use of complex analysis: the study of the Riemann zeta function and other L-functions can be seen as the epitome of analytic number theory. At the same time, the subfield is often held to cover studies of elementary problems by elementary means, e.g., the study of the divisors of a number without the use of analysis, or the application of sieve methods. A problem in number theory can be said to be analytic simply if it involves statements on quantity or distribution, or if the ordering of the objects studied (e.g., the primes) is crucial. Several different senses of the word analytic are thus conflated in the designation analytic number theory as it is commonly used.

The following are examples of problems in analytic number theory: the prime number theorem, the Goldbach conjecture (or the twin prime conjecture, or the Hardy-Littlewood conjectures), the Waring problem and the Riemann Hypothesis. Some of the most important tools of analytic number theory are the circle method, sieve methods and L-functions (or, rather, the study of their properties).

One may ask analytic questions about algebraic numbers, and use analytic means to answer such questions; it is thus that algebraic and analytic number theory intersect. For example, one may define prime ideals (generalisations of prime numbers living in the field of algebraic numbers) and ask how many prime ideals there are up to a certain size. This question can be answered by means of an examination of Dedekind zeta functions, which are generalisations of the Riemann zeta function, an all-important analytic object that controls the distribution of prime numbers.

### Algebraic number theory

Algebraic number theory studies fields of algebraic numbers, which are generalisations of the rational numbers. (Briefly, an algebraic number is any complex number that is a solution to some polynomial equation $\scriptstyle f(x)=0$ with rational coefficients; for example, every solution $x$ of $\scriptstyle x^5 + (11/2) x^3 - 7 x^2 + 9 = 0$ (say) is an algebraic number.) Fields of algebraic numbers are also called number fields.

It could be argued that the simplest kind of number fields (viz., quadratic fields) were already studied by Gauss, as the discussion of quadratic forms in Disquisitiones arithmeticae can be restated in terms of ideals and norms in quadratic fields. (A quadratic field consists of all numbers of the form $\scriptstyle a + b \sqrt{d}$, where $a$ and $b$ are rational numbers and $d$ is a fixed rational number whose square root is not rational.) For that matter, the 11th-century cakravāla method amounts - in modern terms - to an algorithm for finding the units of a real quadratic number field. However, neither Bhāskara nor Gauss knew of number fields as such.

The grounds of the subject as we know it were set in the late nineteenth century, when ideal numbers, the theory of ideals and valuation theory were developed; these are three complementary ways of dealing with the lack of unique factorisation in algebraic number fields. (For example, in the field generated by the rationals and $\scriptstyle \sqrt{-5}$, the number $6$ can be factorised both as $\scriptstyle 6 = 2 \cdot 3$ and $\scriptstyle 6 = (1 + \sqrt{-5}) ( 1 - \sqrt{-5})$; all of $2$, $3$, $\scriptstyle 1 + \sqrt{-5}$ and $\scriptstyle 1 - \sqrt{-5}$ are irreducible, and thus, in a naïve sense, analogous to primes among the integers.) A failure of awareness of this lack had led to an early erroneous "proof" of Fermat's Last Theorem by G. Lamé; the realisation that this proof was erroneous made others study the consequences of this lack, and ways in which it could be alleviated.

Number fields are often studied as extensions of smaller number fields: a field L is said to be an extension of a field K if L contains K. (For example, the complex numbers C are an extension of the reals R, and the reals R are an extension of the rationals Q.) Classifying the possible extensions of a given number field is a difficult and partially open problem. Abelian extensions -- that is, extensions L of K such that the Galois group[8] Gal(L/K) of L over K is an abelian group -- are relatively well understood. Their classification was the object of the programme of class field theory, which was initiated in the late 19th century (partly by Kronecker and Eisenstein) and carried out largely in 1900--1950.

The Langlands program, one of the main current large-scale research plans in mathematics, is sometimes described as an attempt to generalise class field theory to non-abelian extensions of number fields.

### Diophantine geometry

Consider an equation or system of equations. Does it have rational or integer solutions, and if so, how many? This is the central question of Diophantine geometry.

We may think of this question in the following graphic way. An equation in two variables defines a curve in the plane; more generally, an equation, or system of equations, in two or more variables defines a curve, a surface or some other such object in n-dimensional space. We are asking whether there are any rational points (points all of whose coordinates are rationals) or integer points (points all of whose coordinates are integers) on the curve or surface. If there are any such points on the curve or surface, we may ask how many there are and how they are distributed. Most importantly: are there finitely or infinitely many rational points on a given curve (or surface)? What about integer points?

An example here may be helpful. Consider the equation $x^2+y^2 = 1$; we would like to study its rational solutions, i.e., its solutions $(x,y)$ such that x and y are both rational. This is the same as asking for all integer solutions to $a^2 + b^2 = c^2$; any solution to the latter equation gives us a solution $x = a/c$, $y = b/c$ to the former. It is also the same as asking for all points with rational coordinates on the curve described by $x^2 + y^2 = 1$. (This curve happens to be a circle of radius 1 around the origin.)

The rephrasing of questions on equations in terms of points on curves turns out to be felicitous. The finiteness or not of the number of rational or integer points on an algebraic curve - that is, rational or integer solutions to an equation $f(x,y)=0$, where $f$ is a polynomial in two variables - turns out to depend crucially on the genus of the curve. The genus can be defined as follows: allow the variables in $f(x,y)=0$ to be complex numbers; then $f(x,y)=0$ defines a 2-dimensional surface in 4-dimensional surface; count[9] the number of (doughnut) holes in the surface; call this number the genus of $f(x,y)=0$. Other geometrical notions turn out to be just as crucial.

There is also the closely linked area of diophantine approximations: given a number $x$, how well can it be approximated by rationals? (We are looking for approximations that are good relative to the amount of space that it takes to write the rational: call $a/q$ (with $gcd(a,q)=1$) a good approximation to $x$ if $\scriptstyle |x-a/q|<\frac{1}{q^c}$, where $c$ is large.) This question is of special interest if $x$ is an algebraic number. If $x$ cannot be well approximated, then some equations do not have integer or rational solutions. Moreover, several concepts (especially that of height) turn out to be crucial both in diophantine geometry and in the study of diophantine approximations.

Diophantine geometry should not be confused with the geometry of numbers, which is a collection of graphical methods for answering certain questions in algebraic number theory.

### Arithmetic combinatorics

Let $A$ be a set of integers. Consider the set $A+A$ consisting of all sums of two elements of $A$. Is $A+A$ much larger than A? Barely larger? If $A + A$ is barely larger than $A$, must $A$ have plenty of arithmetic structure - e.g., does it look like an arithmetic progression?

If we begin from a fairly "thick" infinite set $A$ (say, the primes), does it contain many elements in arithmetic progression: $a$, $a+b$, $a+2 b$, $a+3 b$, ... , $a+10b$, say? Should it be possible to write large integers as sums of elements of $A$?

These questions are characteristic of arithmetic combinatorics. This is a presently coalescing field; it subsumes additive number theory (which concerns itself with certain very specific sets $A$ of arithmetic significance, such as the primes or the squares) and, arguably, some of the geometry of numbers, together with some rapidly developing new material. Its focus on issues of growth and distribution make the strengthening of links with ergodic theory likely. The term additive combinatorics is also used; however, the sets $A$ being studied need not be sets of integers, but rather subsets of non-commutative groups, for which the multiplication symbol, not the addition symbol, is traditionally used; they can also be subsets of rings, in which case the growth of $A+A$ and $A$·$A$ may be compared.

### Probabilistic number theory

Take a number at random between one and a million. How likely is it to be prime? This is just another way of asking how many primes there are between one and a million. Very well; ask further: how many prime divisors will it have, on average? How many divisors will it have altogether, and with what likelihood? What is the probability that it have many more or many fewer divisors or prime divisors than the average?

Much of probabilistic number theory can be seen as an important special case of the study of variables that are almost, but not quite, mutually independent. For example, the event that a random integer between one and a million be divisible by two and the event that it be divisible by three are almost independent, but not quite.

It is sometimes said that probabilistic combinatorics uses the fact that whatever happens with probability greater than $0$ must happen sometimes; one may say with equal justice that many applications of probabilistic number theory hinge on the fact that whatever is unusual must be rare. If certain algebraic objects (say, rational or integer solutions to certain equations) can be shown to be in the tail of certain sensibly defined distributions, it follows that there must be few of them; this is a very concrete non-probabilistic statement following from a probabilistic one.

### Computations in number theory

While the word algorithm goes back only to certain readers of Al-Kwarismi, careful descriptions of methods of solution are older than proofs: such methods - that is, algorithms - are as old as any recognisable mathematics - ancient Egyptian, Babylonian, Vedic, Chinese - whereas proofs appeared only with the Greeks of the classical period.

There are two main questions: "can we compute this?" and "can we compute it rapidly?". Anybody can test whether a number is prime or, if it is not, split it into prime factors; doing so rapidly is another matter. We now know fast algorithms for testing primality, but, in spite of much work, no truly fast algorithm for factoring.

The difficulty of a computation can be useful: modern protocols for encrypting messages depend on functions that are known to all, but whose inverses (a) are known only to a chosen few, and (b) would take one too long a time to figure out on one's own. For example, these functions can be such that their inverses can be computed only if certain large integers are factorised. While many difficult computational problems outside number theory are known, most working encryption protocols nowadays are based on the difficulty of a few number-theoretical problems.

On a different note - some things may not be computable at all; in fact, this can be proven. For instance, Turing showed in 1936 that there is no algorithm for deciding in finite time whether a given algorithm ends in finite time. In 1970, it was proven that there is no algorithm for solving any and all Diophantine equations. There are thus some problems in number theory that will never be solved. We even know the shape of some of them, viz., Diophantine equations in nine variables; we simply do not know, and cannot know, which coefficients give us equations for which the following two statements are both true: there are no solutions, and we shall never know that there are no solutions.

## Problems solved and unsolved

### The beginnings

What are the integers x, y, z such that $\scriptstyle x^2 + y^2 = z^2$?

A scribe from Larsa (1800 BCE) almost certainly had a full solution. The late source Proclus credits Pythagoras with the partial solution $\scriptstyle (x,(x^2-1)/2,(x^2+1)/2)$, where $x$ ranges on the odd integers. He also credits Plato with a closely related rule. A general solution makes its first fully explicit appearance in Euclid's Elements (Book X, Lemma 1).

Are there incommensurable line segments? (In our language: are there irrational numbers?)

Yes (early Pythagoreans, before Plato's day). The question belongs to the history of number systems at least as much as it belongs here. The proof in Euclid's Elements is purely arithmetical; nothing besides the "theory of the odd and the even" (likely early Pythagorean) is needed.

Are there infinitely many prime numbers?

Yes (Euclid).

Given two integers, find the largest integer that divides them both.

Euclid's algorithm does the job. It also provides the basis for the standard method for finding integer solutions to linear equations in two variables. Such equations, however, were not addressed by Euclid; the first algorithm found for solving them was Āryabhaṭa's kuṭṭaka (see below).

## References

1. Sir Thomas Heath, A History of Greek Mathematics, vol. 1, Dover, 1981, p. 13.
2. Take, e.g., Serre's A Course in Arithmetic (1970; translated into English in 1973). In 1952, Davenport still had to specify that he meant The Higher Arithmetic. Hardy and Wright wrote in the introduction to An Introduction to the Theory of Numbers (1938): "We proposed at one time to change [the title] to An introduction to arithmetic, a more novel and in some ways a more appropriate title; but it was pointed out that this might lead to misunderstandings about the content of the book."
3. Eleanor Robson, "Neither Sherlock Holmes nor Babylon: a reassessment of Plimpton 322", Historia Math. 28 (3), p. 189.
4. Eleanor Robson, "Neither Sherlock Holmes nor Babylon: a reassessment of Plimpton 322", Historia Math. 28 (3), p. 184.
5. J. Friberg, Methods and traditions of Babylonian mathematics: Plimpton 322, Pythagorean triples and the Babylonian triangle parameter equations, Historia Math. 8, p. 302.
6. Eleanor Robson, "Neither Sherlock Holmes nor Babylon: a reassessment of Plimpton 322", Historia Math. 28 (3), p. 201.
7. Roshdi Rashed, Ibn al-Haytham el le théorème de Wilson, Arch. Hist. Exact Sci. 22 (1980), no. 4, pp. 305-321.
8. The Galois group of an extension K/L consists of the operations (isomorphisms) that send elements of L to other elements of L while leaving all elements of K fixed. Thus, for instance, Gal(C/R) consists of two elements: the identity element (taking every element x+iy of C to itself) and complex conjugation (the map taking each element x+iy to x-iy). The Galois group of an extension tells us many of its crucial properties. The study of Galois groups started with Evariste Galois; in modern language, the main outcome of his work is that an equation f(x)=0 can be solved by radicals (that is, x can be expressed in terms of the four basic operations together with square roots, cubic roots, etc.) if and only if the extension of the rationals by the roots of the equation f(x)=0 has a Galois group that is solvable in the sense of group theory. ("Solvable", in the sense of group theory, is a simple property that can be checked easily for finite groups.)
9. It may be useful to look at an example here. Say we want to study the curve $y^2 = x^3 + 7$. We allow x and y to be complex numbers: $(a + b i)^2 = (c + d i)^3 + 7$. This is, in effect, a set of two equations on four variables, since both the real and the imaginary part on each side must match. As a result, we get a surface (two-dimensional) in four dimensional space. After we choose a convenient hyperplane on which to project the surface (meaning that, say, we choose to ignore the coordinate a), we can plot the resulting projection, which is a surface in ordinary three-dimensional space. It then becomes clear that the result is a torus, i.e., the surface of a doughnut (somewhat stretched). A doughnut has one hole; hence the genus is 1.

## Bibliography

B. Datta and A. N. Singh, History of Hindu mathematics: a source book, Parts I and II, Asia publishing house, Bombay, 1962.

T. Heath, A history of Greek mathematics, Vol. I: From Thales to Euclid, Dover, New York, 1981.

T. Heath, A history of Greek mathematics, Vol. II: From Aristarchus to Diophantus, Dover, New York, 1981.

T. Heath, Diophantus of Alexandria: A Study in the History of Greek Algebra, 2nd. ed, Cambridge University Press, 1910.

Y. Mikami, The development of mathematics in China and Japan, Chelsea, New York, 1974.

R. Rashed, Diophante: Les Arithmetiques, Tome III: livre iv, Paris, Les Belles Lettres, 1984.

R. Rashed, Diophante: Les Arithmetiques, Tome IV: livre v, vi and vii, Paris, Les Belles Lettres, 1984.

E. Robson, "Neither Sherlock Holmes nor Babylon: a reassessment of Plimpton 322", Historia Math. 28 (3), pp. 167-206, 2001.

B. L. van der Waerden, Science awakening, Oxford University Press, New York, 1961.

A. Weil, Number theory. An approach through history. From Hammurapi to Legendre. Birkhäuser, Boston, MA, 1984.


text:
text-2.0.1: An efficient packed Unicode text type.
Copyright (c) 2009 2010 Bryan O'Sullivan(c) 2009 Simon Marlow BSD-style bos@serpentine.com GHC Trustworthy Haskell2010

Data.Text.Lazy.IO

Description

Efficient locale-sensitive support for lazy text I/O.

The functions in this module obey the runtime system's locale, character set encoding, and line ending conversion settings.

If you know in advance that you will be working with data that has a specific encoding (e.g. UTF-8), and your application is highly performance sensitive, you may find that it is faster to perform I/O with bytestrings and to encode and decode yourself than to use the functions in this module.

Synopsis

# File-at-a-time operations

Read a file and return its contents as a string. The file is read lazily, as with getContents.

Beware that this function (similarly to readFile) is locale-dependent. Unexpected system locale may cause your application to read corrupted data or throw runtime exceptions about "invalid argument (invalid byte sequence)" or "invalid argument (invalid character)". This is also slow, because GHC first converts an entire input to UTF-32, which is afterwards converted to UTF-8.

If your data is UTF-8, using decodeUtf8 . readFile is a much faster and safer alternative.

writeFile :: FilePath -> Text -> IO () Source #

Write a string to a file. The file is truncated to zero length before writing begins.

appendFile :: FilePath -> Text -> IO () Source #

Write a string to the end of a file.

# Operations on handles

Lazily read the remaining contents of a Handle. The Handle will be closed after the read completes, or on error.

Read a single line from a handle.

hPutStr :: Handle -> Text -> IO () Source #

Write a string to a handle.

hPutStrLn :: Handle -> Text -> IO () Source #

Write a string to a handle, followed by a newline.

# Special cases for standard input and output

interact :: (Text -> Text) -> IO () Source #

The interact function takes a function of type Text -> Text as its argument. The entire input from the standard input device is passed (lazily) to this function as its argument, and the resulting string is output on the standard output device.

Lazily read all user input on stdin as a single string.

Read a single line of user input from stdin.

putStr :: Text -> IO () Source #

Write a string to stdout.

putStrLn :: Text -> IO () Source #

Write a string to stdout, followed by a newline.