~ubuntu-branches/ubuntu/oneiric/yacas/oneiric

« back to all changes in this revision

Viewing changes to manualmaker/in/preds.chapt.txt

  • Committer: Bazaar Package Importer
  • Author(s): Gopal Narayanan
  • Date: 2002-04-23 13:50:51 UTC
  • Revision ID: james.westby@ubuntu.com-20020423135051-bbd6ov4orr8eufmw
Tags: upstream-1.0.51
ImportĀ upstreamĀ versionĀ 1.0.51

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
                        Predicates
 
3
 
 
4
*INTRO
 
5
A predicate is a function that returns a boolean value, i.e. {True} or {False}. Predicates are
 
6
often used in patterns, For instance, a rule that only holds for a
 
7
positive integer would use a pattern such as {n_IsPositiveInteger}.
 
8
 
 
9
*CMD < --- test for "less than"
 
10
*STD
 
11
*CALL
 
12
        e1 < e2
 
13
(prec. 9)
 
14
 
 
15
*PARMS
 
16
 
 
17
e1, e2 - expressions to be compared
 
18
 
 
19
*DESC
 
20
 
 
21
The two expression are evaluated. If both results are numeric, they
 
22
are compared. If the first expression is smaller than the second one,
 
23
the result is {True} and it is {False} otherwise. If either of the expression is not numeric, after
 
24
evaluation, the expression is returned with evaluated arguments.
 
25
 
 
26
The word "numeric" in the previous paragraph has the following
 
27
meaning. An expression is numeric if it is either a number (i.e. {IsNumber} returns {True}), or the
 
28
quotient of two numbers, or an infinity (i.e. {IsInfinity} returns {True}).
 
29
 
 
30
*E.G.
 
31
 
 
32
        In> 2 < 5;
 
33
        Out> True;
 
34
        In> Cos(1) < 5;
 
35
        Out> Cos(1)<5;
 
36
        In> N(Cos(1)) < 5;
 
37
        Out> True
 
38
 
 
39
*SEE IsNumber, IsInfinity, N
 
40
 
 
41
*CMD > --- test for "greater than"
 
42
*STD
 
43
*CALL
 
44
        e1 > e2
 
45
(prec. 9)
 
46
 
 
47
*PARMS
 
48
 
 
49
e1, e2 - expressions to be compared
 
50
 
 
51
*DESC
 
52
 
 
53
The two expression are evaluated. If both results are numeric, they
 
54
are compared. If the first expression is larger than the second one,
 
55
the result is {True} and it is {False} otherwise. If either of the expression is not numeric, after
 
56
evaluation, the expression is returned with evaluated arguments.
 
57
 
 
58
The word "numeric" in the previous paragraph has the following
 
59
meaning. An expression is numeric if it is either a number (i.e. {IsNumber} returns {True}), or the
 
60
quotient of two numbers, or an infinity (i.e. {IsInfinity} returns {True}).
 
61
 
 
62
*E.G.
 
63
 
 
64
        In> 2 > 5;
 
65
        Out> False;
 
66
        In> Cos(1) > 5;
 
67
        Out> Cos(1)>5;
 
68
        In> N(Cos(1)) > 5;
 
69
        Out> False
 
70
 
 
71
*SEE IsNumber, IsInfinity, N
 
72
 
 
73
*CMD <= --- test for "less or equal"
 
74
*STD
 
75
*CALL
 
76
        e1 <= e2
 
77
(prec. 9)
 
78
 
 
79
*PARMS
 
80
 
 
81
e1, e2 - expressions to be compared
 
82
 
 
83
*DESC
 
84
 
 
85
The two expression are evaluated. If both results are numeric, they
 
86
are compared. If the first expression is smaller than or equals the
 
87
second one, the result is {True} and it is {False} otherwise. If either of the expression is not
 
88
numeric, after evaluation, the expression is returned with evaluated
 
89
arguments.
 
90
 
 
91
The word "numeric" in the previous paragraph has the following
 
92
meaning. An expression is numeric if it is either a number (i.e. {IsNumber} returns {True}), or the
 
93
quotient of two numbers, or an infinity (i.e. {IsInfinity} returns {True}).
 
94
 
 
95
*E.G.
 
96
 
 
97
        In> 2 <= 5;
 
98
        Out> True;
 
99
        In> Cos(1) <= 5;
 
100
        Out> Cos(1)<=5;
 
101
        In> N(Cos(1)) <= 5;
 
