Initial commit

This commit is contained in:
Ian Jauslin 2019-12-16 15:06:59 -05:00
commit e6bf8349d7
18 changed files with 3076 additions and 0 deletions

1437
Carlen_Jauslin_Lieb_2019.tex Normal file

File diff suppressed because it is too large Load Diff

54
Makefile Normal file
View File

@ -0,0 +1,54 @@
PROJECTNAME=$(basename $(wildcard *.tex))
LIBS=$(notdir $(wildcard libs/*))
FIGS=$(notdir $(wildcard figs/*.fig))
PDFS=$(addsuffix .pdf, $(PROJECTNAME))
SYNCTEXS=$(addsuffix .synctex.gz, $(PROJECTNAME))
all: $(PROJECTNAME)
$(PROJECTNAME): $(LIBS) $(FIGS)
pdflatex -file-line-error $@.tex
pdflatex -file-line-error $@.tex
pdflatex -synctex=1 $@.tex
$(PROJECTNAME).aux: $(LIBS) $(FIGS)
pdflatex -file-line-error -draftmode $(PROJECTNAME).tex
$(SYNCTEXS): $(LIBS) $(FIGS)
pdflatex -synctex=1 $(patsubst %.synctex.gz, %.tex, $@)
libs: $(LIBS)
$(LIBS):
ln -fs libs/$@ ./
figs: $(FIGS)
$(FIGS):
make -C figs/$@
for pdf in $$(find figs/$@/ -name '*.pdf'); do ln -fs "$$pdf" ./ ; done
clean-aux: clean-figs-aux
rm -f $(addsuffix .aux, $(PROJECTNAME))
rm -f $(addsuffix .log, $(PROJECTNAME))
rm -f $(addsuffix .out, $(PROJECTNAME))
rm -f $(addsuffix .toc, $(PROJECTNAME))
clean-libs:
rm -f $(LIBS)
clean-figs:
$(foreach fig,$(addprefix figs/, $(FIGS)), make -C $(fig) clean; )
rm -f $(notdir $(wildcard figs/*.fig/*.pdf))
clean-figs-aux:
$(foreach fig,$(addprefix figs/, $(FIGS)), make -C $(fig) clean-aux; )
clean-tex:
rm -f $(PDFS) $(SYNCTEXS)
clean: clean-aux clean-tex clean-libs clean-figs

47
README Normal file
View File

@ -0,0 +1,47 @@
This directory contains the source files to typeset the article, and generate
the figures. This can be accomplished by running
make
A program is bundled with this document to compute solutions to the simple
equation numerically. It is located in figs/numerical.figs/simpleq. We will not
give a full documentation of the program, which will be provided with a more
complete version at some later time. The program is run when running 'make' to
compute the data for the figures.
This document uses a custom class file, located in the 'libs' directory, which
defines a number of commands. Most of these are drop-in replacements for those
defined in the 'article' class.
Some extra functionality is provided in custom style files, located in the
'libs' directory.
* Dependencies:
pdflatex
TeXlive packages:
amsfonts
array
color
dsfont
etoolbox
graphics
hyperref
latex
marginnote
pgf
standalone
GNU make
julia
* Files:
Carlen_Jauslin_Lieb_2019.tex:
main LaTeX file
libs:
custom LaTeX class file
figs:
source code for the figures

View File

@ -0,0 +1,42 @@
\bibitem[Bo47]{Bo47}N. Bogolubov - {\it On the theory of superfluidity}, Journal of Physics (USSR), volume\-~11, number\-~1 , pages\-~23-32 (translated from the Russian Izv.Akad.Nauk Ser.Fiz, volume\-~11, pages\-~77-90), 1947.\par\medskip
\bibitem[CHe]{CHe}E.\-~Carlen, M.\-~Holzmann, I.\-~Jauslin, E.H.\-~Lieb, in preparation.\par\medskip
\bibitem[Dy57]{Dy57}F.J. Dyson - {\it Ground-State Energy of a Hard-Sphere Gas}, Physical Review, volume\-~106, issue\-~1, pages\-~20-26, 1957,\par\penalty10000
doi:{\tt\href{http://dx.doi.org/10.1103/PhysRev.106.20}{10.1103/PhysRev.106.20}}.\par\medskip
\bibitem[FS19]{FS19}S.\-~Fournais, J.P.\-~Solovej - {\it The energy of dilute Bose gases}, 2019,\par\penalty10000
arxiv:{\tt\href{http://arxiv.org/abs/1904.06164}{1904.06164}}.\par\medskip
\bibitem[Ga99]{Ga99}G. Gallavotti - {\it Statistical mechanics, a short treatise}, Springer, 1999.\par\medskip
\bibitem[LHY57]{LHY57}T.D. Lee, K. Huang, C.N. Yang - {\it Eigenvalues and Eigenfunctions of a Bose System of Hard Spheres and Its Low-Temperature Properties}, Physical Review, volume\-~106, issue\-~6, pages\-~1135-1145, 1957,\par\penalty10000
doi:{\tt\href{http://dx.doi.org/10.1103/PhysRev.106.1135}{10.1103/PhysRev.106.1135}}.\par\medskip
\bibitem[Le29]{Le29}W. Lenz - {\it Die Wellenfunktion und Geschwindigkeitsverteilung des entarteten Gases}, Zeitschrift f\"ur Physik, volume\-~56, issue\-~11-12, pages\-~778-789, 1929,\par\penalty10000
doi:{\tt\href{http://dx.doi.org/10.1007/BF01340138}{10.1007/BF01340138}}.\par\medskip
\bibitem[Li63]{Li63}E.H. Lieb - {\it Simplified Approach to the Ground-State Energy of an Imperfect Bose Gas}, Physical Review, volume\-~130, issue\-~6, pages\-~2518-2528, 1963,\par\penalty10000
doi:{\tt\href{http://dx.doi.org/10.1103/PhysRev.130.2518}{10.1103/PhysRev.130.2518}}.\par\medskip
\bibitem[LL64]{LL64}E.H. Lieb, W. Liniger - {\it Simplified Approach to the Ground-State Energy of an Imperfect Bose Gas. III. Application to the One-Dimensional Model}, Physical Review, volume\-~134, issue\-~2A, pages A312-A315, 1964,\par\penalty10000
doi:{\tt\href{http://dx.doi.org/10.1103/PhysRev.134.A312}{10.1103/PhysRev.134.A312}}.\par\medskip
\bibitem[LL01]{LL01}E.H. Lieb, M. Loss - {\it Analysis}, Second edition, Graduate studies in mathematics, Americal Mathematical Society, 2001.\par\medskip
\bibitem[LY98]{LY98}E.H. Lieb, J. Yngvason - {\it Ground State Energy of the Low Density Bose Gas}, Physical Review Letters, volume\-~80, issue\-~12, pages\-~2504-2507, 1998,\par\penalty10000
doi:{\tt\href{http://dx.doi.org/10.1103/PhysRevLett.80.2504}{10.1103/PhysRevLett.80.2504}}, arxiv:{\tt\href{http://arxiv.org/abs/cond-mat/9712138}{cond-mat/9712138}}.\par\medskip
\bibitem[LY01]{LY01}E.H. Lieb, J. Yngvason - {\it The Ground State Energy of a Dilute Two-Dimensional Bose Gas}, Journal of Statistical Physics, volume\-~103, issue\-~3-4, pages\-~509-526, 2001,\par\penalty10000
doi:{\tt\href{http://dx.doi.org/10.1023/A:1010337215241}{10.1023/A:1010337215241}}, arxiv:{\tt\href{http://arxiv.org/abs/math-ph/0002014}{math-ph/0002014}}.\par\medskip
\bibitem[PT12]{PT12}E. Pulvirenti, D. Tsagkarogiannis - {\it Cluster Expansion in the Canonical Ensemble}, Communications in Mathematical Physics, volume\-~316, issue\-~2, pages\-~289-306, 2012,\par\penalty10000
doi:{\tt\href{http://dx.doi.org/10.1007/s00220-012-1576-y}{10.1007/s00220-012-1576-y}}, arxiv:{\tt\href{http://arxiv.org/abs/1105.1022}{1105.1022}}.\par\medskip
\bibitem[RS75]{RS75b}M. Reed, B. Simon - {\it Methods of Modern Mathematical Physics II: Fourier Analysis, Self-Adjointness}, second edition, Academic Press, New York, 1975.\par\medskip
\bibitem[Ru99]{Ru99}D. Ruelle - {\it Statistical mechanics: rigorous results}, Imperial College Press, World Scientific, (first edition: Benjamin, 1969), 1999.\par\medskip
\bibitem[YY09]{YY09}H. Yau, J. Yin - {\it The Second Order Upper Bound for the Ground Energy of a Bose Gas}, Journal of Statistical Physics, volume\-~136, issue\-~3, pages\-~453-503, 2009,\par\penalty10000
doi:{\tt\href{http://dx.doi.org/10.1007/s10955-009-9792-3}{10.1007/s10955-009-9792-3}}, arxiv:{\tt\href{http://arxiv.org/abs/0903.5347}{0903.5347}}.\par\medskip

View File

@ -0,0 +1,32 @@
PROJECTNAME=bosegas convexity
DATS=erho.dat ddrhoe.dat
PDFS=$(addsuffix .pdf, $(PROJECTNAME))
TEXS=$(addsuffix .tikz.tex, $(PROJECTNAME))
all: $(PDFS)
$(PDFS): $(DATS)
gnuplot $(patsubst %.pdf, %.gnuplot, $@) > $(patsubst %.pdf, %.tikz.tex, $@)
pdflatex -jobname $(basename $@) -file-line-error $(patsubst %.pdf, %.tikz.tex, $@)
erho.dat:
julia ./simpleq/main.jl -p "tolerance=1e-14;order=100" energy_rho > $@
ddrhoe.dat:
julia ./simpleq/main.jl -p "tolerance=1e-14;order=100" convexity > $@
install: $(PDFS)
cp $^ $(INSTALLDIR)/
clean-aux:
rm -f $(addsuffix .tikz.tex, $(PROJECTNAME))
rm -f $(addsuffix .aux, $(PROJECTNAME))
rm -f $(addsuffix .log, $(PROJECTNAME))
clean-dat:
rm -f $(DATS)
clean-tex:
rm -f $(PDFS)
clean: clean-aux clean-tex

View File

@ -0,0 +1,34 @@
set ylabel "$\\displaystyle\\frac{e}{4\\pi\\rho}$" norotate offset -1,0
set xlabel "$\\rho$"
set xtics 1e-6, 100, 100
set xtics add ("$10^{-6}$" 0.000001, "$10^{-4}$" 0.0001, "$10^{-2}$" 0.01, "$1$" 1.0, "$10^2$" 100)
unset mxtics
set ytics 0.6, 0.1
set mytics 2
set xrange [0.000001:100]
set yrange [0.6:1.05]
# default output canvas size: 12.5cm x 8.75cm
set term lua tikz size 8,6 standalone
set key off
# set linestyle
set style line 1 linetype rgbcolor "#4169E1" linewidth 3
set style line 2 linetype rgbcolor "#DC143C" linewidth 3
set style line 3 linetype rgbcolor "#32CD32" linewidth 3
set style line 4 linetype rgbcolor "#4B0082" linewidth 3
set style line 5 linetype rgbcolor "#DAA520" linewidth 3
set pointsize 1
set logscale x
plot "erho.dat" using 1:(0.95*$2/$1/(4*pi)):(1.05*$2/$1/(4*pi)) with filledcurves linetype rgbcolor "#DDDDDD", \
"erho.dat" using 1:($2/$1/(4*pi)) with lines linestyle 1, \
"holzmann_2019-09-28.dat" using 1:($2/$1/(4*pi)) with points linestyle 2

View File

@ -0,0 +1,30 @@
set ylabel "$\\frac1{4\\pi}\\partial_\\rho^2(e\\rho)$" offset -4,0 norotate
set xlabel "$\\rho$"
set xtics 1e-6, 100, 100
set xtics add ("$10^{-6}$" 0.000001, "$10^{-4}$" 0.0001, "$10^{-2}$" 0.01, "$1$" 1.0, "$10^2$" 100)
unset mxtics
set xrange [0.000001:100]
set ytics 1.2, 0.2
set mytics 2
set yrange [1.2:2.1]
# default output canvas size: 12.5cm x 8.75cm
set term lua tikz size 8,6 standalone
# no key
set key off
# set linestyle
set style line 1 linetype rgbcolor "#4169E1" linewidth 3
set style line 2 linetype rgbcolor "#DC143C" linewidth 3
set style line 3 linetype rgbcolor "#000000" linewidth 1
set style line 4 linetype rgbcolor "#4B0082" linewidth 3
set style line 5 linetype rgbcolor "#DAA520" linewidth 3
set pointsize 0.6
set logscale x
plot "ddrhoe.dat" using 1:($2/(4*pi)) with lines linestyle 1

View File

@ -0,0 +1,9 @@
## data from M. Holzmann, 2019-09-22
# rho E0 E0+dE0
1e-4 8.3500e-4 8.3600e-4
1e-3 9.1340e-3 9.1350e-3
1e-2 1.0609e-1 1.0610e-1
1e-1 1.1930e+0 1.1940e+0
1e-0 1.2445e+1 1.2446e+1
1e+1 1.2544e+2 1.2545e+2

View File

@ -0,0 +1,28 @@
# approximate \int_a^b f using Gauss-Legendre quadratures
function integrate_legendre(f,a,b,weights)
out=0
for i in 1:length(weights[1])
out+=(b-a)/2*weights[2][i]*f((b-a)/2*weights[1][i]+(b+a)/2)
end
return out
end
# \int f*g where g is sampled at the Legendre nodes
function integrate_legendre_sampled(f,g,a,b,weights)
out=0
for i in 1:length(weights[1])
out+=(b-a)/2*weights[2][i]*f((b-a)/2*weights[1][i]+(b+a)/2)*g[i]
end
return out
end
# approximate \int_a^b f/sqrt((b-x)(x-a)) using Gauss-Chebyshev quadratures
function integrate_chebyshev(f,a,b,N)
out=0
for i in 1:N
out=out+pi/N*f((b-a)/2*cos((2*i-1)/(2*N)*pi)+(b+a)/2)
end
return out
end

View File

@ -0,0 +1,55 @@
# \hat u_n
function hatun_iteration(e,order,d,v,maxiter)
# gauss legendre weights
weights=gausslegendre(order)
# init V and Eta
(V,V0,Eta,Eta0)=init_veta(weights,d,v)
# init u and rho
u=Array{Array{Complex{Float64}}}(undef,maxiter+1)
u[1]=zeros(Complex{Float64},order)
rho=zeros(Complex{Float64},maxiter+1)
# iterate
for n in 1:maxiter
u[n+1]=A(e,weights,Eta)\b(u[n],e,rho[n],V)
rho[n+1]=rhon(u[n+1],e,weights,V0,Eta0)
end
return (u,rho)
end
# A
function A(e,weights,Eta)
N=length(weights[1])
out=zeros(Complex{Float64},N,N)
for i in 1:N
k=(1-weights[1][i])/(1+weights[1][i])
out[i,i]=k^2+4*e
for j in 1:N
y=(weights[1][j]+1)/2
out[i,j]+=weights[2][j]*(1-y)*Eta[i][j]/(2*(2*pi)^3*y^3)
end
end
return out
end
# b
function b(u,e,rho,V)
out=zeros(Complex{Float64},length(V))
for i in 1:length(V)
out[i]=V[i]+2*e*rho*u[i]^2
end
return out
end
# rho_n
function rhon(u,e,weights,V0,Eta0)
S=V0
for i in 1:length(weights[1])
y=(weights[1][i]+1)/2
S+=-weights[2][i]*(1-y)*u[i]*Eta0[i]/(2*(2*pi)^3*y^3)
end
return 2*e/S
end

View File

@ -0,0 +1,192 @@
using FastGaussQuadrature
using Printf
using LinearAlgebra
include("tools.jl")
include("integration.jl")
include("simpleq.jl")
include("simpleq-newton.jl")
include("iteration.jl")
function main()
## defaults
tolerance=1e-14
order=100
maxiter=21
rho=1e-6
e=1e-4
d=3
v=v_exp3d
a0=a0_exp3d
# plot range when plotting in x
xmin=0
xmax=100
nx=100
# read cli arguments
(params,command)=read_args(ARGS)
# read params
if params!=""
for param in split(params,";")
terms=split(param,"=")
if length(terms)!=2
print(stderr,"error: could not read parameter '",param,"'.\n")
exit(-1)
end
lhs=terms[1]
rhs=terms[2]
if lhs=="rho"
rho=parse(Float64,rhs)
elseif lhs=="e"
e=parse(Float64,rhs)
elseif lhs=="tolerance"
tolerance=parse(Float64,rhs)
elseif lhs=="order"
order=parse(Int64,rhs)
elseif lhs=="maxiter"
maxiter=parse(Int64,rhs)
elseif lhs=="xmin"
xmin=parse(Float64,rhs)
elseif lhs=="xmax"
xmax=parse(Float64,rhs)
elseif lhs=="nx"
nx=parse(Int64,rhs)
else
print(stderr,"unrecognized parameter '",lhs,"'.\n")
exit(-1)
end
end
end
## run command
# e(rho)
if command=="energy_rho"
energy_rho(order,a0,d,v,maxiter,tolerance)
# d^2(rho*e(rho))
elseif command=="convexity"
ddrhoe(order,a0,d,v,maxiter,tolerance)
# u_n(x)
elseif command=="iteration"
iteration_ux(order,e,a0,d,v,maxiter)
else
print(stderr,"unrecognized command '",command,"'.\n")
exit(-1)
end
end
# read cli arguments
function read_args(ARGS)
# flag
flag=""
# output strings
params=""
command=""
# loop over arguments
for arg in ARGS
# argument that starts with a dash
if arg[1]=='-'
# go through characters after dash
for char in arg[2:length(arg)]
# set params
if char=='p'
# raise flag
flag="params"
else
print_usage()
exit(-1)
end
end
# arguments that do not start with a dash
else
if flag=="params"
params=arg
else
command=arg
end
# reset flag
flag=""
end
end
if command==""
print_usage()
exit(-1)
end
return (params,command)
end
# usage
function print_usage()
print(stderr,"usage: simpleq [-p params] <command>\n")
end
# exponential potential in 3 dimensions
function v_exp3d(k)
return 8*pi/(1+k^2)^2
end
a0_exp3d=1.254356410591064819505409291110046864031181245635821944528
# compute energy as a function of rho
function energy_rho(order,a0,d,v,maxiter,tolerance)
minlrho=-6
maxlrho=2
nlrho=100
for j in 0:nlrho-1
rho=10^(minlrho+(maxlrho-minlrho)*j/nlrho)
# linear spacing
#rho=10.0^minlrho+(10.0^maxlrho-10.0^minlrho)*j/nlrho
(u,E)=hatu_newton(order,rho,a0,d,v,maxiter,tolerance)
@printf("% .8e % .8e\n",rho,real(E))
end
end
# compute \partial^2(e\rho) as a function of rho
function ddrhoe(order,a0,d,v,maxiter,tolerance)
minlrho=-6
maxlrho=2
nlrho=100
for j in 0:nlrho-1
rho=10^(minlrho+(maxlrho-minlrho)*j/nlrho)
# interval
drho=rho*1.01
(u,E)=hatu_newton(order,rho,a0,d,v,maxiter,tolerance)
(up,Ep)=hatu_newton(order,rho+drho,a0,d,v,maxiter,tolerance)
(um,Em)=hatu_newton(order,rho-drho,a0,d,v,maxiter,tolerance)
@printf("% .8e % .8e\n",rho,real((rho+drho)*Ep+(rho-drho)*Em-2*rho*E)/drho^2)
end
end
# compute \int u_n(x) at every step
function iteration_ux(order,e,a0,d,v,maxiter)
(u,rho)=hatun_iteration(e,order,d,v,maxiter)
weights=gausslegendre(order)
intun=0.
for n in 2:maxiter+1
# compute \hat u_n(0)=1/(2*rho_n)+rho_{n-1}/2*\hat u_{n-1}(0)^2
intun=real(1/(2*rho[n])+rho[n-1]/2*intun^2)
@printf("%2d % .15e\n",n-1,abs(intun-1/rho[maxiter+1]))
end
end
main()

View File

@ -0,0 +1,95 @@
# \hat u(k) computed using Newton algorithm
function hatu_newton(order,rho,a0,d,v,maxiter,tolerance)
# compute gaussian quadrature weights
weights=gausslegendre(order)
# initialize V and Eta
(V,V0,Eta,Eta0)=init_veta(weights,d,v)
# initialize u, V and Eta
u=zeros(Complex{Float64},order)
for j in 1:order
# transformed k
k=(1-weights[1][j])/(1+weights[1][j])
if d==2
u[j]=2*pi*a0*rho/k
elseif d==3
u[j]=4*pi*a0*rho/k^2
end
end
# iterate
for i in 1:maxiter-1
new=u-inv(dXi(u,V,V0,Eta,Eta0,weights,rho,d))*Xi(u,V,V0,Eta,Eta0,weights,rho,d)
if(norm(new-u)/norm(u)<tolerance)
u=new
break
end
u=new
end
return (u,en(u,V0,Eta0,rho,weights,d)*rho/2)
end
# Xi(u)=0 is equivalent to the linear equation
function Xi(u,V,V0,Eta,Eta0,weights,rho,d)
order=length(weights[1])
# init
out=zeros(Complex{Float64},order)
# compute E before running the loop
E=en(u,V0,Eta0,rho,weights,d)
for i in 1:order
# k_i
k=(1-weights[1][i])/(1+weights[1][i])
# S_i
S=V[i]-1/(rho*(2*pi)^d)*integrate_legendre_sampled(y->(1-y)/y^3,Eta[i].*u,0,1,weights)
# X_i
X=k^2/(2*E*rho)
# U_i
out[i]=u[i]-S/(2*E*(X+1))*Phi(S/(E*(X+1)^2))
end
return out
end
# derivative of Xi (for Newton)
function dXi(u,V,V0,Eta,Eta0,weights,rho,d)
order=length(weights[1])
# init
out=zeros(Complex{Float64},order,order)
# compute E before the loop
E=en(u,V0,Eta0,rho,weights,d)
for i in 1:order
# k_i
k=(1-weights[1][i])/(1+weights[1][i])
# S_i
S=V[i]-1/(rho*(2*pi)^d)*integrate_legendre_sampled(y->(1-y)/y^3,Eta[i].*u,0,1,weights)
# X_i
X=k^2/(2*E*rho)
for j in 1:order
y=(weights[1][j]+1)/2
dS=-1/rho*(1-y)*Eta[i][j]/(2*(2*pi)^d*y^3)*weights[2][j]
dE=-1/rho*(1-y)*Eta0[j]/(2*(2*pi)^d*y^3)*weights[2][j]
dX=-k^2/(2*E^2*rho)*dE
out[i,j]=(i==j ? 1 : 0)-(dS-S*dE/E-S*dX/(X+1))/(2*E*(X+1))*Phi(S/(E*(X+1)^2))-S/(2*E^2*(X+1)^3)*(dS-S*dE/E-2*S*dX/(X+1))*dPhi(S/(E*(X+1)^2))
end
end
return out
end
# energy
function en(u,V0,Eta0,rho,weights,d)
return V0-1/(rho*(2*pi)^d)*integrate_legendre_sampled(y->(1-y)/y^3,Eta0.*u,0,1,weights)
end

View File

@ -0,0 +1,40 @@
# \eta
function eta(x,t,weights,d,v)
if d==2
return integrate_chebyshev(y->4*((x+t)*y+abs(x-t)*(1-y))*v((x+t)*y+abs(x-t)*(1-y))/sqrt(((x+t)*y+abs(x-t)*(2-y))*((x+t)*(1+y)+abs(x-t)*(1-y))),0,1,length(weights))
elseif d==3
return (x>t ? 2*t/x : 2)* integrate_legendre(y->2*pi*((x+t)*y+abs(x-t)*(1-y))*v((x+t)*y+abs(x-t)*(1-y)),0,1,weights)
end
end
# initialize V and Eta
function init_veta(weights,d,v)
order=length(weights[1])
V=Array{Complex{Float64}}(undef,order)
Eta=Array{Array{Complex{Float64}}}(undef,order)
Eta0=Array{Complex{Float64}}(undef,order)
V0=v(0)
for i in 1:order
k=(1-weights[1][i])/(1+weights[1][i])
V[i]=v(k)
Eta[i]=Array{Complex{Float64}}(undef,order)
for j in 1:order
y=(weights[1][j]+1)/2
Eta[i][j]=eta(k,(1-y)/y,weights,d,v)
end
y=(weights[1][i]+1)/2
Eta0[i]=eta(0,(1-y)/y,weights,d,v)
end
return(V,V0,Eta,Eta0)
end
# inverse Fourier transform
function u_x(x,u,weights,d)
order=length(weights[1])
if d==2
out=integrate_legendre_sampled(y->(1-y)/y^3*besselj(0,x*(1-y)/y)/(2*pi),u,0,1,weights)
elseif d==3
out=integrate_legendre_sampled(y->(1-y)/y^3*sin(x*(1-y)/y)/x/(2*pi^2),u,0,1,weights)
end
return out
end

View File

@ -0,0 +1,20 @@
# \Phi(x)=2*(1-sqrt(1-x))/x
function Phi(x)
if abs(x)>1e-5
return 2*(1-sqrt(1-x))/x
else
return 1+x/4+x^2/8+5*x^3/64+7*x^4/128+21*x^5/512
end
end
# \partial\Phi
function dPhi(x)
#if abs(x-1)<1e-5
# @printf(stderr,"warning: dPhi is singular at 1, and evaluating it at (% .8e+i% .8e)\n",real(x),imag(x))
#end
if abs(x)>1e-5
return 1/(sqrt(1-x)*x)-2*(1-sqrt(1-x))/x^2
else
return 1/4+x/4+15*x^2/64+7*x^3/32+105*x^4/512+99*x^5/512
end
end

673
libs/ian.cls Normal file
View File

@ -0,0 +1,673 @@
%%
%% Ian's class file
%%
%% TeX format
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
%% class name
\ProvidesClass{ian}[2017/09/29]
%% boolean to signal that this class is being used
\newif\ifianclass
%% options
% no section numbering in equations
\DeclareOption{section_in_eq}{\sectionsineqtrue}
\DeclareOption{section_in_fig}{\sectionsinfigtrue}
\DeclareOption{section_in_theo}{\PassOptionsToPackage{\CurrentOption}{iantheo}}
\DeclareOption{section_in_all}{\sectionsineqtrue\sectionsinfigtrue\PassOptionsToPackage{section_in_theo}{iantheo}}
\DeclareOption{subsection_in_eq}{\subsectionsineqtrue}
\DeclareOption{subsection_in_fig}{\subsectionsinfigtrue}
\DeclareOption{subsection_in_theo}{\PassOptionsToPackage{\CurrentOption}{iantheo}}
\DeclareOption{subsection_in_all}{\subsectionsineqtrue\subsectionsinfigtrue\PassOptionsToPackage{subsection_in_theo}{iantheo}}
\DeclareOption{no_section_in_eq}{\sectionsineqfalse}
\DeclareOption{no_section_in_fig}{\sectionsinfigfalse}
\DeclareOption{no_section_in_theo}{\PassOptionsToPackage{\CurrentOption}{iantheo}}
\DeclareOption{no_section_in_all}{\sectionsineqfalse\sectionsinfigfalse\PassOptionsToPackage{no_section_in_theo}{iantheo}}
\DeclareOption{no_subsection_in_eq}{\subsectionsineqfalse}
\DeclareOption{no_subsection_in_fig}{\subsectionsinfigfalse}
\DeclareOption{no_subsection_in_theo}{\PassOptionsToPackage{\CurrentOption}{iantheo}}
\DeclareOption{no_subsection_in_all}{\subsectionsineqfalse\subsectionsinfigfalse\PassOptionsToPackage{no_subsection_in_theo}{iantheo}}
% reset point
\DeclareOption{point_reset_at_section}{\PassOptionsToPackage{reset_at_section}{point}}
\DeclareOption{point_no_reset_at_section}{\PassOptionsToPackage{no_reset_at_section}{point}}
\DeclareOption{point_reset_at_theo}{\PassOptionsToPackage{reset_at_theo}{point}}
\DeclareOption{point_no_reset_at_theo}{\PassOptionsToPackage{no_reset_at_theo}{point}}
\def\ian@defaultoptions{
\ExecuteOptions{section_in_all, no_subsection_in_all}
\ProcessOptions
%% required packages
\RequirePackage{iantheo}
\RequirePackage{point}
\RequirePackage{color}
\RequirePackage{marginnote}
\RequirePackage{amssymb}
\PassOptionsToPackage{hidelinks}{hyperref}
\RequirePackage{hyperref}
}
%% paper dimensions
\setlength\paperheight{297mm}
\setlength\paperwidth{210mm}
%% fonts
\input{size11.clo}
\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}
\DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf}
\DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}
\DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}
\DeclareOldFontCommand{\it}{\normalfont\itshape}{\mathit}
%% text dimensions
\hoffset=-50pt
\voffset=-72pt
\textwidth=460pt
\textheight=704pt
%% remove default indentation
\parindent=0pt
%% indent command
\def\indent{\hskip20pt}
%% something is wrong with \thepage, redefine it
\gdef\thepage{\the\c@page}
%% array lines (to use the array environment)
\setlength\arraycolsep{5\p@}
\setlength\arrayrulewidth{.4\p@}
%% correct vertical alignment at the end of a document
\AtEndDocument{
\vfill
\eject
}
%% hyperlinks
% hyperlinkcounter
\newcounter{lncount}
% hyperref anchor
\def\hrefanchor{%
\stepcounter{lncount}%
\hypertarget{ln.\thelncount}{}%
}
%% define a command and write it to aux file
\def\outdef#1#2{%
% define command%
\expandafter\xdef\csname #1\endcsname{#2}%
% hyperlink number%
\expandafter\xdef\csname #1@hl\endcsname{\thelncount}%
% write command to aux%
\immediate\write\@auxout{\noexpand\expandafter\noexpand\gdef\noexpand\csname #1\endcsname{\csname #1\endcsname}}%
\immediate\write\@auxout{\noexpand\expandafter\noexpand\gdef\noexpand\csname #1@hl\endcsname{\thelncount}}%
}
%% can call commands even when they are not defined
\def\safe#1{%
\ifdefined#1%
#1%
\else%
{\color{red}\bf?}%
\fi%
}
%% define a label for the latest tag
%% label defines a command containing the string stored in \tag
\def\deflabel{
\def\label##1{\expandafter\outdef{label@##1}{\safe\tag}}
\def\ref##1{%
% check whether the label is defined (hyperlink runs into errors if this check is omitted)
\ifcsname label@##1@hl\endcsname%
\hyperlink{ln.\csname label@##1@hl\endcsname}{{\color{blue}\safe\csname label@##1\endcsname}}%
\else%
\ifcsname label@##1\endcsname%
{\color{blue}\csname ##1\endcsname}%
\else%
{\bf ??}%
\fi%
\fi%
}
}
%% make a custom link at any given location in the document
\def\makelink#1#2{%
\hrefanchor%
\outdef{label@#1}{#2}%
}
%% section command
% counter
\newcounter{sectioncount}
% space before section
\newlength\secskip
\setlength\secskip{40pt}
% a prefix to put before the section number, e.g. A for appendices
\def\sectionprefix{}
% define some lengths
\newlength\secnumwidth
\newlength\sectitlewidth
\def\section#1{
% reset counters
\stepcounter{sectioncount}
\setcounter{subsectioncount}{0}
\ifsectionsineq
\setcounter{seqcount}0
\fi
\ifsectionsinfig
\setcounter{figcount}0
\fi
% space before section (if not first)
\ifnum\thesectioncount>1
\vskip\secskip
\penalty-1000
\fi
% hyperref anchor
\hrefanchor
% define tag (for \label)
\xdef\tag{\sectionprefix\thesectioncount}
% get widths
\def\@secnum{{\bf\Large\sectionprefix\thesectioncount.\hskip10pt}}
\settowidth\secnumwidth{\@secnum}
\setlength\sectitlewidth\textwidth
\addtolength\sectitlewidth{-\secnumwidth}
% print name
\parbox{\textwidth}{
\@secnum
\parbox[t]{\sectitlewidth}{\Large\bf #1}}
% write to table of contents
\iftoc
% save lncount in aux variable which is written to toc
\immediate\write\tocoutput{\noexpand\expandafter\noexpand\edef\noexpand\csname toc@sec.\thesectioncount\endcsname{\thelncount}}
\write\tocoutput{\noexpand\tocsection{#1}{\thepage}}
\fi
%space
\par\penalty10000
\bigskip\penalty10000
}
%% subsection
% counter
\newcounter{subsectioncount}
% space before subsection
\newlength\subsecskip
\setlength\subsecskip{30pt}
\def\subsection#1{
% counters
\stepcounter{subsectioncount}
\setcounter{subsubsectioncount}{0}
\ifsubsectionsineq
\setcounter{seqcount}0
\fi
\ifsubsectionsinfig
\setcounter{figcount}0
\fi
% space before subsection (if not first)
\ifnum\thesubsectioncount>1
\vskip\subsecskip
\penalty-500
\fi
% hyperref anchor
\hrefanchor
% define tag (for \label)
\xdef\tag{\sectionprefix\thesectioncount.\thesubsectioncount}
% get widths
\def\@secnum{{\bf\large\hskip.5cm\sectionprefix\thesectioncount.\thesubsectioncount.\hskip5pt}}
\settowidth\secnumwidth{\@secnum}
\setlength\sectitlewidth\textwidth
\addtolength\sectitlewidth{-\secnumwidth}
% print name
\parbox{\textwidth}{
\@secnum
\parbox[t]{\sectitlewidth}{\large\bf #1}}
% write to table of contents
\iftoc
% save lncount in aux variable which is written to toc
\immediate\write\tocoutput{\noexpand\expandafter\noexpand\edef\noexpand\csname toc@subsec.\thesectioncount.\thesubsectioncount\endcsname{\thelncount}}
\write\tocoutput{\noexpand\tocsubsection{#1}{\thepage}}
\fi
% space
\par\penalty10000
\medskip\penalty10000
}
%% subsubsection
% counter
\newcounter{subsubsectioncount}
% space before subsubsection
\newlength\subsubsecskip
\setlength\subsubsecskip{20pt}
\def\subsubsection#1{
% counters
\stepcounter{subsubsectioncount}
% space before subsubsection (if not first)
\ifnum\thesubsubsectioncount>1
\vskip\subsubsecskip
\penalty-500
\fi
% hyperref anchor
\hrefanchor
% define tag (for \label)
\xdef\tag{\sectionprefix\thesectioncount.\thesubsectioncount.\thesubsubsectioncount}
% get widths
\def\@secnum{{\bf\hskip1.cm\sectionprefix\thesectioncount.\thesubsectioncount.\thesubsubsectioncount.\hskip5pt}}
\settowidth\secnumwidth{\@secnum}
\setlength\sectitlewidth\textwidth
\addtolength\sectitlewidth{-\secnumwidth}
% print name
\parbox{\textwidth}{
\@secnum
\parbox[t]{\sectitlewidth}{\large\bf #1}}
% write to table of contents
\iftoc
% save lncount in aux variable which is written to toc
\immediate\write\tocoutput{\noexpand\expandafter\noexpand\edef\noexpand\csname toc@subsubsec.\thesectioncount.\thesubsectioncount.\thesubsubsectioncount\endcsname{\thelncount}}
\write\tocoutput{\noexpand\tocsubsubsection{#1}{\thepage}}
\fi
% space
\par\penalty10000
\medskip\penalty10000
}
%% itemize
\newlength\itemizeskip
% left margin for items
\setlength\itemizeskip{20pt}
\newlength\itemizeseparator
% space between the item symbol and the text
\setlength\itemizeseparator{5pt}
% penalty preceding an itemize
\newcount\itemizepenalty
\itemizepenalty=0
% counter counting the itemize level
\newcounter{itemizecount}
% item symbol
\def\itemizept#1{
\ifnum#1=1
\textbullet
\else
$\scriptstyle\blacktriangleright$
\fi
}
\newlength\current@itemizeskip
\setlength\current@itemizeskip{0pt}
\def\itemize{%
\par\expandafter\penalty\the\itemizepenalty\medskip\expandafter\penalty\the\itemizepenalty%
\addtocounter{itemizecount}{1}%
\addtolength\current@itemizeskip{\itemizeskip}%
\leftskip\current@itemizeskip%
}
\def\enditemize{%
\addtocounter{itemizecount}{-1}%
\addtolength\current@itemizeskip{-\itemizeskip}%
\par\expandafter\penalty\the\itemizepenalty\leftskip\current@itemizeskip%
\medskip\expandafter\penalty\the\itemizepenalty%
}
% item, with optional argument to specify the item point
% @itemarg is set to true when there is an optional argument
\newif\if@itemarg
\def\item{%
% check whether there is an optional argument (if there is none, add on empty '[]')
\@ifnextchar [{\@itemargtrue\@itemx}{\@itemargfalse\@itemx[]}%
}
\newlength\itempt@total
\def\@itemx[#1]{
\if@itemarg
\settowidth\itempt@total{#1}
\else
\settowidth\itempt@total{\itemizept\theitemizecount}
\fi
\addtolength\itempt@total{\itemizeseparator}
\par
\medskip
\if@itemarg
\hskip-\itempt@total#1\hskip\itemizeseparator
\else
\hskip-\itempt@total\itemizept\theitemizecount\hskip\itemizeseparator
\fi
}
%% prevent page breaks after itemize
\newcount\previtemizepenalty
\def\nopagebreakafteritemize{
\previtemizepenalty=\itemizepenalty
\itemizepenalty=10000
}
%% back to previous value
\def\restorepagebreakafteritemize{
\itemizepenalty=\previtemizepenalty
}
%% enumerate
\newcounter{enumerate@count}
\def\enumerate{
\setcounter{enumerate@count}0
\let\olditem\item
\let\olditemizept\itemizept
\def\item{
% counter
\stepcounter{enumerate@count}
% set header
\def\itemizept{\theenumerate@count.}
% hyperref anchor
\hrefanchor
% define tag (for \label)
\xdef\tag{\theenumerate@count}
\olditem
}
\itemize
}
\def\endenumerate{
\enditemize
\let\item\olditem
\let\itemizept\olditemizept
}
%% equation numbering
% counter
\newcounter{seqcount}
% booleans (write section or subsection in equation number)
\newif\ifsectionsineq
\newif\ifsubsectionsineq
\def\seqcount{
\stepcounter{seqcount}
% the output
\edef\seqformat{\theseqcount}
% add subsection number
\ifsubsectionsineq
\let\tmp\seqformat
\edef\seqformat{\thesubsectioncount.\tmp}
\fi
% add section number
\ifsectionsineq
\let\tmp\seqformat
\edef\seqformat{\sectionprefix\thesectioncount.\tmp}
\fi
% define tag (for \label)
\xdef\tag{\seqformat}
% write number
\marginnote{\hfill(\seqformat)}
}
%% equation environment compatibility
\def\equation{\hrefanchor$$\seqcount}
\def\endequation{$$\@ignoretrue}
%% figures
% counter
\newcounter{figcount}
% booleans (write section or subsection in equation number)
\newif\ifsectionsinfig
\newif\ifsubsectionsinfig
% width of figures
\newlength\figwidth
\setlength\figwidth\textwidth
\addtolength\figwidth{-2.5cm}
% caption
\def\defcaption{
\long\def\caption##1{
\stepcounter{figcount}
% hyperref anchor
\hrefanchor
% the number of the figure
\edef\figformat{\thefigcount}
% add subsection number
\ifsubsectionsinfig
\let\tmp\figformat
\edef\figformat{\thesubsectioncount.\tmp}
\fi
% add section number
\ifsectionsinfig
\let\tmp\figformat
\edef\figformat{\sectionprefix\thesectioncount.\tmp}
\fi
% define tag (for \label)
\xdef\tag{\figformat}
% write
\hfil fig \figformat: \parbox[t]{\figwidth}{\leavevmode\small##1}
% space
\par\bigskip
}
}
%% short caption: centered
\def\captionshort#1{
\stepcounter{figcount}
% hyperref anchor
\hrefanchor
% the number of the figure
\edef\figformat{\thefigcount}
% add section number
\ifsectionsinfig
\let\tmp\figformat
\edef\figformat{\sectionprefix\thesectioncount.\tmp}
\fi
% define tag (for \label)
\xdef\tag{\figformat}
% write
\hfil fig \figformat: {\small#1}
%space
\par\bigskip
}
%% environment
\def\figure{
\par
\vfil\penalty100\vfilneg
\bigskip
}
\def\endfigure{
\par
\bigskip
}
%% start appendices
\def\appendix{
\vfill
\pagebreak
% counter
\setcounter{sectioncount}0
% prefix
\def\sectionprefix{A}
% write
{\bf \LARGE Appendices}\par\penalty10000\bigskip\penalty10000
% add a mention in the table of contents
\iftoc
\immediate\write\tocoutput{\noexpand\tocappendices}\penalty10000
\fi
%% uncomment for new page for each appendix
%\def\seqskip{\vfill\pagebreak}
}
%% bibliography
% size of header
\newlength\bibheader
\def\thebibliography#1{
\hrefanchor
% add a mention in the table of contents
\iftoc
% save lncount in aux variable which is written to toc
\immediate\write\tocoutput{\noexpand\expandafter\noexpand\edef\noexpand\csname toc@references\endcsname{\thelncount}}
\write\tocoutput{\noexpand\tocreferences{\thepage}}\penalty10000
\fi
% write
{\bf \LARGE References}\par\penalty10000\bigskip\penalty10000
% width of header
\settowidth\bibheader{[#1]}
\leftskip\bibheader
}
% end environment
\def\endthebibliography{
\par\leftskip0pt
}
%% bibitem command
\def\bibitem[#1]#2{%
\hrefanchor%
\outdef{label@cite#2}{#1}%
\hskip-\bibheader%
\makebox[\bibheader]{\cite{#2}\hfill}%
}
%% cite command (adapted from latex.ltx)
% @tempswa is set to true when there is an optional argument
\newif\@tempswa
\def\cite{%
% check whether there is an optional argument (if there is none, add on empty '[]')
\@ifnextchar [{\@tempswatrue\@citex}{\@tempswafalse\@citex[]}%
}
% command with optional argument
\def\@citex[#1]#2{\leavevmode%
% initialize loop
\let\@citea\@empty%
% format
\@cite{%
% loop over ',' separated list
\@for\@citeb:=#2\do{%
% text to add at each iteration of the loop (separator between citations)
\@citea\def\@citea{,\ }%
% add entry to citelist
\@writecitation{\@citeb}%
\ref{cite\@citeb}%
}%
}%
% add optional argument text (as an argument to '\@cite')
{#1}%
}
\def\@cite#1#2{%
[#1\if@tempswa , #2\fi]%
}
%% add entry to citelist after checking it has not already been added
\def\@writecitation#1{%
\ifcsname if#1cited\endcsname%
\else%
\expandafter\newif\csname if#1cited\endcsname%
\immediate\write\@auxout{\string\citation{#1}}%
\fi%
}
%% table of contents
% boolean
\newif\iftoc
\def\tableofcontents{
{\bf \large Table of contents:}\par\penalty10000\bigskip\penalty10000
% copy content from file
\IfFileExists{\jobname.toc}{\input{\jobname.toc}}{{\tt error: table of contents missing}}
% open new toc
\newwrite\tocoutput
\immediate\openout\tocoutput=\jobname.toc
\toctrue
}
%% close file
\AtEndDocument{
% close toc
\iftoc
\immediate\closeout\tocoutput
\fi
}
%% fill line with dots
\def\leaderfill{\leaders\hbox to 1em {\hss. \hss}\hfill}
%% same as sectionprefix
\def\tocsectionprefix{}
%% toc formats
\newcounter{tocsectioncount}
\def\tocsection #1#2{
\stepcounter{tocsectioncount}
\setcounter{tocsubsectioncount}{0}
\setcounter{tocsubsubsectioncount}{0}
% write
\smallskip\hyperlink{ln.\csname toc@sec.\thetocsectioncount\endcsname}{{\bf \tocsectionprefix\thetocsectioncount}.\hskip5pt {\color{blue}#1}\leaderfill#2}\par
}
\newcounter{tocsubsectioncount}
\def\tocsubsection #1#2{
\stepcounter{tocsubsectioncount}
\setcounter{tocsubsubsectioncount}{0}
% write
{\hskip10pt\hyperlink{ln.\csname toc@subsec.\thetocsectioncount.\thetocsubsectioncount\endcsname}{{\bf \thetocsubsectioncount}.\hskip5pt {\color{blue}\small #1}\leaderfill#2}}\par
}
\newcounter{tocsubsubsectioncount}
\def\tocsubsubsection #1#2{
\stepcounter{tocsubsubsectioncount}
% write
{\hskip20pt\hyperlink{ln.\csname toc@subsubsec.\thetocsectioncount.\thetocsubsectioncount.\thetocsubsubsectioncount\endcsname}{{\bf \thetocsubsubsectioncount}.\hskip5pt {\color{blue}\small #1}\leaderfill#2}}\par
}
\def\tocappendices{
\medskip
\setcounter{tocsectioncount}0
{\bf Appendices}\par
\smallskip
\def\tocsectionprefix{A}
}
\def\tocreferences#1{
\medskip
{\hyperlink{ln.\csname toc@references\endcsname}{{\color{blue}\bf References}\leaderfill#1}}\par
\smallskip
}
%% definitions that must be loaded at begin document
\let\ian@olddocument\document
\def\document{
\ian@olddocument
\deflabel
\defcaption
}
%% end
\ian@defaultoptions
\endinput

162
libs/iantheo.sty Normal file
View File

@ -0,0 +1,162 @@
%%
%% iantheorem package:
%% Ian's customized theorem command
%%
%% boolean to signal that this package was loaded
\newif\ifiantheo
%% TeX format
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
%% package name
\ProvidesPackage{iantheo}[2016/11/10]
%% options
\newif\ifsectionintheo
\DeclareOption{section_in_theo}{\sectionintheotrue}
\DeclareOption{no_section_in_theo}{\sectionintheofalse}
\newif\ifsubsectionintheo
\DeclareOption{subsection_in_theo}{\subsectionintheotrue}
\DeclareOption{no_subsection_in_theo}{\subsectionintheofalse}
\def\iantheo@defaultoptions{
\ExecuteOptions{section_in_theo, no_subsection_in_theo}
\ProcessOptions
%%% reset at every new section
\ifsectionintheo
\let\iantheo@oldsection\section
\gdef\section{\setcounter{theocount}{0}\iantheo@oldsection}
\fi
%% reset at every new subsection
\ifsubsectionintheo
\let\iantheo@oldsubsection\subsection
\gdef\subsection{\setcounter{theocount}{0}\iantheo@oldsubsection}
\fi
}
%% delimiters
\def\delimtitle#1{
\par%
\leavevmode%
\raise.3em\hbox to\hsize{%
\lower0.3em\hbox{\vrule height0.3em}%
\hrulefill%
\ \lower.3em\hbox{#1}\ %
\hrulefill%
\lower0.3em\hbox{\vrule height0.3em}%
}%
\par\penalty10000%
}
%% callable by ref
\def\delimtitleref#1{
\par%
%
\ifdefined\ianclass%
% hyperref anchor%
\hrefanchor%
% define tag (for \label)%
\xdef\tag{#1}%
\fi%
%
\leavevmode%
\raise.3em\hbox to\hsize{%
\lower0.3em\hbox{\vrule height0.3em}%
\hrulefill%
\ \lower.3em\hbox{\bf #1}\ %
\hrulefill%
\lower0.3em\hbox{\vrule height0.3em}%
}%
\par\penalty10000%
}
%% no title
\def\delim{
\par%
\leavevmode\raise.3em\hbox to\hsize{%
\lower0.3em\hbox{\vrule height0.3em}%
\hrulefill%
\lower0.3em\hbox{\vrule height0.3em}%
}%
\par\penalty10000%
}
%% end delim
\def\enddelim{
\par\penalty10000%
\leavevmode%
\raise.3em\hbox to\hsize{%
\vrule height0.3em\hrulefill\vrule height0.3em%
}%
\par%
}
%% theorem
% counter
\newcounter{theocount}
% booleans (write section or subsection in equation number)
\def\theo#1{
\stepcounter{theocount}
\ifdefined\ianclass
% hyperref anchor
\hrefanchor
\fi
% the number
\def\formattheo{\thetheocount}
% add subsection number
\ifsubsectionintheo
\let\tmp\formattheo
\edef\formattheo{\thesubsectioncount.\tmp}
\fi
% add section number
\ifsectionintheo
\let\tmp\formattheo
\edef\formattheo{\sectionprefix\thesectioncount.\tmp}
\fi
% define tag (for \label)
\xdef\tag{\formattheo}
% write
\delimtitle{\bf #1 \formattheo}
}
\let\endtheo\enddelim
%% theorem headers with name
\def\theoname#1#2{
\theo{#1}\hfil({\it #2})\par\penalty10000\medskip%
}
%% qed symbol
\def\qedsymbol{$\square$}
\def\qed{\penalty10000\hfill\penalty10000\qedsymbol}
%% compatibility with article class
\ifdefined\ianclasstrue
\relax
\else
\def\thesectioncount{\thesection}
\def\thesubsectioncount{\thesubsection}
\def\sectionprefix{}
\fi
%% prevent page breaks after displayed equations
\newcount\prevpostdisplaypenalty
\def\nopagebreakaftereq{
\prevpostdisplaypenalty=\postdisplaypenalty
\postdisplaypenalty=10000
}
%% back to previous value
\def\restorepagebreakaftereq{
\postdisplaypenalty=\prevpostdisplaypenalty
}
%% end
\iantheo@defaultoptions
\endinput

19
libs/largearray.sty Normal file
View File

@ -0,0 +1,19 @@
%%
%% largearray package:
%% Array spanning the entire line
%%
%% TeX format
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
%% package name
\ProvidesPackage{largearray}[2016/11/10]
\RequirePackage{array}
%% array spanning the entire line
\newlength\largearray@width
\setlength\largearray@width\textwidth
\addtolength\largearray@width{-10pt}
\def\largearray{\begin{array}{@{}>{\displaystyle}l@{}}\hphantom{\hspace{\largearray@width}}\\[-.5cm]}
\def\endlargearray{\end{array}}

107
libs/point.sty Normal file
View File

@ -0,0 +1,107 @@
%%
%% Points package:
%% \point commands
%%
%% TeX format
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
%% package name
\ProvidesPackage{point}[2017/06/13]
%% options
\newif\ifresetatsection
\DeclareOption{reset_at_section}{\resetatsectiontrue}
\DeclareOption{no_reset_at_section}{\resetatsectionfalse}
\newif\ifresetatsubsection
\DeclareOption{reset_at_subsection}{\resetatsubsectiontrue}
\DeclareOption{no_reset_at_subsection}{\resetatsubsectionfalse}
\newif\ifresetattheo
\DeclareOption{reset_at_theo}{\resetattheotrue}
\DeclareOption{no_reset_at_theo}{\resetattheofalse}
\def\point@defaultoptions{
\ExecuteOptions{reset_at_section, reset_at_subsection, no_reset_at_theo}
\ProcessOptions
%% reset at every new section
\ifresetatsection
\let\point@oldsection\section
\gdef\section{\resetpointcounter\point@oldsection}
\fi
%% reset at every new subsection
\ifresetatsubsection
\let\point@oldsubsection\subsection
\gdef\subsection{\resetpointcounter\point@oldsubsection}
\fi
%% reset at every new theorem
\ifresetattheo
\ifdefined\iantheotrue
\let\point@oldtheo\theo
\gdef\theo{\resetpointcounter\point@oldtheo}
\fi
\fi
}
%% point
% counter
\newcounter{pointcount}
\def\point{
\stepcounter{pointcount}
\setcounter{subpointcount}{0}
% hyperref anchor (only if the class is 'ian')
\ifdefined\ifianclass
\hrefanchor
% define tag (for \label)
\xdef\tag{\arabic{pointcount}}
\fi
% header
\indent{\bf \arabic{pointcount}\ - }
}
%% subpoint
% counter
\newcounter{subpointcount}
\def\subpoint{
\stepcounter{subpointcount}
\setcounter{subsubpointcount}0
% hyperref anchor (only if the class is 'ian')
\ifdefined\ifianclass
\hrefanchor
% define tag (for \label)
\xdef\tag{\arabic{pointcount}-\arabic{subpointcount}}
\fi
% header
\indent\hskip.5cm{\bf \arabic{pointcount}-\arabic{subpointcount}\ - }
}
%% subsubpoint
% counter
\newcounter{subsubpointcount}
\def\subsubpoint{
\stepcounter{subsubpointcount}
% hyperref anchor (only if the class is 'ian')
\ifdefined\ifianclass
\hrefanchor
% define tag (for \label)
\xdef\tag{\arabic{pointcount}-\arabic{subpointcount}-\arabic{subsubpointcount}}
\fi
\indent\hskip1cm{\bf
\arabic{pointcount}-\arabic{subpointcount}-\arabic{subsubpointcount}\ - }
}
%% reset point counters
\def\resetpointcounter{
\setcounter{pointcount}{0}
\setcounter{subpointcount}{0}
\setcounter{subsubpointcount}{0}
}
%% end
\point@defaultoptions
\endinput