Ask Your Question

Hun's profile - activity

2020-06-07 08:39:49 +0200 received badge  Popular Question (source)
2017-02-26 00:10:00 +0200 received badge  Famous Question (source)
2013-10-22 15:10:03 +0200 received badge  Notable Question (source)
2013-01-08 08:59:00 +0200 received badge  Popular Question (source)
2012-01-19 16:31:03 +0200 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 23:26:33 +0200 received badge  Student (source)
2011-11-18 14:10:55 +0200 received badge  Editor (source)
2011-11-18 14:10:45 +0200 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 09:33:38 +0200 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 09:32:07 +0200 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 08:58:41 +0200 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 10:28:07 +0200 received badge  Supporter (source)
2011-09-26 22:55:39 +0200 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 22:55:39 +0200 received badge  Scholar (source)
2011-09-26 22:52:39 +0200 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 19:12:19 +0200 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!