Ask Your Question
1

Evaluating a symbolic expression

asked 2014-12-11 14:22:32 -0500

Jorge gravatar image

I am trying to evaluate a symbolical expression, but I don't know to ask Sage to compute the final expression:

phi = var('phi')

a=.25
beta=1
g=.2
ce=.5
alpha=.1
gamma=10
V=.5
rho=.9
sigma=2
sigmaeps=1
K=2
R=2 
K2=2 

avginv=K+R+K2
Sinv=phi*avginv
Swinv=K2+R-Sinv
psinv=(-1+(1+4*rho^(-2)*sigma^(-2)*K)^(1/2))/(2*rho^(-2)*sigma^(-2))

phipriv=K/avginv
phipub=Swinv/avginv
phimax=1-phipriv
phimin=alpha/(1+alpha)

prob=a-a*e^(-Swinv)
kappa=gamma*prob*(1-prob)*g^2

N=beta^(-1)*(1+alpha)*phi - beta^(-1)*alpha

L=beta^(-2)*(V+(1-phipriv)*avginv^(-1)+sigmaeps - 2*sigmaeps*phi + rho^2*sigma^2*psinv^(-2)*phipriv^2)
q=(beta*ce^(-1)-alpha*kappa^(-1)*N)*(gamma*L + ce^(-1)+kappa^(-1)*N^2)^(-1)
qN=q*N
kg=prob*g

t=-rho^(-1)+(gamma/2)*q^2*beta^(-2)
t2=t(phi=1/3)
print t2


sage: 5.00000000000000*(-0.666666666666667/((0.250000000000000*e^(-2) + 0.750000000000000)*(-2.50000000000000*e^(-2) + 2.50000000000000)) + 2.00000000000000)^2/(-1.77777777777778/((0.250000000000000*e^(-2) + 0.750000000000000)*(-2.50000000000000*e^(-2) + 2.50000000000000)) - 13.2881527307120)^2 - 1.11111111111111

Why Sage hasn't computed the final expression?

edit retag flag offensive close merge delete

Comments

1

What do you mean with "compute the final expression"? If you want a numerical evaluation, print t2.n() will do.

ndomes gravatar imagendomes ( 2014-12-11 14:44:26 -0500 )edit

1 answer

Sort by » oldest newest most voted
2

answered 2014-12-11 14:40:39 -0500

calc314 gravatar image

updated 2014-12-11 14:41:50 -0500

Try N(t2) or t2.n() to get a numerical approximation. Sage is trying to work with e exactly for as long as it can until you request a numerical approximation.

edit flag offensive delete link more

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: 2014-12-11 14:22:32 -0500

Seen: 74 times

Last updated: Dec 11 '14