draw2d()
編
draw2d()
は,関数の分母がゼロになったりしても文句を言わずにグラフを描く。
べき関数
$y = x^{-2}, \ x^{-1}, \ x^2, \ x^3$ のグラフ例。
draw2d(
line_width = 2,
color = 1, key = "x^{-2}",
explicit(x**(-2), x, -5, 5),
color = 2, key = "x^{-1}",
explicit(x**(-1), x, -5, 5),
color = 3, key = "x^{2}",
explicit(x**2, x, -5, 5),
color = 4, key = "x^{3}",
explicit(x**3, x, -5, 5),
xrange = [-5, 5], yrange = [-5, 5],
xtics = 1, ytics = 1, xaxis = true, yaxis = true,
grid = true
)$
$\displaystyle y = \sqrt{x}, \ \frac{1}{\sqrt{x}}$ のグラフ例。
draw2d(
line_width = 2,
color = 1, key = "x^{1/2}",
explicit(sqrt(x), x, 0, 5),
color = 2, key = "x^{-1/2}",
explicit(1/sqrt(x), x, 0, 5),
xrange = [0, 5], yrange = [0, 5],
xtics = 1, ytics = 1, xaxis = true, yaxis = true,
grid = true
)$
指数関数
$y = e^{-x}, \ e^x$ のグラフ例。
draw2d(
line_width = 2,
color = 1, key = "e^{-x}",
explicit(exp(-x), x, -5, 5),
color = 2, key = "e^{x}",
explicit(exp(x), x, -5, 5),
xrange = [-5, 5], yrange = [-0.1, 5],
xtics = 1, ytics = 1, xaxis = true, yaxis = true,
grid = true
)$
三角関数
$ y = \sin x, \ \cos x, \ \tan x $ のグラフ例。
draw2d(
line_width = 2,
color = 1, key = "sin x",
explicit(sin(x), x, -2*%pi, 2*%pi),
color = 2, key = "cos x",
explicit(cos(x), x, -2*%pi, 2*%pi),
color = 3, key = "tan x",
explicit(tan(x), x, -2*%pi, 2*%pi),
xrange = [-2*%pi, 2*%pi], yrange = [-3, 3],
xtics = %pi/2, ytics = 1, xaxis = true, yaxis = true,
grid = true,
user_preamble = "set format x '%3.1P π'; set key sample 0.5;"
)$
逆三角関数
$y = \sin^{-1} x = \arcsin x =$ asin(x)
の定義域は $-1 \leq x \leq 1$
$y = \cos^{-1} x = \arccos x =$ acos(x)
の定義域は $-1 \leq x \leq 1$
$y = \tan^{-1} x = \arctan x =$ atan(x)
の定義域は $-\infty < x < \infty$
draw2d(
line_width = 2,
color = 1, key = "sin^{-1} x",
explicit(asin(x), x, -1, 1),
color = 2, key = "cos^{-1} x",
explicit(acos(x), x, -1, 1),
xrange = [-1, 1], yrange = [-%pi/2, %pi],
xtics = 0.5, ytics = %pi/4, xaxis = true, yaxis = true,
grid = true,
user_preamble = "set format y '%4.2P π'; set key sample 1;"
)$
draw2d(
line_width = 2,
key = "tan^{-1} x",
explicit(atan(x), x, -10, 10),
xrange = [-10, 10], yrange = [-%pi/2, %pi/2],
xtics = 2, ytics = %pi/4, xaxis = true, yaxis = true,
grid = true,
user_preamble = "set format y '%4.2P π'; set key top left;"
)$
双曲線関数
$y = \sinh x, \ \cosh x, \ \tanh x$ のグラフ例。
draw2d(
line_width = 2,
color = 1, key = "sinh x",
explicit(sinh(x), x, -4, 4),
color = 2, key = "cosh x",
explicit(cosh(x), x, -4, 4),
xrange = [-4, 4], yrange = [-30, 30],
xtics = 1, ytics = 10, xaxis = true, yaxis = true,
grid = true,
user_preamble = "set key top left;"
)$
draw2d(
line_width = 2,
key = "tanh x",
explicit(tanh(x), x, -5, 5),
xrange = [-5, 5], yrange = [-1, 1],
xtics = 1, ytics = 0.2, xaxis = true, yaxis = true,
grid = true,
user_preamble = "set key top left;"
)$
逆双曲線関数
$ y = \sinh^{-1} x = \mbox{arsinh}\ x = $ asinh(x)
$= \log\left(x+\sqrt{x^2+1}\right)$
$ y = \cosh^{-1} x = \mbox{arcosh}\ x = $ acosh(x)
$= \log\left(x+\sqrt{x^2-1}\right)$
$ y = \tanh^{-1} x = \mbox{artanh}\ x = $ atanh(x)
$\displaystyle = \frac{1}{2} \log\left(\frac{1+x}{1-x}\right)$
draw2d(
line_width = 2,
key = "sinh^{-1} x",
explicit(asinh(x), x, -5, 5),
xrange = [-5, 5], yrange = [-3, 3],
xtics = 1, ytics = 1, xaxis = true, yaxis = true,
grid = true,
user_preamble = "set key top left;"
)$
draw2d(
line_width = 2,
key = "cosh^{-1} x",
explicit(acosh(x), x, 1, 5),
xrange = [1, 5], yrange = [0, 3],
xtics = 1, ytics = 1, xaxis = true, yaxis = true,
grid = true,
user_preamble = "set key top left;"
)$
draw2d(
line_width = 2,
key = "tanh^{-1} x",
explicit(atanh(x), x, 0, 1),
xrange = [0, 1], yrange = [0, 3],
xtics = auto, ytics = 1, xaxis = true, yaxis = true,
grid = true,
user_preamble = "set key top left;"
)$
plot2d()
編
plot2d()
は,関数の分母がゼロになったりすると文句を言いながらグラフを描く。
べき関数
$y = x^{-2}, \ x^{-1}, \ x^2, \ x^3$ のグラフ例。
plot2d(
[x**(-2), x**(-1), x**2, x**3], [x, -5, 5],
[style, [lines, 2], [lines, 2], [lines, 2], [lines, 2]],
[y, -5, 5], grid2d, [xtics, 1], [ytics, 1]
)$
$\displaystyle y = \sqrt{x}, \ \frac{1}{\sqrt{x}}$ のグラフ例。
plot2d(
[sqrt(x), 1/sqrt(x)], [x, 0, 5],
[style, [lines, 2], [lines, 2]],
[y, 0, 5], grid2d, [xtics, 1], [ytics, 1]
)$
指数関数
$y = e^{-x}, \ e^x$ のグラフ例。
plot2d(
[exp(-x), exp(x)], [x, -5, 5],
[style, [lines, 2], [lines, 2]],
[legend, "exp(-x)", "exp(x)"],
[y, -0.1, 5], grid2d, [xtics, 1], [ytics, 1]
)$
三角関数
$ y = \sin x, \ \cos x, \ \tan x $ のグラフ例。
plot2d(
[sin(x), cos(x), tan(x)], [x, -2*%pi, 2*%pi],
[style, [lines, 2], [lines, 2], [lines, 2]],
[legend, "sin x", "cos x", "tan x"],
[y, -3, 3], grid2d, [xtics, %pi/2], [ytics, 1],
[gnuplot_preamble, "set format x '%3.1P π';set key sample 0.2;"]
)$
逆三角関数
$y = \sin^{-1} x = \arcsin x =$ asin(x)
の定義域は $-1 \leq x \leq 1$
$y = \cos^{-1} x = \arccos x =$ acos(x)
の定義域は $-1 \leq x \leq 1$
$y = \tan^{-1} x = \arctan x =$ atan(x)
の定義域は $-\infty < x < \infty$
plot2d(
[asin(x), acos(x)], [x, -1, 1],
[style, [lines, 2], [lines, 2]],
[legend, "arcsin x", "arccos x"],
[y, -%pi/2, %pi], grid2d, [xtics, 0.5], [ytics, %pi/4],
[gnuplot_preamble, "set format y '%4.2P π';"]
)$
plot2d(
atan(x), [x, -10, 10],
[style, [lines, 2]],
[legend, "arctan x"],
[y, -%pi/2, %pi/2], grid2d, [xtics, 2], [ytics, %pi/4],
[gnuplot_preamble, "set format y '%4.2P π';set key top left;"]
)$
双曲線関数
$y = \sinh x, \ \cosh x, \ \tanh x$ のグラフ例。
plot2d(
[sinh(x), cosh(x)], [x, -4, 4],
[style, [lines, 2], [lines, 2]],
[y, -30, 30], grid2d, [xtics, 1], [ytics, 10],
[gnuplot_preamble, "set key top left;"]
)$
plot2d(
tanh(x), [x, -5, 5],
[style, [lines, 2]],
[y, -1, 1], grid2d, [xtics, 1], [ytics, 0.2],
[gnuplot_preamble, "set key top left;"]
)$
逆双曲線関数
$ y = \sinh^{-1} x = \mbox{arsinh}\ x = $ asinh(x)
$= \log\left(x+\sqrt{x^2+1}\right)$
$ y = \cosh^{-1} x = \mbox{arcosh}\ x = $ acosh(x)
$= \log\left(x+\sqrt{x^2-1}\right)$
$ y = \tanh^{-1} x = \mbox{artanh}\ x = $ atanh(x)
$\displaystyle = \frac{1}{2} \log\left(\frac{1+x}{1-x}\right)$
plot2d(
asinh(x), [x, -5, 5],
[style, [lines, 2]],
[y, -3, 3], grid2d, [xtics, 1], [ytics, 1],
[gnuplot_preamble, "set key top left;"]
)$
plot2d(
acosh(x), [x, 1, 5],
[style, [lines, 2]],
[y, 0, 3], grid2d, [xtics, 1], [ytics, 1],
[gnuplot_preamble, "set key top left;"]
)$
plot2d(
atanh(x), [x, 0, 1],
[style, [lines, 2]],
[y, 0, 3], grid2d, [xtics, 0.2], [ytics, 1],
[gnuplot_preamble, "set key top left;"]
)$