Ask Your Question
0

Further factorization

asked 2023-04-27 22:19:15 +0100

Cyrille gravatar image

In the following code

varx=var('x y') 
paramu=var('A α β u')
paramuc=tuple(list(paramu)+[u])
paramb=var('R p_x p_y')
varl=var('λ')
varg=tuple(list(varx)+[λ])

def Cobb_Douglas(x, y, A, α, β) :
    return A*x^α*y^β

def expense(x,y,p_x,p_y) :
    return p_x*x+ p_y*y

L(x,y,λ) = Cobb_Douglas(x,y,A, α, β) -λ*(expense(x,y,p_x,p_y)-R)

stationary_points = lambda f: solve([gi==0 for gi in f.gradient()],varg)
opt=flatten(stationary_points(L))
opt1= [x.full_simplify().factor().simplify_rational()for x in opt]
show(opt1)

it is evident that $x$, $y$ and $\lambda$ could be factorized further. But I have not founded the way.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2023-04-27 23:53:44 +0100

Emmanuel Charpentier gravatar image

Further factorization can be done by :

opt2=[u.factor() for u in opt1]

More interesting :

show(opt2[2].subs([u.rhs()==u.lhs() for u in opt2[:2]]))

Since you used non-ASCII symbols such as α and β, which are not accepted by the default LaTeX compiler in Sage (and possibly not by the peculiar Mathjax engine used in the present site), I can't show you the result. See for yourself.

BTW : since you do not reuse the paramu tuple, I wonder what't's the point of not using the standard `var("alpha, beta") (which BTW does print the relevant greek letters...).

HTH,

edit flag offensive delete link more

Comments

Thank You Emmanuel. I want to stay to more nearer of the standard text books and use the same parameters. If I have defined paramu is because I was expecting because it was a tuple I could use it as an argument of a function. I just have asked a question about that in the same time. What I try to modestly to do, is to show to economist and other collegues that the cost is not so high to invest in SageMath for their curses and researchs. I learn slowly because I always think of the difficulty to link programmation languages, algorithm and specific field problems. Sagemath is a wonder because it is free (I used Mathematica, but in France no student can afford the price). And I find scandalous, that administration accept to pay for softwares when there exist free substitution products.

Cyrille gravatar imageCyrille ( 2023-04-28 08:56:01 +0100 )edit

Dear @Cyrille,

I used Mathematica, but in France no student can afford the price

FWIW, and in passing, the gratis (but not free) WolframEngine + Jupyter/Jupyterlab + the Wolfram language kernel for Jupyter = Mathematica = Mathematica for all practical puroses (except interactive graphics, at least for now (but I hope this will change soon...)).

BTW, this engine is a valuable addition to Sage, which remains unmatched in scope and integration in various reproducible research. platforms.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2023-04-28 17:38:51 +0100 )edit

Dear @Cyrille,

I want to stay to more nearer of the standard text books and use the same parameters

That's no reason to use α instead of alpha, the latter being LaTeXable and not the former...

I just have asked a question about that in the same time.

I commented it explaining why Python/Sage makes this awkward and potentially misleasing. See my comment.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2023-04-28 17:47:18 +0100 )edit

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: 2023-04-27 22:19:15 +0100

Seen: 120 times

Last updated: Apr 27 '23