1 | initial version |

what about using coefficient():

```
sage: expr = sol3[0].rhs()
sage: expr.coefficient(D*H)
1/4
```

let me mention that wild cards could also be useful in this type of task:

```
sage: var('DH'); w0 = SR.wild();
sage: expr.subs({D*H*w0 : DH*w0}).coefficient(DH)
-1/4
```

2 | No.2 Revision |

what about using coefficient():

```
sage: expr = sol3[0].rhs()
sage: expr.coefficient(D*H)
```~~1/4
~~-1/4

let me mention that wild cards could also be useful in this type of task:

```
sage: var('DH'); w0 = SR.wild();
sage: expr.subs({D*H*w0 : DH*w0}).coefficient(DH)
-1/4
```

3 | No.3 Revision |

what about using coefficient():

```
sage: expr = sol3[0].rhs()
sage: expr.coefficient(D*H)
-1/4
```

let me mention that wild cards could also be useful in this type of task:

```
sage: var('DH'); w0 = SR.wild();
sage: expr.subs({D*H*w0 : DH*w0}).coefficient(DH)
-1/4
```

*Edit:* there is the following trick of adding/removing the term of interest:

```
sage: DHterm = expr.coefficient(D*H)*D*H
sage: ((expr-DHterm).factor() + DHterm).collect(D)
-1/4*D*(H - 2*Nb*Pmean/((alpha + 1)*c))
```

... but it would be nice to know if there is a more "direct" (=one command) method!

4 | No.4 Revision |

what about using coefficient():

```
sage: expr = sol3[0].rhs()
sage: expr.coefficient(D*H)
-1/4
```

let me mention that wild cards could also be useful in this type of task:

```
sage: var('DH'); w0 = SR.wild();
sage: expr.subs({D*H*w0 : DH*w0}).coefficient(DH)
-1/4
```

*Edit:* there is the following trick of adding/removing the term of ~~interest:~~interest which works here:

```
sage: DHterm = expr.coefficient(D*H)*D*H
sage: ((expr-DHterm).factor() + DHterm).collect(D)
-1/4*D*(H - 2*Nb*Pmean/((alpha + 1)*c))
```

... but it would be nice to know if there is a more "direct" (=one command) method!

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.