102
        Out> True
 
103
 
 
104
*SEE IsNumber, IsInfinity, N
 
105
 
 
106
*CMD >= --- test for "greater or equal"
 
107
*STD
 
108
*CALL
 
109
        e1 >= e2
 
110
(prec. 9)
 
111
 
 
112
*PARMS
 
113
 
 
114
e1, e2 - expressions to be compared
 
115
 
 
116
*DESC
 
117
 
 
118
The two expression are evaluated. If both results are numeric, they
 
119
are compared. If the first expression is larger than or equals the
 
120
second one, the result is {True} and it is {False} otherwise. If either of the expression is not
 
121
numeric, after evaluation, the expression is returned with evaluated
 
122
arguments.
 
123
 
 
124
The word "numeric" in the previous paragraph has the following
 
125
meaning. An expression is numeric if it is either a number (i.e. {IsNumber} returns {True}), or the
 
126
quotient of two numbers, or an infinity (i.e. {IsInfinity} returns {True}).
 
127
 
 
128
*E.G.
 
129
 
 
130
        In> 2 >= 5;
 
131
        Out> False;
 
132
        In> Cos(1) >= 5;
 
133
        Out> Cos(1)>=5;
 
134
        In> N(Cos(1)) >= 5;
 
135
        Out> False
 
136
 
 
137
*SEE IsNumber, IsInfinity, N
 
138
 
 
139
*CMD != --- test for "not equal"
 
140
*STD
 
141
*CALL
 
142
        e1 != e2
 
143
(prec. 9)
 
144
 
 
145
*PARMS
 
146
 
 
147
e1, e2 - expressions to be compared
 
148
 
 
149
*DESC
 
150
 
 
151
Both expression are evaluated and compared. If they turn out to be
 
152
equal, the result is {False}. Otherwise, the result
 
153
is {True}.
 
154
 
 
155
The expression {e1 != e2} is equivalent to {Not(e1 = e2)}.
 
156
 
 
157
*E.G.
 
158
 
 
159
        In> 1 != 2;
 
160
        Out> True;
 
161
        In> 1 != 1;
 
162
        Out> False;
 
163
 
 
164
*SEE =
 
165
 
 
166
*CMD = --- test for equality of expressions
 
167
*STD
 
168
*CALL
 
169
        e1 = e2
 
170
(prec. 9)
 
171
 
 
172
*PARMS
 
173
 
 
174
e1, e2 - expressions to be compared
 
175
 
 
176
*DESC
 
177
 
 
178
Both expression are evaluated and compared. If they turn out to be equal, the
 
179
result is {True}. Otherwise, the result is {False}. The function {Equals} does
 
180
the same.
 
181
 
 
182
Note that the test is on syntactic equality, not mathematical equality. Hence
 
183
even if the result is {False}, the expressions can still be
 
184
<i>mathematically</i> equal; see the examples below. Put otherwise, this
 
185
function tests whether the two expressions would be displayed in the same way
 
186
if they were printed.
 
187
 
 
188
*E.G.
 
189
 
 
190
        In> e1 := (x+1) * (x-1);
 
191
        Out> (x+1)*(x-1);
 
192
        In> e2 := x^2 - 1;
 
193
        Out> x^2-1;
 
194
        
 
195
        In> e1 = e2;
 
196
        Out> False;
 
197
        In> Expand(e1) = e2;
 
198
        Out> True;
 
199
 
 
200
*SEE !=, Equals
 
201
 
 
202
*CMD Not --- logical negation
 
203
*CORE
 
204
*CALL
 
205
        Not expr
 
206
 
 
207
*PARMS
 
208
 
 
209
{expr} -- a boolean expression
 
210
 
 
211
*DESC
 
212
 
 
213
Not returns the logical negation of the argument expr. If {expr} is
 
214
{False} it returns {True}, and if {expr} is {True}, {Not expr} returns {False}.
 
215
If the argument is neither {True} nor {False}, it returns the entire
 
216
expression with evaluated arguments.
 
217
 
 
218
*E.G.
 
219
 
 
220
        In> Not True
 
221
        Out> False;
 
222
        In> Not False
 
223
        Out> True;
 
224
        In> Not(a)
 
225
        Out> Not a;
 
226
 
 
227
*SEE And, Or
 
228
 
 
229
*CMD And --- logical conjunction
 
230
*CORE
 
231
*CALL
 
232
        a1 And a2
 
