acer

32385 Reputation

29 Badges

19 years, 334 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

You added material since first asking. I wrote this to address the original bit, where you seem to be asking to reverse the "product rule". First I yank off the extra 1/r^2 factor. Then I integrate wrt r, then do "by parts", and then differentiate wrt r. And then I multiply by the extra factor.

I don't know how much of that you want to automate.

I have not yet looked at the addendum.

# Using `diff`
restart;

expr:='1/r^2*diff(r^2*diff(v(r),r),r)';

(diff(r^2*(diff(v(r), r)), r))/r^2

t1,t2:=op(expr);

1/r^2, 2*r*(diff(v(r), r))+r^2*(diff(diff(v(r), r), r))

T2:=map(Int,t2,r);

Int(2*r*(diff(v(r), r)), r)+Int(r^2*(diff(diff(v(r), r), r)), r)

T2b := op(1,T2)+IntegrationTools:-Parts(op(2,T2),r^2);

r^2*(diff(v(r), r))

t1*'diff'(T2b,r)

(diff(r^2*(diff(v(r), r)), r))/r^2

# Using `Diff`
restart;

expr:='1/r^2*diff(r^2*diff(v(r),r),r)';

(diff(r^2*(diff(v(r), r)), r))/r^2

t1,t2:=op(expr);

1/r^2, 2*r*(diff(v(r), r))+r^2*(diff(diff(v(r), r), r))

new:=subs(diff=Diff,t2);

2*r*(Diff(v(r), r))+r^2*(Diff(Diff(v(r), r), r))

T2:=map(Int,new,r);

Int(2*r*(Diff(v(r), r)), r)+Int(r^2*(Diff(Diff(v(r), r), r)), r)

T2b := op(1,T2)+IntegrationTools:-Parts(op(2,T2),r^2);

(Diff(v(r), r))*r^2

t1*Diff(T2b,r)

(Diff((Diff(v(r), r))*r^2, r))/r^2

 

Download rev_prodrule.mw

The following does a "hot" edit of VectorCalculus:-D, replacing two uses of apply with direct function application.

It seems to behave so far with Maple 2016.2 through 2019.0.  Let me know if not.

restart;

 

# Hot edit, only needs running once per restart.
# Suitable for personal initialization file.
#
try
  ver:=convert(kernelopts(':-version'),string)[7..];
  ver:=parse(ver[1..StringTools:-Search(",",ver)-1]);
  if ver>=2016.0 and ver<=2019.0 then
    unprotect(:-VectorCalculus:-D);
    __Q:=ToInert(eval(:-VectorCalculus:-D)):
    if op([5,2,3,2,3,3,3,2],__Q)
       = _Inert_FUNCTION(_Inert_NAME("apply"),
                         _Inert_EXPSEQ(_Inert_LOCAL(3), _Inert_LOCAL(6))) then
      __Q:=subsop([5,2,3,2,3,3,3,2]
                  = _Inert_FUNCTION(_Inert_LOCAL(3),
                                    _Inert_EXPSEQ(_Inert_LOCAL(6))),__Q);
      print("VectorCalculus:-D updated");
    end if;
    if op([5,2,3,2,3,1,2,2,1,2,1,2,1],__Q)
       = _Inert_FUNCTION(_Inert_NAME("apply"),
                         _Inert_EXPSEQ(_Inert_PARAM(1), _Inert_LOCAL(6))) then
      :-VectorCalculus:-D:=FromInert(subsop([5,2,3,2,3,1,2,2,1,2,1,2,1]
                                     = _Inert_FUNCTION(_Inert_PARAM(1),
                                                       _Inert_EXPSEQ(_Inert_LOCAL(6))),__Q));
    end if;
  end if;
catch:
finally
  __Q:='__Q'; protect(:-VectorCalculus:-D);
end try:

"VectorCalculus:-D updated"

 

with(VectorCalculus):

assume(x, 'real');
assume(y, 'real');

 

D[1]((x,y)->x^2-y^2);

proc (x, y) options operator, arrow; 2*x end proc

D[2]((x,y)->x^2-y^2);

proc (x, y) options operator, arrow; -2*y end proc

D(x->sin(x^2));

