Ask Your Question
0

subs: why it accepts one form but not the other?

asked 2020-06-10 03:51:05 +0100

curios_mind gravatar image

updated 2020-06-10 04:09:11 +0100

Hello,

Consider the following expression

y=function("y")(x)
z=-3*diff(y,x)/y^4

I would like to replace diff(y,x)/y^4 by, say, 2/5

I tried,

z.subs(diff(y,x)/y^4==2/5).show()

But this didn't work (threw back at me the original expression)

I tried to replace y^4 by 5, and to do that I did

z.subs(y^4==5).show()

It didn't work. However,

z.subs(1/y^4==5).show()

worked!. I am confused!

If I tried to replace just y with 5^(1/4)

z.subs(y==(5)^(1/4)).show()

it worked! so it cannot replace y^4 with 5, but it can replace y with (5)^1/4.

To get what I want I finally did

z.subs(diff(y,x)==2).subs(1/y^4==5).show()

I got this by trial and error. Shouldn't the first one

z.subs(diff(y,x)/y^4==2/5).show()

have worked in the first place? What is the logic behind this that it didn't work?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-06-10 17:41:02 +0100

eric_g gravatar image

updated 2020-06-10 17:41:44 +0100

The general strategy to replace a composed expression like diff(y, x)/y^4 is to replace only a simple part of it by an equivalent expression. In your case:

sage: y = function('y')
sage: Y = y(x)
sage: z = -3*diff(Y, x)/Y^4
sage: z.subs(diff(Y, x) == 2/5*Y^4)
-6/5
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-06-10 03:51:05 +0100

Seen: 245 times

Last updated: Jun 10 '20