233
(prec. 100)
 
234
        And(a1, a2, a3, ..., aN)
 
235
 
 
236
*PARMS
 
237
 
 
238
{a}1, ..., {a}N - boolean values (may evaluate to {True} or {False})
 
239
 
 
240
*DESC
 
241
 
 
242
This function returns {True} if all arguments are true. The
 
243
{And} operation is "lazy", i.e. it returns {False} as soon as a {False} argument
 
244
is found (from left to right). If an argument other than {True} or
 
245
{False} is encountered a new {And} expression is returned with all
 
246
arguments that didn't evaluate to {True} or {False} yet.
 
247
 
 
248
*E.G.
 
249
 
 
250
        In> True And False
 
251
        Out> False;
 
252
        In> And(True,True)
 
253
        Out> True;
 
254
        In> False And a
 
255
        Out> False;
 
256
        In> True And a
 
257
        Out> And(a);
 
258
        In> And(True,a,True,b)
 
259
        Out> b And a;
 
260
 
 
261
*SEE Or, Not
 
262
 
 
263
*CMD Or --- logical disjunction
 
264
*CORE
 
265
*CALL
 
266
        a1 Or a2
 
267
(prec. 101)
 
268
        Or(a1, a2, a3, ..., aN)
 
269
 
 
270
*PARMS
 
271
 
 
272
{a}1, ..., {a}N - boolean expressions (may evaluate to {True} or {False})
 
273
 
 
274
*DESC
 
275
 
 
276
This function returns {True} if an argument is encountered
 
277
that is true (scanning from left to right). The
 
278
{Or} operation is "lazy", i.e. it returns {True} as soon as a {True} argument
 
279
is found (from left to right). If an argument other than {True} or
 
280
{False} is encountered, an unevaluated {Or} expression is returned with all
 
281
arguments that didn't evaluate to {True} or {False} yet.
 
282
 
 
283
*E.G.
 
284
 
 
285
        In> True Or False
 
286
        Out> True;
 
287
        In> False Or a
 
288
        Out> Or(a);
 
289
        In> Or(False,a,b,True)
 
290
        Out> True;
 
291
 
 
292
*SEE And, Not
 
293
 
 
294
*CMD IsFreeOf --- test whether expression depends on variable
 
295
*STD
 
296
*CALL
 
297
        IsFreeOf(var, expr)
 
298
        IsFreeOf({var, ...}, expr)
 
299
 
 
300
*PARMS
 
301
 
 
302
expr - expression to test
 
303
 
 
304
var - variable to look for in "expr"
 
305
 
 
306
*DESC
 
307
 
 
308
This function checks whether the expression "expr" (after being
 
309
evaluated) depends on the variable "var". It returns {False} if this is the case and {True}
 
310
otherwise.
 
311
 
 
312
The second form test whether the expression depends on <i>any</i> of
 
313
the variables named in the list. The result is {True} if none of the variables appear in the expression and {False} otherwise.
 
314
 
 
315
*E.G.
 
316
 
 
317
        In> IsFreeOf(x, Sin(x));
 
318
        Out> False;
 
319
        In> IsFreeOf(y, Sin(x));
 
320
        Out> True;
 
321
        In> IsFreeOf(x, D(x) a*x+b);
 
322
        Out> True;
 
323
        In> IsFreeOf({x,y}, Sin(x));
 
324
        Out> False;
 
325
 
 
326
The third command returns {True} because the
 
327
expression {D(x) a*x+b} evaluates to {a}, which does not depend on {x}.
 
328
 
 
329
*SEE Contains
 
330
 
 
331
*CMD IsZeroVector --- test whether list contains only zeroes
 
332
*STD
 
333
*CALL
 
334
        IsZeroVector(list)
 
335
 
 
336
*PARMS
 
337
 
 
338
list - list to compare against the zero vector
 
339
 
 
340
*DESC
 
341
 
 
342
The only argument given to {IsZeroVector} should be
 
343
a list. The result is {True} if the list contains
 
344
only zeroes and {False} otherwise.
 
345
 
 
346
*E.G.
 
347
 
 
348
        In> IsZeroVector({0, x, 0});
 
349
        Out> False;
 
350
        In> IsZeroVector({x-x, 1 - D(x) x});
 
351
        Out> True;
 
352
 
 
353
*SEE IsList, ZeroVector
 
354
 
 
355
*CMD IsNonObject --- test whether argument is not an {Object()}
 