proc (x) options operator, arrow; 2*x*cos(x^2) end proc

 

Download VCDhotedit.mw

The regression bug in apply has been reported, along with the unnecessary use of apply in VectorCalculus:-D.

This is just for general interest. I expect the OP may be busy implementing his own Emacs Lisp-based CAS (since Maple, Mathematica, Maxima, Sympy, and Axiom have all failed him) so as to finish implementing his significant improvement over FFT.

It seems that plot is having difficulty recognizing or handling some jump discontinuities (eg, at x=0.0) when that is used as the left end-point of the plotted domain.

Here I'm using Maple 12.02 to try and match your setup.

For three of the plots, if I supply a slightly wider domain (range for x) then the discont=true option seems to kick in ok and the jump is not displayed.

For plt02 I had to use an even wider range, and that one may be suffering a slightly different issue.

ps. I changed the B value for plt11 from 21 to 1, to agree with the other in that group. Perhaps a typo.

It might be possible that in modern Maple the issues could be handled by using discont=[fdiscont=[...]] with some judicious choice of options. I didn't fiddle with that because Maple 12 doesn't offer it.

I see that you've ignored my previous suggestion to compute all these plots much faster using fsolve to solve all the roots at once (per x value). Oh well.

file_discont_ac.mw

 

Is this adequate for your purposes?

with(inttrans):
sinc := x->piecewise(x = 0, 1, sin(Pi*x)/x/Pi):
S := x->sinc(x):
SE := unapply(simplify(sinc(x)*exp(-x^2)),x);
abs(fourier(convert(SE(x),Heaviside),x,s));
plot(%,s=0..5);

The original definition of SE := x->sinc(x)*exp(-x^2) gets the same plot, if used above instead. The main difference was the conversion of the piecewise to Heaviside before applying fourier. Hopefully I have not misunderstood.

I don't really understand the point of constructing an operator for SE just to plot SE(x), when an expression would do. Maybe you need/prefer an operator later on...

[edit] I see that Carl posted his working revision only moments after I posted this; doubtless we were composing at the same time. The only difference being that Carl put the Heaviside into the defn of SE while I left SE with a piecewise and only converted for the purpose of calling fourier.[/edit]

It looks like gfun:-listtorec can handle this.

You can also use rsolve(...,makeproc) to get a procedure.

Or you can construct a procedure from the recursive formula (with option remember for better efficiency). I could cut and paste the recursive formula obtained from listtorec, but for fun I build it programmatically below.

restart;

raw := gfun:-listtorec([1, 3, 5, 11, 21, 43, 85, 171, 341, 683, 1365], a(n));

[{a(n+2)-a(n+1)-2*a(n), a(0) = 1, a(1) = 3}, ogf]

rsolve(raw[1], a(n));

(4/3)*2^n-(1/3)*(-1)^n

F := rsolve(raw[1], a(n), makeproc):

seq(F(i), i=0..11);

1, 3, 5, 11, 21, 43, 85, 171, 341, 683, 1365, 2731

restart;

raw := gfun:-listtorec([1, 3, 5, 11, 21, 43, 85, 171, 341, 683, 1365], a(n));

[{a(n+2)-a(n+1)-2*a(n), a(0) = 1, a(1) = 3}, ogf]

temp1,temp2 := selectremove(type,raw[1],`=`):
G := subs(a=procname,unapply(rhs(isolate(subs(n=n-2,temp2[1]),a(n))),
                             n,proc_options=[remember]));
assign(subs(a=G,temp1)):

proc (n) option remember; procname(n-1)+2*procname(n-2) end proc

seq(G(i), i=0..11);

1, 3, 5, 11, 21, 43, 85, 171, 341, 683, 1365, 2731

 

Download listtorec.mw

I converted your Post to a Question. Please submit your future questions a Questions rather than Posts.

restart;

f := (x,y) -> x^2-y^2;

proc (x, y) options operator, arrow; x^2-y^2 end proc

Vector(2,(i)->D[i](f));

Vector(2, {(1) = proc (x, y) options operator, arrow; 2*x end proc, (2) = proc (x, y) options operator, arrow; -2*y end proc})

Vector[row](2,(i)->D[i](f));

