AAbsAccuracyAllAlternativesAndAnyAnyNullSequenceAnySequenceApplyArCoshArSinhArTanhArcCosArcSinArcTanArgAttributes
BBernoulliBinaryFormatBinomialBoole
CCalculateCeilClearClearAttributesComplementComplexComplexInfinityComplexOverflowComplexUnderflowCompoundConditionConjugateContainCosCoshCount
DDefineDefineDelayedDefinitionsDenominatorDepthDigitBaseDirectedInfinityDivide
EEEndiannessEqualEulerMascheroniExpExpandExpression
FFactorialFalseFibonacciFlatFlattenFloorFunction
GGoldenAngleGoldenRatioGreaterGreaterEqual
IIIfImIndeterminateInfinityIntegerInternalFormIntersectionIsEvenIsNumericIsOddIsPrimeIterate
JJoin
LLengthLessLessEqualListListableLockedLog
MMachinePrecisionMapMatchingMaxMinMinusMod
OOptionalOptionsOrOrderOrderlessOutputOverflow
PPartPartitionPatternPiPlusPowerPrecisionPrintProtected
RRandomRationalRationalizeReRealReplaceRoundRuleRuleDelayed
SSameScopeSelectSequenceSequenceHoldSetAttributesShiftLeftShiftRightSignSinSinhSlotSortSpanSplitSqrtStringSubDefineSubDefineDelayedSubtractSymbolSymbols
TTanTanhTimesToIntegerToRealToStringToSymbolTrueTrunc
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 && 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(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)
???head
Matching( 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)
??head
Matching( 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
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
Attributes(s)
Attributes(s) = attr
Attributes(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}
{Orderless, Flat}
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)
n! |
k! (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) // 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
x = 123
123
x^2
15129
Clear(x)
x^2
x^2
f(10) = 0
f(z?Integer) := 2*z
f(z?) * w? @:= -w*z
0
Definitions(f)
f(10) = 0
f(Pattern(z, ?Integer)) := 2*z
f(Pattern(z, Any))*Pattern(w, Any) @:= Minus(w*z)
Clear(f)
Definitions(f)
/* no definitions */
ClearAttributes(s, attr)
ClearAttributes(s, {attr1, attr2, … } )
Boole({True, False, True})
{1, 0, 1}
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))
x + y*I
Complex
ComplexInfinity
Abs(ComplexInfinity) > Abs(ComplexOverflow)
True
1 / ComplexInfinity
0
1 / 0
ComplexInfinity
ComplexOverflow
(7.0+4.0*I) ^ Exp(100.0)
ComplexOverflow
3.14 + ComplexOverflow
ComplexOverflow
ComplexOverflow * (-2)
ComplexOverflow
ComplexUnderflow
(7.0+4.0*I) ^ (-Exp(100.0))
ComplexUnderflow
3.14 + ComplexUnderflow
3.14+0.0*I
ComplexUnderflow * (-2)
ComplexUnderflow
1 / ComplexUnderflow
ComplexOverflow
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}
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
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
Define(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(123)
k(123)
6.28
246
DefineDelayed(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(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) = 1
f(2) = 1
f(Condition(Pattern(x, Any), x <= 0)) = 0
f(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
a/b
Depth( 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) ^ 4
Infinity
Tan(DirectedInfinity(1+I))
I
ArcCos(Infinity)
DirectedInfinity(I)
ArTanh(DirectedInfinity(I))
1/2*I*Pi
4 / 2
2
x^5 / x^2
x^3
4 / 6
4.0 / 6
2/3
0.666667
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
True
0.2 == 1/5
True
Overflow == Overflow
Overflow === OverflowOverflow == Overflow
True
a == b
a == b
1.0000000000000000002 == 1.0000000000000000001
True
1.00000000000000000020 == 1.00000000000000000010
False
EulerMascheroni
Calculate(EulerMascheroni)
0.577216
Calculate(EulerMascheroni, 70)
0.5772156649015328606065120900824024310421593359399235988057672348848677
2*EulerMascheroni
2*EulerMascheroni
2.0*EulerMascheroni
1.15443
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 @ 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(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)
φn − cos(π n) φ−n |
5 |
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}
GoldenAngle
2 π |
φ2 |
2 π |
φ2 |
Calculate(GoldenAngle)
2.39996
Calculate(GoldenAngle, 70)
2.399963229728653322231555506633613853124999011058115042935112750731307
Calculate(GoldenAngle*180/Pi)
137.508
GoldenRatio
1+5 |
2 |
Calculate(GoldenRatio)
1.61803
Calculate(GoldenRatio, 70)
1.618033988749894848204586834365638117720309179805762862135448622705260
GoldenRatio - 1.0/GoldenRatio
1.0
2 > 1
True
1/3 > 0 > -0.5
True
x > 2 > 2
False
2 > 1 > x
1 > x
GreaterEqual(x1, x2, … )
x1 >= x2 >= …
2 >= 1
True
3/2 >= 1.5 >= -0.5
True
x >= 1 >= 2
False
2 >= 1 >= x
1 >= x
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
Indeterminate
n
Integer
12 + 34
46
32845723658234756 * 346594876456456546
11384159533448787206618577180912776
11384159533448787206618577180912776 / 346594876456456546
32845723658234756
3^200
265613988875874769338781322035779626829233452653394495974574961739092490901302182994384699044001
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))
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(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}}
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
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
1 <= 2
True
-0.5 <= 1.5 <= 3/2
True
x <= 2 <= 1
False
1 <= 2 <= x
2 <= 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(f) = {Flat, Locked}
{Flat, Locked}
Attributes(f) = {Orderless}
{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
MachinePrecision
Calculate(MachinePrecision)
15.9546
Precision(3.1415)
MachinePrecision
Precision(789.456e123)
MachinePrecision
Precision(123.4e5678)
15.9546
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^10
121.899
Not(bool)
!bool
Not(int)
!int
Not(str)
!str
! 15
-16
! 'BINARY'
'½¶±¾¦'
Not( x < 3 )
x >= 3
Not( x == 3 )
x != 3
Null
Numerator(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}
{8, 8, 8, 8, 8}
{0, 8, 9, 5, 2}
Or(bool1, bool2, … )
bool1 || bool2 || …
Or(int1, int2, … )
int1 || int2 || …
Or(str1, str2, … )
str1 || str2 || …
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(…). |
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)
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 // 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,4) , 2 )
f(f(1, 2), f(3, 4))
Pattern(sym, pat)
sym?
sym??
sym???
sym?head
sym??head
sym???head
f(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}
Pi
Calculate(Pi, 70)
3.141592653589793238462643383279502884197169399375105820974944592307816
2.0*Pi
6.28319
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^(-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)
1
2
3
3
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)
Hello
World
Protected
Pi = 3
3
x = 123
123
Attributes(x) = Protected
Protected
x = 0
0
x
123
Random(z)
Random(z, n)
Random(str)
Random(str, n)
Random(list)
Random(list, n)
Random(7)
5
Random(30!)
167201965988113934175870619124744
Random(2/3)
0
Random(2.0)
1.06403
Random(1.0+2.0*I)
0.987346+0.990154*I
Random("abcdefgh")
"g"
Random( {a, b, c} )
b
Random( 9, 10 )
{5, 4, 5, 7, 0, 9, 9, 9, 1, 0}
Random( 1.0, 10 )
{0.882984, 0.998793, 0.981307, 0.64749, 0.631102, 0.296387, 0.568334, 0.507116, 0.0236576, 0.501795}
Random( {True, False}, 10 )
{True, False, False, True, True, True, True, False, False, False}
Random("ABC", 20)
"BCBBACCACBCCACBBACAB"
Random("---|", 40)
"-|------|||---||---|---|-|-------------|"
Random('', 32)
'ZÉ»bÅ×èq\x9D\x97\x8D\rã\x197B³\x04Ãó\x1CøÕ³\x05¨Â¿\x1B\f©'
a/b
Rational
4/12
1/3
5 + 1/3
16/3
1/123456 + 1/678901
802357/83814401856
(2/3)^100
1267650600228229401496703205376/515377520732011331036461129765621272702107522001
Rationalize -> False
Rationalize -> True
ShiftRight(15)
ShiftRight(15, Rationalize->False)
ShiftRight(15, Rationalize->True)
7
7
15/2
ShiftRight(4, 5)
ShiftRight(4, 5, Rationalize->True)
0
1/8
x
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.4798, 29.0899}
x ^ y
1.0018442638e257256
Precision(x^y)
10.3898
123.456 ^ (10^100)
Overflow
123.456 ^ (-10^100)
Underflow
Replace(exp, rule)
exp /: rule
Replace(exp, {r1, r2, … })
exp /: {r1, r2, … }
Replace(exp, rule, depth)
Replace(str, a->b )
str /: a->b
Replace(str, {a1->b1, a2->b2, … } )
str /: {a1->b1, a2->b2, … }
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
{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 -> x
b + 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)
{8, 8, 8, 8, 8}
{x, x, x, x, x} /: x :> Random(10)
{4, 1, 6, 3, 5}
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}
Replace({1, x, 2, x, 3, x}, x :> Random(1000) )
{1, 644, 2, 270, 3, 610}
123 === "text"
False
x === y
False
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 === a
False
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(f(x?) := x^2, {f(5), f(y)} )
{25, y^2}
f(5)
f(5)
Scope(x, x+y )
x$4 + y
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??) :> x
Sequence(1, 2, 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)
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
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 @= rhs
f(beta) @= 2
2
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 + on
on
off
off + on = on;
f(alpha) = 1
f(alpha) @= 2
1
2
f(alpha)
2
SubDefineDelayed(lhs, rhs)
lhs @:= rhs
f(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 - 2
1
2*x - 3*x
-x
2 - 1/4
2 - 0.25
7/4
1.75
s
Symbol
foo + foo
2*foo
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}
ToSymbol("world")
world
Var = 123
123
{Var, var}
{123, var}
Symbols()
{Abs, Accuracy, All, Alternatives, And, Any, AnyNullSequence, AnySequence, Apply, ArCosh, ArSinh, ArTanh, ArcCos, ArcSin, ArcTan, Arg, Attributes, Bernoulli, BinaryFormat, Binomial, Boole, Calculate, Ceil, Clear, ClearAttributes, Complement, Complex, ComplexInfinity, ComplexOverflow, ComplexUnderflow, Compound, Condition, Conjugate, Contain, Cos, Cosh, Count, Define, DefineDelayed, Definitions, Denominator, Depth, DigitBase, DirectedInfinity, Divide, E, Endianness, Equal, EulerMascheroni, Exp, Expand, Factorial, False, Fibonacci, Flat, Flatten, Floor, Function, GCD, GoldenAngle, GoldenRatio, Greater, GreaterEqual, GreatestCommonDivisor, Head, Hold, HoldAll, HoldFirst, HoldRest, I, If, Im, Indeterminate, Infinity, Integer, InternalForm, Intersection, IsEven, IsNumeric, IsOdd, IsPrime, Iterate, Join, Kernel, Length, Less, LessEqual, List, Listable, Locked, Log, MachinePrecision, Map, Matching, Max, Min, Minus, Mod, Nest, None, Not, Null, Numerator, NumericConstant, NumericFunction, OneIdentity, Optional, Options, Or, Order, Orderless, Output, Overflow, Part, Partition, Pattern, Pi, Plus, Power, Precision, Print, Protected, Random, Rational, Rationalize, Re, Real, Replace, Round, Rule, RuleDelayed, Same, Scope, Select, Sequence, SequenceHold, SetAttributes, ShiftLeft, ShiftRight, Sign, Sin, Sinh, Slot, Sort, Span, Split, Sqrt, String, SubDefine, SubDefineDelayed, Subtract, Symbol, Symbols, Tan, Tanh, Temporary, Times, 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
Underflow
1 != 2
True
1 != 2 != 1
False
a != b
a != b
1.0000000000000000002 != 1.0000000000000000001
False
1.00000000000000000020 != 1.00000000000000000010
True
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 =!= y
True
f(5) =!= f(5)
False
x =!= y =!= x
False
x =!= 2
Replace( x =!= 2 , x->2 )
True
True
x != 2
Replace( x != 2 , x->2 )
x != 2
False
A =!= a
True
Xor(bool1, bool2, … )
bool1 !! bool2 !! …
Xor(int1, int2, … )
int1 !! int2 !! …
Xor(str1, str2, … )
str1 !! str2 !! …
True !! True
True !! True !! TrueFalse
True
12 !! 7
11
'BINARY' !! 'abc'
'#+-ARY'
True !! a > 0
a <= 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, …) |