Sorry I should make my question clearer. I'm not trying to substitute
for sigma^2. What I want to do is replace the various constants
multiplying the terms in sigma with a single constant. For example  I
get the following term in sigma^2:

-1/2*(1/R^2 - beta_0/(R^2*beta))*sigma(r)^2

And I want to get:

-epsilon*sigma(r)^2

And basically I want to do this for each power or derivative of sigma
in the expression I get. I've tried using subs(), but for some reason
for my case it doesn't work, but for a simple example I tried it does
and I don't see the difference.

When I try

var('epsilon')
(-1/2*(1/R^2 - beta_0/(R^2*beta))*sigma(r)^2).subs(-1/2*(1/R^2 -
beta_0/(R^2*beta))==epsilon)

I get back the expression unchanged.

But when I try:

var('a b c')
((a+b)*x^2).subs((a+b)==c)

the substitution does work. What's the difference?




On Oct 7, 4:20 pm, "ma...@mendelu.cz" <ma...@mendelu.cz> wrote:
> On 7 říj, 16:21, Ranjit <rjcha...@gmail.com> wrote:
>
>
>
>
>
> > I'm trying to figure out how to do a simple substitution. I've the
> > following code:
>
> > var('r beta beta_0 R a h')
> > psi=function('psi',r)
> > sigma=function('sigma',r)
>
> > H_0=function('H_0',r)
>
> > H_grad = lambda psi : (1/2)*(beta/beta_0)*R^2*(psi.diff(r))^2
> > H_0(psi) = -(1/2)*(beta/beta_0-1)*psi^2 + beta*a*psi^4 + beta*h*psi
>
> > H_1=H_grad((1/R)*(beta_0/beta)^(1/2)*sigma)
> > H=H_1+H_0((1/R)*(beta_0/beta)^(1/2)*sigma)
>
> > H=H.simplify_radical().expand().collect(sigma^2)
> > H
>
> > Let's say I want to rewrite the coefficient on sigma^2 as simply
> > epsilon, how can I do that?
>
> perhaps like this (I used alpha indstead of epsilon)
>
> alpha=function('alpha',r)
> H.subs_expr(sigma==sqrt(alpha)).subs_expr(diff(sigma)==diff(sqrt
> (alpha)))
>
> Not exactly what you want, but similar.
>
> BTW: When looked at this problem, the notation D[0](alpha)(r)^2  seems
> to be unusual to me.
> Is it possible to fix sage so that it prints derivatives of functions
> in one variable
> as usual: alpha'(r) ?
>
> And is it possible to get sin^2(x) ans (alpha'(r))^2 in LaTeX output
> instead of sin(x)^2 and y'(r)^2?
>
> Robert Marik
--~--~---------~--~----~------------~-------~--~----~
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
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to