acer

32333 Reputation

29 Badges

19 years, 326 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Here are some ideas for reducing the size of the over expression, and one example of substituting names for common subexpressions.

restart;

A:=Matrix([[phi,conjugate(psi),chi,conjugate(rho)],
          [psi,-conjugate(phi),rho,-conjugate(chi)],
          [lambda1*phi,conjugate(lambda1)*conjugate(psi),
           lambda2*chi,conjugate(lambda2)*conjugate(rho)],
          [lambda1*psi,-conjugate(lambda1)*conjugate(phi),
           lambda2*rho,-conjugate(lambda2)*conjugate(chi)]]);

Matrix(4, 4, {(1, 1) = phi, (1, 2) = conjugate(psi), (1, 3) = chi, (1, 4) = conjugate(rho), (2, 1) = psi, (2, 2) = -conjugate(phi), (2, 3) = rho, (2, 4) = -conjugate(chi), (3, 1) = lambda1*phi, (3, 2) = conjugate(lambda1)*conjugate(psi), (3, 3) = lambda2*chi, (3, 4) = conjugate(lambda2)*conjugate(rho), (4, 1) = lambda1*psi, (4, 2) = -conjugate(lambda1)*conjugate(phi), (4, 3) = lambda2*rho, (4, 4) = -conjugate(lambda2)*conjugate(chi)})

d := LinearAlgebra:-Determinant(A):

d; length(%);

-conjugate(lambda2)*conjugate(chi)*conjugate(lambda1)*conjugate(psi)*chi*psi+conjugate(lambda2)*conjugate(chi)*conjugate(lambda1)*conjugate(psi)*phi*rho+conjugate(lambda2)*conjugate(chi)*conjugate(psi)*chi*lambda2*psi-conjugate(lambda2)*conjugate(chi)*conjugate(psi)*lambda1*phi*rho-conjugate(lambda2)*conjugate(chi)*conjugate(phi)*chi*lambda1*phi+conjugate(lambda2)*conjugate(chi)*conjugate(phi)*chi*lambda2*phi+conjugate(lambda2)*conjugate(rho)*conjugate(lambda1)*conjugate(phi)*chi*psi-conjugate(lambda2)*conjugate(rho)*conjugate(lambda1)*conjugate(phi)*phi*rho-conjugate(lambda2)*conjugate(rho)*conjugate(psi)*lambda1*psi*rho+conjugate(lambda2)*conjugate(rho)*conjugate(psi)*lambda2*psi*rho-conjugate(lambda2)*conjugate(rho)*conjugate(phi)*chi*lambda1*psi+conjugate(lambda2)*conjugate(rho)*conjugate(phi)*lambda2*phi*rho+conjugate(chi)*conjugate(lambda1)*conjugate(psi)*chi*lambda1*psi-conjugate(chi)*conjugate(lambda1)*conjugate(psi)*lambda2*phi*rho+conjugate(chi)*conjugate(lambda1)*conjugate(phi)*chi*lambda1*phi-conjugate(chi)*conjugate(lambda1)*conjugate(phi)*chi*lambda2*phi-conjugate(chi)*conjugate(psi)*chi*lambda1*lambda2*psi+conjugate(chi)*conjugate(psi)*lambda1*lambda2*phi*rho+conjugate(rho)*conjugate(lambda1)*conjugate(psi)*lambda1*psi*rho-conjugate(rho)*conjugate(lambda1)*conjugate(psi)*lambda2*psi*rho-conjugate(rho)*conjugate(lambda1)*conjugate(phi)*chi*lambda2*psi+conjugate(rho)*conjugate(lambda1)*conjugate(phi)*lambda1*phi*rho+conjugate(rho)*conjugate(phi)*chi*lambda1*lambda2*psi-conjugate(rho)*conjugate(phi)*lambda1*lambda2*phi*rho

2161

simplify(d,size); length(%);

