123456789+987654321
1111111110
142857142857 7
999999999999
100!
933262154439441526816992388562667004907159682643816214\ 6859296389521759999322991560894146397615651828625369\ 7920827223758251185210916864000000000000000000000000
2 の 100 乗なんていうのでも,へっちゃらです.
2^100
1267650600228229401496703205376
Sqrt[10!]
720 Sqrt[7]
例えば,Log[2] (2の自然対数)を計算させてみても,もとのままです.
Log[2]
Log[2]
N[%]
0.693147
関数Nの第2引数に精度を与えることによって, より高い精度の数値を求めることもできます.
N[Log[2], 40]
0.6931471805599453094172321214581765680755
N[Pi, 100]
3.1415926535897932384626433832795028841971693993751058\ 20974944592307816406286208998628034825342117068
例えば,n 番目の素数を求める関数 Prime[n] なんていうのも,用意されています.
Prime[303]
1999
2a + 3a
5 a
Expand[(a+b)^5]
5 4 3 2 2 3 4 5 a + 5 a b + 10 a b + 10 a b + 5 a b + b
Factor[x^4+64]
2 2 (8 - 4 x + x ) (8 + 4 x + x )
Integrate[ x^2 Sin[x]^2, x ]
3 2
4 x - 6 x Cos[2 x] + 3 Sin[2 x] - 6 x Sin[2 x]
------------------------------------------------
24
D[%, x] (* 上の結果の偏微分 *)
2 2
12 x - 12 x Cos[2 x]
----------------------
24
Simplify[%] (* 上の結果の簡単化 *)
2 2 x Sin[x]
Solve[ x^2 - 7x + 3a == 0, x ]
7 - Sqrt[49 - 12 a]
{{x -> -------------------},
2
7 + Sqrt[49 - 12 a]
{x -> -------------------}}
2
Solve[ {x^3+y^3==1, x+y==2}, {x,y} ]
I 12 + 2 I Sqrt[6]
{{x -> 1 - -------, y -> ----------------},
Sqrt[6] 12
I 12 - 2 I Sqrt[6]
{x -> 1 + -------, y -> ----------------}}
Sqrt[6] 12
DSolve[ y''[x]-k y[x]==1, y[x], x ]
1 C[1] Sqrt[k] x
{{y[x] -> -(-) + ---------- + E C[2]}}
k Sqrt[k] x
E
Plot[ Sin[x^2], {x,-Pi,Pi} ]
-Graphics-
Plot[ Sin[x^2], {x,-Pi,Pi},
Axes->None, (* 軸を消す *)
Frame->True, (* 枠を付ける *)
FrameLabel->{"x","sin(x^2)"}, (* ラベルを付ける *)
GridLines->Automatic, (* グリッドを付ける *)
PlotStyle->{{Thickness[0.03]}} (* 線の太さの指定 *)
]
-Graphics-
Show[Graphics[{
Circle[{0,0}, 1],
Disk[{0.2,0.1}, {0.05,0.1}],
Disk[{-0.2,0.1}, {0.05,0.1}],
Circle[{0,0}, 0.7, {-0.85Pi,-0.15Pi}] }],
AspectRatio->Automatic ]
-Graphics-
Plot3D[ Sin[x y], {x,-Pi,Pi}, {y,-Pi,Pi} ]
-SurfaceGraphics-
Plot3D[ Sin[x y], {x,-Pi,Pi}, {y,-Pi,Pi},
PlotPoints->30, (* 30*30点で計算 *)
Axes->False, (* 軸を消す *)
Boxed->False, (* 枠を消す *)
ViewPoint->{1.5, -1, 3} (* 視点の座標を指定 *)
]
-SurfaceGraphics-
Needs["Graphics`Shapes`"];
Show[Graphics3D[{
TranslateShape[Sphere[0.7], {0,0,1}],
Cone[],
RotateShape[Cylinder[0.2,1,8], 0, Pi/2, 0] }],
Boxed->False, ViewPoint->{2,0,1}
]
-Graphics3D-
図のすぐ右にある線のさらに少し右側をマウスでクリックしてから, Ctrl-Yを押すと絵が動き出します. マウスをクリックすると終わります.
Needs["Graphics`Animation`"];
Animate[ Plot[Sin[n x], {x,0,2Pi}], {n,1,6,0.5} ]
Needs["Graphics`Animation`"];
Animate[
Plot3D[Sin[n x] Sin[n y], {x,0,2Pi}, {y,0,2Pi},
PlotRange->{-1,1} ],
{n,1,2,0.1} ]
data = {
{0.05, 0.04},
{0.10, 0.06},
{0.15, 0.10},
{0.20, 0.14},
{0.25, 0.22},
{0.30, 0.26},
{0.35, 0.34},
{0.40, 0.38},
{0.45, 0.46},
{0.50, 0.58},
{0.55, 0.62},
{0.60, 0.74},
{0.65, 0.82},
{0.70, 0.86},
{0.75, 0.94},
{0.80, 1.06},
{0.85, 1.18},
{0.90, 1.22},
{0.95, 1.34},
{1.00, 1.42}
};
ListPlot[data]
-Graphics-
ListPlot[ data, AspectRatio->Automatic ]
-Graphics-
ListPlot[ data, AspectRatio->Automatic, PlotStyle->PointSize[0.02] ]
-Graphics-
graph1 = %
-Graphics-
Fit[ data, {1,x,x^2}, x ]
2 -0.0384737 + 0.882201 x + 0.597403 x
近似した結果は後から使うので,関数 f として定義しておきます.
f[x_] = %
2 -0.0384737 + 0.882201 x + 0.597403 x
Plot[ f[x], {x,0,1}, AspectRatio->Automatic ]
-Graphics-
graph2 = %
-Graphics-
Show[ graph1, graph2 ]
-Graphics-
Sum[ ( f[data[[i,1]]] - data[[i,2]] )^2, {i,1,Length[data]} ]
0.00919605
n
Σ xi
i=m
を求めています.
また Length[data] は data の長さ,つまりデータの個数を求めています.
data[[i,1]] は i 番目のデータ点の x 座標値,
data[[i,2]] は y 座標値を取り出しています.