acer

32343 Reputation

29 Badges

19 years, 327 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

The backslash is the escape character. If you want a literal backslash then you can escape the backslash itself.

with(StringTools):

URL := "F:\\GoogleDrive\\api";

"F:\GoogleDrive\api"

SubstituteAll(URL, "\\", "/");

"F:/GoogleDrive/api"

 

Download string_subs.mw

I see three Sections in the uploaded Document, because the file is corrupted starting in the third Section.

Beton_Notat_og_opgaveark_ac.zip

I don't see anything past that point, as meaningful data.

On the other hand, the Standard GUI itself fails to recover and save as usable anything but the first two sections. Even when it claims (via file manager popup) that it's attempting to recover from the corrupt file, the Standard GUI still fails to close off the XML tags open at the end of the incomplete third section, and thus fails to recover all possible from that section in usable way. I find that to be disappointing behavior (and I've submitted several bugs reports about it).

There have been several dozen related reports over the years. It's not clear whether the primary trigger of the bug is the Danish language pack extension, or the inlining of several large images/canvases in the Documents. 

I may be able to address usefully only your first point.

When a Code Edit Region is collapsed a snippet is displayed, almost like a title of sorts. That's taken from the first line of the Region. If the first line is empty then so can that snippet be...

I've learned not to leave the first line of a Code Edit Region empty.

If you know the component's identity then you can toggle its `visible` property with the SetProperty command of the DocumentTools package.

If an Embedded Component (of which Code Edit Regions are one sort, under the hood) is toggled visible=false and you don't know its identity then the situation is a little tricky. On Sept 19, 2018 someone asked a Question about that. I answered with code which can be used/modified to return the identities of all components of a given sort.

I'm away from a computer for a few days, and copying the link to that other thread is hard, sorry.

For the followup example, even though combine (alone) is enough to handle the expression for t<1, I'll use combine@factor@expand below since it produces a terse form (with combined exponent) for either case t<1 and t>1.

restart;

expr := ((1-t)^2)^q;

                                    q
                          /       2\ 
                          \(1 - t) / 

combine(factor(expand(expr))) assuming t < 1;

                                 (2 q)
                          (1 - t)     

combine(factor(expand(expr))) assuming t > 1;

                                 (2 q)
                          (t - 1)

It also happens to fix up the inadvertantly expanded result from calling simplify under the assumption t>0, which the OP did. That is not fixed by wrapping with combine alone. (Here, combine@factor is enough.)

alt := simplify(expr) assuming t > 1;

                                      q
                        /           2\ 
                        \1 - 2 t + t / 

combine(factor(expand(alt))) assuming t > 1;

                                 (2 q)
                          (t - 1)

I have a mild fondness for uniform approaches. (Not that this solves all other examples, of course!)

restart;

kernelopts(version);

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

sum(1/(1+x)^t, t=1..infinity, formal);

                               1
                               -
                               x

See also the Help page for topic updates,Maple2016,AdvancedMath and on that page the link to the bookmark #SymbolicSummation .

An unadorned and unmatched, literal, single right-quote is not valid syntax in the plaintext Maple language.

What you're asking for cannot be done with a literal single right-quote in plaintext 1D Maple Notation, unless it is wrapped in either a set of quotation marks or a set of left-quotes (aka name quotes).

And even such a quoted, literal, single right-quote were entered you'd still have to set things up to interpret it as a derivative. Which could be tricky if you want the notation to work automatically for any arbitrary function name, and not just f.

restart;

cc := arctan(sin(phi)/cos(phi))-arccos(cos(phi)):

simplify( cc ) assuming phi>0, phi<Pi/2;

                   0

simplify(evalc(convert( cc, ln ))) assuming phi>Pi/2, phi<Pi;

                  -Pi

simplify(expand( eval(cc,phi=x+2*n*Pi) )) assuming n::posint, x>0, x<Pi/2;

                   0