356
*STD
 
357
*CALL
 
358
        IsNonObject(expr)
 
359
 
 
360
*PARMS
 
361
 
 
362
expr - the expression to examine
 
363
 
 
364
*DESC
 
365
 
 
366
This function returns {True} if "expr" is not of
 
367
the form {Object(...)} and {False}
 
368
otherwise.
 
369
 
 
370
*HEAD Bugs
 
371
 
 
372
In fact, the result is always {True}.
 
373
 
 
374
*SEE Object
 
375
 
 
376
*CMD IsEven --- test for an even integer
 
377
*STD
 
378
*CALL
 
379
        IsEven(n)
 
380
 
 
381
*PARMS
 
382
 
 
383
n - integer to test
 
384
 
 
385
*DESC
 
386
 
 
387
This function tests whether the integer "n" is even. An integer is
 
388
even if it is divisible by two. Hence the even numbers are 0, 2, 4, 6,
 
389
8, 10, etcetera, and -2, -4, -6, -8, -10, etcetera.
 
390
 
 
391
*E.G.
 
392
 
 
393
        In> IsEven(4);
 
394
        Out> True;
 
395
        In> IsEven(-1);
 
396
        Out> False;
 
397
 
 
398
*SEE IsOdd, IsInteger
 
399
 
 
400
*CMD IsOdd --- test for an odd integer
 
401
*STD
 
402
*CALL
 
403
        IsOdd(n)
 
404
 
 
405
*PARMS
 
406
 
 
407
n - integer to test
 
408
 
 
409
*DESC
 
410
 
 
411
This function tests whether the integer "n" is odd. An integer is
 
412
odd if it is not divisible by two. Hence the odd numbers are 1, 3, 5,
 
413
7, 9, etcetera, and -1, -3, -5, -7, -9, etcetera.
 
414
 
 
415
*E.G.
 
416
 
 
417
        In> IsOdd(4);
 
418
        Out> False;
 
419
        In> IsOdd(-1);
 
420
        Out> True;
 
421
 
 
422
*SEE IsEven, IsInteger
 
423
 
 
424
*CMD IsFunction --- test for a composite object
 
425
*CORE
 
426
*CALL
 
427
        IsFunction(expr)
 
428
 
 
429
*PARMS
 
430
 
 
431
expr - expression to test
 
432
 
 
433
*DESC
 
434
 
 
435
This function tests whether "expr" is a composite object, i.e. not an
 
436
atom. This includes not only obvious functions such as {f(x)}, but also expressions such as {x+5} and lists.
 
437
 
 
438
*E.G.
 
439
 
 
440
        In> IsFunction(x+5);
 
441
        Out> True;
 
442
        In> IsFunction(x);
 
443
        Out> False;
 
444
 
 
445
*SEE IsAtom, IsList, Type
 
446
 
 
447
*CMD IsAtom --- test for an atom
 
448
*CORE
 
449
*CALL
 
450
        IsAtom(expr)
 
451
 
 
452
*PARMS
 
453
 
 
454
expr - expression to test
 
455
 
 
456
*DESC
 
457
 
 
458
This function tests whether "expr" is an atom. Numbers, strings, and
 
459
variables are all atoms.
 
460
 
 
461
*E.G.
 
462
 
 
463
        In> IsAtom(x+5);
 
464
        Out> Falso;
 
465
        In> IsAtom(5);
 
466
        Out> True;
 
467
 
 
468
*SEE IsFunction, IsNumber, IsString
 
469
 
 
470
*CMD IsString --- test for an string
 
471
*CORE
 
472
*CALL
 
473
        IsString(expr)
 
474
 
 
475
*PARMS
 
476
 
 
477
expr - expression to test
 
478
 
 
479
*DESC
 
480
 
 
481
This function tests whether "expr" is a string. A string is a text
 
482
within quotes, eg. {"duh"}.
 
483
 
 
484
*E.G.
 
485
 
 
486
        In> IsString("duh");
 
487
        Out> True;
 
488
        In> IsString(duh);
 
489
        Out> False;
 
490
 
 
491
*SEE IsAtom, IsNumber
 
492
 
 
493
*CMD IsNumber --- test for a number
 
494
*CORE
 
495
*CALL
 
496
        IsNumber(expr)
 
497
 
 
498
*PARMS
 
499
 
 
500
expr - expression to test
 
501
 
 
502
*DESC
 
