AAbsAccuracyAllAlternativesAndAnyAnyNullSequenceAnySequenceApplyArCoshArCothArCschArSechArSinhArTanhArcCosArcCotArcCscArcSecArcSinArcTanArgAttributes
BBernoulliBinaryFormatBinomialBoole
CCalculateCeilClearClearAttributesComplementComplexComplexInfinityComplexOverflowComplexUnderflowCompoundConditionConjugateContainCosCoshCotCothCountCscCsch
DDefineDefineDelayedDefinitionsDenominatorDepthDigitBaseDirectedInfinityDivide
EEEndiannessEqualErfErfcEulerMascheroniExpExpandExpression
FFactorialFalseFibonacciFlatFlattenFloorFunction
GGoldenAngleGoldenRatioGreaterGreaterEqual
HHarmonicNumberHeadHoldAllHoldFirstHoldRest
IIIfImIndeterminateInfinityIntegerInternalFormIntersectionIsEvenIsInfiniteIsNumericIsOddIsOverflowIsPrimeIsUnderflowIterateIterateParallel
JJoin
LLaunchKernelsLengthLessLessEqualListListableLockedLog
MMachinePrecisionMapMapParallelMatchingMaxMinMinusMod
OOptionalOptionsOrOrderOrderlessOutputOverflow
PPartPartitionPatternPausePiPlusPowerPrecisionPrintProtected
RRandomRationalRationalizeReRealReplaceRoundRuleRuleDelayed
SSameScopeSecSechSelectSequenceSequenceHoldSetAttributesShiftLeftShiftRightSignSinSinhSlotSortSpanSplitSqrtStringSubDefineSubDefineDelayedSubtractSymbolSymbols
TTanTanhTimesTimingToIntegerToRealToStringToSymbolTrueTrunc
XXor
Accuracy(z)Accuracy(3.14)14.4577
Accuracy(2.0e24)-9.34644
Accuracy(1234567890123456.7890)4.0
Alternatives(pat1, pat2, … )pat1 | pat2 | …Replace( {a, b, c, a, b, c} , a|b -> 0 ){0, 0, c, 0, 0, c}
f( x?Rational | x?Integer ) := x^2;
{ f(2), f(1.0), f(1/2) }{4, f(1.0), 1/4}
And(bool1, bool2, … )bool1 && bool2 && …And(int1, int2, … )int1 && int2 && …And(str1, str2, … )str1 && str2 && …12 && 74
'BINARY' && 'abc''@@B'
(Print(1);True) && False && (Print(2);True)1False
2==2 && a==5 && b==10 && Truea == 5 && b == 10
Any?Any(head)?headMatching( f(123), Any(f) )True
Replace( { 1, 1.0, 1/2, 4 } , ?Integer -> x ){x, 1.0, 1/2, x}
f(?Real) = "real";
{ f(1), f(1.0), f(2^0.5) }{f(1), "real", "real"}
? + ?
Matching( a + b, ? + ? )
Matching( a + b, x? + y? )2*Any
False
True
AnyNullSequence???AnyNullSequence(head)???headMatching( f(), f(AnyNullSequence) )True
Matching( f(x, y), f(AnyNullSequence(Symbol)) )True
Matching( f(), f(AnyNullSequence(Symbol)) )True
f(???Real) = "reals or nothing";
{ f(), f(1.0), f(1.0, 2.0), f(1) }{"reals or nothing", "reals or nothing", "reals or nothing", f(1)}
AnySequence??AnySequence(head)??headMatching( f(1, 2, 3), f(AnySequence) )True
Matching( f(x, y), f(AnySequence(Symbol)) )True
f(??Real) = "reals";
{ f(1), f(1.0), f(1.0, 2.0), f(1, 0.5) }{f(1), "reals", "reals", f(1, 0.5)}
Apply(g, f(1, a, x))g(1, a, x)
Plus @@ {2, 3, 4}9
f @@ (a+b)f(a, b)
Apply( #1^#2 & , {3, 2} )9
ArCosh(z)ArCosh(1.5)0.962424
Calculate(ArCosh(3/2), 70)0.9624236501192068949955178268487368462703686687713210393220363376803277
ArCosh(2.0+3.0*I)1.98339+1.00014*I
ArCosh(1)0
ArcTan(z)ArcTan(x,y)ArcTan(2.0)1.10715
Calculate(ArcTan(2), 70)1.107148717794090503017065460178537040070047645401432646676539207433710
ArcTan(2.0+3.0*I)1.40992+0.229073*I
ArcTan(0)0
ArcTan(-1.0, -3.0)-1.89255
ArSech(z)ArSech(0.5)1.31696
Calculate(ArSech(1/2), 70)1.316957896924816708625046347307968444026981971467516479768472256920460
ArSech(2.0+1.0*I)0.215612-1.16921*I
ArSech(1)0
ArTanh(z)ArTanh(0.5)0.549306
Calculate(ArTanh(1/2), 70)0.5493061443340548456976226184612628523237452789113747258673471668187471
ArTanh(2.0+3.0*I)0.146947+1.33897*I
ArTanh(0)0
Attributes(s)Attributes(s) = attrAttributes(s) = {attr1, attr2, …}| Flat | f is associative. |
| Orderless | f is commutative. |
| Listable | f is automatically threaded over List{…}. |
| Protected | Definitions of f cannot be changed. |
| Locked | Attributes of f cannot be changed. |
| HoldAll | All argument of f maintain unevaluated. |
| HoldFirst | The first argument of f maintains unevaluated. |
| HoldRest | All argument of f, except the first one, maintain unevaluated. |
| SequenceHold | An expicit Sequence as an argument of f maintains unevaluated. |
Attributes(Plus){Flat, Listable, Locked, NumericFunction, OneIdentity, Orderless, Protected}
f(1, z, f(a, 2))f(1, z, f(a, 2))
Attributes(f) = {Orderless, Flat}{Flat, Orderless}
f(1, z, f(a, 2))f(1, 2, a, z)
Attributes(g) = Listable;
g(x?) := "<" ~ ToString(x) ~ ">"
g(7)"<7>"
g({-1,2,a}){"<-1>", "<2>", "<a>"}
Bernoulli(n)BinaryFormat -> type| Integer formats: | |
| "Integer8", "int8" | 8-bit signed integer |
| "Integer16", "int16" | 16-bit signed integer 1) |
| "Integer32", "int32" | 32-bit signed integer 1) |
| "Integer64", "int64" | 64-bit signed integer 1) |
| "IntegerN", "intn" | n-bit signed integer 1) 2) |
| "UnsignedInteger8", "uint8" | 8-bit unsigned integer |
| "UnsignedInteger16", "uint16" | 16-bit unsigned integer 1) |
| "UnsignedInteger32", "uint32" | 32-bit unsigned integer 1) |
| "UnsignedInteger64", "uint64" | 64-bit unsigned integer 1) |
| "UnsignedIntegerN", "uintn" | n-bit unsigned integer 1) 2) |
| Floating-point formats: | |
| "Real16", "float16", "half" | 16-bit IEEE 754 floating point number |
| "Real32", "float32", "single" | 32-bit IEEE 754 floating point number |
| "Real64", "float64", "double" | 64-bit IEEE 754 floating point number |
| "Complex32" | Two 16-bit IEEE 754 floating point numbers |
| "Complex64" | Two 32-bit IEEE 754 floating point numbers |
| "Complex128" | Two 64-bit IEEE 754 floating point numbers |
| String formats: | |
| "ANSI" | Windows codepage 1252 - latin 1 encoded string |
| "UTF8" | UTF-8 encoded string |
| "UTF16" | UTF-16 encoded string 1) |
| "UTF32" | UTF-32 encoded string 1) |
| 1) By default the order of bytes are handled as little-endian. Use Endianness to change it. | |
| 2) The size depends on the most significant bit and is rounded to a full byte. | |
ToString(12345, BinaryFormat->"Integer16")
ToString(3.1415, BinaryFormat->"double")'90'
'o\x12\x83ÀÊ!\t@'
ToInteger('ÿ', BinaryFormat->"Integer8")
ToInteger('ÿ', BinaryFormat->"UnsignedInteger8")-1
255
ToString("yä€𝄞", BinaryFormat->"ANSI")
ToString("yä€𝄞", BinaryFormat->"UTF8")
ToString("yä€𝄞", BinaryFormat->"UTF16", Endianness->-1)
ToString("yä€𝄞", BinaryFormat->"UTF16", Endianness->1)
ToString("yä€𝄞", BinaryFormat->"UTF32")'yä\x80?'
'yäâ\x82¬ð\x9D\x84\x9E'
'y\0ä\0¬ 4Ø\x1EÝ'
'\0y\0ä ¬Ø4Ý\x1E'
'y\0\0\0ä\0\0\0¬ \0\0\x1EÑ\x01\0'
ToString('yäâ\x82¬ð\x9D\x84\x9E', BinaryFormat->"UTF8")
ToString('\0y\0ä ¬Ø4Ý\x1E', BinaryFormat->"UTF16", Endianness->1)"yä€𝄞"
"yä€𝄞"
ToString(12345, BinaryFormat->"Integer8")
ToString(12345, BinaryFormat->"float16")'9'
'\ar'
ToReal('\ar', BinaryFormat->"float16")12344.0
Binomial(n, k)Binomial(49, 6)13983816
Binomial(365, 31)884481797664650696626118102000059032909354320
Binomial(7/2, 3/2)35/8
Binomial(3.5, 2.1)4.26099
(10^20)!Overflow
Binomial(10^20, 3)166666666666666666661666666666666666666700000000000000000000
Calculate(exp)Calculate(exp, n)Log(-5) // Calculate1.60944+3.14159*I
x = { 4/6 , Cos(3) , Cos(Pi/6) }{2/3, Cos(3), 1/2*3^(1/2)}
Calculate(x){0.666667, -0.989992, 0.866025}
Calculate(Log(-5), 25)1.609437912434100374600759+3.141592653589793238462643*I
Calculate(Cos(2^10), 50)0.98735361821984829524651338092244419111051208085007
x = Calculate(Pi, 15)3.14159265358979
Calculate(x, 30)3.14159265358979
y = Calculate(Sin(10^40), 30)-0.569633400953636327308
y // Precision21.6803
Calculate(Exp(1/10^100)-1, 30)0.e-61
Calculate(z^4)z^4
Clear(s)Clear({s1, s2, … })x = 123123
x^215129
Clear(x)
x^2x^2
f(10) = 0
f(z?Integer) := 2*z
f(z?) * w? @:= -w*z0
Definitions(f)f(10) = 0f(Pattern(z, ?Integer)) := 2*zf(Pattern(z, Any))*Pattern(w, Any) @:= Minus(w*z)
Clear(f)
Definitions(f)/* no definitions */
ClearAttributes(s)ClearAttributes(s, attr)ClearAttributes(s, {attr1, attr2, … } )Boole({True, False, True}){1, 0, 1}
ClearAttributes(Boole, Listable){Listable}
Boole({True, False, True})Boole({True, False, True})
Complement(list, list1, list2, … )Complement( {4,2,3,2,1} , {1,4} ){2, 3}
Complement( {x, y, z} , {y} ){x, z}
Complement( {1,2,3,4} , {1,2} , {2,3} ){4}
Complement( a + b + c + d , a + c )b + d
Complement( f(1, 4, 2), f(2, 3) )f(1, 4)
Complement( f(1, 4, 2), g(2, 3) )Complement(f(1, 4, 2), g(2, 3))
Complex(x, y)x + y*IComplexComplexInfinityAbs(ComplexInfinity) > Abs(ComplexOverflow)True
1 / ComplexInfinity0
1 / 0ComplexInfinity
ComplexOverflow(7.0+4.0*I) ^ Exp(100.0)ComplexOverflow
3.14 + ComplexOverflowComplexOverflow
ComplexOverflow * (-2)ComplexOverflow
ComplexUnderflow(7.0+4.0*I) ^ (-Exp(100.0))ComplexUnderflow
3.14 + ComplexUnderflow3.14+0.0*I
ComplexUnderflow * (-2)ComplexUnderflow
1 / ComplexUnderflowComplexOverflow
Condition(pat, cond)pat /? condMatching( 1, x? /? x>0 )
Matching( -1, x? /? x>0 )True
False
f(x? /? x!=0) := 1/x
f(2)
f(1/2)
f(0)1/2
2
f(0)
g(x?, y?) /? x>y := x^y
g(10, 2)
g(2, 4)
g(x, 3)100
g(2, 4)
g(x, 3)
Replace( {-1,2,-3,4,-5,6} , x?Integer /? x<0 -> 0 ){0, 2, 0, 4, 0, 6}
g( x? /? x!=1 ) := (x^2-1)/(x-1) /* general definition with exception */
h(x?) := If( x!=1 , (x^2-1)/(x-1) , "problem" ) /* definition with If */
{ g(0.0) , g(1.0) , g(2.0) }
{ h(0.0) , h(1.0) , h(2.0) }{1.0, g(1.0), 3.0}
{1.0, "problem", 3.0}
Contain( {1,2,3,4,5} , 3 )
Contain( {1,2,3,4,5} , 6 )True
False
Contain( {1, 2, {31, 32}, 4} , 31 )True
Contain( {1, Pi, 4.5, f()} , ?Real)True
Contain( 2 + 2*x + 3*x^2 , Condition(x^y?, y>3) )
Contain( 2 + 2*x + 3*x^2 - 5*x^4 , Condition(x^y?, y>3) )False
True
Cos(z)Cos(2.0)-0.416147
Calculate(Cos(2), 70)-0.4161468365471423869975682295007621897660007710755448907551499737819649
Cos(2.0+3.0*I)-4.18963-9.10923*I
Cos(0)1
Cosh(z)Cosh(2.0)3.7622
Calculate(Cosh(2), 70)3.762195691083631459562213477773746108293973558230711602777643347588324
Cosh(2.0+3.0*I)-3.72455+0.511823*I
Cosh(0)1
Cot(z)Cot(2.0)-0.457658
Calculate(Cot(2), 70)-0.4576575543602857637502774104320472764284863292316743296413921626362923
Cot(2.0+3.0*I)-0.00373971-0.996758*I
Coth(z)Coth(1.0)1.31304
Calculate(Coth(1), 70)1.313035285499331303636161246930847832912013941240452655543152967567084
Coth(1.0+2.0*I)0.82133+0.171384*I
Count(exp, el)Count(str, sr)Count( {1, 0, 0, 1, 0} , 1 )2
Count( {a, x, {b, x}, x, c} , x )3
Count( {1, Pi, 4.5, f(), 2.0} , ?Real)2
Count( 3+3*x+4*x^2, x)2
Count( 2 + 2*x + 3*x^2 , x^y?)1
Count( "foobaabaabaafoofoobaa", "baa")4
Count( 'ABAABABAA', 'A')6
Count( {2.0, 2.0, 3.0} , 2 )
Count( {2.0, 2.0, 3.0} , 2.0 )0
2
Csc(z)Csc(2.0)1.09975
Calculate(Csc(2), 70)1.099750170294616466756697397026312896658764443149845708742554443062569
Csc(2.0+3.0*I)0.0904732+0.041201*I
Csch(z)Csch(2.0)0.275721
Calculate(Csch(2), 70)0.2757205647717832077583514821630271212496226719912580519731712337225655
Csch(2.0+3.0*I)-0.272549-0.0403006*I
Define(lhs, rhs)lhs = rhsx = 123123
x*2246
y = a^2 + b^2a^2 + b^2
2*y2*(a^2 + b^2)
{a, b, c} = {123, 3.14, "Test"};
a
b
c123
3.14
"Test"
f(z?) = z^2 + zz + z^2
f(9)
f(a+b)90
16037.4
f(z?, n?) = z^n + zz + z^n
f(w)
f(w, 5)w + w^2
w + w^5
x = 3.143.14
h(x?) = 2*x6.28
k(x?) := 2*x
h(123)
k(123)6.28
246
DefineDelayed(lhs, rhs)lhs := rhsx := 123
x*2246
y := a^2 + b^2
2*y2*(a^2 + b^2)
{a, b, c} := {123, 3.14, "Test"}
a
b
c123
3.14
"Test"
f(z?) := z^2 + z
f(9)
f(a+b)90
16037.4
f(z?, n?) := z^n + z
f(w)
f(w, 5)w + w^2
w + w^5
m = 22
k(q?) := m*q
h(q?) = m*q2*q
h(a)
k(a)246
246
m = 55
h(123)
k(123)246
615
Definitions(s)Definitions(Plus)Plus(AnyNullSequence) /* built-in function */
f(1) = 1;
f(x?) := f(x-1)+f(x-2);
f(2) = 1;
f(x? /? x <= 0) = 0;
Definitions(f)f(1) = 1f(2) = 1f(Condition(Pattern(x, Any), x <= 0)) = 0f(Pattern(x, Any)) := f(x - 1) + f(x - 2)
Denominator(z)Denominator(3/7)7
Denominator(-8/3)3
Denominator(123)1
Denominator(3.4)1
Denominator(1/2 + 1/3*I)6
Denominator(f/g)g
Denominator(a^2*b^(-3)*c^4)b^3
Depth(exp)Depth( { {1,2}, 3, {4,{5,6}} } )3
Depth( 123 )0
Depth( f(x^2) )2
Depth( a + 2*b^2 + 3*c )3
Depth( 1/3 )0
a/b
Depth( a/b )a/b
2
InternalForm( a/b )Times(a, Power(b, -1))
DirectedInfinity()DirectedInfinity(z)DirectedInfinity(1.0+I) * DirectedInfinity(I)DirectedInfinity(-0.707107+0.707107*I)
DirectedInfinity(I) ^ 4Infinity
Tan(DirectedInfinity(1+I))I
ArcCos(Infinity)DirectedInfinity(I)
ArTanh(DirectedInfinity(I))1/2*I*Pi
4 / 22
x^5 / x^2x^3
4 / 6
4.0 / 62/3
0.666667
Endianness -> -1Endianness -> 1ToString(1023, BinaryFormat->"Integer32")
ToString(1023, BinaryFormat->"Integer32", Endianness->-1)
ToString(1023, BinaryFormat->"Integer32", Endianness->1)'ÿ\x03\0\0'
'ÿ\x03\0\0'
'\0\0\x03ÿ'
ToString("yä€𝄞", BinaryFormat->"UTF16", Endianness->-1)
ToString("yä€𝄞", BinaryFormat->"UTF16", Endianness->1)'y\0ä\0¬ 4Ø\x1EÝ'
'\0y\0ä ¬Ø4Ý\x1E'
ToInteger('ÿ\x01\0\0', BinaryFormat->"Integer32")
ToInteger('ÿ\x01\0\0', BinaryFormat->"Integer32", Endianness->-1)
ToInteger('ÿ\x01\0\0', BinaryFormat->"Integer32", Endianness->1)511
511
-16711680
1 == 1True
3.0 == 3True
0.2 == 1/5True
Overflow == Overflow
Overflow === OverflowOverflow == Overflow
True
a == ba == b
1.0000000000000000002 == 1.0000000000000000001True
1.00000000000000000020 == 1.00000000000000000010False
Erf(x)Erf(1.0)0.842701
Calculate(Erf(1), 70)0.8427007929497148693412206350826092592960669979663029084599378978347173
Erf(-0.2)-0.222703
Erf(3.0)0.999978
Erf(0)0
1 - Calculate(Erf(10))
1 - Calculate(Erf(10), 60)0.0
2.08848758376254e-45
Erfc(x)Erfc(1.0)0.157299
Calculate(Erfc(1), 70)0.1572992070502851306587793649173907407039330020336970915400621021652827
Erfc(-2.2)1.99814
Erfc(40.0)1.896961059966e-697
Erfc(0)1
EulerMascheroniCalculate(EulerMascheroni)0.577216
Calculate(EulerMascheroni, 70)0.5772156649015328606065120900824024310421593359399235988057672348848677
2*EulerMascheroni + 3*EulerMascheroni5*EulerMascheroni
2.0*EulerMascheroni1.15443
HarmonicNumber(10000) - Log(10000) // Calculate0.577266
Exp(z)Exp(-2.5)0.082085
Exp(1000.0)1.970071114017e434
Exp(3.0+2.0*I)-8.35853+18.2637*I
Calculate(Exp(10), 70)22026.46579480671651695790064528424436635351261855678107423542635522520
Exp(0)1
Expand(exp)Expand( 3*(a+b) )3*a + 3*b
Expand( (a+b)^2 )a^2 + 2*a*b + b^2
Expand( (Pi+1)^3 * (E-2) )-2 + E - 6*Pi + 3*E*Pi - 6*Pi^2 + 3*E*Pi^2 - 2*Pi^3 + E*Pi^3
Expand( (a+b)^2 + (a-b)^2 )2*a^2 + 2*b^2
head(arg1, arg2, … )head @ argarg // headHead( func(a, b) )func
Head( h(y)(a, b) )h(y)
func @ 123func(123)
123 // funcfunc(123)
f(1) = 2
f(foo) = 3
f("bar") = 42
3
4
{ f(), f(0), f(1) }
{ f(foo), f(bar), f("bar"), f("foo") }{f(), f(0), 2}
{3, f(bar), 4, f("foo")}
g(x?) := x^2
{ g(7) , g(a) , g(2+b) }{49, a^2, (2 + b)^2}
Factorial(10)3628800
50!30414093201713378043612608166064768844377641568960512000000000000
(-5)!ComplexInfinity
6.32!1321.18
1000.0!4.02387260077e2567
Calculate(Factorial(22/7), 70)7.199869288735633700776845665344668943490127819531077381591855761162949
(-1/2)!Pi^(1/2)
Fibonacci(n)Fibonacci(10)55
Fibonacci(350)6254449428820551641549772190170184190608177514674331726439961915653414425
Fibonacci(-10)-55
Fibonacci(10.0)55.0
Fibonacci(16.32)1151.31
Fibonacci(10000.0)3.36447648764e2089
Calculate(Fibonacci(22/7), 70)2.118038120159998741207512266041453547560232382534595267287508988177487
a + (b + c)a + b + c
f(1, f(2, 3))f(1, f(2, 3))
Matching( f(1, 2, 3) , f(x?, y?) )False
Attributes(f) = Flat{Flat}
f(1, f(2, 3))f(1, 2, 3)
f(1, 2, 3) /: f(x?, y?) :> {x, y}{1, f(2, 3)}
Flatten(exp)Flatten(exp, n)Flatten( f( 1, f(), 2, f(3, 4)) )f(1, 2, 3, 4)
Flatten( { a, {b1, b2}, {c1, c2, {c3x, c3y}} } ){a, b1, b2, c1, c2, c3x, c3y}
Flatten( {1, {2, {3, {4, {5}}}}}, 1 ){1, 2, {3, {4, {5}}}}
Flatten( {1, {2, {3, {4, {5}}}}}, 2 ){1, 2, 3, {4, {5}}}
Flatten( {1, {2, {3, {4, {5}}}}}, 3 ){1, 2, 3, 4, {5}}
Flatten( {1, {2, {3, {4, {5}}}}}, 4 ){1, 2, 3, 4, 5}
f = Function( 2*#+1 )Function(2*#1 + 1)
f(x)
f(5)1 + 2*x
11
g = #1^#2 + #2^#1 &Function(#1^#2 + #2^#1)
g(x, y)
g(4,3)x^y + y^x
145
Select( {1,2,3,4} , #<3 & ){1, 2}
f = {#1, #2} &Function({#1, #2})
f(a,b,c){a, b}
f(a,b){a, b}
f(a){a, #2}
GoldenAngleCalculate(GoldenAngle)2.39996
Calculate(GoldenAngle, 70)2.399963229728653322231555506633613853124999011058115042935112750731307
Calculate(GoldenAngle*180/Pi)137.508
GoldenRatioCalculate(GoldenRatio)1.61803
Calculate(GoldenRatio, 70)1.618033988749894848204586834365638117720309179805762862135448622705260
GoldenRatio - 1.0/GoldenRatio1.0
2 > 1True
1/3 > 0 > -0.5True
x > 2 > 2False
2 > 1 > x1 > x
GreaterEqual(x1, x2, … )x1 >= x2 >= …2 >= 1True
3/2 >= 1.5 >= -0.5True
x >= 1 >= 2False
2 >= 1 >= x1 >= x
HarmonicNumber(n)HarmonicNumber(5)137/60
HarmonicNumber(60)15117092380124150817026911/3230237388259077233637600
HarmonicNumber(100) // Calculate5.18738
HarmonicNumber({1,2,3,4,5}){1, 3/2, 11/6, 25/12, 137/60}
HarmonicNumber(-2)-2
HarmonicNumber(3.5)HarmonicNumber(3.5)
Head(exp)InternalForm(a/b)Times(a, Power(b, -1))
Attributes(And){Flat, HoldAll, Protected}
Attributes(h) = {HoldAll}{HoldAll}
h(x?+y?) := {x, y} /* h has the attribute HoldAll */
f(x?+y?) := {x, y} /* f hasn't the attribute HoldAll */
h(3+7) /* 3+7 holds and matches x?+y? */
f(3+7) /* 3+7 is evaluated to 10 and does not matching */{3, 7}
f(10)
Attributes(Define){HoldFirst, Locked, Protected, SequenceHold}
Attributes(h) = {HoldFirst}{HoldFirst}
h(x?+y?) := {x, y} /* h has the attribute HoldFirst */
f(x?+y?) := {x, y} /* f hasn't the attribute HoldFirst */
h(3+7) /* 3+7 holds and matches x?+y? */
f(3+7) /* 3+7 is evaluated to 10 and does not matching */{3, 7}
f(10)
If(True, 123, -10)
If(False, 123, -10)123
-10
x = 3; If(x!=0, 1.0/x, "Div 0")
x = 0; If(x!=0, 1.0/x, "Div 0")0.333333
"Div 0"
If(a==b, 1, 2)If(a == b, 1, 2)
If(a==b, 1, 2, 3)3
IndeterminatenInteger12 + 3446
32845723658234756 * 34659487645645654611384159533448787206618577180912776
11384159533448787206618577180912776 / 34659487645645654632845723658234756
3^200265613988875874769338781322035779626829233452653394495974574961739092490901302182994384699044001
InternalForm(exp)InternalForm(4+2*I)Complex(4, 2)
InternalForm(1/5)Rational(1, 5)
InternalForm(1+2*x)Plus(1, Times(2, x))
InternalForm(x?Integer)Pattern(x, Any(Integer))
InternalForm(a-b)Plus(a, Times(-1, b))
InternalForm(1/x)Power(x, -1)
InternalForm(Exp(z))Power(E, z)
Intersection(list1, list2, … )Intersection( {4,3,3,1} , {1,4,4,5} ){1, 4}
Intersection( {x, y} , {u, v} ){}
Intersection( {1,2,3} , {1,10,100} , {1,2,4,8} ){1}
Intersection( a + b + d , a + c + d )a + d
Intersection( f(1, 4, 2), f(2, 3, 4) )f(2, 4)
Intersection( f(1, 2), g(2, 3) )Intersection(f(1, 2), g(2, 3))
IsInfinite(z)IsInfinite(1/0)True
IsInfinite(Log(0))True
IsInfinite(123)False
IsOverflow(z)IsOverflow(Exp(10.0^100))True
IsOverflow(ComplexOverflow)True
IsOverflow(1.0/Underflow)True
IsOverflow(123)False
IsOverflow(Exp(Infinity))False
IsOverflow(1/0)False
IsUnderflow(z)IsUnderflow(Exp(-10.0^30))True
IsUnderflow(ComplexUnderflow)True
IsUnderflow(1.0/Overflow)True
IsUnderflow(123)False
IsUnderflow(Exp(-Infinity))False
IsUnderflow(1/0)False
Iterate(exp, n)Iterate(exp, {i, imax} )Iterate(exp, {i, imin, imax} )Iterate(exp, {x, xmin, xmax, xstep} )Iterate(exp, {e, {e1, e2, …, en } } )Iterate(exp, spec1, spec2, … )Iterate(0, 8){0, 0, 0, 0, 0, 0, 0, 0}
Iterate("Text", 4){"Text", "Text", "Text", "Text"}
Iterate(i, {i, 10} ){1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Iterate(i^2, {i, -3, 3} ){9, 4, 1, 0, 1, 4, 9}
Iterate(x, {x, 0.5, 0.9, 0.1} ){0.5, 0.6, 0.7, 0.8, 0.9}
Iterate(Sin(x), {x, 0, 4*Pi, Pi/2} ){0, 1, 0, -1, 0, 1, 0, -1, 0}
Iterate(w*2, {w, {1,0.7,t,1/3} } ){2, 1.4, 2*t, 2/3}
Iterate(m+n*10, {m, 1, 4}, {n, 1, 4}){{11, 12, 13, 14}, {21, 22, 23, 24}, {31, 32, 33, 34}, {41, 42, 43, 44}}
Iterate(m+n*10, {m, 1, n}, {n, 1, 4}){{11}, {21, 22}, {31, 32, 33}, {41, 42, 43, 44}}
IterateParallel(exp, n)IterateParallel(exp, {i, imax} )IterateParallel(exp, {i, imin, imax} )IterateParallel(exp, {x, xmin, xmax, xstep} )IterateParallel(exp, {e, {e1, e2, …, en } } )IterateParallel(exp, spec1, spec2, … )IterateParallel(x^2, {x, 1, 10} ){1, 4, 9, 16, 25, 36, 49, 64, 81, 100}
IterateParallel(Fibonacci(i), {i, 1, 10} ){1, 1, 2, 3, 5, 8, 13, 21, 34, 55}
Timing(Iterate(Pause(1), 4);){4.00127, Null}
Timing(IterateParallel(Pause(1), 4);){1.00117, Null}
Timing(Count(Iterate(IsPrime(n), {n, 2^70, 2^70+5000}), True)){0.213779, 116}
Timing(Count(IterateParallel(IsPrime(n), {n, 2^70, 2^70+5000}), True)){0.0450858, 116}
Timing(Iterate(Sin(x), {x,0.0,1.0,0.01}); ){3.792e-4, Null}
Timing(IterateParallel(Sin(x), {x,0.0,1.0,0.01}); ){0.0021673, Null}
QuitKernels(); LaunchKernels(3);
x = 0;
IterateParallel( x = x + 1; Print("Kernel "~ToString(KernelID)~", x = "~ToString(x)); , 10 );Kernel 13, x = 1Kernel 14, x = 1Kernel 15, x = 1Kernel 14, x = 2Kernel 13, x = 2Kernel 15, x = 2Kernel 14, x = 3Kernel 13, x = 3Kernel 15, x = 3Kernel 14, x = 4
x0
Join( {1,2} , {3,4,5} ){1, 2, 3, 4, 5}
Join( "Hello ", "World!" )"Hello World!"
Join( a + b , c + d )a + b + c + d
Join( f(1, 2), f(x) )f(1, 2, x)
KernelIDIterate(KernelID, 10)
IterateParallel(KernelID, 10){0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
{1, 2, 3, 4, 1, 2, 3, 1, 2, 3}
IterateParallel(i^2, {i, 0, 16}){0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256}
Kernels(){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
LaunchKernels()LaunchKernels(n)LaunchKernels(4){1, 2, 3, 4}
IterateParallel(KernelID, 10){1, 2, 3, 4, 1, 2, 3, 1, 2, 3}
LaunchKernels(3){5, 6, 7}
Kernels(){1, 2, 3, 4, 5, 6, 7}
Length(exp)Length(str)Length( {1,2,3,4,5} )5
Length( "Hello World!" )12
Length( '\0\x80ÿ\n' )4
Length( a + 2*b + c )3
Length( f(a, b) )2
Length( 1/3 )0
InternalForm( -x )Times(-1, x)
1 < 2True
-0.5 < 0 < 1/3True
x < 2 < 2False
1 < 2 < x2 < x
1 <= 2True
-0.5 <= 1.5 <= 3/2True
x <= 2 <= 1False
1 <= 2 <= x2 <= x
List( 1, 2, 3 ){1, 2, 3}
{{a1,a2}, {b1,b2}}{{a1, a2}, {b1, b2}}
Sqrt({1, 4, 9}){1, 2, 3}
Exp({0.0, 1.0, 10.0}){1.0, 2.71828, 22026.5}
{a, b} + {c, d}{a + c, b + d}
Sin({x, 2, 0.5}){Sin(x), Sin(2), 0.479426}
f({1, 2, 3})f({1, 2, 3})
Attributes(f) = Listable{Listable}
f({1, 2, 3}){f(1), f(2), f(3)}
f({1, 2, 3}, {a, b, c}){f(1, a), f(2, b), f(3, c)}
Attributes(Plus) = Flat{}
Attributes(f) = {Flat, Locked}{Flat, Locked}
Attributes(f) = {Orderless}{}
Attributes(f){Flat, Locked}
Log(1000.0)6.90776
Log(3.0+2.0*I)1.28247+0.588003*I
Calculate(Log(100), 70)4.605170185988091368035982909368728415202202977257545952066655801935145
Log(10, 1000)3
Log(4.5, 4.5^100000)1.0e5
Log(2/3, 16/81)4
Log(1/4, 8)-3/2
MachinePrecisionCalculate(MachinePrecision)15.9546
Precision(3.1415)MachinePrecision
Precision(789.456e123)MachinePrecision
Precision(123.4e5678)15.9546
MapParallel(f, exp)MapParallel(f, {1, a, x}){f(1), f(a), f(x)}
MapParallel(Cos, {Pi, 1.0, I, x}){-1, 0.540302, Cosh(1), Cos(x)}
Timing( Map(Pause, {0.5, 1.0, 1.5, 2.0} ) ){5.00082, {Null, Null, Null, Null}}
Timing( MapParallel(Pause, {0.5, 1.0, 1.5, 2.0} ) ){2.00053, {Null, Null, Null, Null}}
testlist = Random(2^70, 5000); /* Create a list of 5000 random huge numbers. */
Timing( Count(Map(IsPrime, testlist), True) ){0.267339, 107}
Timing( Count(MapParallel(IsPrime, testlist), True) ){0.0458072, 107}
Matching(exp, pat)Matching(123, ?Integer)
Matching(123.0, ?Integer)True
False
Matching({a, b, c}, {??Symbol})
Matching({a, 2, b}, {??Symbol})True
False
Matching({10, 11}, {x?, x?})
Matching({10, 10}, {x?, x?})False
True
Matching({2, 1}, {x?, y?} /? x>y )
Matching({1, 2}, {x?, y?} /? x>y )True
False
Mod(m, n)Mod(7, 3)1
Mod(4.0, 1.2)0.4
Mod(5/9, 1/2)1/18
Mod(10, 5^(1/2))10 - 4*5^(1/2)
Mod(14*a^2, 3*a^2)2*a^2
Mod(7, 3)1
Mod(-7, 3)2
Mod(7, -3)-2
Mod(-7, -3)-1
Nest(f, exp, n)Nest(f, x, 4)f(f(f(f(x))))
Nest(Function((#+1)^2), x, 3)(1 + (1 + (1 + x)^2)^2)^2
Cos(0.739085)0.739085
Nest(Function(1.02*#), 100.0, 10)121.899
100.0 * 1.02^10121.899
Not(bool)!boolNot(int)!intNot(str)!str! 15-16
! 'BINARY''½¶±¾¦'
Not( x < 3 )x >= 3
Not( x == 3 )x != 3
NullNumerator(z)Numerator(3/7)3
Numerator(-8/3)-8
Numerator(123)123
Numerator(3.4)3.4
Numerator(f/g)f
Numerator(a^2*b^(-3)*c^4)a^2*c^4
Options(sym1 -> val1, sym2 -> val2, … )Options(sym1 :> val1, sym2 :> val2, … )f(Options(x->1, y->2)) := {x, y}
f()
f(x->100)
f(y->100)
f(y->100, x->99){1, 2}
{100, 2}
{1, 100}
{99, 100}
f(Options(x->0)) := {x, x, x, x, x}
f()
f(x->Random(10))
f(x:>Random(10)){0, 0, 0, 0, 0}
{1, 1, 1, 1, 1}
{0, 6, 3, 7, 1}
Or(bool1, bool2, … )bool1 || bool2 || …Or(int1, int2, … )int1 || int2 || …Or(str1, str2, … )str1 || str2 || …12 || 715
'BINARY' || 'abc''ckoARY'
(Print(1);False) || True || (Print(2);False)1True
1==2 || a==5 || b==10 || Falsea == 5 || b == 10
Order(exp1, exp2)| Integern, Rationala/b and Realx numbers are ordered by their numerical value. |
| Complexx+y*I numbers are ordered by their real part and then by their imaginary part. |
| String"…",'…' are ordered using the Unicode collation algorithm. |
| Numerical values are ordered before String"…",'…', Symbols and Expressionf(…). |
a + c + ba + b + c
f(1, b, 2, a)f(1, b, 2, a)
Matching( f(x, 2) , f(?Integer, x) )False
Attributes(f) = Orderless{Orderless}
f(1, b, 2, a)f(1, 2, a, b)
Part(exp, level1, level2, … )exp[level1, level2, … ]Part(str, part)str[part] …[n] | gives the nth element of an expression or the nth character of a string. |
…[-n] | counts from the end of the expression or the string. |
…[0] | gives the head of an expression or the string. |
…[{n1, n2, … }] | gives the expression with elements specified by ni or the string with characters specified by ni. |
…[m..n] | gives the expression with a span of elements or the string with characters from m until n. |
…[m..n..s] | gives a span of elements or characters from m until n in steps of s, where s can also be negative. |
…[All] | gives the expression with all elements in this level or the string with all characters. |
"Hello World!"[-1]"!"
{a,b,c,d,e}[{-1,3,3}]{e, c, c}
"Hello World!"[{1,8,3,-2}]"Hold"
{a,b,c,d,e}[2..-2]{b, c, d}
{a,b,c,d,e}[-1..1..-1]{e, d, c, b, a}
Part( "Hello World!" , 1..7..2 )"HloW"
{{a1,a2}, {b1,b2}, {c1,c2}}[All, 2]{a2, b2, c2}
Part( a+b*x+x^2 , 2, 1)b
f(1, 2, x, 4, y)[3..5]f(x, 4, y)
Part( 3/4 , 1 )
Numerator( 3/4 )(3/4)[1]
3
Part( 2+3*I , 1 )
Re( 2+3*I )(2+3*I)[1]
2
Part( a+c+b , 2)
a+c+b // InternalFormb
Plus(a, b, c)
Part( (a*b)*(c*d) , 2)
(a*b)*(c*d) // InternalFormb
Times(a, b, c, d)
Partition(str, n)Partition(exp, n)Partition( {1, 2, 3, 4, 5, 6} , 3 ){{1, 2, 3}, {4, 5, 6}}
Partition( {1, 2, 3, 4, 5, 6} , 4 ){{1, 2, 3, 4}}
Partition( "Hello World!" , 3 ){"Hel", "lo ", "Wor", "ld!"}
Partition( "Hello World!" , 5 ){"Hello", " Worl"}
Partition( f(1,2,3,4) , 2 )f(f(1, 2), f(3, 4))
Pattern(sym, pat)sym?
sym??
sym???sym?head
sym??head
sym???headf(x?, y?) := x ^ y
f(a, 2)a^2
g(x??) := Times(x)
g(3)
g(4, 5)
g(a, 6, x^2)3
20
6*a*x^2
h(Pattern(x, ?Integer|Infinity)) := x^2
{ h(1), h(-5), h(Infinity), h(3.14) }{1, 25, Infinity, h(3.14)}
Replace( {2, 3, x} , x? :> x^2 ){4, 9, x^2}
Replace( {1, 2, a, b, c, 3.14} , Pattern(x, a|b) :> x^3 ){1, 2, a^3, b^3, c, 3.14}
PiCalculate(Pi, 70)3.141592653589793238462643383279502884197169399375105820974944592307816
2.0*Pi6.28319
2 ^ 1001267650600228229401496703205376
5 ^ (-2)1/25
27 ^ (1/3)
10 ^ (1/3)3
10^(1/3)
10 ^ (1/3) // Calculate
10.0 ^ (1/3)2.15443
2.15443
2.5 ^ 10008.709809816217e397
{2, 3, 4} ^ 2{4, 9, 16}
{2, 10} ^ {4, 3}{16, 1000}
0^(-1)ComplexInfinity
10.0 ^ (10.0^20.0)Overflow
0.5 ^ (10.0^20.0)Underflow
Precision(z)Precision(3.14)MachinePrecision
Precision(123456.78901234567890)20.0915
Precision(4.0 + 3*I)MachinePrecision
Print(exp1, exp2, …, explast )Print(1, 2, 3)1233
Print("String are shown\r\nwith line breaks\tand tabs.")String are shown
with line breaks and tabs."String are shown\r\nwith line breaks\tand tabs."
Print(Hello, World, Null)HelloWorld
ProtectedPi = 33
x = 123123
Attributes(x) = Protected{Protected}
x = 00
x123
QuitKernels()QuitKernels(n)QuitKernels({id1, id2, … })LaunchKernels(8){1, 2, 3, 4, 5, 6, 7, 8}
QuitKernels(3){6, 7, 8}
Kernels(){1, 2, 3, 4, 5}
QuitKernels({2, 5}){2, 5}
Kernels(){1, 3, 4}
QuitKernels(){1, 3, 4}
Kernels(){}
Random(z)Random(z, n)Random(str)Random(str, n)Random(list)Random(list, n)Random(7)6
Random(30!)127744442400524630741569973393108
Random(2/3)0
Random(2.0)1.46042
Random(1.0+2.0*I)0.303707+1.77864*I
Random("abcdefgh")"d"
Random( {a, b, c} )c
Random( 9, 10 ){0, 6, 5, 4, 3, 3, 3, 2, 9, 8}
Random( 1.0, 10 ){0.435244, 0.0371735, 0.673563, 0.323152, 0.760165, 0.665368, 0.704443, 0.584308, 0.939667, 0.242821}
Random( {True, False}, 10 ){False, True, True, False, True, False, True, True, True, False}
Random("ABC", 20)"CCBBBCACCABACAACCCAA"
Random("---|", 40)"---------||----|--|-||-----|-|------|-|-"
Random('', 32)'¼øÚ÷àï\x80n÷\x7F«-\x89´\x11%4\x85«GÕr,NÇrj\x9C\x81BxÆ'
Rational(a, b)a/bRational3/73/7
Rational(3, 7)3/7
5 + 1/316/3
1/123456 + 1/678901802357/83814401856
4/121/3
6/23
(2/3)^1001267650600228229401496703205376/515377520732011331036461129765621272702107522001
Log(2, 1/8)-3
Bernoulli(10)5/66
Rationalize -> FalseRationalize -> TrueShiftRight(15)
ShiftRight(15, Rationalize->False)
ShiftRight(15, Rationalize->True)7
7
15/2
ShiftRight(4, 5)
ShiftRight(4, 5, Rationalize->True)0
1/8
xReal4.0 * 0.72.8
1 + 2.03.0
1/3 + 1.01.33333
1.0000000000000000000000000000000000000000123 + 1011.0000000000000000000000000000000000000000123
123.456 ^ 1000.03.25238259113e2091
0.012 ^ 1000.01.517910089172e-1921
Precision(123.456)MachinePrecision
Precision(789.456e123)MachinePrecision
x = 123.456 ^ 1000.0
y = 123.000000000000000000004567893.25238259113e2091
123.00000000000000000000456789
{ Precision(x) , Precision(y) }{12.4798, 29.0899}
x ^ y1.0018442638e257256
Precision(x^y)10.3898
123.456 ^ (10^100)Overflow
123.456 ^ (-10^100)Underflow
Replace(exp, rule)exp /: ruleReplace(exp, {r1, r2, … })exp /: {r1, r2, … }Replace(exp, rule, depth)Replace(str, a->b )str /: a->bReplace(str, {a1->b1, a2->b2, … } )str /: {a1->b1, a2->b2, … }x^2 + x /: x->420
{x+y, x*y, x^y} /: {x->2, y->3}{5, 6, 8}
x^2 /: {2->x, x->2}2^x
{x, x, {x, x, {x, x}}, x} /: x->0{0, 0, {0, 0, {0, 0}}, 0}
Replace( {x, x, {x, x, {x, x}}, x} , x->0 , 2 ){0, 0, {0, 0, {x, x}}, 0}
a+b+c+d /: a+d -> xb + c + x
{a, b, 1, 2, 3.0, 0.4, "Hello", "World"} /: ?Real -> 0{a, b, 1, 2, 0, 0, "Hello", "World"}
{1, 2, Pi, 4, -5} /: Condition( x?, x>3) :> -x{1, 2, -Pi, -4, -5}
"Hello World!" /: "World" -> "User""Hello User!"
"AB_AABB" /: {"A"->"B", "B"->"A"}"BA_BBAA"
{x, y, z} /: {x->y, y->z, z->0}{y, z, 0}
{x, x, x, x, x} /: x -> Random(10){0, 0, 0, 0, 0}
{x, x, x, x, x} /: x :> Random(10){1, 10, 3, 7, 9}
f(2, 3, 4) /: x? -> x^2f(2, 3, 4)^2
f(2, 3, 4) /: x?Integer -> x^2f(4, 9, 16)
Replace(x+y, { x->2, y->4 } )6
Replace(a+b+c+d, b+c -> 4 )4 + a + d
Replace({1, 2.0, 3, 4.0, 5}, ?Integer -> Null ){Null, 2.0, Null, 4.0, Null}
Replace({1, 2.0, 3, 4.0, 5}, x?Integer -> x^2 ){1, 2.0, 9, 4.0, 25}
x = 44
x?Integer -> x^2Pattern(x, ?Integer) -> 16
Replace({2, 3, 4}, x?Integer -> x^2 ){16, 16, 16}
Replace({1, x, 2, x, 3, x}, x :> Random(1000) ){1, 357, 2, 319, 3, 997}
123 === "text"False
x === yFalse
f(5) === f(5)True
Overflow === Overflow
Overflow == OverflowTrue
Overflow == Overflow
x === 2
Replace( x === 2 , x->2 )False
False
x == 2
Replace( x == 2 , x->2 )x == 2
True
A === aFalse
Scope(sym, body)Scope({sym1, sym2, … }, body)x = 123; a=3; b=44
Scope({x, y},
x=a+b; y=a-b;
x/y )-7
{x, y, a, b}{123, y, 3, 4}
Scope({z=2, w=3}, z*w )6
{z, w}{z, w}
Scope(f(x?) := x^2, {f(5), f(y)} ){25, y^2}
f(5)f(5)
Scope(x, x+y )x$4 + y
Sec(z)Sec(2.0)-2.403
Calculate(Sec(2), 70)-2.402997961722380989754600401420066226245121093154526013044400970212074
Sec(2.0+3.0*I)-0.041675+0.0906111*I
Sec(0)1
Sech(z)Sech(2.0)0.265802
Calculate(Sech(2), 70)0.2658022288340796921208627398198889715307826544322680697146411474667245
Sech(2.0+3.0*I)-0.263513-0.0362116*I
Sech(0)1
Select( {1,2,3,4,5,6,7} , IsEven )
Select( {1,2,3,4,5,6,7} , IsPrime ){2, 4, 6}
{2, 3, 5, 7}
Select( {"Hello", x+y, 4, 3+I, "World!", z} , Matching(#, ?String) & ){"Hello", "World!"}
check(x?) := x^2 < 6
Select( {1, 2, 3, 4, y, 2.2}, check ){1, 2, 2.2}
Sequence(arg1, arg2, … )func(Sequence(a, b, c), d)func(a, b, c, d)
arg = Sequence(2,4,6)
Plus(arg)
Times(arg)Sequence(2, 4, 6)
12
48
f(1, 2, 3) /: f(x??) :> xSequence(1, 2, 3)
f(1, 2, 3) /: 2 -> Sequence()f(1, 3)
Attributes(Define){HoldFirst, Locked, Protected, SequenceHold}
Attributes(h) = {SequenceHold}{SequenceHold}
h(x?, y?:0) := {{x}, {y}} /* h has the attribute SequenceHold */
f(x?, y?:0) := {{x}, {y}} /* f hasn't the attribute SequenceHold */
h(Sequence(1, 2)) /* Sequence(1, 2) holds and is passed as x */
f(Sequence(1, 2)) /* Sequence(1, 2) is expanded and is passed as x and y */{{1, 2}, {0}}
{{1}, {2}}
SetAttributes(s, attr)SetAttributes(s, {attr1, attr2, … } )f(1, f(2, 3))f(1, f(2, 3))
SetAttributes(f, Flat){Flat}
f(1, f(2, 3))f(1, 2, 3)
SetAttributes(f, {Orderless, HoldAll}){HoldAll, Orderless}
Attributes(f){Flat, HoldAll, Orderless}
ShiftLeft(z)ShiftLeft(z, k)| Rationalize | Handling of integers when bits would be dropped. The default value is False. |
ShiftLeft(32)64
ShiftLeft(32, 4)512
ShiftLeft(32, -2)8
ShiftLeft(2.5, 2)10.0
ShiftLeft(2/7, 3)16/7
ShiftLeft('ABC', 4)'\x10$4'
ShiftLeft(6, -2)1
ShiftLeft(6, -2, Rationalize->True)3/2
ShiftLeft('ABCDEFGH', 32)'\0\0\0\0ABCD'
ShiftRight(z)ShiftRight(z, k)| Rationalize | Handling of integers when bits would be dropped. The default value is False. |
ShiftRight(32)16
ShiftRight(32, 4)2
ShiftRight(32, -2)128
ShiftRight(2.5, 2)0.625
ShiftRight(2/7, 3)1/28
ShiftRight('ABC', 4)'$4\x04'
ShiftRight(6, 2)1
ShiftRight(6, 2, Rationalize->True)3/2
ShiftRight('ABCDEFGH', 32)'EFGH\0\0\0\0'
Sign(z)Sign(-123)-1
Sign(2.5)1
Sign(1.2 + 3.4*I)0.33282+0.94299*I
Sin(z)Sin(2.0)0.909297
Calculate(Sin(2), 70)0.9092974268256816953960198659117448427022549714478902683789730115309673
Sin(2.0+3.0*I)9.1545-4.16891*I
Sin(0)0
Sinh(z)Sinh(2.0)3.62686
Calculate(Sinh(2), 70)3.626860407847018767668213982801261704886342012321135721309484474934250
Sinh(2.0+3.0*I)-3.59056+0.530921*I
Sinh(0)0
Sort(list)Sort(list, cmp)| True | e1 and e2 are in order |
| False | e1 and e2 are out of order |
| 1 | e1 comes before e2 |
| -1 | e1 comes after e2 |
| 0 | e1 and e2 are identical |
Sort({ "Hello", x+y, 4, 3+I, z}){3+I, 4, "Hello", x + y, z}
Sort( f(3,1,2) )f(1, 2, 3)
Sort( {-3, 2, -1, 0, Pi, 4} ){-3, -1, 0, 2, 4, Pi}
Sort( {-3, 2, -1, 0, Pi, 4}, GreaterEqual ){4, Pi, 2, 0, -1, -3}
Sort( {-3, 2, -1, 0, Pi, 4}, Abs(#1) <= Abs(#2) & ){0, -1, 2, -3, Pi, 4}
Sort({"NINO", "Nina", "Nino", "Ninu", "Niño"}){"Nina", "Nino", "NINO", "Niño", "Ninu"}
Sort({"Hello", "Foo", "Baa", "World", "!"}, Length(#1) <= Length(#2) & ){"!", "Foo", "Baa", "Hello", "World"}
Split(str, del)Split(exp, el)Split( "Grumpy wizards make toxic brew for the evil Queen and Jack" , " " ){"Grumpy", "wizards", "make", "toxic", "brew", "for", "the", "evil", "Queen", "and", "Jack"}
Split( "Hello\r\nWorld!" , "\r\n" ){"Hello", "World!"}
Split( {1, 2, 0, 3, 4, 0, 5, 6} , 0 ){{1, 2}, {3, 4}, {5, 6}}
"…"'…'String| \0 | NUL | \f | FF |
| \a | BEL | \r | CR |
| \b | BS | \" | " |
| \t | TAB | \' | ' |
| \n | LF | \\ | \ |
| \v | VT | \x00 – \xFF | Two-digit hexadecimal code |
"abc αβγ \t ♦♥♠♣ \0 fl""abc αβγ \t ♦♥♠♣ \0 fl"
Head("abc αβγ \t ♦♥♠♣ \0 fl")String
'\0\0ÿ7)<''\0\0ÿ7)<'
"Hello " + "World!""Hello " + "World!"
"Hello " ~ "World!""Hello World!"
'Cost: ' ~ "10 €"'Cost: 10 â\x82¬'
SubDefine(lhs, rhs)lhs @= rhsf(beta) @= 22
Definitions(f)/* no definitions */
Definitions(beta)f(beta) @= 2
{ f(alpha), f(beta), f(123) }{f(alpha), 2, f(123)}
off + off @= off; off + on @= on; on + on @= off;
on + off
on + off + onon
off
off + on = on;
f(alpha) = 1
f(alpha) @= 21
2
f(alpha)2
SubDefineDelayed(lhs, rhs)lhs @:= rhsf(a(x?)) @:= x^2
Definitions(f)/* no definitions */
Definitions(a)f(a(Pattern(x, Any))) @:= x^2
{ f(7), f(a(7)), f(a) }{f(7), 49, f(a)}
angle(x?) + angle(y?) @:= angle( Mod(x+y, 360) )
angle(270) + angle(180)angle(90)
angle(x?) + angle(y?) := angle( Mod(x+y, 360) )
f(g(x?)) := x^2
f(g(x?)) @:= x*2
f(g(10))20
3 - 21
2*x - 3*x-x
2 - 1/4
2 - 0.257/4
1.75
sSymbolfoo + foo2*foo
x = 123
y = 4123
4
{ x+y, x*y, x^y }{127, 492, 228886641}
φ = a*b^2a*b^2
{ φ , φ/b }{a*b^2, a*b}
ToSymbol("world")world
Var = 123123
{Var, var}{123, var}
Symbols(){Abs, Accuracy, All, Alternatives, And, Any, AnyNullSequence, AnySequence, Apply, ArCosh, ArCoth, ArCsch, ArSech, ArSinh, ArTanh, ArcCos, ArcCot, ArcCsc, ArcSec, ArcSin, ArcTan, Arg, Attributes, Bernoulli, BinaryFormat, Binomial, Boole, Calculate, Ceil, Clear, ClearAttributes, Complement, Complex, ComplexInfinity, ComplexOverflow, ComplexUnderflow, Compound, Condition, Conjugate, Contain, Cos, Cosh, Cot, Coth, Count, Csc, Csch, Define, DefineDelayed, Definitions, Denominator, Depth, DigitBase, DirectedInfinity, Divide, E, Endianness, Equal, Erf, Erfc, EulerMascheroni, Exp, Expand, Factorial, False, Fibonacci, Flat, Flatten, Floor, Function, GoldenAngle, GoldenRatio, Greater, GreaterEqual, HarmonicNumber, Head, Hold, HoldAll, HoldFirst, HoldRest, I, If, Im, Indeterminate, Infinity, Integer, InternalForm, Intersection, IsEven, IsInfinite, IsNumeric, IsOdd, IsOverflow, IsPrime, IsUnderflow, Iterate, IterateParallel, Join, Kernel, KernelID, Kernels, LaunchKernels, Length, Less, LessEqual, List, Listable, Locked, Log, MachinePrecision, Map, MapParallel, Matching, Max, Min, Minus, Mod, Nest, None, Not, Null, Numerator, NumericConstant, NumericFunction, OneIdentity, Optional, Options, Or, Order, Orderless, Output, Overflow, Part, Partition, Pattern, Pause, Pi, Plus, Power, Precision, Print, Protected, QuitKernels, Random, Rational, Rationalize, Re, Real, Replace, Round, Rule, RuleDelayed, Same, Scope, Sec, Sech, Select, Sequence, SequenceHold, SetAttributes, ShiftLeft, ShiftRight, Sign, Sin, Sinh, Slot, Sort, Span, Split, Sqrt, String, SubDefine, SubDefineDelayed, Subtract, Symbol, Symbols, Tan, Tanh, Temporary, Times, Timing, ToInteger, ToReal, ToString, ToSymbol, True, Trunc, Underflow, Unequal, Union, Unsame, Xor}
Complex:
Symbols("Complex*"){Complex, ComplexInfinity, ComplexOverflow, ComplexUnderflow}
Sin:
Symbols("*Sin*"){ArSinh, ArcSin, Sin, Sinh}
Tan(z)Tan(2.0)-2.18504
Calculate(Tan(2), 70)-2.185039863261518991643306102313682543432017746227663164562955869966774
Tan(2.0+3.0*I)-0.00376403+1.00324*I
Tan(0)0
Tanh(z)Tanh(1.0)0.761594
Calculate(Tanh(1), 70)0.7615941559557648881194582826047935904127685972579365515968105001219532
Tanh(2.0+0.5*I)0.979941+0.030216*I
Tanh(0)0
| DigitBase | Base of the digits to parse from a text string. The default base is 10. |
| BinaryFormat | Format, how to parse a binary string. |
| Endianness | Byte order in a binary string. |
ToInteger(5/3)1
ToInteger(-3.1415)-3
ToInteger("12345")12345
ToInteger("FF", DigitBase->16)255
ToInteger('Oa¼\0', BinaryFormat->"Integer32")12345679
ToInteger('\0\0\0@êítFÐ\x9C,\x9F\f')1000000000000000000000000000000
| DigitBase | Base of the digits to parse from a text string. The default base is 10. |
| BinaryFormat | Format, how to parse a binary string. |
ToReal(123)123.0
ToReal(3/5)0.6
ToReal("123.45")123.45
ToReal("FF.8", DigitBase->16)255.5
ToReal('yéöB', BinaryFormat->"float32")123.456
ToString(str)ToString(exp)| BinaryFormat | Format of the string encoding. |
| DigitBase | Base of the digits in a text string. The default base is 10. |
| Endianness | Byte order in a binary string. |
ToString(123)"123"
ToString(3/2)"3/2"
ToString(-3.1415)"-3.141500000000000"
ToString(123.45678901234567890123456789e12345)"1.2345678901234567890123456789e12347"
ToString("yä€𝄞", BinaryFormat->"UTF16")'y\0ä\0¬ 4Ø\x1EÝ'
ToString('y\0\0\0ä\0\0\0¬ \0\0\x1EÑ\x01\0', BinaryFormat->"UTF32")"yä€𝄞"
ToString(10000, DigitBase->2)"10011100010000"
ToString(10^100, DigitBase->36)"2HQBCZU2OW52BALA8LGC3S5Y9MM5TIY0VO9TKE25466GFI6AX8GS22X7KUU8L1TDS"
ToString(1024.0625, DigitBase->16)"400.1000000000"
ToString(123456, BinaryFormat->"Integer32")'@â\x01\0'
ToString(3.1415, BinaryFormat->"Real64")'o\x12\x83ÀÊ!\t@'
ToSymbol("var")var
a = 123;
ToSymbol("a")123
b = "al"; c = "pha"; alpha = 456;
b~c"alpha"
ToSymbol(b~c)456
1 != 2True
1 != 2 != 1False
a != ba != b
1.0000000000000000002 != 1.0000000000000000001False
1.00000000000000000020 != 1.00000000000000000010True
Union(list)Union(list1, list2, … )Union( {4,3,3,1} ){1, 3, 4}
Union( {4,3,3,1} , {2,4,4,5} ){1, 2, 3, 4, 5}
Union( {4,3,3,1} , {2,3.0} , {x} ){1, 2, 3, 3.0, 4, x}
Union( a + b , a + c + d )a + b + c + d
Union( f(1, 2), f(2, 3) )f(1, 2, 3)
123 =!= "text"True
x =!= yTrue
f(5) =!= f(5)False
x =!= y =!= xFalse
x =!= 2
Replace( x =!= 2 , x->2 )True
True
x != 2
Replace( x != 2 , x->2 )x != 2
False
A =!= aTrue
Xor(bool1, bool2, … )bool1 !! bool2 !! …Xor(int1, int2, … )int1 !! int2 !! …Xor(str1, str2, … )str1 !! str2 !! …True !! True
True !! True !! TrueFalse
True
12 !! 711
'BINARY' !! 'abc''#+-ARY'
True !! a > 0a <= 0
| Numbers | 123 , 3.14 | a sequence of decimal digits with an optional decimal point |
| Operators | + , !=, -> | individual defined character groups |
| Symbols | x , φ, var | a sequence of any unicode characters which are not defined as operator |
| Strings | "yä€𝄞" , '\0\0\0ÿ' | a sequence of unicode or binary characters |
| Expressions | head(arg1, arg2) | a function with a head and arguments |
| Comments | /* no code */ | not interpreted code blocks |
f(x) | f(x) | Expressionf(…) |
f(x)(y) | (f(x))(y) | Expressionf(…) |
f[x] | Part(f, x) |
f[x][y] | Part(Part(f, x), y) |
f[x,y,…] | Part(f, x, y, …) |
{x, y, …} | List(x, y, …) |
"x" | String"…",'…' | |
'x' | String"…",'…' |
?h | Any(h) |
??h | AnySequence(h) |
???h | AnyNullSequence(h) |
s?h | Pattern(s, Any(h)) |
s??h | Pattern(s, AnySequence(h)) |
s???h | Pattern(s, AnyNullSequence(h)) |
f @ g @ x | f(g(x)) | Expressionf(…) |
f @@ g @@ x | Apply(f, Apply(g, x)) |
f /@ g /@ x | Map(f, Map(g, x)) |
x! | Factorial(x) |
x ~ y ~ … | Join(x, y, …) |
x ^ y ^ z | Power(x, Power(y, z)) |
x * y * … | Times(x, y, …) |
x / y / z | Divide(Divide(x, y), z) |
-x | Minus(x) |
x + y + … | Plus(x, y, …) |
x - y - z | Subtract(Subtract(x, y), z) |
x == y == … | Equal(x, y, …) |
x != y != … | Unequal(x, y, …) |
x < y < … | Less(x, y, …) |
x <= y <= … | LessEqual(x, y, …) |
x > y > … | Greater(x, y, …) |
x >= y >= … | GreaterEqual(x, y, …) |
x === y === … | Same(x, y, …) |
x .. y .. … | Span(x, y, …) |
!b | Not(b) |
x || y || … | Or(x, y, …) |
x && y && … | And(x, y, …) |
x !! y !! … | Xor(x, y, …) |
x | y | … | Alternatives(x, y, …) |
x /? y /? f | Condition(x, Condition(y, f)) |
x : y : z | Optional(Optional(x, y), z) |
x -> y -> z | Rule(x, Rule(y, z)) |
x :> y :> z | RuleDelayed(x, RuleDelayed(y, z)) |
x /: y /: z | Replace(Replace(x, y), z)) |
x // f // g | f(g(x)) | Expressionf(…) |
f & | Function(f) |
x = y = z | Define(x, Define(y, z)) |
x := y := z | DefineDelayed(x, DefineDelayed(y, z)) |
x @= y @= z | SubDefine(x, SubDefine(y, z)) |
x @:= y @:= z | SubDefineDelayed(x, SubDefineDelayed(y, z)) |
x ; y ; … | Compound(x, y, …) |
x , y , … | Sequence(x, y, …) |