AAbsAllAlternativesAndAnyAnyNullSequenceAnySequenceApplyArcTanArgAttributes
CCalculateCeilComplexComplexInfinityComplexOverflowComplexUnderflowCompoundConditionCosCosh
DDefinitionsDepthDigitBaseDirectedInfinityDivide
FFactorialFalseFlatFloorFunction
HHead
IIIfIndeterminateInfinityInteger
JJoin
LLengthLessLessEqualListListableLockedLog
MMachinePrecisionMapMatchingMinusMod
OOptionalOptionsOrOrderOrderlessOutputOverflow
PPartPartitionPatternPiPlusPowerPrecisionPrintProtected
RRandomRationalRealReplaceRuleRuleDelayed
SSameScopeSelectSequenceSetSetDelayedSinSinhSlotSortSpanStringSubtractSymbol
TTableTimesToIntegerToRealToStringToSymbolTrueTrunc
XXor
Abs(z)
Abs(-123)
123
Abs(1.2 + 3.4*I)
3.60555
Abs(3+4*I)
5
Abs(Sin(4))
-Sin(4)
-Sin(4) // Calculate
0.756802
Abs(-2*x)
2*Abs(x)
Abs(x^3)
Abs(x)^3
All
Part( {{a1,a2}, {b1,b2}, {c1,c2}} , All, 1 )
{a1, b1, c1}
Matching( a, a|b )
True
Replace( {a, b, c, a, b, c} , a|b -> 0 , All )
Replace({a, b, c, a, b, c}, Alternatives(a, b) -> 0, All)
f(?Rational|?Integer) = "exact";
{ f(1), f(1.0), f(1/2) }
{"exact", f(1.0), "exact"}
And(bool1, bool2, … )
bool1 && bool2 && …
And(int1, int2, … )
int1 && int2 && …
And(str1, str2, … )
str1 && str2 && …
True && False
False
12 && 7
4
'BINARY' && 'abc'
'@@B'
(Print(1);True) && False && (Print(2);True)
1
False
2==2 && a==5 && b==10 && True
a == 5 && b == 10
Any
?
Any(head)
?head
Matching( f(123), Any )
True
Matching( 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*?
False
True
AnyNullSequence
???
AnyNullSequence(head)
???head
Matching( f(), f(AnyNullSequence) )
True
Matching( f(x, y), f(AnySequence(Symbol)) )
True
f(???Real) = "real";
{ f(), f(1.0), f(1.0, 2.0), f(1) }
{"real", "real", "real", f(1)}
AnySequence
??
AnySequence(head)
??head
Matching( f(1, 2, 3), f(AnySequence) )
True
Matching( f(x, y), f(AnySequence(Symbol)) )
True
f(??Real) = "real";
{ f(1), f(1.0), f(1.0, 2.0), f(1, 0.5) }
{f(1), "real", "real", f(1, 0.5)}
Apply(g, f(1, a, x))
g(1, a, x)
Apply(Plus, {2, 3, 4})
9
Apply(Times, a+b+c)
a*b*c
Apply(f, a+b)
f(a, b)
Apply( {#1^#2, #2^#1} & , {3, 2} )
{9, 8}
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)
1/4*Pi
ArcTan(3^(1/2))
1/3*Pi
ArcTan(Infinity)
1/2*Pi
ArcTan(1, 1)
1/4*Pi
ArcTan(-1, 0)
Pi
ArcTan(-1.0, -3.0)
-1.89255
Arg(z)
Arg(1.2 + 3.4*I)
1.2315
Arg(-123)
Pi
Arg(1+I)
1/4*Pi
Arg(2.5)
0
Arg(-2*x)
Arg(-x)
Arg(x^(1/3))
1/3*Arg(x)
Arg(Abs(z))
0
Attributes(s)
Attributes(s) = attr
Attributes(s) = {attr1, attr2, …}
Attributes(Plus)
{Flat, Listable, NumericFunction, OneIdentity, Orderless, Protected}
f(1, z, f(a, 2))
f(1, z, f(a, 2))
Attributes(f) = {Orderless, Flat}
{Orderless, Flat}
f(1, z, f(a, 2))
f(1, 2, a, z)
Attributes(g) = Listable
g(x?) := "<" ~ ToString(x) ~ ">"
Listable
g(7)
g({-1,2,a})
"<7>"
{"<-1>", "<2>", "<a>"}
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
Calculate(exp)
Calculate(exp, n)
Log(-5)
Log(-5)
Log(-5) // Calculate
1.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 // Precision
21.6803
Calculate(Exp(1/10^100)-1, 30)
0.e-61
Ceil(x)
Ceil(2.1)
3
Ceil(-2.9)
-2
Ceil(3/8)
1
Ceil(1.2 + 3.8*I)
2+4*I
Ceil(Log(10))
3
Ceil(Overflow)
Overflow
Ceil(Underflow)
1
Ceil(-Underflow)
0
x + y*I
Complex
Head(1+2*I)
Complex
(1-I)^3
-2-2*I
1/2 + 0.4*I
1/2+0.4*I
ComplexInfinity
1 / ComplexInfinity
0
1 / 0
ComplexInfinity
Log(ComplexInfinity)
Infinity
ComplexOverflow
(7.0+4.0*I) ^ Exp(100.0)
ComplexOverflow
3.14 + ComplexOverflow
ComplexOverflow
ComplexOverflow * (-2)
ComplexOverflow
Abs( ComplexOverflow )
Overflow
Arg( ComplexOverflow )
Indeterminate
ComplexUnderflow
(7.0+4.0*I) ^ (-Exp(100.0))
ComplexUnderflow
3.14 + ComplexUnderflow
3.14+0.0*I
ComplexUnderflow * (-2)
ComplexUnderflow
1 / ComplexUnderflow
Indeterminate
Abs( ComplexUnderflow )
Underflow
Arg( ComplexUnderflow )
Indeterminate
Compound(exp1, exp2, … )
exp1 ; exp2 ; …
exp;
x = 1 ; y = 2 ; x + y
3
z = 10^10000;
Log(10, z)
10000
Condition(pat, cond)
pat /? cond
Matching( 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}
Replace( {-1,2,-3,4,-5,6} , x?Integer :> If(x<0, 0, x) )
{0, 2, 0, 4, 0, 6}
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
Cos(Pi/2)
0
Cos(Pi/3)
1/2
Cos(Pi/4)
1/2^(1/2)
Cos(2*I)
Cosh(2)
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
Cosh(2*I)
Cos(2)
Definitions(s)
Definitions(Plus)
Plus(???) /* 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) = 1
f(2) = 1
f(Condition(Pattern(x, ?), x <= 0)) = 0
f(Pattern(x, ?)) := f(x - 1) + f(x - 2)
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
Depth( 1+2*I )
0
a/b
a/b
Depth( a/b )
2
InternalForm( a/b )
Times(a, Power(b, -1))
ToString(12345, DigitBase->2)
"11000000111001"
ToString(10^100, DigitBase->36)
"2HQBCZU2OW52BALA8LGC3S5Y9MM5TIY0VO9TKE25466GFI6AX8GS22X7KUU8L1TDS"
ToInteger("FF", DigitBase->16)
255
ToInteger("5yc1s", DigitBase->36)
10000000
ToReal("0.C4", DigitBase->16)
0.765625
DirectedInfinity()
DirectedInfinity(z)
DirectedInfinity(1.0+I) * DirectedInfinity(I)
DirectedInfinity(-0.707107+0.707107*I)
4 / 2
2
x^5 / x^2
x^3
4 / 6
4.0 / 6
2/3
0.666667
E
Calculate(E)
2.71828
Calculate(E, 70)
2.718281828459045235360287471352662497757247093699959574966967627724077
2*E
2*E
2.0*E
5.43656
Log(E)
1
Endianness -> -1
Endianness -> 1
ToString(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 == 1
True
3.0 == 3 == 9/3
True
1.0000000000000000002 == 1.0000000000000000001
True
1.000000000000000000200 == 1.000000000000000000100
False
1 == 1.0
1 === 1.0
True
False
Overflow == Overflow
Overflow === Overflow
Overflow == Overflow
True
a == b
a == b
head(arg1, arg2, … )
head @ arg
arg // head
Head( func(a, b) )
func
Head( h(y)(a, b) )
h(y)
func @ 123
func(123)
123 // func
func(123)
f(1) = 2
f(foo) = 3
f("bar") = 4
2
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(I) }
{49, a^2, -1}
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)
(2.1+0.4*I)!
1.97507+0.802929*I
False
1 == 2
False
Not(False)
True
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)}
Floor(x)
Floor(-2.1)
-3
Floor(2.9)
2
Floor(7/8)
0
Floor(1.2 + 3.8*I)
1+3*I
Floor(Log(10))
2
Floor(Overflow)
Overflow
Floor(Underflow)
0
Floor(-Underflow)
-1
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}
2 > 1
True
1/3 > 0 > -0.5
True
x > 2 > 2
False
2 > 1 > x
1 > x
Sin(2) > 0
True
GreaterEqual(x1, x2, … )
x1 >= x2 >= …
2 >= 1
True
3/2 >= 1.5 >= -0.5
True
x >= 1 >= 2
False
2 >= 1 >= x
1 >= x
Sin(2) >= 0
True
Head(exp)
Head( f(a, b) )
f
Head( 123 )
Integer
Head( a * b )
Times
a/b
Head(a/b)
a/b
Times
InternalForm(a/b)
Times(a, Power(b, -1))
I
I // Head
Complex
I * I
-1
(-4)^(1/2)
2*I
x = 3; If(x!=0, 1.0/x, "Div 0")
0.333333
x = 0; If(x!=0, 1.0/x, "Div 0")
"Div 0"
If(a==b, 1, 2)
If(a == b, 1, 2)
If(a==b, 1, 2, 3)
3
Indeterminate
0 / 0
Indeterminate
0 ^ 0
Indeterminate
Infinity - Infinity
Indeterminate
Infinity
1 / Infinity
0
Log(0)
-Infinity
E^(-Infinity)
0
n
Integer
Head(123)
Integer
32845723658234756 * 346594876456456546
11384159533448787206618577180912776
11384159533448787206618577180912776 / 346594876456456546
32845723658234756
3^200
265613988875874769338781322035779626829233452653394495974574961739092490901302182994384699044001
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)
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
Length( 1+2*I )
0
Minus(x)
-x
Length( -x )
2
InternalForm( -x )
Times(-1, x)
1 < 2
True
-0.5 < 0 < 1/3
True
x < 2 < 2
False
1 < 2 < x
2 < x
Sin(4) < 0
True
1 <= 2
True
-0.5 <= 1.5 <= 3/2
True
x <= 2 <= 1
False
1 <= 2 <= x
2 <= x
Sin(4) <= 0
True
List( 1, 2, 3 )
{1, 2, 3}
{{a1,a2}, {b1,b2}}
{{a1, a2}, {b1, b2}}
{a, b} + {c, d}
{a + c, b + d}
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
Flat
Attributes(f) = {Flat, Locked}
{Flat, Locked}
Attributes(f) = {Orderless}
{Orderless}
Attributes(f)
{Flat, Locked}
Log(1000.0)
6.90776
Log(-3.14)
1.14422+3.14159*I
Log(3.0+2.0*I)
1.28247+0.588003*I
Calculate(Log(100), 70)
4.605170185988091368035982909368728415202202977257545952066655801935145
Log(E)
1
Log(0)
-Infinity
Log(10, 1000)
3
Log(4.5, 4.5^100000)
1.0e5
Log(2/3, 16/81)
4
Log(1/4, 8)
-3/2
Log(2, 100)
Log(100)/Log(2)
MachinePrecision
Calculate(MachinePrecision)
15.9546
Precision(3.1415)
MachinePrecision
Precision(789.456e123)
MachinePrecision
Precision(123.4e5678)
15.9546
Map(f, g(1, a, x))
g(f(1), f(a), f(x))
Map(Cos, Pi+b+c)
-1 + Cos(b) + Cos(c)
#^2 & /@ {4, 9, a, 0.4}
{16, 81, a^2, 0.16}
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
Minus(123)
-123
Minus(a+b+c)
-a - b - c
Mod(m, n)
Mod(7, 3)
1
Mod(-7, 3)
2
Mod(4.0, -1.2)
-0.8
Mod(5/9, 1/2)
9/10
Mod(Pi, 2)
-2 + Pi
Mod(7*Pi, 2*Pi)
Pi
Mod(10, 5^(1/2))
10 - 4*5^(1/2)
Not(bool)
!bool
Not(int)
!int
Not(str)
!str
! False
True
! 15
-16
! 'BINARY'
'½¶±¾¦'
Not( x < 3 )
x >= 3
Not( Not( exp ) )
exp
Null
Null
x := 1
z = 3;
{1, Print(2), z}
2
{1, Null, 3}
Matching( {1, 2}, {x?, y?:0} )
Matching( {1}, {x?, y?:0} )
True
True
f(x?, y?:2) := x^y
f(a, b)
f(a)
a^b
a^2
g(n?Integer:0, str?String ) := {n, str}
g("Text")
g(10, "Text")
{0, "Text"}
{10, "Text"}
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}
{3, 3, 3, 3, 3}
{7, 10, 1, 10, 0}
Or(bool1, bool2, … )
bool1 || bool2 || …
Or(int1, int2, … )
int1 || int2 || …
Or(str1, str2, … )
str1 || str2 || …
True || False
True
12 || 7
15
'BINARY' || 'abc'
'ckoARY'
(Print(1);False) || True || (Print(2);False)
1
True
1==2 || a==5 || b==10 || False
a == 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(…). |
Order(123, var)
1
Order("b", "a")
-1
Order(x^2, x^2)
0
a + c + b
a + 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)
Matching( f(x, 2) , f(?Integer, x) )
True
1+2
3*4
5^6
3
12
15625
f(Output(1,2,3))
f(1
2
3)
Overflow
Exp(10.0^20.0)
Overflow
3.14 + Overflow
Overflow
Overflow * (-2)
-Overflow
3.14 / Overflow
Underflow
ArcTan(Overflow)
1.5708
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. |
Part( {a,b,c,d,e} , 3 )
c
"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( a+c+b , 2)
a+c+b//InternalForm
b
Plus(a, b, c)
Part( (a*b)*(c*d) , 2)
(a*b)*(c*d)//InternalForm
b
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) , 1 )
f(f(1), f(2), f(3))
Pattern(sym, pat)
sym?
sym??
sym???
sym?head
sym??head
sym???head
f(x?, y?) := x ^ y
f(a, b)
a^b
g(Pattern(x, ?Integer|Infinity)) := x^2
{ g(1), g(-5), g(Infinity), g(3.14) }
{1, 25, Infinity, g(3.14)}
Pi
Calculate(Pi)
3.14159
Calculate(Pi, 70)
3.141592653589793238462643383279502884197169399375105820974944592307816
2*Pi
2*Pi
2.0*Pi
6.28319
Cos(Pi)
-1
Log(-1)
I*Pi
ArcTan(Infinity)
1/2*Pi
1 + 2 + 3
6
2*x + 3*x
5*x
2 + 1/4
2 + 0.25
9/4
2.25
(a + c) + (b + 4)
4 + a + b + c
{1, 2, 3} + 10
{11, 12, 13}
{1, 2, x} + {5, 10, y}
{6, 12, x + y}
2 ^ 100
1267650600228229401496703205376
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 ^ 1000
8.709809816217e397
{2, 3, 4} ^ 2
{4, 9, 16}
{2, 10} ^ {4, 3}
{16, 1000}
0^0
Indeterminate
0^(-1)
ComplexInfinity
10.0 ^ (10.0^20.0)
Overflow
0.5 ^ (10.0^20.0)
Underflow
Precision( z )
Precision(123)
Infinity
Precision(3/7)
Infinity
Precision(3.14)
MachinePrecision
Precision(123456.78901234567890)
20.0915
Precision(4.0 + 3*I)
MachinePrecision
Print(1, 2, 3)
1
2
3
Print("String are shown\r\nwith line breaks\tand tabs.")
String are shown
with line breaks and tabs.
Protected
Pi = 3
3
x = 123
123
Attributes(x) = Protected
Protected
x = 0
0
x
123
Random(z)
Random(list)
Random(7)
3
Random(2/3)
2/3
Random(2.0)
1.84223
Random(1.0+2.0*I)
0.447681+1.13909*I
Random( {a, b, c} )
a
Table( Random(9), 10 )
{2, 3, 8, 7, 3, 1, 8, 1, 3, 6}
a/b
Rational
Head(1/2)
Rational
4/12
1/3
1/123456 + 1/678901
802357/83814401856
x
Real
Head(1.0)
Real
4.0 * 0.7
2.8
1 + 2.0
3.0
1/3 + 1.0
1.33333
1.0000000000000000000000000000000000000000123 + 10
11.0000000000000000000000000000000000000000123
123.456 ^ 1000.0
3.25238259113e2091
0.012 ^ 1000.0
1.517910089172e-1921
Precision(123.456)
MachinePrecision
Precision(789.456e123)
MachinePrecision
x = 123.456 ^ 1000.0
y = 123.00000000000000000000456789
3.25238259113e2091
123.00000000000000000000456789
{ Precision(x) , Precision(y) }
{12.4795, 29.0899}
x ^ y
1.0018442638e257256
Precision(x^y)
10.3862
123.456 ^ (10^100)
Overflow
Head(Overflow)
Real
123.456 ^ (-10^100)
Underflow
Head(Underflow)
Real
Overflow * Underflow
Indeterminate
Underflow - Underflow
ComplexUnderflow
Replace(exp, rule)
exp /: rule
Replace(exp, {r1, r2, … })
exp /: {r1, r2, … }
Replace(str, a->b )
str /: a->b
x^2 + x /: x->4
20
{x+y, x*y, x^y} /: {x->2, y->3}
{5, 6, 8}
x^2 /: {2->x, x->2}
2^x
a+b+c+d /: a+d -> x
b + c + x
{a, b, 1, 2, 3.0, 0.4, "Hello", "World"} /: ?Real -> 0
{a, b, 1, 2, 0, 0, "Hello", "World"}
"Hello World!" /: "World" -> "User"
"Hello User!"
{x, y, z} /: {x->y, y->z, z->0}
{y, z, 0}
{x, x, x, x, x} /: x -> Random(10)
{4, 4, 4, 4, 4}
{x, x, x, x, x} /: x :> Random(10)
{0, 10, 5, 10, 6}
f(2, 3, 4) /: x? -> x^2
f(2, 3, 4)^2
f(2, 3, 4) /: x?Integer -> x^2
f(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 = 4
4
x?Integer -> x^2
Pattern(x, ?Integer) -> 16
Replace({2, 3, 4}, x?Integer -> x^2 )
{16, 16, 16}
x?Integer :> x^2
Pattern(x, ?Integer) :> x^2
Replace({2, 3, 4}, x?Integer :> x^2 )
{4, 9, 16}
Replace({1, x, 2, x, 3, x}, x :> Random(1000) )
{1, 611, 2, 738, 3, 178}
Replace({2, 3, 4}, x?Integer :> x^3 )
{8, 27, 64}
x === y
False
1 === 1.0
1 == 1.0
False
True
Overflow === Overflow
Overflow == Overflow
True
Overflow == Overflow
Scope(sym, body)
Scope({sym1, sym2, … }, body)
x = 123; a=3; b=4
4
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(x, x+y )
x$3 + y
Select( {"Hello", x+y, 4, 3+I, "World!", z} , Head(#)===String & )
{"Hello", "World!"}
check(x?) := x^2 < 6
Select( {1, 2, 3, 4, y, 2.2}, check )
{1, 2, 2.2}
Select( 1 + w - Pi + x^2 + E, Head(Calculate(#))===Real & )
1 + E - Pi
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??) :> x
Sequence(1, 2, 3)
Set(lhs, rhs)
lhs = rhs
x = 123
123
x*2
246
y = a^2 + b^2
a^2 + b^2
2*y
2*(a^2 + b^2)
{a, b, c} = {123, 3.14, "Test"};
a
b
c
123
3.14
"Test"
f(z?) = z^2 + z
z + z^2
f(9)
f(a+b)
90
16037.4
f(z?, n?) = z^n + z
z + z^n
f(w)
f(w, 5)
w + w^2
w + w^5
x = 3.14
3.14
h(x?) = 2*x
6.28
k(x?) := 2*x
h(a)
k(a)
6.28
246
SetDelayed(lhs, rhs)
lhs := rhs
x := 123
x*2
246
y := a^2 + b^2
2*y
2*(a^2 + b^2)
{a, b, c} := {123, 3.14, "Test"}
a
b
c
123
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 = 2
2
k(q?) := m*q
h(q?) = m*q
2*q
h(a)
k(a)
246
246
m = 5
5
h(a)
k(a)
246
615
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
Sin(Pi/2)
1
Sin(Pi/3)
1/2*3^(1/2)
Sin(Pi/4)
1/2^(1/2)
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
Slot(n)
#n
#
Select( {0,1,2,3,4,5,6,7,8,9} , #<5 & )
{0, 1, 2, 3, 4}
f = Function(#1^#2)
f(a, b)
f(3, 4)
Function(#1^#2)
a^b
81
Sort(exp)
Sort(exp, 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", z, x + y}
Sort( f(3,1,2) )
f(1, 2, 3)
Sort( {-3, 2, -1, 0, 4} )
{-3, -1, 0, 2, 4}
Sort( {-3, 2, -1, 0, 4}, GreaterEqual )
{4, 2, 0, -1, -3}
Sort( {-3, 2, -1, 0, 4}, Abs(#1) <= Abs(#2) & )
{0, -1, 2, -3, 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"}
Span(m, n)
m .. n
Span(m, n, s)
m .. n .. s
"Hello World!"[7..-1]
"World!"
"Hello World!"[-1..-6..-1]
"!dlroW"
"…"
'…'
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)<'
Head('\0\0ÿ7)<')
String
"Hello " + "World!"
"Hello " + "World!"
"Hello " ~ "World!"
"Hello World!"
'Cost: ' ~ "10 €"
'Cost: 10 â\x82¬'
3 - 2
1
2*x - 3*x
-x
2 - 1/4
2 - 0.25
7/4
1.75
s
Symbol
Head(var)
Symbol
x = 123
y = 4
123
4
{ x+y, x*y, x^y }
{127, 492, 228886641}
φ = a*b^2
a*b^2
{ φ , φ/b }
{a*b^2, a*b}
Var = 123
123
{Var, var}
{123, var}
Table(exp, n)
Table(exp, {i, imax} )
Table(exp, {i, imin, imax} )
Table(exp, {x, xmin, xmax, xstep} )
Table(exp, {e, {e1, e2, …, en } } )
Table(exp, spec1, spec2, … )
Table(1, 5)
{1, 1, 1, 1, 1}
Table(Random(9), 10)
{2, 3, 9, 2, 7, 3, 8, 4, 3, 7}
Table(i, {i, 10} )
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Table(i^2, {i, -3, 3} )
{9, 4, 1, 0, 1, 4, 9}
Table(x, {x, 0.5, 0.9, 0.1} )
{0.5, 0.6, 0.7, 0.8, 0.9}
Table(w*2, {w, {1,0.7,t,1/3} } )
{2, 1.4, 2*t, 2/3}
Table(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}}
2 * 3 * 4
24
x^2 * x^3
x^5
2 * 1/4
2 * 0.25
1/2
0.5
(a * c) * (b * 4)
4*a*b*c
{1, 2, 3} * 10
{10, 20, 30}
{1, 2, x} * {5, 10, y}
{5, 20, x*y}
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(3/2)
1
ToInteger(-3.1415)
-3
ToInteger(5+2*I)
5
ToInteger(E)
2
ToInteger(Pi^2)
9
ToInteger("12345")
12345
ToInteger("FF", DigitBase->16)
255
ToInteger('Oa¼\0', BinaryFormat->"Integer32")
12345679
ToInteger('\0\0\0@êítFÐ\x9C,\x9F\f')
1000000000000000000000000000000
ToInteger(Overflow)
ToInteger(Overflow)
ToInteger({1,2,3})
ToInteger({1, 2, 3})
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(5+2*I)
5.0
ToReal(E)
2.71828
ToReal(Pi^2)
9.8696
ToReal("123.45")
123.45
ToReal("FF.8", DigitBase->16)
255.5
ToReal('yéöB', BinaryFormat->"float32")
123.456
ToReal(ComplexOverflow)
Indeterminate
ToReal({1,2,3})
ToReal({1, 2, 3})
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(5+2*I)
"5+2i"
ToString(E)
"E"
ToString(Pi^2)
"Power(Pi, 2)"
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
ToSymbol("1a")
ToSymbol("1a")
ToSymbol("no-var")
ToSymbol("no-var")
True
1 == 1
True
Not(True)
False
Trunc(x)
Trunc(-2.1)
-2
Trunc(2.9)
2
Trunc(-13/8)
-1
Trunc(1.2 + 3.8*I)
1+3*I
Trunc(Log(10))
2
Underflow
Exp(-10.0^20.0)
Underflow
3.14 + Underflow
3.14
Underflow * (-2)
-Underflow
3.14 / Underflow
Overflow
Log(Underflow)
-Overflow
1 != 2
True
1 != Pi != 3.0
True
1.0000000000000000002 != 1.0000000000000000001
False
1.000000000000000000200 != 1.000000000000000000100
True
1 != 1.0
1 === 1.0
False
False
1 != 2 != 1
False
a != b
a != b
Unset(pat)
x = 123
123
x^2
15129
Unset(x)
x^2
x^2
f(10) = 0
f(z?Integer) = 2*z
f(z?) = z^2
0
2*z
z^2
Definitions(f)
f(10) = 0
f(Pattern(z, ?Integer)) = 2*z
f(Pattern(z, ?)) = z^2
Unset(f(z?))
Definitions(f)
f(10) = 0
f(Pattern(z, ?Integer)) = 2*z
Xor(bool1, bool2, … )
bool1 !! bool2 !! …
Xor(int1, int2, … )
int1 !! int2 !! …
Xor(str1, str2, … )
str1 !! str2 !! …
True !! True
True !! True !! True
False
True
12 !! 7
11
'BINARY' !! 'abc'
'#+-ARY'
True !! exp
!exp
True !! exp !! True
exp
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(…) |
x[y] | Part(x, y) |
x[y][z] | Part(Part(x, y), z) |
x[y,z,…] | Part(x, y, z, …) |
{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(…) |
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 /@ g /@ x | Map(f, Map(g, x)) |
f & | Function(f) |
x = y = z | Set(x, Set(y, z)) |
x := y := z | SetDelayed(x, SetDelayed(y, z)) |
x ; y ; … | Compound(x, y, …) |
x , y , … | Sequence(x, y, …) |