# non-constant
convert(simplify(evalc(convert( cc, ln ))),tan) assuming phi>Pi, phi<3*Pi/2;

          -Pi + arccot(cot(2 phi))

dd := arctan(sin(phi),cos(phi))-arccos(cos(phi)):

simplify( dd ) assuming phi>0, phi<Pi;

                   0

simplify(expand( eval(dd,phi=x+2*n*Pi) )) assuming n::posint, x>0, x<Pi;

                   0

eval(cc, phi=5*Pi/4);

                   Pi
                - ----
                   2
restart;
A:=45*Unit(cm): B := 5.3*Unit(m):
C:=A+B;
          C := 45 [cm] + 5.3 [m]

C:=simplify(C);
           C := 5.750000000 [m]

Units:-Standard:-round( C );
                6 [m]
restart;
with(Units:-Standard, round):
A:=45*Unit(cm): B := 5.3*Unit(m):
C:=A+B;
          C := 45 [cm] + 5.3 [m]

C:=simplify(C);
           C := 5.750000000 [m]

round(C);
                6 [m]
restart;
with(Units:-Standard):
A:=45*Unit(cm): B := 5.3*Unit(m):
C:=A+B;
           C := 5.750000000 [m]

round(C);
                6 [m]

Another difference is that Units:-Standard:-round will not automatically "combine" units to the base SI units. In the following example it will not turn cm into meters, where round(0.054) becomes zero.

restart;
C :=  5.4*Unit(cm);
                C := 5.4 [cm]

simplify( round( C ) );
                     0

Units:-Standard:-round( C );
                   5 [cm]

combine( round( C ), units );
                  1/20 [m]

So which approach you choose could depend on whether you want rounding in terms of the original unit or the base SI unit.

It is an initially known constant in Maple, as a stand-in for Euler's constant (also known as the Euler-Mascheroni constant).

See the help page for Topic initialconstants.

evalf(gamma);

                   0.5772156649

restart;

ee := 3*log[10](a)-log[10](b);

3*ln(a)/ln(10)-ln(b)/ln(10)

ans := combine(ee,ln,symbolic);

ln(a^3/b)/ln(10)

inertans := applyrule(ln(x::anything)/ln(y::posint)=%log[y](x), ans);

%log[10](a^3/b)

combine(value(inertans) - ee, symbolic);

0

InertForm:-Display(inertans, inert=false);

%log[10](a^3/b)

 

Download some_log10.mw

The fine structure constant is not a derived constant in the ScientificConstants package.

Using rhs on a particular indexed position where you think an equation might lie -- when that position might vary -- is not a great idea. (It is common, inferior use of results from dsolve numeric, with listprocedure output.)

restart;

with(ScientificConstants):

form:=eval(derive,select(type,[GetConstant(e)],`=`));

2^(1/2)*(alpha*h/(mu[0]*c))^(1/2)

raw:=subsindets(form,And(name,Non(constant)),Constant);

2^(1/2)*(ScientificConstants:-Constant([fine_structure_constant])*ScientificConstants:-Constant([Planck_constant])/(ScientificConstants:-Constant([permeability_of_vacuum])*ScientificConstants:-Constant([speed_of_light_in_vacuum])))^(1/2)

evalf(raw);

0.1602176620e-18

evalf(Constant(e));

0.1602176620e-18

 

Download const_derive.mw

restart;

ans:=numapprox:-minimax(LambertW(x),x=0.3..30.0,[3,2],1,'maxerror');

(0.49622184e-3+(0.2471621408e-1+(0.5095498506e-2+0.2054985893e-4*x)*x)*x)/(0.279566316e-1+(0.2370869536e-1+0.1803666695e-2*x)*x)

maxerror;

0.8223993648e-3

plot(abs(LambertW(x)-ans),x=0.3..30,
     size=[600,200],gridlines=false);

 

Download lambertw_minimax.mw

It sounds as if you are trying to describe what Maple provides through its Statistics package as the ProbabilityTable discrete distribution.

The Statistics:-Sample command can be used to generate samples from it. Eg,

