Re: [sage-support] Re: Constrained optimization with strange result.

2021-11-30 Thread Emmanuel Charpentier


Le mardi 30 novembre 2021 à 18:18:35 UTC+1, cyrille piatecki a écrit :

> Thanks Emmanuel for your so precious answer. But obviously the doc must be 
> upgraded. From
>
> "maxima", "fricas", "sympy", "giac"
>
> only "sympy" has a reference.
>

(Almost) right : the documentation I pointed to doesn’t list anything but 
maxima. The up to date documentation 

 
is similar, but gives example of algorithm="sympy" uses…

Would you care to file a ticket against that ? A further problem being that 
the documentatin mentions the use of algorithm for single-equation solving, 
whereas your current example shows success for (an) equation *system*. This 
should be clarified…
​
 

> I wonder If one could add a parameter asking, in all cases, only for Real 
> solutions.
>

Beware : There Might Be Tygers ! (Hint : I left you an exercise... ;-)
 

>
> - Mail d’origine -
> De: Emmanuel Charpentier 
> À: sage-support 
> Envoyé: Tue, 30 Nov 2021 14:54:31 +0100 (CET)
> Objet: Re: [sage-support] Re: Constrained optimization with strange result.
>
> Le lundi 29 novembre 2021 à 16:33:41 UTC+1, cyrille piatecki a écrit :
>
>
>
> Thanks Emmanuel for your precious answer. But It generates some few new 
>> questions :
>> - is there a place in the documentation where I can find the information 
>> on `solve()` and mainly its options ?
>>
>
>
> The documentation 
> ,
>  
> of course…
>
>
>
>
>> - if I understand clearly z_{6497} is an integer but how to fix it to 
>> zero --- when the number change at each iteration
>>
>
>
> That’s why I used a methods sequence to designate it, rather than using 
> its name…
>
>
>
>
>> - sympy seems to be the good approach
>>
>
>
> Beware : see below…
>
>
>
> but it is not self evident that to call y one must typpeset sol2[0][x]
>>
>
>
> It is, because algorithm="sympy" will cause the results to be expressed 
> as dictionaries and D[x] is the canonical way to get the value of the 
> entry of dictionary D indexed by x. Basic Python…
>
>
>
>
>> - the giac way is certainly the better but it keeps no track of the 
>> variable's order.
>>
>
>
> Again, ask for a solution dictionary. As for algorithm="giac", I have 
> seen it go pear-shaped a couple times…
>
> Now for the various expression of solutions : consider :
>
> print(table([[u,solve(FOC,[x,y,l], solution_dict=True, algorithm=u)] for u in 
> ["maxima", "fricas", "sympy", "giac"]]))
>   maxima   [{l: 1/p_y, x: (p_x/p_y)^(1/a)*e^(2*I*pi*z3541/a), y: 
> -(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3541/a) - R)/p_y}]
>   fricas   [{l: 1/p_y, x: (p_x/p_y)^(1/a)*e^(2*I*pi*z3892/a), y: 
> -(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3892/a) - R)/p_y}]
>   sympy[{x: (p_x/p_y)^(1/a), l: 1/p_y, y: -(p_x*(p_x/p_y)^(1/a) - R)/p_y}]
>   giac [{x: (p_x/p_y)^(1/a), y: -(p_x*(p_x/p_y)^(1/a) - R)/p_y, l: 1/p_y}]
>
> Both maxima and fricas try to explicitly express the set of solutions of 
> the equation z^a==p_x/p_y, which is a set of a complexes if a is a 
> positive integer. (I leave to you (as en exercise ;-) to determine what it 
> means (if any…) if a is rational, algebraic or transcendental, real or 
> complex…).
>
> OTOH, both sympy and giac use the notation (p_x/p_y)^(1/a) to *implicitly* 
> denote *the very same set of solutions to the very same equation. One could 
> say that tey are glossing over whatever maxima and fricas insist on. 
> Choose your poison…
>
> HTH,
> ​
>
>  
>
>>
>> I have tried my solution assuming l>0 on the 3 conditions but it changes 
>> nothing.
>>
>>
>>
>> - Mail d’origine -
>> De: Emmanuel Charpentier 
>> À: sage-support 
>> Envoyé: Mon, 29 Nov 2021 11:03:37 +0100 (CET)
>> Objet: [sage-support] Re: Constrained optimization with strange result.
>>
>> Variables of the form z_ are *integer* variables created by Maxima, 
>> which attempts to give you *also* the complex roots, if any, thus 
>> ignoring the assumptions on x, y and l. Note that :
>>
>> sage: solve(FOC[0], x)
>> ---
>>
>> [ Snip… ]
>>
>> TypeError: Computation failed since Maxima requested additional constraints; 
>> using the 'assume' command before evaluation *may* help (example of legal 
>> syntax is 'assume(l>0)', see `assume?` for more details)
>> Is l positive, negative or zero?
>> sage: with assuming(l>0): print(solve(FOC[0], x))
>> [
>> x == (l*p_x)^(1/a)
>> ]
>> sage: with assuming(l<0): print(solve(FOC[0], x))
>> [
>> x^a == l*p_x
>> ]
>> sage: with assuming(l<0): print(solve(FOC[0], x, to_poly_solve=True))
>> [x == (l*p_x)^(1/a)*e^(2*I*pi*z4353/a)]
>>
>> Interestingly:
>>
>> sage: solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l)
>> [[l == (1/p_y), x == (p_x/p_y)^(1/a)*e^(2*I*pi*z3540/a), y == 
>> -(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3540/a) - R)/p_y]]
>> sage: solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l, algorithm="sympy")
>> [{x: (p_x/

Re: [sage-support] Re: LatexExpr

2021-11-30 Thread cyrille.piate...@univ-orleans.fr
Thanks obviously I have not understud the suggestion of John.
- Mail d’origine -
De: Samuel Lelièvre 
À: Sage-support 
Envoyé: Tue, 30 Nov 2021 18:59:04 +0100 (CET)
Objet: Re: [sage-support] Re: LatexExpr

2021-11-30 17:46 UTC, Cyrille Piatecki:
>
> Thanks John. But LatexExpr(r"\text{there"'"s a way} x_i =")
> generates a mistake.

John's suggestion was that a string that contains
both single-quote and double-quote characters
can be enclosed by tripled delimiters, using
either '''...''' or """...""".

More examples:

LatexExpr(r"\text{there's a way } x_i =")
LatexExpr(r'''\text{there's a way } y' + y" = 0''')
LatexExpr(r"""\text{there's a way } y' + y" = 0""")

See more on strings, also known as "text sequences",
in the Python documentation for built-in types:

https://docs.python.org/3/library/stdtypes.html#textseq

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CAEcArF2ZmBE66XSAudqt0MOeU82yvt7ctgtoksoFyFX2JuGSZw%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/1841280528.6250938.1638296225757.JavaMail.zimbra%40univ-orleans.fr.


[sage-support] Some problems with a notebook dor calculating many concept in market equilibria

2021-11-30 Thread cyrille.piate...@univ-orleans.fr
I am obliged to give a huge lot of command since the equations in my systems 
are derived. Sorry the comments are in french but they are not important;
var('a x y p_x p_y D Rev R l')
assume(a,'real')
assume(x,'real')
assume(y,'real')
assume(p_x,'real')
assume(p_y,'real')
assume(D,'real')
assume(Rev,'real')
assume(R,'real')
assume(l,'real')
assume(l>0)
#assume(a>-1)
assume(a>0)
assume(p_x>0)
assume(p_y>0)
assume(R>0)
U =(1/(1-(1/a)))*x^(1-(1/a))+y
show(LatexExpr(r'\text{La fonction d}^\prime\text{utilité est }U(x,y) = '),U)
D= x*p_x + y*p_y
show(LatexExpr(r'\text{La Dépense } D = '),D)
Rev= R
show(LatexExpr(r'\text{Le Revenu } Rev = '),R)
L=U+l*(Rev-D)
show(LatexExpr(r'\text{Le lagrangien est } \mathcal{L}(x, y, λ) = '),L)
FOC = [diff(L,x),diff(L,y),diff(L,l)]
show(LatexExpr(r'\text{Les condition du premier ordre sont } 
\left\{\begin{array}{c}\mathcal{L}_x= 0\\\mathcal{L}_y= 0\\\mathcal{L}_λ= 
0\end{array}\right. '))
show(LatexExpr(r'\text{soit }'))
show(LatexExpr(r'\mathcal{L}_x= 0 \Longleftrightarrow '),FOC[0]==0) 
show(LatexExpr(r'\mathcal{L}_y= 0 \Longleftrightarrow '),FOC[1]==0)
show(LatexExpr(r'\mathcal{L}_λ= 0 \Longleftrightarrow '),FOC[2]==0)
sol = solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l, algorithm="sympy")
xs=sol[0][x]
ys=sol[0][y]
ls=sol[0][l]
show(LatexExpr(r'\text{À l}\'\text{optimum, on a :}'))
show(LatexExpr(r' \,\,\,\,\,\,\,\,\, x^d = '),xs)
show(LatexExpr(r' \,\,\,\,\,\,\,\,\, y^d = '),ys)
show(LatexExpr(r' \,\,\,\,\,\,\,\,\, \lambda^\star = '),ls)
show(LatexExpr(r'\text{Si le bien } y \text{ sert de numéraire, on a : }p_y =1 
\text{ et, ainsi :}'))
xsn=xs.substitute(p_y=1).factor()
ysn=ys.substitute(p_y=1).factor()
lsn=ls.substitute(p_y=1).factor()
show(LatexExpr(r' \,\,\,\,\,\,\,\,\, x^\star = '),xsn)
show(LatexExpr(r' \,\,\,\,\,\,\,\,\, y^\star = '),ysn)
show(LatexExpr(r' \,\,\,\,\,\,\,\,\, \lambda^\star = '),lsn)
show(LatexExpr(r'\text{On a :}'))
x_p=diff(xsn,p_x).simplify()
show(LatexExpr(r'x_p = '),x_p,LatexExpr(r'< 0.'))var('C c')
assume(c, 'real')
assume(c>0)
C= (1/2)*c*x^2
show(LatexExpr(r'\text{On suppose que la fonction de coût du producteur est : } 
C(x) ='), C)
pi=(p_x *x- C)
show(LatexExpr(r'\text{ Le profit est : } \pi(x) = '), pi)
pip= diff(pi,x)
show(LatexExpr(r'\text{ Le profit marginal est : } \pi^\prime(x) = '), pip, 
LatexExpr(r'( = 0\text{ à l}^\prime\text{optimum})'))
pipp= diff(pi,x,2)
show(LatexExpr(r'\text{ il s}^\prime\text{agit bien d}^\prime\text{un maximum 
puisque : } \pi^{\prime\prime}(x) = '),pipp,LatexExpr(r'<0'))
prod=solve(pip==0,x)[0].rhs()
show(LatexExpr(r'\text{L}^\prime\text{offre de produit est : } x^o = 
'),prod)Until there all is fine now I use some results from above to avaluate 
an equilibrium. But now  it seems that maxima need to know if a certain 
variable is an integer (but I do not see which since I have tried to gives the 
more extended assumptions.I wonder if this is because my variable is p_x which 
is not understood by maxima ?show(LatexExpr(r'\text{L}^\prime\text{équilibre de 
concurrence pure et parfaite est caractérisé par le système 
d}^\prime\text{équations : } '))
show(LatexExpr(r'x^d = x^o'))
show(LatexExpr(r'x^d = '),xsn)
show(LatexExpr(r'x^o = '),prod)
pem= solve(xsn==prod, p_x)[0].rhs()
show(LatexExpr(r'\text{Le prix d}^\prime\text{équilibre du marché est : } p_x^E 
= '),pem)
qem = prod.subs(p_x=pem).simplify()
show(LatexExpr(r'\text{La quantité d}^\prime\text{équilibre du marché est : } 
q^E = '),qem)Also I need the inverse function of 'xsn' (look just above) as a 
function of x. I have tried many thing found here and there but even if some 
times I have the good result it is not considered as a function.Thanks for help

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/1091423200.6245539.1638295441317.JavaMail.zimbra%40univ-orleans.fr.


Re: [sage-support] Re: LatexExpr

2021-11-30 Thread Samuel Lelièvre
2021-11-30 17:46 UTC, Cyrille Piatecki:
>
> Thanks John. But LatexExpr(r"\text{there"'"s a way} x_i =")
> generates a mistake.

John's suggestion was that a string that contains
both single-quote and double-quote characters
can be enclosed by tripled delimiters, using
either '''...''' or """...""".

More examples:

LatexExpr(r"\text{there's a way } x_i =")
LatexExpr(r'''\text{there's a way } y' + y" = 0''')
LatexExpr(r"""\text{there's a way } y' + y" = 0""")

See more on strings, also known as "text sequences",
in the Python documentation for built-in types:

https://docs.python.org/3/library/stdtypes.html#textseq

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CAEcArF2ZmBE66XSAudqt0MOeU82yvt7ctgtoksoFyFX2JuGSZw%40mail.gmail.com.


Re: [sage-support] Re: LatexExpr

2021-11-30 Thread cyrille.piate...@univ-orleans.fr
Thanks John. But LatexExpr(r"\text{there"'"s a way} x_i =") generate a mistake.

- Mail d’origine -
De: John H Palmieri 
À: sage-support 
Envoyé: Mon, 29 Nov 2021 23:47:56 +0100 (CET)
Objet: [sage-support] Re: LatexExpr

Or if you need single and double quotes, delimit the string with """ or ''' 
(three double-quotes or three single-quotes):

r"""here is "some" 'text' """

On Monday, November 29, 2021 at 11:07:21 AM UTC-8 slelievre wrote:
2021-11-29 18:05:58 UTC+1, Cyrille Piatecki:
>
> I often use LatexExpr(r'\text{blabla} x_i =') encapsulated
> in show(). It's very easy to use but not if I need single quotes
> as in "it's". Is there a way to escape the quotes?

LatexExpr(r"\text{there's a way} x_i =")


-- 

You received this message because you are subscribed to the Google Groups 
"sage-support" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.

To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/ce3ddb95-05d2-46ae-9bfa-e4253527a997n%40googlegroups.com.


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/1950007382.6200643.1638294382727.JavaMail.zimbra%40univ-orleans.fr.


Re: [sage-support] Re: Constrained optimization with strange result.

2021-11-30 Thread cyrille.piate...@univ-orleans.fr
Thanks Emmanuel for your so precious answer. But obviously the doc must be 
upgraded. From
"maxima", "fricas", "sympy", "giac"only "sympy" has a reference. I wonder If 
one could add a parameter asking, in all cases, only for Real solutions.

- Mail d’origine -
De: Emmanuel Charpentier 
À: sage-support 
Envoyé: Tue, 30 Nov 2021 14:54:31 +0100 (CET)
Objet: Re: [sage-support] Re: Constrained optimization with strange result.

Le lundi 29 novembre 2021 à 16:33:41 UTC+1, cyrille piatecki a écrit :

Thanks Emmanuel for your precious answer. But It generates some few new 
questions :
- is there a place in the documentation where I can find the information on 
`solve()` and mainly its options ?


The documentation, of course…


- if I understand clearly z_{6497} is an integer but how to fix it to zero --- 
when the number change at each iteration


That’s why I used a methods sequence to designate it, rather than using its 
name…


- sympy seems to be the good approach

Beware : see below…

but it is not self evident that to call y one must typpeset sol2[0][x]


It is, because algorithm="sympy" will cause the results to be expressed as 
dictionaries and D[x] is the canonical way to get the value of the entry of 
dictionary D indexed by x. Basic Python…


- the giac way is certainly the better but it keeps no track of the variable's 
order.


Again, ask for a solution dictionary. As for algorithm="giac", I have seen it 
go pear-shaped a couple times…Now for the various expression of solutions : 
consider :print(table([[u,solve(FOC,[x,y,l], solution_dict=True, algorithm=u)] 
for u in ["maxima", "fricas", "sympy", "giac"]]))
  maxima   [{l: 1/p_y, x: (p_x/p_y)^(1/a)*e^(2*I*pi*z3541/a), y: 
-(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3541/a) - R)/p_y}]
  fricas   [{l: 1/p_y, x: (p_x/p_y)^(1/a)*e^(2*I*pi*z3892/a), y: 
-(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3892/a) - R)/p_y}]
  sympy[{x: (p_x/p_y)^(1/a), l: 1/p_y, y: -(p_x*(p_x/p_y)^(1/a) - R)/p_y}]
  giac [{x: (p_x/p_y)^(1/a), y: -(p_x*(p_x/p_y)^(1/a) - R)/p_y, l: 1/p_y}]
Both maxima and fricas try to explicitly express the set of solutions of the 
equation z^a==p_x/p_y, which is a set of a complexes if a is a positive 
integer. (I leave to you (as en exercise ;-) to determine what it means (if 
any…) if a is rational, algebraic or transcendental, real or complex…).OTOH, 
both sympy and giac use the notation (p_x/p_y)^(1/a) to implicitly denote *the 
very same set of solutions to the very same equation. One could say that tey 
are glossing over whatever maxima and fricas insist on. Choose your poison…HTH,​
 
I have tried my solution assuming l>0 on the 3 conditions but it changes 
nothing.



- Mail d’origine -
De: Emmanuel Charpentier 
À: sage-support 
Envoyé: Mon, 29 Nov 2021 11:03:37 +0100 (CET)
Objet: [sage-support] Re: Constrained optimization with strange result.

Variables of the form z_ are integer variables created by Maxima, which 
attempts to give you also the complex roots, if any, thus ignoring the 
assumptions on x, y and l. Note that :sage: solve(FOC[0], x)
---
[ Snip… ]TypeError: Computation failed since Maxima requested additional 
constraints; using the 'assume' command before evaluation *may* help (example 
of legal syntax is 'assume(l>0)', see `assume?` for more details)
Is l positive, negative or zero?
sage: with assuming(l>0): print(solve(FOC[0], x))
[
x == (l*p_x)^(1/a)
]
sage: with assuming(l<0): print(solve(FOC[0], x))
[
x^a == l*p_x
]
sage: with assuming(l<0): print(solve(FOC[0], x, to_poly_solve=True))
[x == (l*p_x)^(1/a)*e^(2*I*pi*z4353/a)]
Interestingly:sage: solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l)
[[l == (1/p_y), x == (p_x/p_y)^(1/a)*e^(2*I*pi*z3540/a), y == 
-(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3540/a) - R)/p_y]]
sage: solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l, algorithm="sympy")
[{x: (p_x/p_y)^(1/a), l: 1/p_y, y: -(p_x*(p_x/p_y)^(1/a) - R)/p_y}]
sage: solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l, algorithm="fricas")
[[l == (1/p_y), x == (p_x/p_y)^(1/a)*e^(2*I*pi*z3891/a), y == 
-(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3891/a) - R)/p_y]]
sage: giac.solve(giac(FOC),giac([x,y,l])).sage()
[[(p_x/p_y)^(1/a), -(p_x*(p_x/p_y)^(1/a) - R)/p_y, 1/p_y]]
HTH,​Le dimanche 28 novembre 2021 à 22:13:12 UTC+1, cyrille piatecki a écrit :
On my computer the solution of
var('a x y p_x p_y D Rev R l')
assume(a,'real')
assume(x,'real')
assume(y,'real')
assume(p_x,'real')
assume(p_y,'real')
assume(D,'real')
assume(Rev,'real')
assume(R,'real')
assume(l,'real')
assume(a<1)
assume(a>0)
assume(p_x>0)
assume(p_y>0)
assume(R>0)
U =(1/(a+1))*x^(a+1)+y
show(LatexExpr(r'\text{La fonction d}^\prime\text{utilité est }U(x,y) = '),U)
D= x*p_x + y*p_y
show(LatexExpr(r'\text{La Dépense } D = '),D)
Rev= R
show(LatexExpr(r'\text{Le Revenu } Rev = '),R)
L=U+l*(Rev-D)
show(LatexExpr(r'\text{Le lagrangien est } \mathcal{L}(x, y, λ) = '),L)
FOC = [diff(L,x),diff(L,y),diff(L,l)]
show(LatexExpr(r'\text{Le

Re: [sage-support] Re: Constrained optimization with strange result.

2021-11-30 Thread Emmanuel Charpentier


Le lundi 29 novembre 2021 à 16:33:41 UTC+1, cyrille piatecki a écrit :

Thanks Emmanuel for your precious answer. But It generates some few new 
> questions :
> - is there a place in the documentation where I can find the information 
> on `solve()` and mainly its options ?
>
The documentation 
,
 
of course…

- if I understand clearly z_{6497} is an integer but how to fix it to zero 
> --- when the number change at each iteration
>
That’s why I used a methods sequence to designate it, rather than using its 
name…

- sympy seems to be the good approach
>
Beware : see below…

but it is not self evident that to call y one must typpeset sol2[0][x]
>
It is, because algorithm="sympy" will cause the results to be expressed as 
dictionaries and D[x] is the canonical way to get the value of the entry of 
dictionary D indexed by x. Basic Python…

- the giac way is certainly the better but it keeps no track of the 
> variable's order.
>
Again, ask for a solution dictionary. As for algorithm="giac", I have seen 
it go pear-shaped a couple times…

Now for the various expression of solutions : consider :

print(table([[u,solve(FOC,[x,y,l], solution_dict=True, algorithm=u)] for u in 
["maxima", "fricas", "sympy", "giac"]]))
  maxima   [{l: 1/p_y, x: (p_x/p_y)^(1/a)*e^(2*I*pi*z3541/a), y: 
-(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3541/a) - R)/p_y}]
  fricas   [{l: 1/p_y, x: (p_x/p_y)^(1/a)*e^(2*I*pi*z3892/a), y: 
-(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3892/a) - R)/p_y}]
  sympy[{x: (p_x/p_y)^(1/a), l: 1/p_y, y: -(p_x*(p_x/p_y)^(1/a) - R)/p_y}]
  giac [{x: (p_x/p_y)^(1/a), y: -(p_x*(p_x/p_y)^(1/a) - R)/p_y, l: 1/p_y}]

Both maxima and fricas try to explicitly express the set of solutions of 
the equation z^a==p_x/p_y, which is a set of a complexes if a is a positive 
integer. (I leave to you (as en exercise ;-) to determine what it means (if 
any…) if a is rational, algebraic or transcendental, real or complex…).

OTOH, both sympy and giac use the notation (p_x/p_y)^(1/a) to *implicitly* 
denote *the very same set of solutions to the very same equation. One could 
say that tey are glossing over whatever maxima and fricas insist on. Choose 
your poison…

HTH,
​
 

> I have tried my solution assuming l>0 on the 3 conditions but it changes 
> nothing.
>
>
>
> - Mail d’origine -
> De: Emmanuel Charpentier 
> À: sage-support 
> Envoyé: Mon, 29 Nov 2021 11:03:37 +0100 (CET)
> Objet: [sage-support] Re: Constrained optimization with strange result.
>
> Variables of the form z_ are *integer* variables created by Maxima, 
> which attempts to give you *also* the complex roots, if any, thus 
> ignoring the assumptions on x, y and l. Note that :
>
> sage: solve(FOC[0], x)
> ---
>
> [ Snip… ]
>
> TypeError: Computation failed since Maxima requested additional constraints; 
> using the 'assume' command before evaluation *may* help (example of legal 
> syntax is 'assume(l>0)', see `assume?` for more details)
> Is l positive, negative or zero?
> sage: with assuming(l>0): print(solve(FOC[0], x))
> [
> x == (l*p_x)^(1/a)
> ]
> sage: with assuming(l<0): print(solve(FOC[0], x))
> [
> x^a == l*p_x
> ]
> sage: with assuming(l<0): print(solve(FOC[0], x, to_poly_solve=True))
> [x == (l*p_x)^(1/a)*e^(2*I*pi*z4353/a)]
>
> Interestingly:
>
> sage: solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l)
> [[l == (1/p_y), x == (p_x/p_y)^(1/a)*e^(2*I*pi*z3540/a), y == 
> -(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3540/a) - R)/p_y]]
> sage: solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l, algorithm="sympy")
> [{x: (p_x/p_y)^(1/a), l: 1/p_y, y: -(p_x*(p_x/p_y)^(1/a) - R)/p_y}]
> sage: solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l, algorithm="fricas")
> [[l == (1/p_y), x == (p_x/p_y)^(1/a)*e^(2*I*pi*z3891/a), y == 
> -(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3891/a) - R)/p_y]]
> sage: giac.solve(giac(FOC),giac([x,y,l])).sage()
> [[(p_x/p_y)^(1/a), -(p_x*(p_x/p_y)^(1/a) - R)/p_y, 1/p_y]]
>
> HTH,
> ​
> Le dimanche 28 novembre 2021 à 22:13:12 UTC+1, cyrille piatecki a écrit :
>
>> On my computer the solution of
>>
>> var('a x y p_x p_y D Rev R l')
>> assume(a,'real')
>> assume(x,'real')
>> assume(y,'real')
>> assume(p_x,'real')
>> assume(p_y,'real')
>> assume(D,'real')
>> assume(Rev,'real')
>> assume(R,'real')
>> assume(l,'real')
>> assume(a<1)
>> assume(a>0)
>> assume(p_x>0)
>> assume(p_y>0)
>> assume(R>0)
>> U =(1/(a+1))*x^(a+1)+y
>> show(LatexExpr(r'\text{La fonction d}^\prime\text{utilité est }U(x,y) = 
>> '),U)
>> D= x*p_x + y*p_y
>> show(LatexExpr(r'\text{La Dépense } D = '),D)
>> Rev= R
>> show(LatexExpr(r'\text{Le Revenu } Rev = '),R)
>> L=U+l*(Rev-D)
>> show(LatexExpr(r'\text{Le lagrangien est } \mathcal{L}(x, y, λ) = '),L)
>> FOC = [diff(L,x),diff(L,y),diff(L,l)]
>> show(LatexExpr(r'\text{Les condition du premier ordre sont } 
>> \left\{\begin{array}{c}\mathcal{L}_x= 0\\\mathcal{L}_y= 0\\\mathcal{L}_λ= 
>> 0\end{array}\righ

Re: [sage-support] Re: LatexExpr

2021-11-30 Thread cyrille.piate...@univ-orleans.fr
Thanks

- Mail d’origine -
De: John H Palmieri 
À: sage-support 
Envoyé: Mon, 29 Nov 2021 23:47:56 +0100 (CET)
Objet: [sage-support] Re: LatexExpr

Or if you need single and double quotes, delimit the string with """ or ''' 
(three double-quotes or three single-quotes):

r"""here is "some" 'text' """

On Monday, November 29, 2021 at 11:07:21 AM UTC-8 slelievre wrote:
2021-11-29 18:05:58 UTC+1, Cyrille Piatecki:
>
> I often use LatexExpr(r'\text{blabla} x_i =') encapsulated
> in show(). It's very easy to use but not if I need single quotes
> as in "it's". Is there a way to escape the quotes?

LatexExpr(r"\text{there's a way} x_i =")


-- 

You received this message because you are subscribed to the Google Groups 
"sage-support" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.

To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/ce3ddb95-05d2-46ae-9bfa-e4253527a997n%40googlegroups.com.


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/488618476.3122984.1638260348678.JavaMail.zimbra%40univ-orleans.fr.