503
 
 
504
This function tests whether "expr" is a number. There are two kinds
 
505
of numbers, integers (e.g. 6) and reals (e.g. -2.75 or 6.0). Note that a
 
506
complex number is represented by the {Complex}
 
507
function, so {IsNumber} will return {False}.
 
508
 
 
509
*E.G.
 
510
 
 
511
        In> IsNumber(6);
 
512
        Out> True;
 
513
        In> IsNumber(3.25);
 
514
        Out> True;
 
515
        In> IsNumber(I);
 
516
        Out> False;
 
517
        In> IsNumber("duh");
 
518
        Out> False;
 
519
 
 
520
*SEE IsAtom, IsString, IsInteger, IsPositiveNumber, IsNegativeNumber, Complex
 
521
 
 
522
*CMD IsList --- test for a list
 
523
*CORE
 
524
*CALL
 
525
        IsList(expr)
 
526
 
 
527
*PARMS
 
528
 
 
529
expr - expression to test
 
530
 
 
531
*DESC
 
532
 
 
533
This function tests whether "expr" is a list. A list is a sequence
 
534
between curly braces, e.g. {{2, 3, 5}}.
 
535
 
 
536
*E.G.
 
537
 
 
538
        In> IsList({2,3,5});
 
539
        Out> True;
 
540
        In> IsList(2+3+5);
 
541
        Out> False;
 
542
 
 
543
*SEE IsFunction
 
544
 
 
545
*CMD IsNumericList --- test for a list of numbers
 
546
*STD
 
547
*CALL
 
548
        IsNumericList({list})
 
549
 
 
550
*PARMS
 
551
 
 
552
{{list}} -- a list
 
553
 
 
554
*DESC
 
555
Returns {True} when called on a list of numbers or expressions that evaluate to numbers using {N()}. Returns {False} otherwise.
 
556
 
 
557
*SEE N, IsNumber
 
558
 
 
559
*CMD IsBound --- test for a bound variable
 
560
*CORE
 
561
*CALL
 
562
        IsBound(var)
 
563
 
 
564
*PARMS
 
565
 
 
566
var - variable to test
 
567
 
 
568
*DESC
 
569
 
 
570
This function tests whether the variable "var" is bound, ie. whether
 
571
it has been assigned a value. The argument "var" is not evaluated.
 
572
 
 
573
*E.G.
 
574
 
 
575
        In> IsBound(x);
 
576
        Out> False;
 
577
        In> x := 5;
 
578
        Out> 5;
 
579
        In> IsBound(x);
 
580
        Out> True;
 
581
 
 
582
*SEE IsAtom
 
583
 
 
584
*CMD IsBoolean --- test for a Boolean value
 
585
*STD
 
586
*CALL
 
587
        IsBoolean(expression)
 
588
 
 
589
*PARMS
 
590
 
 
591
expression - an expression
 
592
 
 
593
*DESC
 
594
 
 
595
IsBoolean returns True if the argument is of a boolean type.
 
596
This means it has to be either True, False, or an expression involving
 
597
functions that return a boolean result, e.g.
 
598
{=}, {>}, {<}, {>=}, {<=}, {!=}, {And}, {Not}, {Or}.
 
599
 
 
600
*E.G.
 
601
 
 
602
        In> IsBoolean(a)
 
603
        Out> False;
 
604
        In> IsBoolean(True)
 
605
        Out> True;
 
606
        In> IsBoolean(a And b)
 
607
        Out> True;
 
608
 
 
609
*SEE True, False
 
610
 
 
611
*CMD IsNegativeNumber --- test for a negative number
 
612
*STD
 
613
*CALL
 
614
        IsNegativeNumber(n)
 
615
 
 
616
*PARMS
 
617
 
 
618
{n} - number to test
 
619
 
 
620
*DESC
 
621
 
 
622
{IsNegativeNumber(n)} evaluates to {True} if $n$ is (strictly) negative, i.e.
 
623
if $n<0$. If {n} is not a number, the functions return {False}. 
 
624
 
 
625
*E.G.
 
626
 
 
627
        In> IsNegativeNumber(6);
 
628
        Out> False;
 
629
        In> IsNegativeNumber(-2.5);
 
630
        Out> True;
 
631
 
 
632
*SEE IsNumber, IsPositiveNumber, IsNotZero, IsNegativeInteger, IsNegativeReal
 
633
 
 
634
*CMD IsNegativeInteger --- test for a negative integer
 
