作図:draw メモ
~/bin/go TMP/tmp_lang/chunk-2.mxl > TMP/tmp_lang/chunk-2.out 2>&1
batch("/var/www/html/LANG/TMP/tmp_lang/chunk-2.mxl")
read and interpret /var/www/html/LANG/TMP/tmp_lang/chunk-2.mxl
display2d:false
" /* F(x) = erf(x) の場合 */ "
define(F(x),erf(x))
define(f(x),diff(F(x),x))
Maxima encountered a Lisp error:
Condition in MACSYMA-TOP-LEVEL [or a callee]: INTERNAL-SIMPLE-UNDEFINED-FUNCTION: Cell error on ^RULE1: Undefined function:
Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.
c0show(f(x))
f(x) = f(x)
g01:gr2d(key = "f(x)",explicit(f(x),x,-4,4),grid = true,title = "f(x)=dF(x)/dx")
g02:gr2d(key = "F(x)",explicit(F(x),x,-4,4),grid = true,title = "F(x)=erf(x)")
draw(g01,g02,columns = 2,dimensions = [800,300],'terminal = 'png,
'file_name = "figs/fig11-3")
draw2d (explicit): non defined variable in term: 'realpart(f(-3.7241379))
-- an error. To debug this try: debugmode(true);
"/var/www/html/LANG/TMP/tmp_lang/chunk-2.mxl"
Graph of erf(x) 誤差関数
Graph of Phi(x)
標準正規分布の分布関数
作図:draw
"draw"|"DRAW")
echo "
******* Maxima (数式電卓): draw **********
draw2d(color=blue, key="sin(x), yrange=[-0.1, 1.1], explicit(sin(x)/x,x,-10,10));
draw2d(xrange=[-20,20],explicit(sin(x)/x,x,-10,10));
(%i4) neko:explicit(sin(x)/x,x,-10,10); sin(x)
(%i5) X1:xrange=[-20,20];
(%i6) Y1:yrange=[-0.5,1.5];
(%i7) draw2d(X1,neko,Y1);
(%i28) nekoneko:points([1,2,3],[1,2,3]);
(%o28) points([1, 2, 3], [1, 2, 3]);
(%i29) draw2d(xrange=[-1,6], yrange=[-1,6], nekoneko, point_size=3,
point_type=diamant, points_joined=true, line_type=dots,
color=red, nekoneko);
(%o29) [gr2d(points, points)]
draw函数とdraw2d函数,draw3d函数との関係
draw2d(対象1, ... , 対象n) draw3d(対象1, ... ,対象n)
⇒ ⇒ draw(gr2d(対象1, ... , 対象n)) draw(gr3d(対象1, ... , 対象n))
(%i7) draw(gr2d(explicit(sin(x),x,-10,10)), gr2d(explicit(x^2+1,x,-2,2)));
(%i15) draw(columns=1,gr2d(explicit(sin(x),x,-10,10)),
gr3d(explicit(x*y,x,-2,2,y,-2,2)),
(%i16) draw(columns=3,gr2d(explicit(sin(x),x,-10,10)),
gr3d(explicit(x*y,x,-2,2,y,-2,2)),
gr2d(explicit(x^2-x+1,x,-2,2)));
===============================================================================
◎ drawの大域的属性
columns=1 terminal={eps|wxt|png} pic width=640 pic height=480
eps_width=12 eps_height=8 file_name=\"maxima_out\"
◎ グラフ枠に関連する属性
xrange=[xl,xr] yrange=[yl,yr] zrange=[zl,zr]
axis_top=true axis_bottom=true axis_right=true axis_left=true axis_3d=true
◎ 軸の目盛とグリッド(網線)の属性
grid=true, xtics=true ytics=true ztics=true logx=false logy=false logz=false
◎ 表題や各軸のラベルに関連する属性
title=\"\", xlabel=\"\", ylabel=\"\", zlabel=\"\"
◎ 視点の変更, 検出した座標値の保存に関連する属性
rot_vertical=60, rot_horizontal=30, xy_file=\"\"
-------------------------------------------------------------------------------
◎ 関数
explicit(exp, x, xl, xr) <--- y=f(x)
adapt_depth=10, nticks=30, line_width=1, line_type={solid|dots},
color=black, filled_func=false, fill_color=red, key=\"\"
explicit(exp, x, xl, xr, y, yl, yr) <--- z=f(x,y)
xu_grid=30, yv_grid=30, contour={surface|base|both|map},
contour_levels=5, enhanced3d=\"\",
line_width=1, line_type={solid|dots}, color=black, key=\"\"```
◎ 陰関数
implicit(exp, x, xl, xr, y, yl, yr) <--- f(x,y)=0
implicit(exp, x, xl, xr, y, yl, yr, z, zl, zr) <--- f(x,y,z)=0
ip_grid=[50,50], ip_grid_in=[5,5],
x_voxel=10, y_voxel=10, z_voxel=10,
line_width=1, line_type={solid|dots}, color=black, key=\"\"
◎ 媒介変数表示
parametric(x(t), y(t), t, tl, tr)
parametric(x(t), y(t), z(t), t, tl, tr) <---
nticks=30, line_width=1, line_type={solid|dots}, color=black, key=\"\"
◎ 極座標表示
polar(r(t),t,tmin,tmax)
nticks=30, line_width=1, line_type={solid|dots}, color=black, key=\"\"
◎ 媒介変数表示された空間曲面
parametric_surface(x(t,u),y(t,u),z(t,u), t,tl,tr, u,ul,ur)
xu_grid=30, yv_grid=30, line_width=1, line_type={solid|dots}, color=black, key=\"\"
◎ 点列の描画
points(List)
List : [[x1, y1], ... , [xn, yn]] or [[x1, ... , xn], [y1, ... , yn]]
List : [[x1, y1, z1], ... , [xn, yn, zn]] or
[[x1, ... , xn], [y1, ... , yn], [z1, ... , zn]]
point_size=, point_type=, points_joined=false, line_width=,
line_type={solid,dots}, color=black, key=\"\"
point_type=x -1:none, 0:dot, 1:plus, 2:multiply 3:asterisk, 4:square
5:full_square, 6:circle, 7:filled_circle, 8:up_triabgle, 9:filled_up_triangle,
10:down_triangle, 11:filled_down_triabgle, 12:diamant, 13:filled_diamant
◎ 平面上の多角形の描画
polygon(List)
List : [[x1, y1], ... , [xn, yn]] or [[x1, ... , xn], [y1, ..., yn]]
rectangle([x1, y1], [x2, y2]) <--- 長方形の対角線上の点を指定
transparent=false (透明化の有無), border=true, fill_color=red, line_width=1,
line_type={dots|solid}, color=black, key=\"\"
◎ 楕円の描画
ellipse(原点x, 原点y, 半径1, 半径2, 角度1, 角度2 )
nticks=30, transparent=false, border=true, fill_color=red,
line_width=1, line_type=solid, color=black, key=\"\"
◎ 矢印(ベクトル)の描画
vector([基点のx座標, 基点のy座標], [基点からのx成分の増分, 基点からのy成分の増分])
vector([基点のx座標, 基点のy座標, 基点のz座標],
[基点からのx成分の増分, 基点からのy成分の増分, 基点からのZ成分の増分])
head_angle=45, head_both=false, head_length=2
head_type={filled,empty,nofilled}, line_width=1, line_type={solid,dots},
color=black, key=\"\"
◎ 画像(イメージ)の描画
image(実数行列, x0, y0, 幅, 高さ)
image([r, g, b]の行列, x0, y0, 幅, 高さ)
colorbox=true, palette=\"\"
◎ 指定凡例(legend)を記述
label([文字列1, x1, y1], ... , [文字列n, xn, yn])
label([文字列1, x1, y1, z1], ... , [文字列n, xn, yn, zn])
label_allgnment={center,left,right}
label_orientation={horizontal,vertical}
◎ その他の函数
add_zeroes(整数)
T:title=sconcat(\"f(x)=\",f(x))$ K:key=sconcat(\"f(x)=\",f(x))$
draw(font_size=12,gr2d(T,K,explicit(sin(x),x,-10,10)))$
---> font_size は maxima-5.19以降で可
*******************************";;
3次元作図例1
batchload("/home/inoue/Maxlib-20/on3lib21.mx")$
on3env()$
max_save()$ /* lisp ファイルに書き出す */
## ~/bin/go TMP/tmp_lang/chunk-9.mx > TMP/tmp_lang/chunk-9.out 2>&1
## batch("/var/www/html/LANG/TMP/tmp_lang/chunk-9.mx")
## read and interpret /var/www/html/LANG/TMP/tmp_lang/chunk-9.mx
## batchload("/home/inoue/Maxlib-20/on3lib21.mx")
## on3env()
## -- <on3env> logbegin --
## maxima_tempdir = TMP/tmp_maxima figs_dir = figs
## max_save()
## save("/tmp/max_save.lisp", all)
## "/var/www/html/LANG/TMP/tmp_lang/chunk-9.mx"
## ~/bin/go TMP/tmp_lang/chunk-10.mxl > TMP/tmp_lang/chunk-10.out 2>&1
## batch("/var/www/html/LANG/TMP/tmp_lang/chunk-10.mxl")
## read and interpret /var/www/html/LANG/TMP/tmp_lang/chunk-10.mxl
## on3lib()
## -- <on3env> logbegin --
## maxima_tempdir = TMP/tmp_maxima figs_dir = figs
## -- batchload: --- ~/Maxlib-20/on3lib21.mx and on3env() ---
## "-- batchload: --- ~/Maxlib-20/on3lib21.mx and on3env() ---"
## if true
## then (r0:1,
## g1:gr3d(axis_3d = false,enhanced3d = false,palette = gray,
## proportional_axes = 'xyz,title = "spherical",
## spherical(r0,a,0,2*%pi,z,0,%pi)),zr:30,zrr:(zr/180)*%pi,
## g1a:gr3d(axis_3d = false,enhanced3d = false,palette = gray,
## proportional_axes = 'xyz,title = "spherical",
## spherical(r0,a,0,2*%pi,z,0,%pi/2)),h0:2.5,r0:1,
## g2:gr3d(axis_3d = false,proportional_axes = 'xyz,view = [60,30],
## enhanced3d = false,palette = gray,title = "parametric_surface",
## parametric_surface(r*cos(t),r*sin(t),h0*on3(r,0,r0,cc),r,0,r0+1/1000,t,
## 0,2*%pi),xrange = [(-r0)*1.1,r0*1.1],
## yrange = [(-r0)*1.1,r0*1.1],zrange = [(-h0)*0.1,h0*1.1]),O:[0,0,0],
## P:[0,0,h0],OM:[-r0,0,0],OP:[r0,0,0],zr:120,zrr:(zr/180)*%pi,
## g2a:gr3d(axis_3d = false,proportional_axes = 'xyz,view = [60,zr],
## title = "parametric_surface",enhanced3d = false,palette = gray,
## point_size = 1.0,points_joined = true,color = blue,
## parametric_surface(r*cos(t),r*sin(t),0,r,r0,r0,t,0,2*%pi),
## parametric_surface(r*cos(t),r*sin(t),h0,r,r0,r0,t,0,2*%pi),
## parametric_surface(r0*cos(t),r0*sin(t),h,h,0,h0,t,zrr,zrr),
## parametric_surface(r0*cos(t),r0*sin(t),h,h,0,h0,t,zrr+%pi,zrr+%pi),
## points([[0,0,0]]),points([[0,0,h0]]),xrange = [(-r0)*1.1,r0*1.1],
## yrange = [(-r0)*1.1,r0*1.1],zrange = [(-h0)*0.1,h0*1.1]),h0:2.5,r0:1,
## g3:gr3d(axis_3d = false,proportional_axes = 'xyz,view = [60,30],
## enhanced3d = false,palette = gray,title = "parametric_surface",
## parametric_surface(r*cos(t),r*sin(t),h0*abs(r-r0)*on3(r,0,r0,cc),r,0,
## r0,t,0,2*%pi),xrange = [(-r0)*1.1,r0*1.1],
## yrange = [(-r0)*1.1,r0*1.1],zrange = [(-h0)*0.1,h0*1.1]),O:[0,0,0],
## P:[0,0,h0],OM:[-r0,0,0],OP:[r0,0,0],zr:30,zrr:(zr/180)*%pi,
## g3a:gr3d(axis_3d = false,proportional_axes = 'xyz,view = [60,zr],
## enhanced3d = false,palette = gray,point_size = 1.0,
## points_joined = true,color = blue,title = "parametric_surface",
## parametric_surface(r*cos(t),r*sin(t),0,r,r0,r0,t,0,2*%pi),
## parametric_surface(((r0*(h0-h))/h0)*cos(zrr),
## ((r0*(h0-h))/h0)*sin(zrr),h,h,0,h0,t,zrr,zrr),
## parametric_surface(((r0*(h0-h))/h0)*cos(t),((r0*(h0-h))/h0)*sin(t),h,
## h,0,h0,t,zrr+%pi,zrr+%pi),points([[0,0,0]]),
## points([[0,0,h0]]),xrange = [(-r0)*1.1,r0*1.1],
## yrange = [(-r0)*1.1,r0*1.1],zrange = [(-h0)*0.1,h0*1.1]),a:5,
## A:[0,0,0],B:[a,0,0],C:[a,a,0],P:[0,a,a],
## g4:gr3d(axis_3d = false,proportional_axes = 'xyz,view = [60,30],
## enhanced3d = false,palette = gray,title = "view=[60,30]",
## point_type = filled_circle,point_size = 1.0,points_joined = true,
## color = blue,points([A,B,C,A]),points([P,A]),points([P,B]),
## points([P,C]),label(["A",A[1],A[2],A[3]-a/10]),
## label(["B",B[1],B[2],B[3]-a/10]),label(["C",C[1],C[2],C[3]-a/10]),
## label(["P",P[1],P[2],P[3]+a/10]),xrange = [0-a/10,a+a/10],
## yrange = [0-a/10,a+a/10],zrange = [0-a/10,a+a/10]),a:10,A:[0,0,a],
## B:[a,0,a],C:[a,a,a],D:[0,0,0],E:[a,0,0],F:[a,a,0],
## g5:gr3d(axis_3d = false,proportional_axes = 'xyz,view = [60,30],
## enhanced3d = false,palette = gray,title = "view=[60,30]",
## point_type = filled_circle,point_size = 1.0,points_joined = true,
## color = blue,points([A,B,C,A]),points([D,E,F,D]),points([A,D]),
## points([B,E]),points([C,F]),label(["A",A[1],A[2],A[3]+a/10]),
## label(["B",B[1],B[2],B[3]+a/10]),label(["C",C[1],C[2],C[3]+a/10]),
## label(["D",D[1],D[2],D[3]-a/10]),label(["E",E[1],E[2],E[3]-a/10]),
## label(["F",F[1],F[2],F[3]-a/10]),xrange = [0-a/10,a+a/10],
## yrange = [0-a/10,a+a/10],zrange = [0-a/10,a+a/10]),
## g0:gr3d(axis_3d = false,proportional_axes = xyz,view = [60,120],
## enhanced3d = false,palette = gray,title = "view by slit [60,120]",
## point_type = filled_circle,point_size = 1.0,points_joined = true,
## color = blue,points([[0,0,6],[6,0,6],[6,6,6],[0,6,6],[0,0,6]]),
## points([[0,0,0],[6,0,0],[6,6,0],[0,6,0],[0,0,0]]),
## points([[0,0,6],[0,0,0]]),points([[6,0,6],[6,0,0]]),
## points([[6,6,6],[6,6,0]]),points([[0,6,6],[0,6,0]]),
## label(["A",0,0,33/5]),label(["B",6,0,33/5]),label(["C",6,6,33/5]),
## label(["D",0,6,33/5]),label(["E",0,0,(-3)/5]),label(["F",6,0,(-3)/5]),
## label(["G",6,6,(-3)/5]),label(["H",0,6,(-3)/5]),label(["K",0,3,33/5]),
## label(["L",3,(-3)/5,6]),label(["M",33/5,0,3]),color = red,
## line_width = 1.5,parametric_surface(9-z,0,z,z,3,6,y,0,6),
## parametric_surface(6,3-z,z,x,0,6,z,0,3),
## parametric_surface(3-z,6,z,z,0,3,y,0,6),
## parametric_surface(0,9-z,z,x,0,6,z,3,6),
## parametric_surface(x,3-x,6,x,0,3,z,0,6),
## parametric_surface(x,9-x,0,x,3,6,z,0,6),xrange = [(-3)/5,33/5],
## yrange = [(-3)/5,33/5],zrange = [(-3)/5,33/5]),
## draw(g1,g1a,g2,g2a,g3,g3a,g4,g5,g0,columns = 3,dimensions = [500*3,500*3],
## terminal = 'png,file_name = "figs/draw3-1"))
## [gr3d(spherical),gr3d(spherical),gr3d(parametric_surface),
## gr3d(parametric_surface,parametric_surface,parametric_surface,parametric_surface,points,
## points),gr3d(parametric_surface),
## gr3d(parametric_surface,parametric_surface,parametric_surface,points,points),
## gr3d(points,points,points,points,label,label,label,label),
## gr3d(points,points,points,points,points,label,label,label,label,label,label),
## gr3d(points,points,points,points,points,points,label,label,label,label,label,label,
## label,label,label,label,label,parametric_surface,parametric_surface,
## parametric_surface,parametric_surface,parametric_surface,parametric_surface)]
## if false then system("eog figs/draw3-1.png")
## false
## "/var/www/html/LANG/TMP/tmp_lang/chunk-10.mxl"
figs/draw3-1.pngのグラフ
3次元作図構文メモ
/* spherical(<radius>, <azi>, <minazi>, <maxazi>, <zen>, <minzen>, <maxzen>) */
spherical(r0,a,0,2*%pi,z,0,%pi)),
/* parametric_surface (xfun, yfun, zfun, par1, par1min, par1max,
par2, par2min, par2max)
par1minから par1maxまでを値として取るパラメータ par1と
par2minから par2maxまでを値として取るパラメータ par2を伴う
パラメトリックな表面 [xfun, yfun, zfun]をプロットします。
*/
/* spherical(<radius>, <azi>, <minazi>, <maxazi>, <zen>, <minzen>, <maxzen>)
minaziから maxaziまで値を取る 方位角 aziと
minzenから maxzenまで値を取る 天頂角 zenを
伴う球座標で定義された関数 radius(azi, zen)を描画します。
spherical(1,a,0,2*%pi,z,0,%pi) */
/* cylindrical(<radius>, <z>, <minz>, <maxz>, <azi>, <minazi>, <maxazi>)
cylindrical(1,z,-2,2,az,0,2*%pi) */
/* tube (<xfun>,<yfun>,<zfun>,<rfun>,<p>,<pmin>,<pmax>)
[xfun,yfun,zfun]は pminから pmaxまで値を取るパラメータ pを伴うパラメトリックな
曲線です。 パラメトリックな曲線上に中心を持ち、曲線と垂直な半径 rfunの円が置かれます。
tube(cos(a), a, 0, cos(a/10)^2, a, 0, 4*%pi) */
/* parametric (xfun, yfun, zfun, par, parmin, parmax)は
parminから parmaxまで値を取るパラメータ parを伴うパラメトリック曲線
[xfun, yfun, zfun]をプロットします。*/
/* implicit (fcn,x,xmin,xmax, y,ymin,ymax, z,zmin,zmax)は
xminから xmaxまでの値を取る変数 xと
yminから ymaxまでの値を取る変数 yと
zminから zmaxまでの値を取る変数 zを伴う fcnで定義された陰表面をプロットします。
このオブジェクトはマーチングキューブアルゴリズムを実装します。*/
3次元作図例2
## ~/bin/go TMP/tmp_lang/chunk-11.mx > TMP/tmp_lang/chunk-11.out 2>&1
## batch("/var/www/html/LANG/TMP/tmp_lang/chunk-11.mx")
## read and interpret /var/www/html/LANG/TMP/tmp_lang/chunk-11.mx
## if true
## then (g1:gr3d(enhanced3d = [2-x+2*y,x,y,z],title = "explicit",
## palette = gray,explicit(20+exp((-x^2)-y^2),x,-3,3,y,-3,3)),
## g2:gr3d(cylindrical(1,z,-2,2,az,0,2*%pi),title = "cylindrical"),
## g3:gr3d(enhanced3d = [cos(x-y),x,y,z],palette = gray,xu_grid = 50,
## title = "tube",tube(cos(a),a,0,1,a,0,4*%pi)),
## g4:gr3d(capping = [true,false],palette = [26,15,-2],
## enhanced3d = [-foo,foo],title = "tube",
## tube(a,a,a^2,1,a,-2,2)),
## g5:gr3d(title = "explicit",surface_hide = true,enhanced3d = true,
## wired_surface = true,contour_levels = 10,
## user_preamble = "set for [i=1:8] linetype i dashtype i linecolor 0",
## explicit(sin(x)*cos(y),x,1,10,y,1,10)),
## g6:gr3d(title = "explicit",key = "Gauss",color = "#a02c00",
## explicit(20*exp((-x^2)-y^2)-10,x,-3,3,y,-3,3),yv_grid = 10,
## color = blue,key = "Plane",explicit(x+y,x,-5,5,y,-5,5),
## surface_hide = true),
## g6a:gr3d(title = "explicit",key = "Gauss",color = "#a02c00",
## cylindrical(4,z,-12,5,az,0,2*%pi),color = blue,
## key = "Plane",explicit(x+y-2,x,-5,5,y,-5,5),
## surface_hide = true),
## g7:gr3d(title = "implicit",color = blue,
## implicit((x^2+y^2+z^2-1)*(x^2+(y-1.5)^2+z^2-0.5) = 0.015,x,
## -1,1,y,-1.2,2.3,z,-1,1),surface_hide = true),
## g8:gr3d(title = "implicit",enhanced3d = [x-y,x,y,z],
## implicit((x^2+y^2+z^2-1)*(x^2+(y-1.5)^2+z^2-0.5) = 0.015,x,
## -1,1,y,-1.2,2.3,z,-1,1)),
## g9:gr3d(title = "parametric",
## explicit(exp(sin(x)+cos(x^2)),x,-3,3,y,-3,3),
## color = royalblue,parametric(cos(5*u)^2,sin(7*u),u-2,u,0,2),
## color = turquoise,line_width = 2,
## parametric(t^2,sin(t),2+t,t,0,2),surface_hide = true,
## title = "Surface & curves"),
## draw(g1,g2,g3,g4,g5,g6,g6a,g7,g8,columns = 3,
## dimensions = [800*3,800*3],terminal = 'png,
## file_name = "figs/draw3-2"),
## if false then system("eog figs/draw3-2.png"))
## set pm3d at s depthorder explicit hidden3d 1
## ^
## "/tmp/maxout18688.gnuplot" line 171: invalid pm3d option
## false
## /var/www/html/LANG/TMP/tmp_lang/chunk-11.mx
figs/draw3-2.pngのグラフ