Dice Wars game

Dicewars A simplified version of game DiceWars between two players goes such that each player is assigned a stack of 6-sided dice which equate to relative power. On a player’s turn, the player challenges other player. The challenge is resolved when each player rolls their dice, with the higher total winning. Each player roll all of their dices and the value at the top of each dice is added to find the players score. Whoever has the higher score wins and the equal score is a tie. The goal is to find the probability that, in a game between two players with $m$ and $k$ dice respectively, any player wins over the other or there is a tie. ...

April 16, 2020

A sample plot with legend

A sample diagram with custom defined function that also has legend. \begin{tikzpicture}[ declare function={ gamma(\z) = (2.50*sqrt(1/\z)+0.20*(1/\z)^(1.5)+ 0.00*(1/\z)^(2.5)-(174.21*(1/\z)^(3.5))/25920- (715.64*(1/\z)^(4.5))/1244160)*exp((-ln(1/\z)-1)*\z); }, declare function={ gammapdf(\x,\a,\b) = (\b^\a)*\x^(\a-1)*exp(-\b*\x)/gamma(\a); }] \begin{axis}[ width=9cm, height=6cm, samples=40, no marks, smooth, xlabel=$x$, ylabel=$f(x)$, xlabel style={at={(1,0)}, anchor=north west}, ylabel style={at={(0,1)}, anchor=south east}, legend style={draw=none, fill=none}, domain=0:22] \addplot[black] {gammapdf(x,3,1)}; \addlegendentry{$\alpha=3, \beta=1$} \addplot[blue] {gammapdf(x,8,1)}; \addlegendentry{$\alpha=8, \beta=1$} \addplot[red] {gammapdf(x,8,2)}; \addlegendentry{$\alpha=8, \beta=2$} \node[anchor=east] at (axis description cs: 1, 0.5) {$f(x) = \dfrac{\beta^{\alpha}}{\Gamma(\alpha)}\cdot x^{\alpha-1} \cdot \text{e}^{-\beta x}$}; \end{axis} \end{tikzpicture}

February 15, 2018

Complex integration path diagram.

This diagram was made for my homework of Mathematical Physics at Drexel University during my Masters education The homework assignment can be found here at http://physics.drexel.edu/~pgautam/courses/ \begin{tikzpicture} [ %decoration={ % markings, % mark=at position 1cm with {\arrow[line width=1pt]{>}}, % mark=at position .3 with {\arrow[line width=1pt]{>}}, % mark=at position .6 with {\arrow[line width=1pt]{>}}, % mark=at position 0.8 with {\arrow[line width=1pt]{>}}, % mark=at position -5mm with {\arrow[line width=1pt]{>}}, %}, on each segment/.style={ decorate, decoration={ show path construction, moveto code={}, lineto code={ \path [#1] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast); }, curveto code={ \path [#1] (\tikzinputsegmentfirst) .. controls (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb) .. (\tikzinputsegmentlast); }, closepath code={ \path [#1] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast); }, }, }, mid arrow/.style={ postaction={decorate, decoration={ markings, mark=at position .5 with {\arrow[#1]{stealth}} } } }, contourline/.style={line width=1.0pt}, axisline/.style={->,line width=0.3pt}, ] \tikzmath{\R=3;\r=0.5;\X=1.1*\R;\Y=1.1*\R;} \draw [axisline] (-\X,0) -- (\X,0) node [below right] {Re($z$)}; \draw [axisline] (0,1.2*\r) -- (0,-\Y) node[left] {Im($z$)}; \node at (0,0) {$\times$}; %\draw [contourline, postaction=decorate] \draw [contourline, postaction=={on each segment={mid arrow=red}}] (\r,0) node [below, font=\scriptsize] {$\epsilon$} -- (\R,0) node [above] {$R$} arc (0:-180:\R) node [above] {$-R$} -- (-\r,0) node [below, font=\scriptsize] {$-\epsilon$} arc (180:0:\r); \node at (\r,1.1*\r) {$\Gamma_{\varepsilon}$}; \node at (1.15*\R*0.7,-1.15*\R*0.7) {$\Gamma_{R}$}; % 0.7 = sin(45) = cos(45) \end{tikzpicture}

February 15, 2018

Complex integration path diagram.

This diagram was made for my homework of Mathematical Physics at Drexel University during my Masters education The homework assignment can be found here at http://physics.drexel.edu/~pgautam/courses/ \begin{tikzpicture} [ decoration={ markings, mark=at position 0.10 with {\arrow[line width=1pt]{>}}, mark=at position 0.20 with {\arrow[line width=1pt]{>}}, mark=at position 0.30 with {\arrow[line width=1pt]{>}}, mark=at position 0.50 with {\arrow[line width=1pt]{>}}, mark=at position 0.70 with {\arrow[line width=1pt]{>}}, mark=at position 0.80 with {\arrow[line width=1pt]{>}}, mark=at position 0.90 with {\arrow[line width=1pt]{>}}, }, axes/.style={line width=0.1pt,->,opacity=.6, text opacity=1}, small/.style={font=\scriptsize} ] \tikzmath{\R=4;\r=0.7;}% Change these values to see the magic \draw [axes] (-\R*1.1,0) -- (\R*1.2,0) coordinate (xaxis) node [below] {Re$(z)$}; \draw [axes] (0,-0.1*\R) -- (0,\R*1.1) coordinate (yaxis) node [left] {Im$(z)$}; \node at (-0.5*\R,0) {$\times$}; \node at(-0.5*\R,0) [above] {$-\sigma$}; \node at (0.5*\R,0) {$\times$}; \node at (0.5*\R,0) [above] {$\sigma$}; \path [draw, line width=1.0pt, postaction=decorate] (0,0) -- (0.5*\R-\r,0) node [below,small]{$\sigma-\epsilon$} arc (180:0:\r) node [below,small]{$\sigma+\epsilon$} -- (\R,0) node [below] {$R$} arc (0:180:\R) node [below] {$-R$} -- (-0.5*\R-\r,0) node [below,small] {$-\sigma-\epsilon$} arc (180:0:\r) node [below,small] {$-\sigma + \epsilon$}-- cycle; \node at (0.5*\R,1.3*\r) {$\Gamma_{\varepsilon}$}; \node at (0.5*\R,0.8*\R) {$\Gamma_{R}$}; \end{tikzpicture}