635
*STD
 
636
*CALL
 
637
        IsNegativeInteger(n)
 
638
 
 
639
*PARMS
 
640
 
 
641
{n} - integer to test
 
642
 
 
643
*DESC
 
644
 
 
645
This function tests whether the integer {n} is (strictly)
 
646
negative. The negative integers are -1, -2, -3, -4, -5, etcetera. If
 
647
{n} is not a integer, the function returns {False}.
 
648
 
 
649
*E.G.
 
650
 
 
651
        In> IsNegativeInteger(31);
 
652
        Out> False;
 
653
        In> IsNegativeInteger(-2);
 
654
        Out> True;
 
655
 
 
656
*SEE IsPositiveInteger, IsNonZeroInteger, IsNegativeNumber
 
657
 
 
658
*CMD IsPositiveNumber --- test for a positive number
 
659
*STD
 
660
*CALL
 
661
        IsPositiveNumber(n)
 
662
 
 
663
*PARMS
 
664
 
 
665
{n} - number to test
 
666
 
 
667
*DESC
 
668
 
 
669
{IsPositiveNumber(n)} evaluates to {True} if $n$ is (strictly) positive, i.e.
 
670
if $n>0$. If {n} is not a number the function returns {False}.
 
671
 
 
672
*E.G.
 
673
 
 
674
        In> IsPositiveNumber(6);
 
675
        Out> True;
 
676
        In> IsPositiveNumber(-2.5);
 
677
        Out> False;
 
678
 
 
679
*SEE IsNumber, IsNegativeNumber, IsNotZero, IsPositiveInteger, IsPositiveReal
 
680
 
 
681
*CMD IsPositiveInteger --- test for a positive integer
 
682
*STD
 
683
*CALL
 
684
        IsPositiveInteger(n)
 
685
 
 
686
*PARMS
 
687
 
 
688
{n} - integer to test
 
689
 
 
690
*DESC
 
691
 
 
692
This function tests whether the integer {n} is (strictly) positive. The
 
693
positive integers are 1, 2, 3, 4, 5, etcetera. If {n} is not a integer, the
 
694
function returns {False}.
 
695
 
 
696
*E.G.
 
697
 
 
698
        In> IsPositiveInteger(31);
 
699
        Out> True;
 
700
        In> IsPositiveInteger(-2);
 
701
        Out> False;
 
702
 
 
703
*SEE IsNegativeInteger, IsNonZeroInteger, IsPositiveNumber
 
704
 
 
705
*CMD IsNotZero --- test for a nonzero number
 
706
*STD
 
707
*CALL
 
708
        IsNotZero(n)
 
709
 
 
710
*PARMS
 
711
 
 
712
{n} - number to test
 
713
 
 
714
*DESC
 
715
 
 
716
{IsNotZero(n)} evaluates to {True} if {n} is not zero. In case {n} is not a
 
717
number, the function returns {False}.
 
718
 
 
719
*E.G.
 
720
 
 
721
        In> IsNotZero(3.25);
 
722
        Out> True;
 
723
        In> IsNotZero(0);
 
724
        Out> False;
 
725
 
 
726
*SEE IsNumber, IsPositiveNumber, IsNegativeNumber, IsNonZeroInteger
 
727
 
 
728
*CMD IsNonZeroInteger --- test for a nonzero integer
 
729
*STD
 
730
*CALL
 
731
        IsNonZeroInteger(n)
 
732
 
 
733
*PARMS
 
734
 
 
735
{n} - integer to test
 
736
 
 
737
*DESC
 
738
 
 
739
This function tests whether the integer {n} is not zero. If {n} is
 
740
not an integer, the result is {False}.
 
741
 
 
742
*E.G.
 
743
 
 
744
        In> IsNonZeroInteger(0)
 
745
        Out> False;
 
746
        In> IsNonZeroInteger(-2)
 
747
        Out> True;
 
748
 
 
749
*SEE IsPositiveInteger, IsNegativeInteger, IsNotZero
 
750
 
 
751
*CMD IsInfinity --- test for an infinity
 
752
*STD
 
753
*CALL
 
754
        IsInfinity(expr)
 
755
 
 
756
*PARMS
 
757
 
 
758
{expr} - expression to test
 
759
 
 
760
*DESC
 
761
 
 
762
This function tests whether {expr} is an infinity. This is only the
 
763
case if {expr} is either {Infinity} or {-Infinity}.
 
