2020/03/31

円錐曲線(conic curve)の書き方

円錐曲線とは


出典: フリー百科事典『ウィキペディア(Wikipedia)

 円錐曲線(えんすいきょくせん、conic curve, conic section; 円錐断面)とは、円錐面を任意の平面で切断したときの断面としてえられる曲線群の総称である。


数式表現




\[ \begin{eqnarray} \left\{ \begin{array}{l} x = a \cos t \\ y = a \sin t \end{array} \right. \end{eqnarray} \tag{1} \label{1} \]

楕円


\[ \begin{eqnarray} \left\{ \begin{array}{l} x = a \cos t \\ y = b \sin t \end{array} \right. \end{eqnarray} \tag{2} \label{2} \]

放物線


\[ \displaystyle y = ax^2 + bx + c \tag{3} \label{3} \]

双曲線


\[ \begin{eqnarray} \left\{ \begin{array}{l} x = \pm a \cosh t \\ y = b \sinh t \end{array} \right. \end{eqnarray} \tag{4} \label{4} \]

書き方


 R言語での書き方は以下のとおり。



 条件: \(a=1\) の時

t=seq(0, 2*pi, length=180)
a=1
x=a*cos(t)
y=a*sin(t)
svg("archimedes.svg", width=5, height=5)
plot(x, y, type="l", asp=1, lwd=2, col=2)
abline(h=0)
abline(v=0)
dev.off()

楕円


 条件: \(a=3, b=2\) の時

t=seq(0, 2*pi, length=180)
a=3
b=2
x=a*cos(t)
y=b*sin(t)
svg("ellipse.svg", width=5, height=5)
plot(x, y, type="l", asp=1, lwd=2, col=2)
abline(h=0)
abline(v=0)
dev.off()

放物線


 条件: \(a=1, b=0, c=0\) の時

a=1
b=0
c=0
svg("parabola.svg", width=5, height=5)
curve(a*x^2+b*x+c, -2, 2, asp=1, lwd=2, col=2)
abline(h=0)
abline(v=0)
dev.off()

双曲線


 条件: \(a=1, b=1\) の時

a=1, b=1のとき
t=seq(-pi, pi, length=300)
a=b=1
x=a*cosh(t)
y=b*sinh(t)
svg("hyperbola.svg", width=5, height=5)
plot( x, y, type="l", asp=1, lwd=2, col=2, xlim=c(-15,15), ylim=c(-15,15), ann=F)
par(new=T)
plot(-x, y, type="l", asp=1, lwd=2, col=2, xlim=c(-15,15), ylim=c(-15,15))
abline(h=0)
abline(v=0)
dev.off()

2020/03/30

トラクトリックス(tractrix)の書き方

トラクトリックスとは


出典: フリー百科事典『ウィキペディア(Wikipedia)

 トラクトリックス (tractrix) は直交座標の方程式 \eqref{1} によって表される曲線である。


数式表現


\[ \begin{eqnarray} \displaystyle x &=& \log \frac{a \pm \sqrt {a^2 - y^2}}{y} \mp \sqrt {a^2 - y^2} \\ \displaystyle &=& a \cosh^{-1} (\frac{a}{y}) \mp \sqrt {a^2 - y^2} \tag{1} \label{1} \end{eqnarray} \]

書き方


 R言語での書き方は以下のとおり。

 条件: \(a=1\) の時

y=seq(0, 1, length=300)
a=1
x1=a*log((a+sqrt(a^2-y^2))/y)-sqrt(a^2-y^2)
x2=a*log((a-sqrt(a^2-y^2))/y)+sqrt(a^2-y^2)
svg("tractrix.svg", width=5, height=5)
plot(x1, y, type="l", asp=1, lwd=2, col=2, xlim=c(-2, 2), ylim=c(-2, 2), ann=F)
par(new=T)
plot(x2, y, type="l", asp=1, lwd=2, col=2, xlim=c(-2, 2), ylim=c(-2, 2), xlab="", ylab="")
abline(h=0)
abline(v=0)
dev.off()

【備忘録】時系列データの編集方法(R言語, tidyverse)

TimeSeries.knit 1 サンプルデータ作成 2 日付単位に集計する 2.1 月毎集計 2.2 四半期毎集計 ...