restart;

with(Statistics):

P := [1/2,1/4,1/8,1/16,1/16];

X := RandomVariable(ProbabilityTable(P)):

S:=Sample(X, 10^5);

Tally(S);

Histogram(S);

And of course you can use Sample(X, 1) to produce a sample of size one.

You can convert a string to a name, or use nprintf to construct a name.

You may be making the mistake of thinking that a name somehow contains the left quotes, just because it prints that way. But it prints that way for clarity (and because it's the easy way to enter it literally).

Here are some ideas to get you started. Your A and B denote a regular 5x5 grid, so there's no real need to supply them, and the C data is enough. But my worksheet shows you a variety of ways, some using all of A,B,C and some using just the C data.

Some of the ways I show allow you to easily re-interpret the dependent x-y values (from A and B) as being in whatever arbitrary fine ranges you choose.

It would also be possible, in Maple 2018, to use the new Interpolation package to produce something (which acts like a procedure) which can compute an interpolated height value (z) for your choice of x-y input pair of values. That would provide yet another way to plot a smooth surface from the data, but would also provide an easy way to do numeric optimization, integration, etc. Let me know if this is what you want. (nb. The better way to do that would be to only use the C data offer the data to Interpolation as regular, not as and irregular, incomplete set.)

These 3D plots look much better in Maple itself. This Mapleprimes site does a poor job of inline rendering 3D plots in a worksheet.

restart;

A:=[1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5]:
B:=[1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5]:
C:=[5,2,7,9,1,6,2,8,4,6,2,1,5,8,3,5,2,9,6,6,3,2,1,6,4]:

M:=<<A>|<B>|<C>>;

M := Vector(4, {(1) = ` 25 x 3 `*Matrix, (2) = `Data Type: `*anything, (3) = `Storage: `*rectangular, (4) = `Order: `*Fortran_order})

plots:-surfdata(M,source=irregular);

R:=Array(ArrayTools:-Reshape(M,[5,5,3]),datatype=float[8]);

R := Vector(4, {(1) = ` 1..5 x 1..5 x 1..3 `*Array, (2) = `Data Type: `*float[8], (3) = `Storage: `*rectangular, (4) = `Order: `*Fortran_order})

Praw:=PLOT3D(MESH(R)):
plots:-display(Praw,
               style=surface, color=blue, transparency=0.1);

# Either of these will produce just the C layer, as a 2D Array.

G := Array(ArrayTools:-Reshape(<C>, [5,5])^%T, datatype=float[8]);

G := R[..,..,3]^%T;

Matrix(5, 5, {(1, 1) = 5.0, (1, 2) = 2.0, (1, 3) = 7.0, (1, 4) = 9.0, (1, 5) = 1.0, (2, 1) = 6.0, (2, 2) = 2.0, (2, 3) = 8.0, (2, 4) = 4.0, (2, 5) = 6.0, (3, 1) = 2.0, (3, 2) = 1.0, (3, 3) = 5.0, (3, 4) = 8.0, (3, 5) = 3.0, (4, 1) = 5.0, (4, 2) = 2.0, (4, 3) = 9.0, (4, 4) = 6.0, (4, 5) = 6.0, (5, 1) = 3.0, (5, 2) = 2.0, (5, 3) = 1.0, (5, 4) = 6.0, (5, 5) = 4.0})

Matrix(%id = 18446884309825804878)

# I made up the ranges 1..3, 5..17 for the axis. Use what you want.
#
plots:-surfdata(G, 1..3, 5..17, labels=["x","y","z"]);

plots:-surfdata(G, 1..3, 5..17, labels=["x","y","z"],
                gridsize=[25,25], interpolation=[method=cubic]);

plots:-surfdata(G, -3..2, 0..1, labels=["x","y","z"],
                gridsize=[51,51], interpolation=[method=spline],
                style=surface, glossiness=0.0, shading=zhue);

 

Download variousirregular.mw

First 168 169 170 171 172 173 174 Last Page 170 of 336