Ask Your Question

Hun's profile - activity

2017-02-25 17:10:00 -0500 received badge  Famous Question (source)
2013-10-22 08:10:03 -0500 received badge  Notable Question (source)
2013-01-08 01:59:00 -0500 received badge  Popular Question (source)
2012-01-19 09:31:03 -0500 asked a question solving system of equations

I'm trying to solve a system of equations, but somehow Sage does not solve for it. I have solved similar systems of equations before using the same methods, but somehow it is not working this time around. What is causing Sage to not solve this?

var('r,B,a,y,k,d,c,N,A,theta')
h=solve([r==B*(a*(y/k)+1-d), y==c+k*(r-1+d), (1-a)*(y/N)==((1-theta)/theta)*(c/(1-N)), y==A*k^a*N^(1-a)],y,c,N,k)
show(h)
2011-11-18 16:26:33 -0500 received badge  Student (source)
2011-11-18 07:10:55 -0500 received badge  Editor (source)
2011-11-18 07:10:45 -0500 answered a question Taking derivative of a solution

So this is what I would have wanted to do.. prior to learning about it from here. :)

var('p, alpha, beta, q, A, B, J, K')
h=solve([p==alpha+2*beta*q, A-B*p==J*q, p*q-K-alpha*q-beta*q^2==0],p,q,J)
show(h[1][0].simplify_full())
show(h[1][1].simplify_full())
show(h[1][2].simplify_full())
show(h[1][0].rhs().diff(A).simplify_full())
show(h[1][1].rhs().diff(A).simplify_full())
show(h[1][2].rhs().diff(A).simplify_full())

and this..

h=solve([p==alpha+2*beta*q, A-B*p==J*q, p*q-K-alpha*q-beta*q^2==0],p,q,J,solution_dict=True)
show([[s.diff(A).simplify_full() for s in sol.values()] for sol in h])
2011-11-18 02:33:38 -0500 commented answer Taking derivative of a solution

Thanks!! I'm going to have to study your answer for a while of course..

2011-11-18 02:32:07 -0500 marked best answer Taking derivative of a solution
sage: h
[[p == -(2*sqrt(K)*beta - alpha*sqrt(beta))/sqrt(beta), q == -(2*B*K*sqrt(beta) - (B*alpha - A)*sqrt(K))/(2*B*sqrt(K)*beta - B*alpha*sqrt(beta) + A*sqrt(beta)), J == -(2*B*K*beta - (B*alpha - A)*sqrt(K*beta))/K], [p == (2*sqrt(K)*beta + alpha*sqrt(beta))/sqrt(beta), q == (2*B*K*sqrt(beta) + (B*alpha - A)*sqrt(K))/(2*B*sqrt(K)*beta + B*alpha*sqrt(beta) - A*sqrt(beta)), J == -(2*B*K*beta + (B*alpha - A)*sqrt(K*beta))/K]]
sage: h[0]
[p == -(2*sqrt(K)*beta - alpha*sqrt(beta))/sqrt(beta), q == -(2*B*K*sqrt(beta) - (B*alpha - A)*sqrt(K))/(2*B*sqrt(K)*beta - B*alpha*sqrt(beta) + A*sqrt(beta)), J == -(2*B*K*beta - (B*alpha - A)*sqrt(K*beta))/K]
sage: h[0][0]
p == -(2*sqrt(K)*beta - alpha*sqrt(beta))/sqrt(beta)
sage: h[0][0].rhs()
-(2*sqrt(K)*beta - alpha*sqrt(beta))/sqrt(beta)
sage: h[0][0].rhs().diff(A)
0
sage: h[0][1].rhs().diff(A)
(2*B*K*sqrt(beta) - (B*alpha - A)*sqrt(K))*sqrt(beta)/(2*B*sqrt(K)*beta - B*alpha*sqrt(beta) + A*sqrt(beta))^2 - sqrt(K)/(2*B*sqrt(K)*beta - B*alpha*sqrt(beta) + A*sqrt(beta))
sage: h[0][2].rhs().diff(A)
-sqrt(K*beta)/K

This is the slow way, though. You might try this.

sage:     h=solve([p==alpha+2*beta*q, A-B*p==J*q, p*q-K-alpha*q-beta*q^2==0],p,q,J,solution_dict=True)
sage: [[s.diff(A) for s in sol.values()] for sol in h]
[[(2*B*K*sqrt(beta) - (B*alpha - A)*sqrt(K))*sqrt(beta)/(2*B*sqrt(K)*beta - B*alpha*sqrt(beta) + A*sqrt(beta))^2 - sqrt(K)/(2*B*sqrt(K)*beta - B*alpha*sqrt(beta) + A*sqrt(beta)), -sqrt(K*beta)/K, 0], [(2*B*K*sqrt(beta) + (B*alpha - A)*sqrt(K))*sqrt(beta)/(2*B*sqrt(K)*beta + B*alpha*sqrt(beta) - A*sqrt(beta))^2 - sqrt(K)/(2*B*sqrt(K)*beta + B*alpha*sqrt(beta) - A*sqrt(beta)), sqrt(K*beta)/K, 0]]
2011-11-18 01:58:41 -0500 asked a question Taking derivative of a solution

Hi, is there a way to take a derivative of a solution of equations?

For example,

var('p, alpha, beta, q, A, B, J, K')
h=solve([p==alpha+2*beta*q, A-B*p==J*q, p*q-K-alpha*q-beta*q^2==0],p,q,J)

in the solution expressions for p,q,J, can I take a partial derivative of each with respect to A by adding some kind of an expression? Also, is there a effective way to simplify the results that I get for p,q,J?

2011-09-27 03:28:07 -0500 received badge  Supporter (source)
2011-09-26 15:55:39 -0500 received badge  Scholar (source)
2011-09-26 15:55:39 -0500 marked best answer basic algebra with several variables-why won't it work?

You are using "implicit multiplication" which Sage does not understand by default (you can turn it on if you want). You should change 2y above to 2*y and 80(3200-x-y) to 80*(3200-x-y), etc... Here is code that works:

x, y = var('x, y')
solve([20*(6400-x-2*y)==0, 80*(3200-x-y)==0], x, y)

Sage's output is:

[[x == 0, y == 3200]]

ps. Implicit multiplication can be turned on using: implicit_multiplication(True), see the preparser documentation.

2011-09-26 15:52:39 -0500 commented answer basic algebra with several variables-why won't it work?

Thanks for clearing that up for me :) Now I won't miss it!

2011-09-26 12:12:19 -0500 asked a question basic algebra with several variables-why won't it work?

Hi,

I'm trying to use Sage-Notebook as a basic calculator and want to do some basic algebra for two variables. However, it keeps giving me syntax error messages when I type in the below. What am I doing wrong?

x, y = var('x, y') solve([20(6400-x-2y)==0, 80(3200-x-y)==0], x, y)

Traceback (click to the left of this block for traceback) ... SyntaxError: invalid syntax

Thank you!