Vector[row](2, {(1) = proc (x, y) options operator, arrow; 2*x end proc, (2) = proc (x, y) options operator, arrow; -2*y end proc})

Vector(nops([op(1,eval(f))]), (i)->D[i](f));

Vector(2, {(1) = proc (x, y) options operator, arrow; 2*x end proc, (2) = proc (x, y) options operator, arrow; -2*y end proc})

 

Download Jac_proc.mw

It's not entirely clear to me from your question whether you want a Vector of procedures or a Vector-valued procedure (ie. a single procedure which returns a Vector of the derivatives evaluated at subsequent input points). Your earlier Question about a bug under assume and with VectorCalculus loaded looked as if you wanted a Vector of procedures.

But often a Vector-valued procedure is convenient to utilize subsequently. Hence my use of codegen[JACOBIAN] below.

For example (and accepting a procedure with an arbitrary number of arguments):

restart;

makeJ := (F::procedure)->Vector(nops([op(1,eval(F))]), (i)->D[i](F)):

g := (x,y,z,a) -> x^2-y^2+sin(a*z);

proc (x, y, z, a) options operator, arrow; x^2-y^2+sin(a*z) end proc

gJ := makeJ(g);

Vector(4, {(1) = proc (x, y, z, a) options operator, arrow; 2*x end proc, (2) = proc (x, y, z, a) options operator, arrow; -2*y end proc, (3) = proc (x, y, z, a) options operator, arrow; a*cos(a*z) end proc, (4) = proc (x, y, z, a) options operator, arrow; z*cos(a*z) end proc})

map(u->u(a,b,c,d), gJ);

Vector(4, {(1) = 2*a, (2) = -2*b, (3) = d*cos(d*c), (4) = c*cos(d*c)})

map(u->u(1.2, c, 3, 2/5), gJ);

Vector(4, {(1) = 2.4, (2) = -2*c, (3) = (2/5)*cos(6/5), (4) = 3*cos(6/5)})

altmakeJ := (F::procedure)->subs(array=Vector,
                                 codegen[':-JACOBIAN']( [F] )):

gJ := altmakeJ( g );

proc (x, y, z, a) local df, grd, t1, t2, t4; t1 := x^2; t2 := y^2; t4 := sin(a*z); df := Vector(1 .. 3); df[3] := 1; df[2] := -1; df[1] := 1; grd := Vector(1 .. 4); grd[1] := 2*df[1]*x; grd[2] := 2*df[2]*y; grd[3] := df[3]*a*cos(a*z); grd[4] := df[3]*z*cos(a*z); return grd end proc

gJ(a,b,c,d);

Vector(4, {(1) = 2*a, (2) = -2*b, (3) = d*cos(d*c), (4) = c*cos(d*c)})

gJ(1.2, c, 3, 2/5);

Vector(4, {(1) = 2.4, (2) = -2*c, (3) = (2/5)*cos(6/5), (4) = 3*cos(6/5)})

 

Download Jac_proc_alt.mw

You haven't shown the full example that demands loading all of VectorCalculus, or using assume instead of say assuming. So it's not possible to properly address subsequent -- but as yet unstated -- issues you may have.

However,

restart;

kernelopts(version);

`Maple 2018.0, X86 64 LINUX, Mar 9 2018, Build ID 1298750`

f := (x, y) -> x^2-y^2;

proc (x, y) options operator, arrow; x^2-y^2 end proc

with(VectorCalculus):

assume(x, 'real');
assume(y, 'real');

:-D[1](f);

proc (x, y) options operator, arrow; 2*x end proc

:-D[2](f);

proc (x, y) options operator, arrow; -2*y end proc

:-D[1]( unapply(x^2-y^2, [x,y]) );

proc (x, y) options operator, arrow; 2*x end proc

:-D[2]( unapply(x^2-y^2, [x,y]) );

proc (x, y) options operator, arrow; -2*y end proc

 

Download VCD.mw

eqs := {a + b + c = 1,
        a^2 + b^2 + c^2 = 2,
        a^3 + b^3 + c^3 = 3}:

a^4 + b^4 + c^4 = eval(R,solve(eqs union {a^4 + b^4 + c^4=R}));

                        4    4    4   25
                       a  + b  + c  = --
                                      6 
