Sponsored links: Algebra eBooks ### The Maxima on-line user's manual

Algebra Calculator

#### Search: #### Delete

Function: delete (<expr_1>, <expr_2>)

Function: delete (<expr_1>, <expr_2>, <n>) `delete(<expr_1>, <expr_2>)` removes from <expr_2> any arguments of its top-level operator which are the same (as determined by "=") as <expr_1>. Note that "=" tests for formal equality, not equivalence. Note also that arguments of subexpressions are not affected.

<expr_1> may be an atom or a non-atomic expression. <expr_2> may be any non-atomic expression. `delete` returns a new expression; it does not modify <expr_2>.

`delete(<expr_1>, <expr_2>, <n>)` removes from <expr_2> the first <n> arguments of the top-level operator which are the same as <expr_1>. If there are fewer than <n> such arguments, then all such arguments are removed.

Examples:

Removing elements from a list.

```          (%i1) delete (y, [w, x, y, z, z, y, x, w]);
(%o1)                  [w, x, z, z, x, w]```

Removing terms from a sum.

```          (%i1) delete (sin(x), x + sin(x) + y);
(%o1)                         y + x```

Removing factors from a product.

```          (%i1) delete (u - x, (u - w)*(u - x)*(u - y)*(u - z));
(%o1)                (u - w) (u - y) (u - z)```

Removing arguments from an arbitrary expression.

```          (%i1) delete (a, foo (a, b, c, d, a));
(%o1)                     foo(b, c, d)```

Limit the number of removed arguments.

```          (%i1) delete (a, foo (a, b, a, c, d, a), 2);
(%o1)                    foo(b, c, d, a)```

Whether arguments are the same as <expr_1> is determined by "=". Arguments which are `equal` but not "=" are not removed.

`          (%i1) [is (equal (0, 0)), is (equal (0, 0.0)), is (equal (0, 0b0))];`

`rat` replaced 0.0 by 0/1 = 0.0 `rat` replaced 0.0B0 by 0/1 = 0.0B0

`          (%o1)                  [true, true, true]`
`          (%i2) [is (0 = 0), is (0 = 0.0), is (0 = 0b0)];`
`          (%o2)                 [true, false, false]`
`          (%i3) delete (0, [0, 0.0, 0b0]);`
`          (%o3)                     [0.0, 0.0b0]`
`          (%i4) is (equal ((x + y)*(x - y), x^2 - y^2));`
`          (%o4)                         true`
`          (%i5) is ((x + y)*(x - y) = x^2 - y^2);`
`          (%o5)                         false`
`          (%i6) delete ((x + y)*(x - y), [(x + y)*(x - y), x^2 - y^2]);`
`                                        2    2`
`          (%o6)                       [x  - y ]`

There are also some inexact matches for `delete`. Try `?? delete` to see them.

```(%o1)                                true
(%i2) ```

### Related Examples

##### delete-matrix-transpose

M:matrix([1,2,3],[a,b...

if M=2 then lis...

list;

Calculate

##### delete-divisors-length

atijd :divisors(50);

atijd : delete(50,ati...

atijd : delete(1,atijd);

Calculate

L : [x,y,z,w];

a : x;

L : delete(a,L);

Calculate

##### delete-print

S:[[1,2],[1,3]];

I:[1,2];

S:delete([1,2],S);

Calculate

##### delete-every-full_listify-lambda-listify-makelist-map-mod-primep-set_partitions-sort-sublist

p:sublist(makelist(k,...

s:makelist([(k-mod(k,...

s:map(lambda([x],dele...

Calculate

##### delete

a:[3,4,5,6,2,3,2];

delete(2,[a]);

Calculate

##### delete-every-full_listify-lambda-listify-makelist-map-mod-primep-set_partitions-sort-sublist

p:sublist(makelist(k,...

s:makelist([(k-mod(k,...

s:map(lambda([x],dele...

Calculate

##### delete

arr: [a,[a],[],[[]]];

delete([],arr);

Calculate

L : [x,y,z,w];

delete(x,L);

Calculate

##### delete-divisors

atijd :divisors(50);

atijd : delete(50,ati...

Calculate 