((conjugate(rho)*conjugate(phi)-conjugate(psi)*conjugate(chi))*(chi*psi-phi*rho)*conjugate(lambda2)+(chi*phi*(lambda1-lambda2)*conjugate(phi)+conjugate(psi)*(chi*lambda1*psi-lambda2*phi*rho))*conjugate(chi)-conjugate(rho)*((chi*lambda2*psi-lambda1*phi*rho)*conjugate(phi)-psi*rho*conjugate(psi)*(lambda1-lambda2)))*conjugate(lambda1)+((-chi*phi*(lambda1-lambda2)*conjugate(phi)+conjugate(psi)*(chi*lambda2*psi-lambda1*phi*rho))*conjugate(chi)-conjugate(rho)*((chi*lambda1*psi-lambda2*phi*rho)*conjugate(phi)+psi*rho*conjugate(psi)*(lambda1-lambda2)))*conjugate(lambda2)+lambda1*lambda2*(conjugate(rho)*conjugate(phi)-conjugate(psi)*conjugate(chi))*(chi*psi-phi*rho)

1045

collect(d,[rho,chi],u->simplify(u,size)); length(%);

((psi*(lambda1-lambda2)*(conjugate(lambda1)-conjugate(lambda2))*conjugate(rho)+phi*conjugate(chi)*(conjugate(lambda2)-lambda2)*(conjugate(lambda1)-lambda1))*conjugate(psi)-conjugate(rho)*phi*conjugate(phi)*(conjugate(lambda2)-lambda1)*(conjugate(lambda1)-lambda2))*rho+((phi*(lambda1-lambda2)*(conjugate(lambda1)-conjugate(lambda2))*conjugate(phi)-psi*conjugate(psi)*(conjugate(lambda2)-lambda1)*(conjugate(lambda1)-lambda2))*conjugate(chi)+conjugate(rho)*psi*conjugate(phi)*(conjugate(lambda2)-lambda2)*(conjugate(lambda1)-lambda1))*chi

761

collect(d,[psi,phi],u->simplify(u,size)); length(%);

((rho*(lambda1-lambda2)*(conjugate(lambda1)-conjugate(lambda2))*conjugate(rho)-chi*conjugate(chi)*(conjugate(lambda2)-lambda1)*(conjugate(lambda1)-lambda2))*conjugate(psi)+chi*conjugate(rho)*conjugate(phi)*(conjugate(lambda2)-lambda2)*(conjugate(lambda1)-lambda1))*psi+((chi*(lambda1-lambda2)*(conjugate(lambda1)-conjugate(lambda2))*conjugate(phi)+rho*conjugate(psi)*(conjugate(lambda2)-lambda2)*(conjugate(lambda1)-lambda1))*conjugate(chi)-conjugate(rho)*rho*conjugate(phi)*(conjugate(lambda2)-lambda1)*(conjugate(lambda1)-lambda2))*phi

761

collect(d,[lambda1,lambda2],u->map(factor,simplify(u,size))); length(%);

(-(conjugate(psi)*conjugate(chi)-conjugate(rho)*conjugate(phi))*(chi*psi-phi*rho)*lambda2+(phi*conjugate(phi)+psi*conjugate(psi))*(chi*conjugate(chi)+conjugate(rho)*rho)*conjugate(lambda1)-conjugate(lambda2)*(conjugate(rho)*psi+phi*conjugate(chi))*(chi*conjugate(phi)+rho*conjugate(psi)))*lambda1+(-(conjugate(rho)*psi+phi*conjugate(chi))*(chi*conjugate(phi)+rho*conjugate(psi))*conjugate(lambda1)+conjugate(lambda2)*(phi*conjugate(phi)+psi*conjugate(psi))*(chi*conjugate(chi)+conjugate(rho)*rho))*lambda2+conjugate(lambda2)*conjugate(lambda1)*(conjugate(rho)*conjugate(phi)-conjugate(psi)*conjugate(chi))*(chi*psi-phi*rho)

983

R1:=abs(lambda1)^2+abs(lambda2)^2-conjugate(lambda2)*lambda1-conjugate(lambda1)*lambda2=K1:
R2:=abs(lambda1)^2+abs(lambda2)^2-conjugate(lambda2)*conjugate(lambda1)-lambda1*lambda2=K2:
R3:=conjugate(psi)*phi*rho*conjugate(chi)=K3:
R4:=chi*conjugate(phi)*conjugate(rho)*psi=conjugate(K3):
temp := simplify(collect(d,[rho,chi],u->simplify(u,size))):
new := simplify(subs([R1,R2,R3,R4],temp),size);
(rhs=lhs)(R1);
(rhs=lhs)(R2);
(rhs=lhs)(R3);

