Ask Your Question
0

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

asked 4 years ago

curios_mind gravatar image

updated 4 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 4 years ago

eric_g gravatar image

updated 4 years ago

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
Preview: (hide)
link

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: 4 years ago

Seen: 282 times

Last updated: Jun 10 '20