[sage-support] Re: substitution problem

2009-03-31 Thread V

This is exactly what I wanted. Thanks for your help! :)

I'll look up the maxima manuals to see if I can force it to think
harder. Thanks anyway!

Have a nice day!
V

On Mar 31, 3:35 pm, Jason Grout  wrote:
> V wrote:
> > On Mar 30, 6:07 pm, Jason Grout  wrote:
> >> V wrote:
> >>> Hi,
> >>> I'm fairly new to sage with some background in maxima.
> >>> My workbook is shared at
> >>>http://www.sagenb.org/home/pub/410/
> >>> the last three lines show the error I get.
> >>> Basically, I derive an equilibrium condition that I would like to use
> >>> in the previous stage of my game (solving by backwards induction), but
> >>> maxima fails (line -2) with simplifying after the substitution is
> >>> made, even though the substitution is successful (line -3).
> >>> I expect to receive the line in the last "paragraph" as defined by
> >>> D1p.
> >>> Is this a bug or did I made a mistake?
> >> In this line,
>
> >> solve([q1==q1.substitute(q2=sol2[0][1].right()).simplify_full()], q1)
>
> >> you are trying to solve for "q1", but q1 is not a variable, it's the
> >> expression:
>
> >> f2^alpha*p1^(alpha - 1)*p2^(beta - alpha*beta)*q2^alpha*A^(1 - alpha)/f1
>
> >> Did you mean to solve for a variable in the solve statement above?
>
> > The expression in the solve line would be a demand function where q
> > stands for quantity. But as it is derived from a later stage of the
> > game, q is present on the "right hand side" as well, and I would like
> > to express the demand function explicitly, that is I have q=f(q,x)
> > where x are all the other parameters and q is defined implicitly, and
> > I would like to have q=g(x).
>
> > I thought solve would do this for me, even though I already understand
> > why it doesn't, I still don't know how to do it. Could you give me a
> > hint, please?
>
> I see.
>
> Disclaimer: I don't know the mathematics that you are doing, so forgive
> me if I mess things up below...
>
> When you do q1==q1.subs(...), what the computer sees is:
>
> f2^alpha*p1^(alpha - 1)*p2^(beta - alpha*beta)*q2^alpha*A^(1 - alpha)/f1
> == f1^(alpha^2 - 1)*p1^((alpha - alpha^2)*beta + alpha - 1)*p2^((1 -
> alpha)*beta + alpha^2 - alpha)*q1^alpha^2*A^(1 - alpha^2)
>
> This doesn't seem like what you want; you want the left side to be a
> single variable, and the right side to have q1 be that same single
> variable.  So maybe you can do something like:
>
> sage: var('q')
> sage: q==q1.substitute(q2=sol2[0][1].right()).simplify_full().subs(q1=q)
> q == f1^(alpha^2 - 1)*p1^((alpha - alpha^2)*beta + alpha - 1)*p2^((1 -
> alpha)*beta + alpha^2 - alpha)*q^alpha^2*A^(1 - alpha^2)
> sage:
> solve(q==q1.substitute(q2=sol2[0][1].right()).simplify_full().subs(q1=q), q)
> [q == f1^(alpha^2 - 1)*p1^((alpha - alpha^2)*beta + alpha - 1)*p2^((1 -
> alpha)*beta + alpha^2 - alpha)*q^alpha^2*A^(1 - alpha^2)]
>
> So it doesn't look like maxima is able to handle this.
>
> Jason
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: substitution problem

2009-03-31 Thread Jason Grout

V wrote:
> On Mar 30, 6:07 pm, Jason Grout  wrote:
>> V wrote:
>>> Hi,
>>> I'm fairly new to sage with some background in maxima.
>>> My workbook is shared at
>>> http://www.sagenb.org/home/pub/410/
>>> the last three lines show the error I get.
>>> Basically, I derive an equilibrium condition that I would like to use
>>> in the previous stage of my game (solving by backwards induction), but
>>> maxima fails (line -2) with simplifying after the substitution is
>>> made, even though the substitution is successful (line -3).
>>> I expect to receive the line in the last "paragraph" as defined by
>>> D1p.
>>> Is this a bug or did I made a mistake?
>> In this line,
>>
>> solve([q1==q1.substitute(q2=sol2[0][1].right()).simplify_full()], q1)
>>
>> you are trying to solve for "q1", but q1 is not a variable, it's the
>> expression:
>>
>> f2^alpha*p1^(alpha - 1)*p2^(beta - alpha*beta)*q2^alpha*A^(1 - alpha)/f1
>>
>> Did you mean to solve for a variable in the solve statement above?
>>
> 
> The expression in the solve line would be a demand function where q
> stands for quantity. But as it is derived from a later stage of the
> game, q is present on the "right hand side" as well, and I would like
> to express the demand function explicitly, that is I have q=f(q,x)
> where x are all the other parameters and q is defined implicitly, and
> I would like to have q=g(x).
> 
> I thought solve would do this for me, even though I already understand
> why it doesn't, I still don't know how to do it. Could you give me a
> hint, please?


