Ask Your Question

Revision history [back]

When you do:

sage: y = function('y',x)
sage: temp = diff(9*x^(1/2) - 2*y^(3/5) - y)
sage: a = solve(temp,diff(y)); a
[D[0](y)(x) == 45/2*y(x)^(2/5)/(5*sqrt(x)*y(x)^(2/5) + 6*sqrt(x))]

You see that the result is a list containing one equality.

If I understand correctly you would like to have just "y" instead of "y(x)" in the equation. Probably on the left-hand side you also want to get rid of the "(x)", and let's also have "y'" instead of "D[0](y)".

Since you're interested in the displayed result, there are two ways we could go.

One is to try to manipulate the expression itself. It's possible to explore the equation and get to all the individual pieces, but replacing "y(x)" by "y" in the symbolic expression is going to be too hard: even when you just ask for "y", you get "y(x)".

sage: y
y(x)

The second option is to just work on the string. Here is what I would do.

For the left-hand side it's easier to just input y' by hand, and let's throw in the equal sign.

sage: sa = 'y\' = '

Then we can work on the right-hand side.

sage: b = a[0].rhs(); b
45/2*y(x)^(2/5)/(5*sqrt(x)*y(x)^(2/5) + 6*sqrt(x))

Get the latex string.

sage: c = str(latex(b)); c
'\\frac{45 \\, y\\left(x\\right)^{\\frac{2}{5}}}{2 \\, ...'

Now replace.

sage: sb = c.replace('y\\left(x\\right)','y'); sb
'\\frac{45 \\, y^{\\frac{2}{5}}}{2 \\, ...'

Put things together, make it into a latex expression again, and display.

sage: aa = LatexExpr(sa+sb); aa
sage: show(aa)