« home

Divergence

mathcetztikz

Plot of ln(1z)-\ln(1-z) which diverges at z=1z = 1.


Divergence

  Download

PNGPDFSVG

  Code

  LaTeX

divergence.tex (21 lines)

\documentclass{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[
      xlabel = $z$,
      smooth,thick,
      axis lines = center,
      every tick/.style = {thick},
      legend pos=north west]

    \addplot[color=blue,domain=0:1.1,samples=150]{-ln(1-x)};
    \legend{$-\ln(1 - z)$}

  \end{axis}
\end{tikzpicture}
\end{document}

  Typst

divergence.typ (34 lines)

#import "@preview/cetz:0.3.4": canvas, draw
#import "@preview/cetz-plot:0.1.1": plot

#set page(width: auto, height: auto, margin: 8pt)

#canvas({
  draw.set-style(
    axes: (
      y: (mark: (end: "stealth", fill: black, scale: 0.5)),
      x: (mark: (end: "stealth", fill: black, scale: 0.5)),
    ),
  )

  plot.plot(
    size: (8, 5),
    x-label: $z$,
    x-max: 1.1,
    x-tick-step: 0.5,
    y-tick-step: 2,
    axis-style: "left",
    legend: "inner-north-west",
    legend-style: (item: (spacing: 0.2), padding: 0.15, stroke: .5pt),
    {
      plot.add(
        style: (stroke: blue + 1.5pt),
        domain: (0, 0.999), // avoid x=1 since ln(0) is undefined
        samples: 150,
        label: $-ln(1-z)$,
        x => -calc.ln(1 - x),
      )
    },
  )
})