I see.

Disclaimer: I don't know the mathematics that you are doing, so forgive 
me if I mess things up below...

When you do q1==q1.subs(...), what the computer sees is:

f2^alpha*p1^(alpha - 1)*p2^(beta - alpha*beta)*q2^alpha*A^(1 - alpha)/f1 
== f1^(alpha^2 - 1)*p1^((alpha - alpha^2)*beta + alpha - 1)*p2^((1 -
alpha)*beta + alpha^2 - alpha)*q1^alpha^2*A^(1 - alpha^2)

This doesn't seem like what you want; you want the left side to be a 
single variable, and the right side to have q1 be that same single 
variable.  So maybe you can do something like:

sage: var('q')
sage: q==q1.substitute(q2=sol2[0][1].right()).simplify_full().subs(q1=q)
q == f1^(alpha^2 - 1)*p1^((alpha - alpha^2)*beta + alpha - 1)*p2^((1 -
alpha)*beta + alpha^2 - alpha)*q^alpha^2*A^(1 - alpha^2)
sage: 
solve(q==q1.substitute(q2=sol2[0][1].right()).simplify_full().subs(q1=q), q)
[q == f1^(alpha^2 - 1)*p1^((alpha - alpha^2)*beta + alpha - 1)*p2^((1 -
alpha)*beta + alpha^2 - alpha)*q^alpha^2*A^(1 - alpha^2)]

So it doesn't look like maxima is able to handle this.

Jason


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: substitution problem

2009-03-31 Thread V

On Mar 30, 6:07 pm, Jason Grout  wrote:
> V wrote:
> > Hi,
>
> > I'm fairly new to sage with some background in maxima.
>
> > My workbook is shared at
> >http://www.sagenb.org/home/pub/410/
>
> > the last three lines show the error I get.
>
> > Basically, I derive an equilibrium condition that I would like to use
> > in the previous stage of my game (solving by backwards induction), but
> > maxima fails (line -2) with simplifying after the substitution is
> > made, even though the substitution is successful (line -3).
>
> > I expect to receive the line in the last "paragraph" as defined by
> > D1p.
>
> > Is this a bug or did I made a mistake?
>
> In this line,
>
> solve([q1==q1.substitute(q2=sol2[0][1].right()).simplify_full()], q1)
>
> you are trying to solve for "q1", but q1 is not a variable, it's the
> expression:
>
> f2^alpha*p1^(alpha - 1)*p2^(beta - alpha*beta)*q2^alpha*A^(1 - alpha)/f1
>
> Did you mean to solve for a variable in the solve statement above?
>

The expression in the solve line would be a demand function where q
stands for quantity. But as it is derived from a later stage of the
game, q is present on the "right hand side" as well, and I would like
to express the demand function explicitly, that is I have q=f(q,x)
where x are all the other parameters and q is defined implicitly, and
I would like to have q=g(x).

I thought solve would do this for me, even though I already understand
why it doesn't, I still don't know how to do it. Could you give me a
hint, please?

Thanks, V
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: substitution problem

2009-03-30 Thread Jason Grout

V wrote:
> Hi,
> 
> I'm fairly new to sage with some background in maxima.
> 
> My workbook is shared at
> http://www.sagenb.org/home/pub/410/
> 
> the last three lines show the error I get.
> 
> Basically, I derive an equilibrium condition that I would like to use
> in the previous stage of my game (solving by backwards induction), but
> maxima fails (line -2) with simplifying after the substitution is
> made, even though the substitution is successful (line -3).
> 
> I expect to receive the line in the last "paragraph" as defined by
> D1p.
> 
> Is this a bug or did I made a mistake?
> 


In this line,

solve([q1==q1.substitute(q2=sol2[0][1].right()).simplify_full()], q1)

you are trying to solve for "q1", but q1 is not a variable, it's the 
expression:

f2^alpha*p1^(alpha - 1)*p2^(beta - alpha*beta)*q2^alpha*A^(1 - alpha)/f1

Did you mean to solve for a variable in the solve statement above?

Jason



--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---