764
 
 
765
*E.G.
 
766
 
 
767
        In> IsInfinity(10^1000);
 
768
        Out> False;
 
769
        In> IsInfinity(-Infinity);
 
770
        Out> True;
 
771
 
 
772
*SEE Integer
 
773
 
 
774
*CMD IsPositiveReal --- test for a numerically positive value
 
775
*STD
 
776
*CALL
 
777
        IsPositiveReal(expr)
 
778
 
 
779
*PARMS
 
780
 
 
781
{expr} - expression to test
 
782
 
 
783
*DESC
 
784
 
 
785
This function tries to approximate "expr" numerically. It returns {True} if this approximation is positive. In case no
 
786
approximation can be found, the function returns {False}. Note that round-off errors may cause incorrect
 
787
results.
 
788
 
 
789
*E.G.
 
790
 
 
791
        In> IsPositiveReal(Sin(1)-3/4);
 
792
        Out> True;
 
793
        In> IsPositiveReal(Sin(1)-6/7);
 
794
        Out> False;
 
795
        In> IsPositiveReal(Exp(x));
 
796
        Out> False;
 
797
 
 
798
The last result is because {Exp(x)} cannot be
 
799
numerically approximated if {x} is not known. Hence
 
800
Yacas can not determine the sign of this expression.
 
801
 
 
802
*SEE IsNegativeReal, IsPositiveNumber, N
 
803
 
 
804
*CMD IsNegativeReal --- test for a numerically negative value
 
805
*STD
 
806
*CALL
 
807
        IsNegativeReal(expr)
 
808
 
 
809
*PARMS
 
810
 
 
811
{expr} - expression to test
 
812
 
 
813
*DESC
 
814
 
 
815
This function tries to approximate {expr} numerically. It returns {True} if this approximation is negative. In case no
 
816
approximation can be found, the function returns {False}. Note that round-off errors may cause incorrect
 
817
results.
 
818
 
 
819
*E.G.
 
820
 
 
821
        In> IsNegativeReal(Sin(1)-3/4);
 
822
        Out> False;
 
823
        In> IsNegativeReal(Sin(1)-6/7);
 
824
        Out> True;
 
825
        In> IsNegativeReal(Exp(x));
 
826
        Out> False;
 
827
 
 
828
The last result is because {Exp(x)} cannot be
 
829
numerically approximated if {x} is not known. Hence
 
830
Yacas can not determine the sign of this expression.
 
831
 
 
832
*SEE IsPositiveReal, IsNegativeNumber, N
 
833
 
 
834
*CMD IsConstant --- test for a constant
 
835
*STD
 
836
*CALL
 
837
        IsConstant(expr)
 
838
 
 
839
*PARMS
 
840
 
 
841
{expr} - some expression
 
842
 
 
843
*DESC
 
844
 
 
845
{IsConstant} returns {True} if the
 
846
expression is some constant or a function with constant arguments. It
 
847
does this by checking that no variables are referenced in the
 
848
expression. {Pi} is considered a constant.
 
849
 
 
850
*E.G.
 
851
 
 
852
        In> IsConstant(Cos(x))
 
853
        Out> False;
 
854
        In> IsConstant(Cos(2))
 
855
        Out> True;
 
856
        In> IsConstant(Cos(2+x))
 
857
        Out> False;
 
858
 
 
859
*SEE IsNumber, IsInteger, VarList
 
860
 
 
861
 
 
862
 
 
863
 
 
864
 
 
865
*CMD MatchLinear --- match an expression to a polynomial of degree one in a variable
 
866
*STD
 
867
*CALL
 
868
        MatchLinear(variable,expression)
 
869
 
 
870
*PARMS
 
871
 
 
872
{variable} - variable to express the univariate polynomial in
 
873
 
 
874
{expression} - expression to match
 
875
 
 
876
*DESC
 
877
 
 
878
MatchLinear tries to match an expression to a linear (degree less than
 
879
two) polynomial. The function returns True if it could match, and
 
880
it stores the resulting coefficients in the variables 'a' and 'b'
 
881
as a side effect. The function calling this predicate should declare
 
882
local variables 'a' and 'b' for this purpose.
 
883
MatchLinear tries to match to constant coefficients which don't
 
884
depend on the variable passed in, trying to find a form 'a*x+b'
 
885
with 'a' and 'b' not depending on 'x' if 'x' is given as the variable.
 
886
 
 
887
*E.G.
 