-4*Im(lambda1)*Im(lambda2)*(conjugate(K3)+K3)+(K1*abs(phi)^2+abs(psi)^2*K2)*abs(chi)^2+abs(rho)^2*(K1*abs(psi)^2+K2*abs(phi)^2)

K1 = abs(lambda1)^2+abs(lambda2)^2-conjugate(lambda2)*lambda1-conjugate(lambda1)*lambda2

K2 = abs(lambda1)^2+abs(lambda2)^2-conjugate(lambda2)*conjugate(lambda1)-lambda1*lambda2

K3 = conjugate(chi)*conjugate(psi)*phi*rho

# check
subs([(rhs=lhs)(R1),(rhs=lhs)(R2),(rhs=lhs)(R3)], new):
combine(simplify(eval(simplify((% - d)),
                      [lambda1=Re(lambda1)+I*Im(lambda1),
                       lambda2=Re(lambda2)+I*Im(lambda2)])));

0

 

Download some_simp.mw

In my Maple 2018.1 the integral of dex for t=0..phi2 can be done symbolically, under assumptions consisting of the bounds of the outer variables' ranges of integration. This leads to a triple integral that can be done quickly and accurately, numerically, without need to specify a particular method.

restart;

with(LinearAlgebra):

r1 := Vector([0, 0, 1]):

r2 := Vector([sin(theta1), 0, cos(theta1)]):

r3 := Vector([sin(theta2)*cos(phi2), sin(theta2)*sin(phi2), cos(theta2)]):

M := Matrix([r1, r2, r3]);

Matrix(3, 3, {(1, 1) = 0, (1, 2) = sin(theta1), (1, 3) = sin(theta2)*cos(phi2), (2, 1) = 0, (2, 2) = 0, (2, 3) = sin(theta2)*sin(phi2), (3, 1) = 1, (3, 2) = cos(theta1), (3, 3) = cos(theta2)})

ex := simplify(Determinant(M)/(1+DotProduct(r1,r2)+DotProduct(r1,r3)+DotProduct(r2,r3)))
      assuming theta1 > 0, theta2 > 0, phi2 > 0;

sin(theta1)*sin(theta2)*sin(phi2)/((cos(theta1)+1)*cos(theta2)+sin(theta1)*sin(theta2)*cos(phi2)+cos(theta1)+1)

dex := eval(simplify(diff(arctan(ex), phi2)), phi2 = t);

(1/2)*sin(theta1)*((cos(theta2)+1)*(cos(theta1)+1)*cos(t)+sin(theta2)*sin(theta1))*sin(theta2)/((cos(theta2)+1)*(cos(theta1)+1)*(sin(theta1)*sin(theta2)*cos(t)+cos(theta2)*cos(theta1)+1))

Q := simplify(int(dex, t = 0 .. phi2))
       assuming theta1 > 0, theta1 < Pi, theta2 > 0, theta2 < Pi, phi2 > 0, phi2<Pi;

(1/2)*phi2-arctan((cos(theta2)*cos(theta1)-sin(theta2)*sin(theta1)+1)*sin((1/2)*phi2)/(cos((1/2)*phi2)*abs(cos(theta2)+cos(theta1))))*signum(cos(theta2)+cos(theta1))

Tother := 2*Int( 2*Q/(4*Pi) * 2*Pi*sin(theta1)*sin(theta2)/(4*Pi*4*Pi),
                 [phi2 = 0 .. Pi, theta2 = 0 .. Pi, theta1 = 0 .. Pi] );

2*(Int((1/16)*((1/2)*phi2-arctan((cos(theta2)*cos(theta1)-sin(theta2)*sin(theta1)+1)*sin((1/2)*phi2)/(cos((1/2)*phi2)*abs(cos(theta2)+cos(theta1))))*signum(cos(theta2)+cos(theta1)))*sin(theta1)*sin(theta2)/Pi^2, [phi2 = 0 .. Pi, theta2 = 0 .. Pi, theta1 = 0 .. Pi]))

alt := simplify(combine(Tother));

