1@chapter Syntax
2@c man begin SYNTAX
3
4This section documents the syntax and formats employed by the FFmpeg
5libraries and tools.
6
7@anchor{quoting_and_escaping}
8@section Quoting and escaping
9
10FFmpeg adopts the following quoting and escaping mechanism, unless
11explicitly specified. The following rules are applied:
12
13@itemize
14@item
15@samp{'} and @samp{\} are special characters (respectively used for
16quoting and escaping). In addition to them, there might be other
17special characters depending on the specific syntax where the escaping
18and quoting are employed.
19
20@item
21A special character is escaped by prefixing it with a @samp{\}.
22
23@item
24All characters enclosed between @samp{''} are included literally in the
25parsed string. The quote character @samp{'} itself cannot be quoted,
26so you may need to close the quote and escape it.
27
28@item
29Leading and trailing whitespaces, unless escaped or quoted, are
30removed from the parsed string.
31@end itemize
32
33Note that you may need to add a second level of escaping when using
34the command line or a script, which depends on the syntax of the
35adopted shell language.
36
37The function @code{av_get_token} defined in
38@file{libavutil/avstring.h} can be used to parse a token quoted or
39escaped according to the rules defined above.
40
41The tool @file{tools/ffescape} in the FFmpeg source tree can be used
42to automatically quote or escape a string in a script.
43
44@subsection Examples
45
46@itemize
47@item
48Escape the string @code{Crime d'Amour} containing the @code{'} special
49character:
50@example
51Crime d\'Amour
52@end example
53
54@item
55The string above contains a quote, so the @code{'} needs to be escaped
56when quoting it:
57@example
58'Crime d'\''Amour'
59@end example
60
61@item
62Include leading or trailing whitespaces using quoting:
63@example
64'  this string starts and ends with whitespaces  '
65@end example
66
67@item
68Escaping and quoting can be mixed together:
69@example
70' The string '\'string\'' is a string '
71@end example
72
73@item
74To include a literal @samp{\} you can use either escaping or quoting:
75@example
76'c:\foo' can be written as c:\\foo
77@end example
78@end itemize
79
80@anchor{date syntax}
81@section Date
82
83The accepted syntax is:
84@example
85[(YYYY-MM-DD|YYYYMMDD)[T|t| ]]((HH:MM:SS[.m...]]])|(HHMMSS[.m...]]]))[Z]
86now
87@end example
88
89If the value is "now" it takes the current time.
90
91Time is local time unless Z is appended, in which case it is
92interpreted as UTC.
93If the year-month-day part is not specified it takes the current
94year-month-day.
95
96@anchor{time duration syntax}
97@section Time duration
98
99There are two accepted syntaxes for expressing time duration.
100
101@example
102[-][@var{HH}:]@var{MM}:@var{SS}[.@var{m}...]
103@end example
104
105@var{HH} expresses the number of hours, @var{MM} the number of minutes
106for a maximum of 2 digits, and @var{SS} the number of seconds for a
107maximum of 2 digits. The @var{m} at the end expresses decimal value for
108@var{SS}.
109
110@emph{or}
111
112@example
113[-]@var{S}+[.@var{m}...][s|ms|us]
114@end example
115
116@var{S} expresses the number of seconds, with the optional decimal part
117@var{m}.  The optional literal suffixes @samp{s}, @samp{ms} or @samp{us}
118indicate to interpret the value as seconds, milliseconds or microseconds,
119respectively.
120
121In both expressions, the optional @samp{-} indicates negative duration.
122
123@subsection Examples
124
125The following examples are all valid time duration:
126
127@table @samp
128@item 55
12955 seconds
130
131@item 0.2
1320.2 seconds
133
134@item 200ms
135200 milliseconds, that's 0.2s
136
137@item 200000us
138200000 microseconds, that's 0.2s
139
140@item 12:03:45
14112 hours, 03 minutes and 45 seconds
142
143@item 23.189
14423.189 seconds
145@end table
146
147@anchor{video size syntax}
148@section Video size
149Specify the size of the sourced video, it may be a string of the form
150@var{width}x@var{height}, or the name of a size abbreviation.
151
152The following abbreviations are recognized:
153@table @samp
154@item ntsc
155720x480
156@item pal
157720x576
158@item qntsc
159352x240
160@item qpal
161352x288
162@item sntsc
163640x480
164@item spal
165768x576
166@item film
167352x240
168@item ntsc-film
169352x240
170@item sqcif
171128x96
172@item qcif
173176x144
174@item cif
175352x288
176@item 4cif
177704x576
178@item 16cif
1791408x1152
180@item qqvga
181160x120
182@item qvga
183320x240
184@item vga
185640x480
186@item svga
187800x600
188@item xga
1891024x768
190@item uxga
1911600x1200
192@item qxga
1932048x1536
194@item sxga
1951280x1024
196@item qsxga
1972560x2048
198@item hsxga
1995120x4096
200@item wvga
201852x480
202@item wxga
2031366x768
204@item wsxga
2051600x1024
206@item wuxga
2071920x1200
208@item woxga
2092560x1600
210@item wqsxga
2113200x2048
212@item wquxga
2133840x2400
214@item whsxga
2156400x4096
216@item whuxga
2177680x4800
218@item cga
219320x200
220@item ega
221640x350
222@item hd480
223852x480
224@item hd720
2251280x720
226@item hd1080
2271920x1080
228@item 2k
2292048x1080
230@item 2kflat
2311998x1080
232@item 2kscope
2332048x858
234@item 4k
2354096x2160
236@item 4kflat
2373996x2160
238@item 4kscope
2394096x1716
240@item nhd
241640x360
242@item hqvga
243240x160
244@item wqvga
245400x240
246@item fwqvga
247432x240
248@item hvga
249480x320
250@item qhd
251960x540
252@item 2kdci
2532048x1080
254@item 4kdci
2554096x2160
256@item uhd2160
2573840x2160
258@item uhd4320
2597680x4320
260@end table
261
262@anchor{video rate syntax}
263@section Video rate
264
265Specify the frame rate of a video, expressed as the number of frames
266generated per second. It has to be a string in the format
267@var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
268number or a valid video frame rate abbreviation.
269
270The following abbreviations are recognized:
271@table @samp
272@item ntsc
27330000/1001
274@item pal
27525/1
276@item qntsc
27730000/1001
278@item qpal
27925/1
280@item sntsc
28130000/1001
282@item spal
28325/1
284@item film
28524/1
286@item ntsc-film
28724000/1001
288@end table
289
290@anchor{ratio syntax}
291@section Ratio
292
293A ratio can be expressed as an expression, or in the form
294@var{numerator}:@var{denominator}.
295
296Note that a ratio with infinite (1/0) or negative value is
297considered valid, so you should check on the returned value if you
298want to exclude those values.
299
300The undefined value can be expressed using the "0:0" string.
301
302@anchor{color syntax}
303@section Color
304
305It can be the name of a color as defined below (case insensitive match) or a
306@code{[0x|#]RRGGBB[AA]} sequence, possibly followed by @@ and a string
307representing the alpha component.
308
309The alpha component may be a string composed by "0x" followed by an
310hexadecimal number or a decimal number between 0.0 and 1.0, which
311represents the opacity value (@samp{0x00} or @samp{0.0} means completely
312transparent, @samp{0xff} or @samp{1.0} completely opaque). If the alpha
313component is not specified then @samp{0xff} is assumed.
314
315The string @samp{random} will result in a random color.
316
317The following names of colors are recognized:
318@table @samp
319@item AliceBlue
3200xF0F8FF
321@item AntiqueWhite
3220xFAEBD7
323@item Aqua
3240x00FFFF
325@item Aquamarine
3260x7FFFD4
327@item Azure
3280xF0FFFF
329@item Beige
3300xF5F5DC
331@item Bisque
3320xFFE4C4
333@item Black
3340x000000
335@item BlanchedAlmond
3360xFFEBCD
337@item Blue
3380x0000FF
339@item BlueViolet
3400x8A2BE2
341@item Brown
3420xA52A2A
343@item BurlyWood
3440xDEB887
345@item CadetBlue
3460x5F9EA0
347@item Chartreuse
3480x7FFF00
349@item Chocolate
3500xD2691E
351@item Coral
3520xFF7F50
353@item CornflowerBlue
3540x6495ED
355@item Cornsilk
3560xFFF8DC
357@item Crimson
3580xDC143C
359@item Cyan
3600x00FFFF
361@item DarkBlue
3620x00008B
363@item DarkCyan
3640x008B8B
365@item DarkGoldenRod
3660xB8860B
367@item DarkGray
3680xA9A9A9
369@item DarkGreen
3700x006400
371@item DarkKhaki
3720xBDB76B
373@item DarkMagenta
3740x8B008B
375@item DarkOliveGreen
3760x556B2F
377@item Darkorange
3780xFF8C00
379@item DarkOrchid
3800x9932CC
381@item DarkRed
3820x8B0000
383@item DarkSalmon
3840xE9967A
385@item DarkSeaGreen
3860x8FBC8F
387@item DarkSlateBlue
3880x483D8B
389@item DarkSlateGray
3900x2F4F4F
391@item DarkTurquoise
3920x00CED1
393@item DarkViolet
3940x9400D3
395@item DeepPink
3960xFF1493
397@item DeepSkyBlue
3980x00BFFF
399@item DimGray
4000x696969
401@item DodgerBlue
4020x1E90FF
403@item FireBrick
4040xB22222
405@item FloralWhite
4060xFFFAF0
407@item ForestGreen
4080x228B22
409@item Fuchsia
4100xFF00FF
411@item Gainsboro
4120xDCDCDC
413@item GhostWhite
4140xF8F8FF
415@item Gold
4160xFFD700
417@item GoldenRod
4180xDAA520
419@item Gray
4200x808080
421@item Green
4220x008000
423@item GreenYellow
4240xADFF2F
425@item HoneyDew
4260xF0FFF0
427@item HotPink
4280xFF69B4
429@item IndianRed
4300xCD5C5C
431@item Indigo
4320x4B0082
433@item Ivory
4340xFFFFF0
435@item Khaki
4360xF0E68C
437@item Lavender
4380xE6E6FA
439@item LavenderBlush
4400xFFF0F5
441@item LawnGreen
4420x7CFC00
443@item LemonChiffon
4440xFFFACD
445@item LightBlue
4460xADD8E6
447@item LightCoral
4480xF08080
449@item LightCyan
4500xE0FFFF
451@item LightGoldenRodYellow
4520xFAFAD2
453@item LightGreen
4540x90EE90
455@item LightGrey
4560xD3D3D3
457@item LightPink
4580xFFB6C1
459@item LightSalmon
4600xFFA07A
461@item LightSeaGreen
4620x20B2AA
463@item LightSkyBlue
4640x87CEFA
465@item LightSlateGray
4660x778899
467@item LightSteelBlue
4680xB0C4DE
469@item LightYellow
4700xFFFFE0
471@item Lime
4720x00FF00
473@item LimeGreen
4740x32CD32
475@item Linen
4760xFAF0E6
477@item Magenta
4780xFF00FF
479@item Maroon
4800x800000
481@item MediumAquaMarine
4820x66CDAA
483@item MediumBlue
4840x0000CD
485@item MediumOrchid
4860xBA55D3
487@item MediumPurple
4880x9370D8
489@item MediumSeaGreen
4900x3CB371
491@item MediumSlateBlue
4920x7B68EE
493@item MediumSpringGreen
4940x00FA9A
495@item MediumTurquoise
4960x48D1CC
497@item MediumVioletRed
4980xC71585
499@item MidnightBlue
5000x191970
501@item MintCream
5020xF5FFFA
503@item MistyRose
5040xFFE4E1
505@item Moccasin
5060xFFE4B5
507@item NavajoWhite
5080xFFDEAD
509@item Navy
5100x000080
511@item OldLace
5120xFDF5E6
513@item Olive
5140x808000
515@item OliveDrab
5160x6B8E23
517@item Orange
5180xFFA500
519@item OrangeRed
5200xFF4500
521@item Orchid
5220xDA70D6
523@item PaleGoldenRod
5240xEEE8AA
525@item PaleGreen
5260x98FB98
527@item PaleTurquoise
5280xAFEEEE
529@item PaleVioletRed
5300xD87093
531@item PapayaWhip
5320xFFEFD5
533@item PeachPuff
5340xFFDAB9
535@item Peru
5360xCD853F
537@item Pink
5380xFFC0CB
539@item Plum
5400xDDA0DD
541@item PowderBlue
5420xB0E0E6
543@item Purple
5440x800080
545@item Red
5460xFF0000
547@item RosyBrown
5480xBC8F8F
549@item RoyalBlue
5500x4169E1
551@item SaddleBrown
5520x8B4513
553@item Salmon
5540xFA8072
555@item SandyBrown
5560xF4A460
557@item SeaGreen
5580x2E8B57
559@item SeaShell
5600xFFF5EE
561@item Sienna
5620xA0522D
563@item Silver
5640xC0C0C0
565@item SkyBlue
5660x87CEEB
567@item SlateBlue
5680x6A5ACD
569@item SlateGray
5700x708090
571@item Snow
5720xFFFAFA
573@item SpringGreen
5740x00FF7F
575@item SteelBlue
5760x4682B4
577@item Tan
5780xD2B48C
579@item Teal
5800x008080
581@item Thistle
5820xD8BFD8
583@item Tomato
5840xFF6347
585@item Turquoise
5860x40E0D0
587@item Violet
5880xEE82EE
589@item Wheat
5900xF5DEB3
591@item White
5920xFFFFFF
593@item WhiteSmoke
5940xF5F5F5
595@item Yellow
5960xFFFF00
597@item YellowGreen
5980x9ACD32
599@end table
600
601@anchor{channel layout syntax}
602@section Channel Layout
603
604A channel layout specifies the spatial disposition of the channels in
605a multi-channel audio stream. To specify a channel layout, FFmpeg
606makes use of a special syntax.
607
608Individual channels are identified by an id, as given by the table
609below:
610@table @samp
611@item FL
612front left
613@item FR
614front right
615@item FC
616front center
617@item LFE
618low frequency
619@item BL
620back left
621@item BR
622back right
623@item FLC
624front left-of-center
625@item FRC
626front right-of-center
627@item BC
628back center
629@item SL
630side left
631@item SR
632side right
633@item TC
634top center
635@item TFL
636top front left
637@item TFC
638top front center
639@item TFR
640top front right
641@item TBL
642top back left
643@item TBC
644top back center
645@item TBR
646top back right
647@item DL
648downmix left
649@item DR
650downmix right
651@item WL
652wide left
653@item WR
654wide right
655@item SDL
656surround direct left
657@item SDR
658surround direct right
659@item LFE2
660low frequency 2
661@end table
662
663Standard channel layout compositions can be specified by using the
664following identifiers:
665@table @samp
666@item mono
667FC
668@item stereo
669FL+FR
670@item 2.1
671FL+FR+LFE
672@item 3.0
673FL+FR+FC
674@item 3.0(back)
675FL+FR+BC
676@item 4.0
677FL+FR+FC+BC
678@item quad
679FL+FR+BL+BR
680@item quad(side)
681FL+FR+SL+SR
682@item 3.1
683FL+FR+FC+LFE
684@item 5.0
685FL+FR+FC+BL+BR
686@item 5.0(side)
687FL+FR+FC+SL+SR
688@item 4.1
689FL+FR+FC+LFE+BC
690@item 5.1
691FL+FR+FC+LFE+BL+BR
692@item 5.1(side)
693FL+FR+FC+LFE+SL+SR
694@item 6.0
695FL+FR+FC+BC+SL+SR
696@item 6.0(front)
697FL+FR+FLC+FRC+SL+SR
698@item hexagonal
699FL+FR+FC+BL+BR+BC
700@item 6.1
701FL+FR+FC+LFE+BC+SL+SR
702@item 6.1
703FL+FR+FC+LFE+BL+BR+BC
704@item 6.1(front)
705FL+FR+LFE+FLC+FRC+SL+SR
706@item 7.0
707FL+FR+FC+BL+BR+SL+SR
708@item 7.0(front)
709FL+FR+FC+FLC+FRC+SL+SR
710@item 7.1
711FL+FR+FC+LFE+BL+BR+SL+SR
712@item 7.1(wide)
713FL+FR+FC+LFE+BL+BR+FLC+FRC
714@item 7.1(wide-side)
715FL+FR+FC+LFE+FLC+FRC+SL+SR
716@item octagonal
717FL+FR+FC+BL+BR+BC+SL+SR
718@item hexadecagonal
719FL+FR+FC+BL+BR+BC+SL+SR+WL+WR+TBL+TBR+TBC+TFC+TFL+TFR
720@item downmix
721DL+DR
722@end table
723
724A custom channel layout can be specified as a sequence of terms, separated by
725'+' or '|'. Each term can be:
726@itemize
727@item
728the name of a standard channel layout (e.g. @samp{mono},
729@samp{stereo}, @samp{4.0}, @samp{quad}, @samp{5.0}, etc.)
730
731@item
732the name of a single channel (e.g. @samp{FL}, @samp{FR}, @samp{FC}, @samp{LFE}, etc.)
733
734@item
735a number of channels, in decimal, followed by 'c', yielding the default channel
736layout for that number of channels (see the function
737@code{av_get_default_channel_layout}). Note that not all channel counts have a
738default layout.
739
740@item
741a number of channels, in decimal, followed by 'C', yielding an unknown channel
742layout with the specified number of channels. Note that not all channel layout
743specification strings support unknown channel layouts.
744
745@item
746a channel layout mask, in hexadecimal starting with "0x" (see the
747@code{AV_CH_*} macros in @file{libavutil/channel_layout.h}.
748@end itemize
749
750Before libavutil version 53 the trailing character "c" to specify a number of
751channels was optional, but now it is required, while a channel layout mask can
752also be specified as a decimal number (if and only if not followed by "c" or "C").
753
754See also the function @code{av_get_channel_layout} defined in
755@file{libavutil/channel_layout.h}.
756@c man end SYNTAX
757
758@chapter Expression Evaluation
759@c man begin EXPRESSION EVALUATION
760
761When evaluating an arithmetic expression, FFmpeg uses an internal
762formula evaluator, implemented through the @file{libavutil/eval.h}
763interface.
764
765An expression may contain unary, binary operators, constants, and
766functions.
767
768Two expressions @var{expr1} and @var{expr2} can be combined to form
769another expression "@var{expr1};@var{expr2}".
770@var{expr1} and @var{expr2} are evaluated in turn, and the new
771expression evaluates to the value of @var{expr2}.
772
773The following binary operators are available: @code{+}, @code{-},
774@code{*}, @code{/}, @code{^}.
775
776The following unary operators are available: @code{+}, @code{-}.
777
778The following functions are available:
779@table @option
780@item abs(x)
781Compute absolute value of @var{x}.
782
783@item acos(x)
784Compute arccosine of @var{x}.
785
786@item asin(x)
787Compute arcsine of @var{x}.
788
789@item atan(x)
790Compute arctangent of @var{x}.
791
792@item atan2(x, y)
793Compute principal value of the arc tangent of @var{y}/@var{x}.
794
795@item between(x, min, max)
796Return 1 if @var{x} is greater than or equal to @var{min} and lesser than or
797equal to @var{max}, 0 otherwise.
798
799@item bitand(x, y)
800@item bitor(x, y)
801Compute bitwise and/or operation on @var{x} and @var{y}.
802
803The results of the evaluation of @var{x} and @var{y} are converted to
804integers before executing the bitwise operation.
805
806Note that both the conversion to integer and the conversion back to
807floating point can lose precision. Beware of unexpected results for
808large numbers (usually 2^53 and larger).
809
810@item ceil(expr)
811Round the value of expression @var{expr} upwards to the nearest
812integer. For example, "ceil(1.5)" is "2.0".
813
814@item clip(x, min, max)
815Return the value of @var{x} clipped between @var{min} and @var{max}.
816
817@item cos(x)
818Compute cosine of @var{x}.
819
820@item cosh(x)
821Compute hyperbolic cosine of @var{x}.
822
823@item eq(x, y)
824Return 1 if @var{x} and @var{y} are equivalent, 0 otherwise.
825
826@item exp(x)
827Compute exponential of @var{x} (with base @code{e}, the Euler's number).
828
829@item floor(expr)
830Round the value of expression @var{expr} downwards to the nearest
831integer. For example, "floor(-1.5)" is "-2.0".
832
833@item gauss(x)
834Compute Gauss function of @var{x}, corresponding to
835@code{exp(-x*x/2) / sqrt(2*PI)}.
836
837@item gcd(x, y)
838Return the greatest common divisor of @var{x} and @var{y}. If both @var{x} and
839@var{y} are 0 or either or both are less than zero then behavior is undefined.
840
841@item gt(x, y)
842Return 1 if @var{x} is greater than @var{y}, 0 otherwise.
843
844@item gte(x, y)
845Return 1 if @var{x} is greater than or equal to @var{y}, 0 otherwise.
846
847@item hypot(x, y)
848This function is similar to the C function with the same name; it returns
849"sqrt(@var{x}*@var{x} + @var{y}*@var{y})", the length of the hypotenuse of a
850right triangle with sides of length @var{x} and @var{y}, or the distance of the
851point (@var{x}, @var{y}) from the origin.
852
853@item if(x, y)
854Evaluate @var{x}, and if the result is non-zero return the result of
855the evaluation of @var{y}, return 0 otherwise.
856
857@item if(x, y, z)
858Evaluate @var{x}, and if the result is non-zero return the evaluation
859result of @var{y}, otherwise the evaluation result of @var{z}.
860
861@item ifnot(x, y)
862Evaluate @var{x}, and if the result is zero return the result of the
863evaluation of @var{y}, return 0 otherwise.
864
865@item ifnot(x, y, z)
866Evaluate @var{x}, and if the result is zero return the evaluation
867result of @var{y}, otherwise the evaluation result of @var{z}.
868
869@item isinf(x)
870Return 1.0 if @var{x} is +/-INFINITY, 0.0 otherwise.
871
872@item isnan(x)
873Return 1.0 if @var{x} is NAN, 0.0 otherwise.
874
875@item ld(var)
876Load the value of the internal variable with number
877@var{var}, which was previously stored with st(@var{var}, @var{expr}).
878The function returns the loaded value.
879
880@item lerp(x, y, z)
881Return linear interpolation between @var{x} and @var{y} by amount of @var{z}.
882
883@item log(x)
884Compute natural logarithm of @var{x}.
885
886@item lt(x, y)
887Return 1 if @var{x} is lesser than @var{y}, 0 otherwise.
888
889@item lte(x, y)
890Return 1 if @var{x} is lesser than or equal to @var{y}, 0 otherwise.
891
892@item max(x, y)
893Return the maximum between @var{x} and @var{y}.
894
895@item min(x, y)
896Return the minimum between @var{x} and @var{y}.
897
898@item mod(x, y)
899Compute the remainder of division of @var{x} by @var{y}.
900
901@item not(expr)
902Return 1.0 if @var{expr} is zero, 0.0 otherwise.
903
904@item pow(x, y)
905Compute the power of @var{x} elevated @var{y}, it is equivalent to
906"(@var{x})^(@var{y})".
907
908@item print(t)
909@item print(t, l)
910Print the value of expression @var{t} with loglevel @var{l}. If
911@var{l} is not specified then a default log level is used.
912Returns the value of the expression printed.
913
914Prints t with loglevel l
915
916@item random(x)
917Return a pseudo random value between 0.0 and 1.0. @var{x} is the index of the
918internal variable which will be used to save the seed/state.
919
920@item root(expr, max)
921Find an input value for which the function represented by @var{expr}
922with argument @var{ld(0)} is 0 in the interval 0..@var{max}.
923
924The expression in @var{expr} must denote a continuous function or the
925result is undefined.
926
927@var{ld(0)} is used to represent the function input value, which means
928that the given expression will be evaluated multiple times with
929various input values that the expression can access through
930@code{ld(0)}. When the expression evaluates to 0 then the
931corresponding input value will be returned.
932
933@item round(expr)
934Round the value of expression @var{expr} to the nearest integer. For example, "round(1.5)" is "2.0".
935
936@item sgn(x)
937Compute sign of @var{x}.
938
939@item sin(x)
940Compute sine of @var{x}.
941
942@item sinh(x)
943Compute hyperbolic sine of @var{x}.
944
945@item sqrt(expr)
946Compute the square root of @var{expr}. This is equivalent to
947"(@var{expr})^.5".
948
949@item squish(x)
950Compute expression @code{1/(1 + exp(4*x))}.
951
952@item st(var, expr)
953Store the value of the expression @var{expr} in an internal
954variable. @var{var} specifies the number of the variable where to
955store the value, and it is a value ranging from 0 to 9. The function
956returns the value stored in the internal variable.
957Note, Variables are currently not shared between expressions.
958
959@item tan(x)
960Compute tangent of @var{x}.
961
962@item tanh(x)
963Compute hyperbolic tangent of @var{x}.
964
965@item taylor(expr, x)
966@item taylor(expr, x, id)
967Evaluate a Taylor series at @var{x}, given an expression representing
968the @code{ld(id)}-th derivative of a function at 0.
969
970When the series does not converge the result is undefined.
971
972@var{ld(id)} is used to represent the derivative order in @var{expr},
973which means that the given expression will be evaluated multiple times
974with various input values that the expression can access through
975@code{ld(id)}. If @var{id} is not specified then 0 is assumed.
976
977Note, when you have the derivatives at y instead of 0,
978@code{taylor(expr, x-y)} can be used.
979
980@item time(0)
981Return the current (wallclock) time in seconds.
982
983@item trunc(expr)
984Round the value of expression @var{expr} towards zero to the nearest
985integer. For example, "trunc(-1.5)" is "-1.0".
986
987@item while(cond, expr)
988Evaluate expression @var{expr} while the expression @var{cond} is
989non-zero, and returns the value of the last @var{expr} evaluation, or
990NAN if @var{cond} was always false.
991@end table
992
993The following constants are available:
994@table @option
995@item PI
996area of the unit disc, approximately 3.14
997@item E
998exp(1) (Euler's number), approximately 2.718
999@item PHI
1000golden ratio (1+sqrt(5))/2, approximately 1.618
1001@end table
1002
1003Assuming that an expression is considered "true" if it has a non-zero
1004value, note that:
1005
1006@code{*} works like AND
1007
1008@code{+} works like OR
1009
1010For example the construct:
1011@example
1012if (A AND B) then C
1013@end example
1014is equivalent to:
1015@example
1016if(A*B, C)
1017@end example
1018
1019In your C code, you can extend the list of unary and binary functions,
1020and define recognized constants, so that they are available for your
1021expressions.
1022
1023The evaluator also recognizes the International System unit prefixes.
1024If 'i' is appended after the prefix, binary prefixes are used, which
1025are based on powers of 1024 instead of powers of 1000.
1026The 'B' postfix multiplies the value by 8, and can be appended after a
1027unit prefix or used alone. This allows using for example 'KB', 'MiB',
1028'G' and 'B' as number postfix.
1029
1030The list of available International System prefixes follows, with
1031indication of the corresponding powers of 10 and of 2.
1032@table @option
1033@item y
103410^-24 / 2^-80
1035@item z
103610^-21 / 2^-70
1037@item a
103810^-18 / 2^-60
1039@item f
104010^-15 / 2^-50
1041@item p
104210^-12 / 2^-40
1043@item n
104410^-9 / 2^-30
1045@item u
104610^-6 / 2^-20
1047@item m
104810^-3 / 2^-10
1049@item c
105010^-2
1051@item d
105210^-1
1053@item h
105410^2
1055@item k
105610^3 / 2^10
1057@item K
105810^3 / 2^10
1059@item M
106010^6 / 2^20
1061@item G
106210^9 / 2^30
1063@item T
106410^12 / 2^40
1065@item P
106610^15 / 2^40
1067@item E
106810^18 / 2^50
1069@item Z
107010^21 / 2^60
1071@item Y
107210^24 / 2^70
1073@end table
1074
1075@c man end EXPRESSION EVALUATION
1076