a^5 + b^5 + c^5 = eval(R,solve(eqs union {a^5 + b^5 + c^5=R}));

                         5    5    5    
                        a  + b  + c  = 6

I recall having the same questions, when ColorTools first appeared.

At that time I was able to find, in the internal code, a transformation Matrix corresponding to D50 (which confirmed a few empirical tests). In a subsequent release I noticed that had changed to correspond to D65. But there seems to be little or no documentation about that.

And I believe that by "RGB" the ColorTools package means sRGB, not a wider gamut like Adobe RGB. (Some monitors allow one to toggle amongst such. But I have never tested what effect that might have on what the Maple GUI shows. A missing bit of knowledge might be which the Java GUI's renderer is using.)

Another interesting detail might be just how ColorTools makes certains colors (when converted to RGB from, say, Lab or Luv) "displayable". It's not always clear how it may regress back to the displayable gamut, ie. does it regress linearly back to the white point, or what?

Eventually I wrote my own converters (also via XYZ colorspace) because I wanted them to Compile and be fast on datatype=float[8] rtables representing many colors (eg, images). That gives me full control about the mathematical conversion, though details of the GUI's renderer may still be a missing link in the chain, if I want to visualize.

What form do you want for the results?

restart;

kernelopts(version);

`Maple 2015.2, X86 64 LINUX, Dec 20 2015, Build ID 1097895`

f:=(coth(x)^(1/3)-tanh(x)^(1/3))*(coth(x)^(2/3)+tanh(x)^(2/3)+1);

(coth(x)^(1/3)-tanh(x)^(1/3))*(coth(x)^(2/3)+tanh(x)^(2/3)+1)

simplify(expand(f)) assuming x>0;

1/(sinh(x)*cosh(x))

h:=simplify(combine(f,trig)) assuming x>0;

1/(sinh(x)*cosh(x))

combine(h);

2/sinh(2*x)

g:=(coth(x)^(1/3)-tanh(x)^(1/3))^2+4;

(coth(x)^(1/3)-tanh(x)^(1/3))^2+4

simplify(map(simplify,combine(g)),trigh) assuming x>0;

2+tanh(x)^(2/3)+coth(x)^(2/3)

P:=u->simplify(map(simplify,expand(simplify(expand(u)))),trigh):

P(f) assuming x>0;

1/(sinh(x)*cosh(x))

P(g) assuming x>0;

cosh(x)^(2/3)/sinh(x)^(2/3)+sinh(x)^(2/3)/cosh(x)^(2/3)+2

Q:=u->simplify(combine(convert(u,tanh)),trigh):

Q(f) assuming x>0;

1/tanh(x)-tanh(x)

Q(g) assuming x>0;

1/tanh(x)^(2/3)+tanh(x)^(2/3)+2

 

Download trighsimp.mw

Do you want something like this?

[edit] Originally I used the range 0*Unit(mm)..100*Unit(mm) along with the accomodating x*Unit(mm) in the calls to tau and Q when plotted. But that only works (by accident) in Maple 2017. So below I've changed the range to 0..100 instead, which makes more sense alongside the argument x*Unit(mm) and which seems to work in both Maple 2017 and Maple 2019.[/edit]

restart

``

b := 120*Unit('mm')

h := 200*Unit('mm')NULL

V := 8*Unit('kN')

I__x := (1/12)*b*h^3

"Q(x):=1/(2)*((h^(2))/(4)-(100&lobrk;mm&robrk;-x)^(2))*b:" 

"tau(x):=(V*Q(x))/(`I__x`*b):"

plot(proc (x) options operator, arrow; Q(x*Unit('mm')) end proc, 0 .. 100, useunits = [Unit('mm'), Unit('mm')^3])

``

plot(proc (x) options operator, arrow; tau(x*Unit('mm')) end proc, 0 .. 100, useunits = [Unit('mm'), Unit('kN')/Unit('mm')^2])

``

Plot_function_with_units_ac3.mw

[edit] How you approach this may well depend on what you start with. If you have the liberty of entering the initial expression passed to exp (or sin and cos) then it is easier since you can use a replacement symbol for Pi. My suggestions below are more for the case that you've already obtained the -1/2+1/2*I*3^(1/2) form. [/edit]

Here are three related ways.

The first two include examples of printing the inert % form of sin and cos calls without getting the gray elements in the output.

The third way simply delays evaluation (and in consequence is fragile because any subsequent full evaluation undoes the effect).

restart;

 

ec:=proc(Z) local t:=argument(Z);
            abs(Z)*(%cos(t)+I*%sin(t));
    end proc:

 

z:=17*exp(I*2*Pi/3);

-17/2+((17/2)*I)*3^(1/2)

ec(z);

17*%cos((2/3)*Pi)+(17*I)*%sin((2/3)*Pi)

InertForm:-Display(ec(z), inert=false);

17*%cos((2/3)*Pi)+(17*I)*%sin((2/3)*Pi)

value(ec(z));

-17/2+((17/2)*I)*3^(1/2)

restart;

 

ec:=proc(Z) local t:=argument(Z);
            abs(Z)*(%cos(t)+I*%sin(t));
    end proc:

`print/%sin` := Z->'sin'(Z):
`print/%cos` := Z->'cos'(Z):

 

z:=17*exp(I*2*Pi/3);

-17/2+((17/2)*I)*3^(1/2)

ec(z);

17*%cos((2/3)*Pi)+(17*I)*%sin((2/3)*Pi)

value(ec(z));

-17/2+((17/2)*I)*3^(1/2)

restart;

 

ec2:=proc(Z) local t:=argument(Z);
            abs(Z)*('cos'(t)+I*'sin'(t));
    end proc:

 

z:=17*exp(I*2*Pi/3);

-17/2+((17/2)*I)*3^(1/2)

foo:=ec2(z);

17*cos((2/3)*Pi)+(17*I)*sin((2/3)*Pi)

eval(foo,1);

17*cos((2/3)*Pi)+(17*I)*sin((2/3)*Pi)

foo;

-17/2+((17/2)*I)*3^(1/2)

 

Download inert_rcistheta.mw

You may also use InertForm:-Display to show the %Pi from Carl's Answer without the gray symbol. Eg,

bar:=cos(2*%Pi/3)+I*sin(2*%Pi/3);
InertForm:-Display(bar, inert=false);
value(bar);

But in that case you cannot so easily extend the `print` facility to make that aspect automatic.

It is possible to adjust the underlying code so that it also colors (extended typesetting mode) typeset math.

The following seems to work ok for me in Maple 2016.2 through to Maple 2019.0.

Tabulate_mathcolor_hotedit.mw

I don't think that you are doing anything wrong. It's not easy to handle the (possible) splitting fields always best, in general. But your example shows that there's likely something to improve. (I'm submitting a bug report.)