888
 
 
889
        In> MatchLinear(x,(R+1)*x+(T-1))
 
890
        Out> True;
 
891
        In> {a,b};
 
892
        Out> {R+1,T-1};
 
893
        In> MatchLinear(x,Sin(x)*x+(T-1))
 
894
        Out> False;
 
895
 
 
896
*SEE Integrate
 
897
 
 
898
 
 
899
*CMD HasExpr, HasExprArith, HasExprSome --- check for expression containing a subexpression
 
900
*STD
 
901
*CALL
 
902
        HasExpr(expr, x)
 
903
        HasExprArith(expr, x)
 
904
        HasExprSome(expr, x, list)
 
905
 
 
906
*PARMS
 
907
 
 
908
{expr} -- an expression
 
909
 
 
910
{x} -- a subexpression to be found
 
911
 
 
912
{list} -- list of function atoms to be considered "transparent"
 
913
 
 
914
*DESC
 
915
 
 
916
The command {HasExpr} returns {True} if the expression {expr} contains a literal subexpression {x}. The expression is recursively traversed.
 
917
 
 
918
The command {HasExprSome} does the same, except it only looks at arguments of a given {list} of functions. All other functions become "opaque" (as if they do not contain anything).
 
919
 
 
920
{HasExprArith} is defined through {HasExprSome} to look only at arithmetic operations {+}, {-}, {*}, {/}.
 
921
 
 
922
Note that since the operators "{+}" and "{-}" are prefix as well as infix operators, it is currently required to use {Atom("+")} to obtain the unevaluated atom "{+}".
 
923
 
 
924
*E.G.
 
925
 
 
926
        In> HasExpr(x+y*Cos(Ln(z)/z), z)
 
927
        Out> True;
 
928
        In> HasExpr(x+y*Cos(Ln(z)/z), Ln(z))
 
929
        Out> True;
 
930
        In> HasExpr(x+y*Cos(Ln(z)/z), z/Ln(z))
 
931
        Out> False;
 
932
        In> HasExprArith(x+y*Cos(Ln(x)/x), z)
 
933
        Out> False;
 
934
        In> HasExprSome({a+b*2,c/d},c/d,{List})
 
935
        Out> True;
 
936
        In> HasExprSome({a+b*2,c/d},c,{List})
 
937
        Out> False;
 
938
 
 
939
*SEE FuncList, VarList, HasFunc
 
940
 
 
941
*CMD HasFunc, HasFuncArith, HasFuncSome --- check for expression containing a function
 
942
*STD
 
943
*CALL
 
944
        HasFunc(expr, func)
 
945
        HasFuncArith(expr, func)
 
946
        HasFuncSome(expr, func, list)
 
947
 
 
948
*PARMS
 
949
 
 
950
{expr} -- an expression
 
951
 
 
952
{func} -- a function atom to be found
 
953
 
 
954
{list} -- list of function atoms to be considered "transparent"
 
955
 
 
956
*DESC
 
957
 
 
958
The command {HasFunc} returns {True} if the expression {expr} contains a function {func}. The expression is recursively traversed.
 
959
 
 
960
The command {HasFuncSome} does the same, except it only looks at arguments of a given {list} of functions. Arguments of all other functions become "opaque" (as if they do not contain anything).
 
961
 
 
962
{HasFuncArith} is defined through {HasFuncSome} to look only at arithmetic operations {+}, {-}, {*}, {/}.
 
963
 
 
964
Note that since the operators "{+}" and "{-}" are prefix as well as infix operators, it is currently required to use {Atom("+")} to obtain the unevaluated atom "{+}".
 
965
 
 
966
*E.G.
 
967
 
 
968
        In> HasFunc(x+y*Cos(Ln(z)/z), Ln)
 
969
        Out> True;
 
970
        In> HasFunc(x+y*Cos(Ln(z)/z), Sin)
 
971
        Out> False;
 
972
        In> HasFuncArith(x+y*Cos(Ln(x)/x), Cos)
 
973
        Out> True;
 
974
        In> HasFuncArith(x+y*Cos(Ln(x)/x), Ln)
 
975
        Out> False;
 
976
        In> HasFuncSome({a+b*2,c/d},/,{List})
 
977
        Out> True;
 
978
        In> HasFuncSome({a+b*2,c/d},*,{List})
 
979
        Out> False;
 
980
 
 
981
*SEE FuncList, VarList, HasExpr