Int(-(1/32)*(cos(-theta2+theta1)-cos(theta2+theta1))*(2*arctan((1/2)*(sin((1/2)*phi2+theta2+theta1)+sin((1/2)*phi2-theta2-theta1)+2*sin((1/2)*phi2))/(abs(cos(theta2)+cos(theta1))*cos((1/2)*phi2)))*signum(cos(theta2)+cos(theta1))-phi2)/Pi^2, [phi2 = 0 .. Pi, theta2 = 0 .. Pi, theta1 = 0 .. Pi])

evalf(alt);  # no special method specified

.1250000000

T := 2*Int( 2*Int(dex, t = 0 .. phi2)/(4*Pi) * 2*Pi*sin(theta1)*sin(theta2)/(4*Pi*4*Pi),
              [phi2 = 0 .. Pi, theta2 = 0 .. Pi, theta1 = 0 .. Pi] );

2*(Int((1/16)*(Int((1/2)*sin(theta1)*((cos(theta2)+1)*(cos(theta1)+1)*cos(t)+sin(theta2)*sin(theta1))*sin(theta2)/((cos(theta2)+1)*(cos(theta1)+1)*(sin(theta1)*sin(theta2)*cos(t)+cos(theta2)*cos(theta1)+1)), t = 0 .. phi2))*sin(theta1)*sin(theta2)/Pi^2, [phi2 = 0 .. Pi, theta2 = 0 .. Pi, theta1 = 0 .. Pi]))

# vv's idea
new := IntegrationTools:-Change(T, t=s*phi2, [s]):
new := simplify(IntegrationTools:-CollapseNested(frontend(combine,[%],[{`+`,`*`,specfunc(Int)},{}])));

Int((1/16)*sin(theta2)^2*phi2*((cos(theta2)+1)*(cos(theta1)+1)*cos(s*phi2)+sin(theta2)*sin(theta1))*sin(theta1)^2/((cos(theta2)+1)*(cos(theta1)+1)*Pi^2*(sin(theta1)*sin(theta2)*cos(s*phi2)+cos(theta2)*cos(theta1)+1)), [s = 0 .. 1, phi2 = 0 .. Pi, theta2 = 0 .. Pi, theta1 = 0 .. Pi])

subsindets(new,specfunc(Int),u->Int(op(u),method = _CubaCuhre, epsilon = 1e-5)):
evalf(%);

HFloat(0.12500056725173295)

 

Download multi_int.mw

 

Do you mean something like this?

g := expand( (x+1)*(x-2) )/(x-2);

                    2
                   x  - x - 2
              g := ----------
                     x - 2

discont(g,x);

                    {2}
restart;
sys:={x^2+y^2+z^2=4,x^2+y^2-z^2=4,x+y+z=0}:

solve(sys, explicit, allsolutions);

               1/2       1/2                1/2        1/2
        {x = -2   , y = 2   , z = 0}, {x = 2   , y = -2   , z = 0}

fsolve(sys,{x,y,z=0},{x=0..infinity});

              {x = 1.414213562, y = -1.414213562, z = 0.}

fsolve(sys,{x,y,z=0},{y=0..infinity});

              {x = -1.414213562, y = 1.414213562, z = 0.}


restart;
sys:={x^2+y^2+z^2=4,x^2+y^2-z^2=4,x+y+z=0}:

Digits:=18:
fsolve(sys,{x,y,z});

                                                                                 -13
  {x = 1.41421356237308740, y = -1.41421356237310269, z = 0.152880100390764231 10   }


restart;
sys:={x^2+y^2+z^2=4,x^2+y^2-z^2=4,x+y+z=0}:

fsolve( map(unapply,map(rhs-lhs,sys),[x,y,z]) );

                                                                   -9
   [-1.4142135624826409, 1.4142135622635492, 0.21909169874140413 10  ]

It's unfortunate that there are so many variations for which fsolve fails on this example. It ought to be made more robust. Often it almost gets there, but stops too early. It's a long-standing problem that the working precision and stopping criteria cannot be specified.

restart:
sys:={x^2+y^2+z^2=4,x^2+y^2-z^2=4,x+y+z=0}:
infolevel[fsolve]:=6:
fsolve(sys);

Another numeric approach,

restart;
sys:={x^2+y^2+z^2=4,x^2+y^2-z^2=4,x+y+z=0}:

Optimization:-Minimize(x,sys)[2];

    [x = -1.41422084007315, y = 1.41420628467304, z = 0.0000145554001009322]

eval(map((lhs-rhs),sys),%);

                          -9                       -16                      -9
    {-0.105929931493165 10  , -0.473626942786715 10   , 0.317789794479495 10  }

Digits:=20:
Optimization:-Minimize(x,sys,feasibilitytolerance=1e-13)[2];
                                                                                        -6
    [x = -1.4142136550635758637, y = 1.4142134696826142339, z = 0.18538096162967075298 10  ]

eval(map((lhs-rhs),sys),%);

                      -13                -18             -13
         {-0.171831 10   , -0.12924702 10   , 0.515491 10   }

 

restart;

 

`print/%maximize`:=proc(expr::algebraic,
                        u::name=range)
  local rng;
  uses T=Typesetting;
  if interface(':-prettyprint')<2 then
    return %maximize(args);
  end if;
  rng := lhs(u) in [rhs(u)];
  # "#000000" is black
  T:-mrow(T:-munder(T:-mo("max",':-mathcolor'="#606060"),
                    T:-Typeset(T:-EV(rng))),
          T:-mspace(':-width'="0.3em"),
          T:-Typeset(T:-EV(expr)));
end proc:

`print/%minimize`:=subs(["max"="min",
                         ':-%maximize'=':-%minimize'],
                        eval(`print/%maximize`)):

 

%maximize(f(x), x=2..3);

%maximize(f(x), x = 2 .. 3)

value(%);

maximize(f(x), x = 2 .. 3)

%maximize((2*x-3)/(x-2), x=2..3);

%maximize((2*x-3)/(x-2), x = 2 .. 3)

value(%);

infinity

%minimize((2*x-3)/(x-2), x=2..3);

%minimize((2*x-3)/(x-2), x = 2 .. 3)

value(%);

3

%maximize((2*x-3)/(x-2), x=2..3, location);

%maximize((2*x-3)/(x-2), x = 2 .. 3, location)

value(%);

infinity, {[{x = 2}, infinity]}

 

Download max_typeset_edited.mw