restart:

M:=Matrix(3, 3, [[-2*lambda-kappa__c, -2*sqrt(2)*g, 0],
                 [(1/2)*g*N*sqrt(2), -lambda-(1/2)*kappa__c-gamma__phi,
                  -sqrt(2)*g], [0, g*N*sqrt(2), -2*gamma__phi]]);

Matrix(3, 3, {(1, 1) = -2*lambda-`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`, (1, 2) = -2*sqrt(2)*g, (1, 3) = 0, (2, 1) = (1/2)*g*N*sqrt(2), (2, 2) = -lambda-(1/2)*`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`, (2, 3) = -sqrt(2)*g, (3, 1) = 0, (3, 2) = g*N*sqrt(2), (3, 3) = -2*`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`})

evals, evecs:=LinearAlgebra:-Eigenvectors(M):

EX := ee ->
  subsindets(ee,And(RootOf,satisfies(u->nops(u)>1 and
                                     type(op(2,u),
                                          identical(index)=posint))),
             u->[allvalues(RootOf(op(1,u)),explicit)][rhs(op(2,u))]):

EX(evals);

Vector(3, {(1) = -lambda-(1/2)*`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`+(1/2)*sqrt(-16*N*g^2+4*lambda^2+4*lambda*`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-8*lambda*`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`+`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`^2-4*`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`*`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`+4*`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`^2), (2) = -lambda-(1/2)*`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`-(1/2)*sqrt(-16*N*g^2+4*lambda^2+4*lambda*`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-8*lambda*`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`+`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`^2-4*`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`*`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`+4*`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`^2), (3) = -lambda-(1/2)*`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`})

