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@item 22.2 723FL+FR+FC+LFE+BL+BR+FLC+FRC+BC+SL+SR+TC+TFL+TFC+TFR+TBL+TBC+TBR+LFE2+TSL+TSR+BFC+BFL+BFR 724@end table 725 726A custom channel layout can be specified as a sequence of terms, separated by '+'. 727Each term can be: 728@itemize 729@item 730the name of a single channel (e.g. @samp{FL}, @samp{FR}, @samp{FC}, @samp{LFE}, etc.), 731each optionally containing a custom name after a '@@', (e.g. @samp{FL@@Left}, 732@samp{FR@@Right}, @samp{FC@@Center}, @samp{LFE@@Low_Frequency}, etc.) 733@end itemize 734 735A standard channel layout can be specified by the following: 736@itemize 737@item 738the name of a single channel (e.g. @samp{FL}, @samp{FR}, @samp{FC}, @samp{LFE}, etc.) 739 740@item 741the name of a standard channel layout (e.g. @samp{mono}, 742@samp{stereo}, @samp{4.0}, @samp{quad}, @samp{5.0}, etc.) 743 744@item 745a number of channels, in decimal, followed by 'c', yielding the default channel 746layout for that number of channels (see the function 747@code{av_channel_layout_default}). Note that not all channel counts have a 748default layout. 749 750@item 751a number of channels, in decimal, followed by 'C', yielding an unknown channel 752layout with the specified number of channels. Note that not all channel layout 753specification strings support unknown channel layouts. 754 755@item 756a channel layout mask, in hexadecimal starting with "0x" (see the 757@code{AV_CH_*} macros in @file{libavutil/channel_layout.h}. 758@end itemize 759 760Before libavutil version 53 the trailing character "c" to specify a number of 761channels was optional, but now it is required, while a channel layout mask can 762also be specified as a decimal number (if and only if not followed by "c" or "C"). 763 764See also the function @code{av_channel_layout_from_string} defined in 765@file{libavutil/channel_layout.h}. 766@c man end SYNTAX 767 768@chapter Expression Evaluation 769@c man begin EXPRESSION EVALUATION 770 771When evaluating an arithmetic expression, FFmpeg uses an internal 772formula evaluator, implemented through the @file{libavutil/eval.h} 773interface. 774 775An expression may contain unary, binary operators, constants, and 776functions. 777 778Two expressions @var{expr1} and @var{expr2} can be combined to form 779another expression "@var{expr1};@var{expr2}". 780@var{expr1} and @var{expr2} are evaluated in turn, and the new 781expression evaluates to the value of @var{expr2}. 782 783The following binary operators are available: @code{+}, @code{-}, 784@code{*}, @code{/}, @code{^}. 785 786The following unary operators are available: @code{+}, @code{-}. 787 788The following functions are available: 789@table @option 790@item abs(x) 791Compute absolute value of @var{x}. 792 793@item acos(x) 794Compute arccosine of @var{x}. 795 796@item asin(x) 797Compute arcsine of @var{x}. 798 799@item atan(x) 800Compute arctangent of @var{x}. 801 802@item atan2(x, y) 803Compute principal value of the arc tangent of @var{y}/@var{x}. 804 805@item between(x, min, max) 806Return 1 if @var{x} is greater than or equal to @var{min} and lesser than or 807equal to @var{max}, 0 otherwise. 808 809@item bitand(x, y) 810@item bitor(x, y) 811Compute bitwise and/or operation on @var{x} and @var{y}. 812 813The results of the evaluation of @var{x} and @var{y} are converted to 814integers before executing the bitwise operation. 815 816Note that both the conversion to integer and the conversion back to 817floating point can lose precision. Beware of unexpected results for 818large numbers (usually 2^53 and larger). 819 820@item ceil(expr) 821Round the value of expression @var{expr} upwards to the nearest 822integer. For example, "ceil(1.5)" is "2.0". 823 824@item clip(x, min, max) 825Return the value of @var{x} clipped between @var{min} and @var{max}. 826 827@item cos(x) 828Compute cosine of @var{x}. 829 830@item cosh(x) 831Compute hyperbolic cosine of @var{x}. 832 833@item eq(x, y) 834Return 1 if @var{x} and @var{y} are equivalent, 0 otherwise. 835 836@item exp(x) 837Compute exponential of @var{x} (with base @code{e}, the Euler's number). 838 839@item floor(expr) 840Round the value of expression @var{expr} downwards to the nearest 841integer. For example, "floor(-1.5)" is "-2.0". 842 843@item gauss(x) 844Compute Gauss function of @var{x}, corresponding to 845@code{exp(-x*x/2) / sqrt(2*PI)}. 846 847@item gcd(x, y) 848Return the greatest common divisor of @var{x} and @var{y}. If both @var{x} and 849@var{y} are 0 or either or both are less than zero then behavior is undefined. 850 851@item gt(x, y) 852Return 1 if @var{x} is greater than @var{y}, 0 otherwise. 853 854@item gte(x, y) 855Return 1 if @var{x} is greater than or equal to @var{y}, 0 otherwise. 856 857@item hypot(x, y) 858This function is similar to the C function with the same name; it returns 859"sqrt(@var{x}*@var{x} + @var{y}*@var{y})", the length of the hypotenuse of a 860right triangle with sides of length @var{x} and @var{y}, or the distance of the 861point (@var{x}, @var{y}) from the origin. 862 863@item if(x, y) 864Evaluate @var{x}, and if the result is non-zero return the result of 865the evaluation of @var{y}, return 0 otherwise. 866 867@item if(x, y, z) 868Evaluate @var{x}, and if the result is non-zero return the evaluation 869result of @var{y}, otherwise the evaluation result of @var{z}. 870 871@item ifnot(x, y) 872Evaluate @var{x}, and if the result is zero return the result of the 873evaluation of @var{y}, return 0 otherwise. 874 875@item ifnot(x, y, z) 876Evaluate @var{x}, and if the result is zero return the evaluation 877result of @var{y}, otherwise the evaluation result of @var{z}. 878 879@item isinf(x) 880Return 1.0 if @var{x} is +/-INFINITY, 0.0 otherwise. 881 882@item isnan(x) 883Return 1.0 if @var{x} is NAN, 0.0 otherwise. 884 885@item ld(var) 886Load the value of the internal variable with number 887@var{var}, which was previously stored with st(@var{var}, @var{expr}). 888The function returns the loaded value. 889 890@item lerp(x, y, z) 891Return linear interpolation between @var{x} and @var{y} by amount of @var{z}. 892 893@item log(x) 894Compute natural logarithm of @var{x}. 895 896@item lt(x, y) 897Return 1 if @var{x} is lesser than @var{y}, 0 otherwise. 898 899@item lte(x, y) 900Return 1 if @var{x} is lesser than or equal to @var{y}, 0 otherwise. 901 902@item max(x, y) 903Return the maximum between @var{x} and @var{y}. 904 905@item min(x, y) 906Return the minimum between @var{x} and @var{y}. 907 908@item mod(x, y) 909Compute the remainder of division of @var{x} by @var{y}. 910 911@item not(expr) 912Return 1.0 if @var{expr} is zero, 0.0 otherwise. 913 914@item pow(x, y) 915Compute the power of @var{x} elevated @var{y}, it is equivalent to 916"(@var{x})^(@var{y})". 917 918@item print(t) 919@item print(t, l) 920Print the value of expression @var{t} with loglevel @var{l}. If 921@var{l} is not specified then a default log level is used. 922Returns the value of the expression printed. 923 924Prints t with loglevel l 925 926@item random(x) 927Return a pseudo random value between 0.0 and 1.0. @var{x} is the index of the 928internal variable which will be used to save the seed/state. 929 930@item root(expr, max) 931Find an input value for which the function represented by @var{expr} 932with argument @var{ld(0)} is 0 in the interval 0..@var{max}. 933 934The expression in @var{expr} must denote a continuous function or the 935result is undefined. 936 937@var{ld(0)} is used to represent the function input value, which means 938that the given expression will be evaluated multiple times with 939various input values that the expression can access through 940@code{ld(0)}. When the expression evaluates to 0 then the 941corresponding input value will be returned. 942 943@item round(expr) 944Round the value of expression @var{expr} to the nearest integer. For example, "round(1.5)" is "2.0". 945 946@item sgn(x) 947Compute sign of @var{x}. 948 949@item sin(x) 950Compute sine of @var{x}. 951 952@item sinh(x) 953Compute hyperbolic sine of @var{x}. 954 955@item sqrt(expr) 956Compute the square root of @var{expr}. This is equivalent to 957"(@var{expr})^.5". 958 959@item squish(x) 960Compute expression @code{1/(1 + exp(4*x))}. 961 962@item st(var, expr) 963Store the value of the expression @var{expr} in an internal 964variable. @var{var} specifies the number of the variable where to 965store the value, and it is a value ranging from 0 to 9. The function 966returns the value stored in the internal variable. 967Note, Variables are currently not shared between expressions. 968 969@item tan(x) 970Compute tangent of @var{x}. 971 972@item tanh(x) 973Compute hyperbolic tangent of @var{x}. 974 975@item taylor(expr, x) 976@item taylor(expr, x, id) 977Evaluate a Taylor series at @var{x}, given an expression representing 978the @code{ld(id)}-th derivative of a function at 0. 979 980When the series does not converge the result is undefined. 981 982@var{ld(id)} is used to represent the derivative order in @var{expr}, 983which means that the given expression will be evaluated multiple times 984with various input values that the expression can access through 985@code{ld(id)}. If @var{id} is not specified then 0 is assumed. 986 987Note, when you have the derivatives at y instead of 0, 988@code{taylor(expr, x-y)} can be used. 989 990@item time(0) 991Return the current (wallclock) time in seconds. 992 993@item trunc(expr) 994Round the value of expression @var{expr} towards zero to the nearest 995integer. For example, "trunc(-1.5)" is "-1.0". 996 997@item while(cond, expr) 998Evaluate expression @var{expr} while the expression @var{cond} is 999non-zero, and returns the value of the last @var{expr} evaluation, or 1000NAN if @var{cond} was always false. 1001@end table 1002 1003The following constants are available: 1004@table @option 1005@item PI 1006area of the unit disc, approximately 3.14 1007@item E 1008exp(1) (Euler's number), approximately 2.718 1009@item PHI 1010golden ratio (1+sqrt(5))/2, approximately 1.618 1011@end table 1012 1013Assuming that an expression is considered "true" if it has a non-zero 1014value, note that: 1015 1016@code{*} works like AND 1017 1018@code{+} works like OR 1019 1020For example the construct: 1021@example 1022if (A AND B) then C 1023@end example 1024is equivalent to: 1025@example 1026if(A*B, C) 1027@end example 1028 1029In your C code, you can extend the list of unary and binary functions, 1030and define recognized constants, so that they are available for your 1031expressions. 1032 1033The evaluator also recognizes the International System unit prefixes. 1034If 'i' is appended after the prefix, binary prefixes are used, which 1035are based on powers of 1024 instead of powers of 1000. 1036The 'B' postfix multiplies the value by 8, and can be appended after a 1037unit prefix or used alone. This allows using for example 'KB', 'MiB', 1038'G' and 'B' as number postfix. 1039 1040The list of available International System prefixes follows, with 1041indication of the corresponding powers of 10 and of 2. 1042@table @option 1043@item y 104410^-24 / 2^-80 1045@item z 104610^-21 / 2^-70 1047@item a 104810^-18 / 2^-60 1049@item f 105010^-15 / 2^-50 1051@item p 105210^-12 / 2^-40 1053@item n 105410^-9 / 2^-30 1055@item u 105610^-6 / 2^-20 1057@item m 105810^-3 / 2^-10 1059@item c 106010^-2 1061@item d 106210^-1 1063@item h 106410^2 1065@item k 106610^3 / 2^10 1067@item K 106810^3 / 2^10 1069@item M 107010^6 / 2^20 1071@item G 107210^9 / 2^30 1073@item T 107410^12 / 2^40 1075@item P 107610^15 / 2^40 1077@item E 107810^18 / 2^50 1079@item Z 108010^21 / 2^60 1081@item Y 108210^24 / 2^70 1083@end table 1084 1085@c man end EXPRESSION EVALUATION 1086