Posts

  • How to create a Slideshow with CSS and JavaScript

  • Automatic Slideshow Change image every 2 seconds: 1 / 3 Sea 2 / 3 Sunshine 3 / 3 Text Create A Slideshow Step 1) Add HTML: Example <div class="slideshow-container">   <div class="mySlides fade">     <div class="numbertext">1 / 3</div>     <img src="img1.jpg" style="width:100%">     <div class="text">Caption Text</div>   </div>   <div class="mySlides fade">     <div class="numbertext">2 / 3</div>     <img src="img2.jpg" style="width:100%">     <div class="text">Caption Two</div>   </div>   <div class="mySlides fade">     <div class="numbertext">3 / 3</div>     <img src="img3.jpg" style="width:100%">     <div class="text">Caption Three</div>   </div>   <a class="prev" onclick="plusSlides(-1)">&#10094;</a>   <a class="next" onclick="plusSlides(1)">&#10095;</a> </div> <br> <div style="text-align:center">   <span...
  • How to change the font size on a matplotlib plot

  • For example, like this import matplotlib matplotlib.rc('xtick', labelsize=20) matplotlib.rc('ytick', labelsize=20) From the matplotlib documentation font = {'family' : 'normal', 'weight' : 'bold', 'size' : 22} matplotlib.rc('font', **font) This sets the font of all items to the font specified by the kwargs object, font. Alternatively, you could also use the rcParams and update method as suggested in this answer: matplotlib.rcParams.update({'font.size': 22}) You can find a full list of available properties on the Customizing matplotlib page. If you want to change the fontsize for just a specific plot that has already been created, try this: import matplotlib.pyplot as plt ax = plt.subplot(111,...
  • Print map while using lambda in Python 3

  • Since lambda x: print(x) is a syntax error in Python < 3, I’m assuming Python 3. That means map returns a generator, meaning to get map to actually call the function on every element of a list, you need to iterate through the resultant generator. Fortunately, this can be done easily: list(map(lambda x:print(x),primes)) Oh, and you can get rid of the lambda too, if you like: list(map(print,primes)) But, at that point you are better off with letting print handle it: print(*primes, sep='\n') NOTE: I said earlier that '\n'.join would be a good idea. That is only true for a list...
  • How to Solve Gamma Function

  • I. Theoretical Analysis Gamma Function is defined in the following, \[\Gamma(n) = \int_{0}^{\infty} \mathrm{e}^{-x}x^{n-1}\mathrm{d}x.\] Using integration by parts, one sees that: \[\Gamma(n) = -[\mathrm{e}^{-x}x^{n-1}]_0^{\infty} + (n-1)\int_{0}^{\infty} \mathrm{e}^{-x}x^{n-2}\mathrm{d}x = (n-1)\Gamma(n-1).\] From the above calculation,and note that \[\Gamma(1) = \int_{0}^{\infty} \mathrm{e}^{-x}\mathrm{d}x = 1\\ \Gamma(1/2) = \int_{0}^{\infty} \mathrm{e}^{-x}x^{-1/2}\mathrm{d}x = 2\int_{0}^{\infty} \mathrm{e}^{-y^2}\mathrm{d}y = \sqrt{\pi},\] where \(y^2 = x\). If \(n\) is a positive integer, one can obtain: \[\Gamma(n) = (n-1)(n-2)\cdots 1 \cdot \Gamma(1) = (n-1)!,\] \[\Gamma(n+\frac{1}{2}) = (n-\frac{1}{2})(n-\frac{3}{2})\cdots\frac{1}{2}\Gamma(\frac{1}{2})= (n-\frac{1}{2})(n-\frac{3}{2})\cdots\frac{1}{2}\sqrt{\pi}.\] Appendix: Integral calculus(\(y\equiv \sqrt{a}[x+(b/2a)]\)) \[\int_{-\infty}^{+\infty}\mathrm{e}^{-(ax^2+bx)}\mathrm{d}x = \int_{-\infty}^{+\infty}\mathrm{e}^{-y^2 + (b^2/4a)}\frac{1}{\sqrt{a}}\mathrm{d}y = \frac{1}{\sqrt{a}}\mathrm{e}^{b^2/4a}\int_{-\infty}^{+\infty}\mathrm{e}^{-y^2}\mathrm{d}y = \boxed{\sqrt{\frac{\pi}{a}}\mathrm{e}^{b^2/4a}}.\] If it meets a condition \(e^{-x^2} > 0\), obviously given that, \[I...
  • How to Support \(LaTeX{}\) in GitHub-Pages

  • Schrödinger Equation (Math Equation as an example) \[\mathrm{i}\hbar\frac{\partial \psi}{\partial t} = -\frac{\hbar^2}{2m}\nabla^2 \psi + V\psi\] Note: Original text from stackoverflow page. Since resources online have changed regarding this question, here’s an update on supporting \(LaTeX{}\) with Github Pages. Note that the closest to Latex rendering without exporting as images and natively supporting it on your Jekyll site would be to use MathJax. MathJax is actually recommended in Jekyllrb docs for math support, with Kramdown, it also converts it from LaTeX to PNG, more details on it here at the Kramdown documentation. Option 1: Write your equation in MathURL and embed...