It seems indeed that you hit a bug:

```
sage: var('x')
x
sage: function('y', x)
y(x)
sage: de = x*e^y*diff(y,x) == 2*(e^y+x^3*e^(2*x))
TypeError:
```

When you write `var('x')`

, two actions are done : it returns the symbolic variable (or "symbol") `x`

and it gives to the Python variable (or 'name') `x`

this value. This process of both returning a value and creating a Python variable with the same name is called *variable injection*, and it is a big source of confusion.

When you write `function('y', x)`

, it is supposed to be the same : it should return the symbolic function `y(x)`

and it give to the Python variable (or 'name') `y`

this value.

The problem comes from the fact that `function()`

does not inject its result into the Python variable `y`

correctly:

```
sage: z = function('y', x)
sage: y
y
sage: z
y(x)
sage: y == z
False
sage: type(y)
<class 'sage.symbolic.function_factory.NewSymbolicFunction'>
sage: type(z)
<type 'sage.symbolic.expression.Expression'>
```

As you can see, `function('y', x)`

returned a *symbolic expression* `y(x)`

, while the Python variable `y`

got some different stuff, more precisely a *function* (with no variable name specifies, somehow similar to `cos`

or `sin`

).

So, a first workaround is to overwrite the variable injection:

```
sage: x = var('x')
sage: y = function('y', x)
sage: de = x*e^y*diff(y,x) == 2*(e^y+x^3*e^(2*x))
sage: de
x*e^y(x)*D[0](y)(x) == 2*x^3*e^(2*x) + 2*e^y(x)
```

Another workaround is to consider `y`

as a function (whose variable name is not specified), and use the symbolic expression `y(x)`

in your equation:

```
sage: var('x')
sage: function('y')
y
sage: de = x*e^y(x)*diff(y(x),x) == 2*(e^y(x)+x^3*e^(2*x))
sage: de
x*e^y(x)*D[0](y)(x) == 2*x^3*e^(2*x) + 2*e^y(x)
```

Thanks for reporting, actually a similar bug was reported as trac ticket 15025.

You should better copy the content of the worksheet in the question, so that it is easier to copy/paste, and so that the information will not disappear when the image will be removed from remote website.