February 15, 2018

Complex integration path diagram.

This diagram was made for my homework of Mathematical Physics at Drexel University during my Masters education The homework assignment can be found here at http://physics.drexel.edu/~pgautam/courses/ \begin{tikzpicture} [ decoration={% markings, mark=at position 1cm with {\arrow[line width=1pt]{>}}, %mark=at position 2cm with {\arrow[line width=1pt]{>}}, mark=at position .3 with {\arrow[line width=1pt]{>}}, mark=at position .6 with {\arrow[line width=1pt]{>}}, mark=at position 0.8 with {\arrow[line width=1pt]{>}}, mark=at position -5mm with {\arrow[line width=1pt]{>}}, }, contourline/.style={line width=1.0pt}, axisline/.style={->,line width=0.3pt}, ] \draw [axisline] (-4,0) -- (4,0) coordinate (xaxis) node [below,thick] {Re($z$)}; \draw [axisline] (0,-0.6) -- (0,3.3) coordinate (yaxis) node [left,thick] {Im($z$)}; \node at (0,0) {$\times$}; \draw [contourline, postaction=decorate] (.5,0) node [below, font=\scriptsize] {$\epsilon$} -- (3,0) node [below] {$R$} arc (0:180:3) node [below] {$-R$} -- (-.5,0) node [below, font=\scriptsize] {$-\epsilon$} arc (180:0:.5); \node at (0.5,0.6) {$\Gamma_{\varepsilon}$}; \node at (2,2.6) {$\Gamma_{R}$}; \end{tikzpicture}

February 15, 2018

Two sine plot

A pgf diagram using custom function to plot with different parameters. \begin{tikzpicture}[ declare function = { seen(\x) = 2*sin(deg(2*\x)); }, mythick/.style={thick,blue} ] \begin{axis}[ width=8cm,height=6cm, samples=30, smooth, domain=0:8, legend style={anchor=north east} ] \addplot[red] {seen(x)}; \addlegendentry{$\omega=1$} \addplot[mythick] {seen(.5*x)}; \addlegendentry{$\omega=.5$} \end{axis} \end{tikzpicture}

February 15, 2018

Spherical Pendulum Basic Solution

Setup first lets setup up some imports import numpy as np import sympy as smp import matplotlib.pyplot as plt plt.rcParams['figure.figsize'] = (16.0, 6.0) smp.init_printing() from sympy.physics import mechanics as mcx #mcx.init_vprinting() mcx.mechanics_printing() #smp.init_printing() Goldstein 1.19 Solve spherical pendulum by lagrangian. t = smp.Symbol('t') g = smp.symbols('g',constant=True); #accleration due to gravity m = smp.symbols('m',real=True,positive=True,constant=True) theta,phi= mcx.dynamicsymbols('theta,phi'); r = smp.symbols('r',constant=True) rdt = smp.diff(r); thd = smp.diff(theta); phd = smp.diff(phi) x = r*smp.sin(theta)*smp.cos(phi); xdt = smp.diff(x,t) y = r*smp.sin(theta)*smp.sin(phi); ydt = smp.diff(y,t) z = r*smp.cos(theta); zdt = smp.diff(z,t); ydt $$r \operatorname{sin}\left(\phi\right) \operatorname{cos}\left(\theta\right) \dot{\theta} + r \operatorname{sin}\left(\theta\right) \operatorname{cos}\left(\phi\right) \dot{\phi}$$V = m*g*r*smp.cos(phi) T = smp.Rational(1,2)*m*(xdt**2+ydt**2+zdt**2); T; smp.simplify(T) $$\frac{m r^{2}}{2} \left(\operatorname{sin}^{2}\left(\theta\right) \dot{\phi}^{2} + \dot{\theta}^{2}\right)$$So the total kinetic energy of the spherical pendulum is ...

December 24, 2017 · Prakash

Discrete Fourier transform of Gaussian function

Introduction This a a direct export from a jupyter notebook that I had for the study of discrete Fourier transfrom of Gaussian function. import numpy as np import sympy as smp from sympy.utilities import lambdify import matplotlib.pyplot as plt plt.style.use(['dark_mode','slide_mode']) import warnings warnings.filterwarnings('ignore') def vsplt(x1,y1,x2,y2): fig,ax = plt.subplots(1,2,figsize=(12,6)) ax[0].plot(x1,y1) ax[1].plot(x2,y2) def vstem(x1,y1,x2,y2): fig,ax = plt.subplots(1,2,figsize=(12,6)) ax[0].stem(x1,y1) ax[1].stem(x2,y2) mu,sigma = smp.symbols('mu,sigma',real=True,positive=True) x = smp.symbols('x',real=True) w = smp.symbols('omega',real=True) I am trying to analyze the discrete fourier transform of gaussian function. I define a gaussian function first. ...

December 12, 2017 · Prakash