subsindets(%,radical,u->map(collect,u,g,simplify));
 

Vector(3, {(1) = -lambda-(1/2)*`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`+(1/2)*sqrt(-16*N*g^2+(2*lambda+`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-2*`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`)^2), (2) = -lambda-(1/2)*`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`-(1/2)*sqrt(-16*N*g^2+(2*lambda+`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-2*`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`)^2), (3) = -lambda-(1/2)*`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`})

EX(evecs):
subsindets(%,radical,u->map(collect,u,g,simplify));

Matrix(3, 3, {(1, 1) = 8*g^2/(lambda+(1/2)*`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`+(1/2)*sqrt(-16*g^2*N+(2*lambda+`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-2*`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`)^2))^2, (1, 2) = 8*g^2/(lambda+(1/2)*`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`-(1/2)*sqrt(-16*g^2*N+(2*lambda+`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-2*`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`)^2))^2, (1, 3) = 2/N, (2, 1) = -2*sqrt(2)*g/(lambda+(1/2)*`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`+(1/2)*sqrt(-16*g^2*N+(2*lambda+`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-2*`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`)^2)), (2, 2) = -2*sqrt(2)*g/(lambda+(1/2)*`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`-(1/2)*sqrt(-16*g^2*N+(2*lambda+`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-2*`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`)^2)), (2, 3) = -(1/4)*sqrt(2)*(2*lambda+`#msub(mi("&kappa;",fontstyle = "normal"),mi("c"))`-2*`#msub(mi("&gamma;",fontstyle = "normal"),mi("&phi;",fontstyle = "normal"))`)/(g*N), (3, 1) = 1, (3, 2) = 1, (3, 3) = 1})

 

Download evals_ac.mw

I have previously submitted bug reports for examples such as this where simplify(...,size) does not compress as much as can a judicious collect with simplification of the ensuing coefficients.

In this example that situation occurs for the subexpression within the radical.

I have an oracle that speculatively tries collecting w.r.t. the relevant names in the subexpression (sum), and indicates which compresses well or best. Hence the following suggestions, relating to collect w.r.t. g. These vary a little because more generally you may or may not want other kinds of simplification effects:

restart:

expr1:=-lambda-(1/2)*kappa__c
       -gamma__p-(1/2)*sqrt(-16*N*g^2+4*lambda^2-8*lambda*gamma__p
                            +4*lambda*kappa__c
                            +4*gamma__p^2-4*gamma__p*kappa__c
                            +kappa__c^2):

desired_form:=1/2*(-2*gamma__p - kappa__c - 2 *lambda
              - sqrt(-16*N*g^2 + (-2 * gamma__p
              + kappa__c + 2 * lambda)^2)):
desired_form;

-gamma__p-(1/2)*kappa__c-lambda-(1/2)*(-16*N*g^2+(-2*gamma__p+kappa__c+2*lambda)^2)^(1/2)

subsindets(expr1,radical,u->map(collect,u,g,simplify));

-gamma__p-(1/2)*kappa__c-lambda-(1/2)*(-16*N*g^2+(-2*gamma__p+kappa__c+2*lambda)^2)^(1/2)

subsindets(expr1,radical,u->map(collect,u,g,uu->simplify(uu,size)));

-gamma__p-(1/2)*kappa__c-lambda-(1/2)*(-16*N*g^2+(-2*gamma__p+kappa__c+2*lambda)^2)^(1/2)

subsindets(expr1,`+`,u->frontend(collect,[u,g,simplify]));

-gamma__p-(1/2)*kappa__c-lambda-(1/2)*(-16*N*g^2+(-2*gamma__p+kappa__c+2*lambda)^2)^(1/2)

subsindets(expr1,`+`,u->frontend(collect,[u,g,uu->simplify(uu,size)],
                                 [{`+`,`*`},{}],uu->simplify(uu,size)));

-gamma__p-(1/2)*kappa__c-lambda-(1/2)*(-16*N*g^2+(-2*gamma__p+kappa__c+2*lambda)^2)^(1/2)

Download simplification_under_sqrt_ac.mw

First 154 155 156 157 158 159 160 Last Page 156 of 336