# Beginner problem solving equations.

Dear all,

This is my second day on Sagemath!

I don't understand what I'm doing wrong, and right now, I can't even open the documentation online (I get error even there). I simply want to solve the last equation for p_n, I suppose that Sage sees that I am comparing two equations, so it doesn't understand that I want to compare the right-hand side of both, but then what is the purpose of the .rhs method? (Even here, it would be nice to understand what this is... I'm copying the code of a friend of mine and trying to apply it to my own problem).

P.S. Also with respect to the documentation, what should I read, about this stuff? I went through the first sections, but I saw nothing on methods.

var('x, p_r, p_n, t, beta, delta')

U_ow_np = x - p_n
U_ow_p  = x*(1-beta) - p_n + (delta/(1-delta))*p_r*(1-t)
U_r_p   = 1-x*(1-beta) - delta*p_r
U_O_O   = 1-x
x_ow_np_ow_p = solve(U_ow_np == U_ow_p, x)[0].rhs
x_ow_p_r_p = solve(U_ow_p == U_r_p, x)[0].rhs
x_r_p_O_O = solve(U_r_p == U_O_O, x)[0].rhs

# Here I get the error.

solve(x_ow_np_ow_p == x_ow_p_r_p, p_n)[0].rhs

P.S. What does the [0] mean?

Sorry for the naivite, I tried to have a look on the forum, but this problem seems too basic for this forum...

edit retag close merge delete

( 2021-06-08 12:57:14 +0200 )edit
1

Try using .rhs() with brackets. [0] gives you the first element of an array.

var('x, p_r, p_n, t, beta, delta')

U_ow_np = x - p_n
U_ow_p  = x*(1-beta) - p_n + (delta/(1-delta))*p_r*(1-t)
U_r_p   = 1-x*(1-beta) - delta*p_r
U_O_O   = 1-x
x_ow_np_ow_p = solve(U_ow_np == U_ow_p, x)[0].rhs()
x_ow_p_r_p = solve(U_ow_p == U_r_p, x)[0].rhs()
x_r_p_O_O = solve(U_r_p == U_O_O, x)[0].rhs()

# Here I get the error.
show(x_ow_np_ow_p)
show(x_ow_p_r_p)

solve(x_ow_np_ow_p == x_ow_p_r_p, p_n)[0].rhs()
( 2021-06-08 13:05:18 +0200 )edit

Exactly, thank you!

( 2021-06-08 15:08:03 +0200 )edit

Sort by ยป oldest newest most voted

Ok I see, I'm not using the parenthesis on the method, hence it doesn't work, and .rhs()tells to Sage exactly that it has to consider only the right hand side of the equation.

Sorry, I found the solution by myself, in the end... Delete everything!

more

( 2021-06-08 13:03:43 +0200 )edit
1

I strongly recommend this book f you want to ease your beginnings with Sagemath...

Also : state your answer explicitly : it could be of use to the next beginner...

( 2021-06-08 13:51:17 +0200 )edit

Hi guys, I am so noob that the forum doesn't even allow me to accept my own answer!

( 2021-06-08 15:09:06 +0200 )edit