[edited with Carl's suggestions]

It's not clear to me what you are asking for. Is it something like this?

limit( (2*x-3)/(x-2), x=2, right );

                infinity

maximize( (2*x-3)/(x-2), x=2..3 );

                infinity

maximize( (2*x-3)/(x-2), x=2..3, location );

         infinity, {[{x = 2}, infinity]}

It's SetProperty not setProperty .

PolarPlotB_a.mw

I wonder whether it might also be possible to get the value from the inert form of the Variance by collapsing the nested integrals, ie. changing from nested Int(Int(...)) form into (a sum of?) Int(...,[...]) calls.  I suspect that in nested form the inner integrals may not "know" about the real-ness of the outer variables of integration. Just an idea.

Here is something,

restart:

kernelopts(version);

`Maple 2018.1, X86 64 LINUX, Jun 8 2018, Build ID 1321769`

with(Statistics):

X := RandomVariable(Normal(mu__x, sigma__x)):
Y := RandomVariable(Normal(mu__y, sigma__y)):

U := X+Y:

Z := q -> cos(q):

v__z := Variance(Z(X));

-(1/2)*(2*cos(mu__x)^2*exp(sigma__x^2)-exp(2*sigma__x^2)-2*cos(mu__x)^2+1)*exp(-2*sigma__x^2)

V := subs({mu__x=Mean(U), sigma__x=StandardDeviation(U)}, v__z);

-(1/2)*(2*cos(mu__x+mu__y)^2*exp(sigma__x^2+sigma__y^2)-exp(2*sigma__x^2+2*sigma__y^2)-2*cos(mu__x+mu__y)^2+1)*exp(-2*sigma__x^2-2*sigma__y^2)

Variance(Z(X+Y),inert):
value(combine(%)) assuming real, sigma__x>0, sigma__y>0:

lprint(%);

-(1/2)*(4*cos(mu__x)^2*cos(mu__y)^2*exp(sigma__x^2+sigma__y^2)-4*cos(mu__x)*cos(mu__y)*sin(mu__x)*sin(mu__y)*exp(sigma__x^2+sigma__y^2)-4*cos(mu__x)^2*cos(mu__y)^2-2*cos(mu__x)^2*exp(sigma__x^2+sigma__y^2)+4*cos(mu__x)*cos(mu__y)*sin(mu__x)*sin(mu__y)-2*cos(mu__y)^2*exp(sigma__x^2+sigma__y^2)-exp(2*sigma__x^2+2*sigma__y^2)+2*cos(mu__x)^2+2*cos(mu__y)^2+2*exp(sigma__x^2+sigma__y^2)-1)*exp(-2*sigma__x^2-2*sigma__y^2)

simplify(combine(%));

(1/2)*(-cos(2*mu__x+2*mu__y)-1)*exp(-sigma__x^2-sigma__y^2)+(1/2)*cos(2*mu__x+2*mu__y)*exp(-2*sigma__x^2-2*sigma__y^2)+1/2

is(%=V);

true

 

Download Stat_2015_something.mw

I'll submit a bug report.

Don't use evalf(h,3) or evalf[3](h) as that will use only 3 digits of working precision which is not enough to handle floating-point error here.

The syntax evalf(h,3) or evalf[3](h) instructs Maple to use 3 digits of working precision (possibly with a few extra guard digits for atomic operations or special function calls). But it does not instruct Maple to compute the result to 3 digits of accuracy.

If you only want 3 decimal places in the final answer then either,

  • compute with higher (significantly more than Digits=3) working precision, then evalf[3] that intermediate result.
  • compute with higher (significantly more than Digits=3) working precision, but use GUI-driven numeric formatting or interface(displayprecision) to control the display of the result

Download evalf_example.mw

As a general rule, never try and do anything complicated with less than Digits=5 working precision.

Use the syntax evalf[d](expr) instead of evalf(expr, d) since the latter can be problematic in the case that expr is an expression sequence and you want to compare with evalf(expr) .

@wswain The current version is Maple 2018, not Maple 18 which used an older naming scheme and was released in the year 2014.  Since the year 2015 the versions have been named by the year in which they were released.

If you execute the command kernelopts('homedir') then you will see what Maple thinks is your so-called home directory. The form of that will depend on your OS. In Linux it is uusally something like "home/acer" while on MS-Windows it is something more like "C:\Users\acer".

In modern Maple (for many years now, since version Maple 10 (2005) the filename extension of a Maple Library Archive is .mla .  In versions like Maple 9.5 (2004) and older each library archive consisted of two files as a pair, with filename extensions .lib and .ind , but that is no longer relevant in modern Maple and shouldn't concern you.

In a Maple session the assigned value of libname is the comma-separated path of locations (or individual library archive files) which the Maple kernel uses to search for Library archives.

Maple ships with its own library archives. But you can create you own, and add to them, using commands from the LibraryTools package. I recommand using that package instead of using the savelib command.

One way to get Maple to notice and utilize your own custom-made library achives is to append to the assigned value of libname .  Eg,

libname := libname, somenewfolderlocation;

One way to get Maple to automatically notice and utilize your own custom-made library archives -- upon restart of the kernel or re-launch of the GUI -- is to put such a command as above (appending to libname) in a so-called initialization file. The exact, valid location of an initialization file is platform-specfic, see here.

There is a way that is simpler than adding an initialization file and editing it with a line to append to libname.  It relies on the fact that the so-called toolbox locations are treated specially. If kernelopts('homedir') returns, say, "/home/acer" then the following location -- if it exists in the OS file system -- is automatically appended to libname upon restart using any modern Maple version. 

cat(kernelopts('homedir'), "/maple/toolbox/OrthogonalExpansions/lib");
                       
      "/home/acer/maple/toolbox/OrthogonalExpansions/lib"

You can even make it version-specific. The following location -- if it exists in the OS file system -- is automatically appended to libname upon restart using version Maple 2018.x but no other version. 

cat(kernelopts('homedir'), "/maple/toolbox/2018/OrthogonalExpansions/lib");
                       
      "/home/acer/maple/toolbox/2018/OrthogonalExpansions/lib"

So in order to get your custom package to be accessible automatically in all future sessions all you have to do is store it in a library archive that is created in such a special, so-called "toolbox" location. That is less work than having to mess around with libname and initialization files.

Notes:

  • You can create multiple library archives. You can store multiple packages to a single library archive.
  • The Maple kernel re-scans for such valid toolbox directories following each restart .
  • The GUI will also scan such toolbox directories (or directories in libname , including those appended in an initialization file) when looking for Help Database files (.help or older .hdb file extension). But this only happens when the GUI is launched fresh. It does not re-scan after restart (since version Maple 13).

@Mac Dude There is a hidden character at the start of your .tst data file.

It looks like <feff> inside my vi editor in binary mode. It is also known as a "Byte Order Mark" (BOM), or "Zero Width No Break Space"  See here

It I get rid of that, and assign the ImportMatrix result to the name `data`, and add in your AddProperty, then all seems to go well.

restart;

#interface(rtablesize=30):

data :=ImportMatrix(cat(kernelopts(homedir),"/mapleprimes/","Radiation_Length_Table_ac.txt")):

test:=data[1][1]:

ScientificConstants:-AddProperty(radiationlength);

ScientificConstants:-ModifyElement(convert(test,'name'),radiationlength=[value=data[1,4],units=g/cm^2]);

ScientificConstants:-GetElement(H);

 

1, symbol = H, name = hydrogen, names = {hydrogen}, ionizationenergy = [value = 13.5984, uncertainty = undefined, units = eV], meltingpoint = [value = 13.81, uncertainty = undefined, units = K], density = [value = proc () option `Copyright (c) 2002 Waterloo Maple Inc. All rights reserved.`; if nargs = 0 then error "element is a gas, access ideal density with parameter 'gas'" elif args[1] = 'gas' then 0.88e-1 else error "incorrect parameters" end if end proc, uncertainty = undefined, units = kg/L], electronegativity = [value = 2.1, uncertainty = undefined, units = 1], boilingpoint = [value = 20.28, uncertainty = undefined, units = K], electronaffinity = [value = proc () option `Copyright (c) 2002 Waterloo Maple Inc. All rights reserved.`; error "access isotopic property electronaffinityisotopic of H[1] and H[2]" end proc, uncertainty = undefined, units = 1], atomicweight = [value = 1.00794, uncertainty = 0.7e-4, units = amu], radiationlength = [value = 63.04, uncertainty = undefined, units = g/cm^2]

(1)

restart;

#interface(rtablesize=30):

data :=ImportMatrix(cat(kernelopts(homedir),"/mapleprimes/","Radiation_Length_Table_ac.txt")):

test:=data[1][1]:

ScientificConstants:-AddProperty(radiationlength);

ScientificConstants:-ModifyElement(parse(test),radiationlength=[value=data[1,4],units=g/cm^2]);

ScientificConstants:-GetElement(H);

1, symbol = H, name = hydrogen, names = {hydrogen}, ionizationenergy = [value = 13.5984, uncertainty = undefined, units = eV], meltingpoint = [value = 13.81, uncertainty = undefined, units = K], density = [value = proc () option `Copyright (c) 2002 Waterloo Maple Inc. All rights reserved.`; if nargs = 0 then error "element is a gas, access ideal density with parameter 'gas'" elif args[1] = 'gas' then 0.88e-1 else error "incorrect parameters" end if end proc, uncertainty = undefined, units = kg/L], electronegativity = [value = 2.1, uncertainty = undefined, units = 1], boilingpoint = [value = 20.28, uncertainty = undefined, units = K], electronaffinity = [value = proc () option `Copyright (c) 2002 Waterloo Maple Inc. All rights reserved.`; error "access isotopic property electronaffinityisotopic of H[1] and H[2]" end proc, uncertainty = undefined, units = 1], atomicweight = [value = 1.00794, uncertainty = 0.7e-4, units = amu], radiationlength = [value = 63.04, uncertainty = undefined, units = g/cm^2]

(2)

 

Download ModifyElementMWE_ac.mw

ps. If data is a Matrix then accessing entries with the syntax like data[1][1] is less efficient that accessing it like data[1,1].  The former creates a temporary Vector unncessarily. If you do it many times then you might see an impact on performance.

 

First, let's consider the case of having all output for "Maple Output" be left-aligned, automatically.

The alignment doesn't seem to show up as an editable property when doing the main menubar choice:  Format->Styles...->(select "Maple Output" from list) Modify.  But it's still possible to modify all "Layout" properties of the "Maple Output" style in an otherwise empty .mw file, using a text editor. Such a file could be saved somewhere out-of-the-way, and even marked as read-only in your OS if you'd like. Here is such a template file: outputleft.mw

That template file can then be used as a new default template, following either of these mechanisms:

  • menubar choice Format->Manage Style Sets->User-defined Style Set (choose that same new file as the template).  This can make all output, in all new worksheets, be left-aligned by default. You might find this too heavy-handed, as it makes it awkward to open a new sheet without the custom style.
  • menubar choice Tools->Options->Interface->"Open worksheet at startup:" and in the combo-box select "Specified worksheet:", and then set it to that template file. Then close with "Apply Globally". Doing this sets the template that will be opened whenever the "open the start page" icon (looks like a house) is chosen from the menubar.

Now let's consider the case of making only some 2D Math output be left aligned. That's trickier.

You cannot get typeset 2D Math displayed using the printf command (which left-aligns), since that line-prints.

The attached worksheet (which won't inline properly here on Mapleprimes) contains some ideas for programmatically displaying some expressions as if it were left-aligned 2D output.  left_tools.mw

You can find the degree symbol in the Common Symbols palette.

You can also insert it, or conjoin it to some other name, programmatically. Here are a few ways, which look better in actual Maple but might not all render properly when inlined here on Mapleprimes.

restart;

kernelopts(version);

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

deg := `&deg;`;

`&deg;`

N := 45;

45

N^deg;

45^`&deg;`

N*deg;

45*`&deg;`

cat(convert(N,name),deg);

`45&deg;`

cat(`result of number in degrees: `, N, deg);

`result of number in degrees: 45&deg;`

convert(%, string);

"result of number in degrees: 45&deg;"

sprintf("result of number in degrees: %s", cat(convert(N,name),deg));

"result of number in degrees: 45&deg;"

sprintf("result of number in degrees: %a%s", N, deg );

"result of number in degrees: 45&deg;"

 

Download degsymb.mw

Your code for assuming something 'real' is incorrect.

It should be lambda::'real' and not lambda='real' , within the context of assume (or assuming).

I'll mention that you don't generally need to assume that lambda is 'real' if you're going to additionally assume that it's less than zero. But you have also messed up the syntax for assuming mu as 'real', and omitted any 'real' assumption on nu.

If you are having trouble exporting a densityplot to Postscript then you could also try a thick line.

In Maple 2018 you can use that same colorscheme option.

restart;
(grad_min, grad_max) := 0.0, 2.7:

P:=plot([0.1, t, t=grad_min..grad_max],thickness=70,
     numpoints=2,adaptive=false,
     colorscheme=["zgradient", ["Red","Blue"]],
     view=[0.06..0.12,default],size=[100,400],axis[1]=[tickmarks=[]]):

plotsetup(cps,
          plotoutput = cat(kernelopts(homedir),kernelopts(dirsep),"eps_2.ps"),
          plotoptions = `portrait, noborder, width=100, height=400`);
print(P);
plotsetup(default);

The above I did on Maple 2018.0 on 64bit Linux. You might have to fiddle a little with the width and centering.

Results seem best when the number of y-points is very low, ie. two. Otherwise faint horizontal light lines appear as artefacts in the Postscript image.

It's possible that this also relates to your line artefacts in the Postscript export of the densityplot. So, you might also try the densityplot but with the addtional grid=[2,3] option.

[edited] ...and with axes=boxed

(grad_min, grad_max) := 0.0, 2.7:
P:=plot([0.1, t, t=grad_min..grad_max],thickness=46,
     numpoints=2,adaptive=false,
     colorscheme=["zgradient", ["Red","Blue"]],
     view=[0.06..0.14,default],size=[100,400],
     axes=boxed,axis[1]=[tickmarks=[]]);

BTW, what is your rationale for choosing .eps export over other graphic formats? I don't see that .eps export of such a 2D surface is going to give you higher resolution (or better fidelity) than all other formats.

First 171 172 173 174 175 176 177 Last Page 173 of 336