Ask Your Question
0

Selecting specific values in Sage

asked 2020-07-16 05:13:23 +0100

EconJohn gravatar image

updated 2020-07-16 05:20:01 +0100

I have the following solution:

solve(...)=[[xa1 == R*a/((a + b)*p1), xa2 == R*b/(a + b), l1 == (a + b)*(R*b/(a + b))^b*(R*a/((a + b)*p1))^a/R]]

Im aware I can get the whole set of solutions back with the use of

solve(...)[0]
[xa1 == R*a/((a + b)*p1), xa2 == R*b/(a + b), l1 == (a + b)*(R*b/(a + b))^b*(R*a/((a + b)*p1))^a/R]

Im only interested in getting back xa1. Is there a way to do that?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-07-16 05:59:28 +0100

EconJohn gravatar image

A solution I found to this problem is that you need to do as follows:

 solution1=solve(...)[0]
 solution1[0]

 xa1 == R*a/((a + b)*p1), xa2 == R*b/(a + b)
edit flag offensive delete link more

Comments

1

solution1(0][0] i more streamlined. And faster.

You should peruse a Python tutorial ; Python lends itself to a lot of useful idioms,which may be time consuming to discover by yourself.

I cannot recommend enough this marvelous book on Sage, even if it's a bit outdated (reporting on a Python 2-based version of Sage, whereas Sage is Python 3-based : version 9.1 and later support only Python 3).

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2020-07-16 12:32:12 +0100 )edit

@EmmanuelCharpentier Thanks for the tip!

EconJohn gravatar imageEconJohn ( 2020-07-16 16:30:02 +0100 )edit

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-07-16 05:13:23 +0100

Seen: 247 times

Last updated: Jul 16 '20