acer

32470 Reputation

29 Badges

20 years, 6 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Somehow you've managed to get an extra, hidden Execution Group between the
   proc(ix,iy)
and the
   global T

I don't know how you managed that. I can cut&paste that procedure definition from my answer to your previous Question, into a new Execution Group, without that happening.

I notice that the 1D code appears to reside inside a Document Block, instead of the usual (single) Execution Group. I suspect that this may be the cause of the problem. I personally would only use Execution Groups (red > cursor) for 1D code inside a Document.

(See the entries in the "Insert" menu from the GUI's menubar. Or use Ctl-k as a keyboard shortcut.)

The densityplot command is passing floating-point values to your procedure f. But the indices of your tables are integers.

Try this (for your second attached Document):

f := proc(ix,iy)
    global T: local x:=trunc(ix), y:=trunc(iy);
    print(x,y," Returning ",T[x][y]):
    return T[x][y]:
end:

The problem in your first Document is different -- some of the inner tables' indices are HFloats, since the part 2*A[1 .. (), 2 .. 3] results in a datatype=float[8] Matrix, with the entries in B[5..,2..] being HFloats as a default consequence. There are various ways to "fix" that. But I'll wait to see if you intend on using floats or integers in some final densityplot construction, ie. perhaps a merging of your second Document's two densityplots with the kind of float values in the Matrix A of your second Document.

In any case, you'll need to ensure that the values used to index into the tables actually match the indices of said tables.

ps. It's spelled table, uncapitalized.

If the option restricttoranges is not specified as true (and it defaults to false) then the procedure is sampled at the midpoints between the grid values.

Notice the positions of the tickmarks on the axes.

It looks as if what you expected was the result from this:

   plots:-densityplot(g, 1 .. 4, 2 .. 8, grid = [5, 5], restricttoranges = true)

note: You can also supply just that option name alone, to get it specified as true.

The subs command substitutes into the stored structure. But N__1/N is not present alone as a separate structural subexpression of q*N__1/N. All three multiplicands in the expression are stored "together". That's why your first example did not succeed.

That is an important reason why the algsubs command exists, to do a substitution mathematically (as opposed to structurally). That command can handle your first example,

g := q*N__1/N

q*N__1/N

algsubs(N__1/N = X__1, g)

q*X__1

Download algsubs_ex.mw

See the Help page for algsubs for more examples. There are also a few examples of differences between subs and algsubs on the Help page for the subs command.

Your second example worked because the lhs of your substitution equation matched the whole expression (which is, of course, structurally present).

The Typesetting system has to be very careful about inadvertantly evaluating expressions, hence the special evaluation behaviour of its Typeset command.

The fact that the Typeset procedure's first parameter is specified with the uneval modifier doesn't mean that its output is "of type uneval", as you phrased it. You've misused that terminology. Yes, the first argument passed to that procedure is not evaluated as usual. (See ?type,uneval for a technical description of that term.)

There is a related export of the Typesetting module, Typesetting:-EV, which can often be utilized to get the kind of evaluation that you might want when calling Typesetting:-Typeset on, say, and assigned name. For example,

ee := sin(x);

sin(x)

Typesetting:-Typeset(ee);

ee

lprint(%);

Typesetting:-mi("ee")

Typesetting:-Typeset(Typesetting:-EV(ee));

sin(x)

lprint(%);

Typesetting:-mrow(Typesetting:-mi("sin",fontstyle = "normal"),Typesetting:-mo(
"⁡"),Typesetting:-mfenced(Typesetting:-mi("x")))


Download TS_ex.mw

The mi stands for mathematical identifier, in MathML parlance. (See here.) Maple's typesetting renders such in italics by default, unless modified by a property such as fontstyle, etc.

That contrasts with, say, mo which as MathML stands for mathematical operator. Maple renders such in upright Roman by default.

You could use the piecewise command. For example,

f := x -> piecewise(x>0, x, x<0, -x);

f := proc (x) options operator, arrow; piecewise(0 < x, x, x < 0, -x) end proc

f := x -> piecewise(x>=0, x, x<0, -x);

f := proc (x) options operator, arrow; piecewise(0 <= x, x, x < 0, -x) end proc

plot(f);

Download pw_ex.mw

Or, as 2D Input (I used command-completion here),

f := proc (x) options operator, arrow; piecewise(0 <= x, x, x < 0, -x) end proc

proc (x) options operator, arrow; piecewise(0 <= x, x, x < 0, -x) end proc

Download pw_ex2d.mw

Here is one way to handle this example. (I did not bother to make it work for other flavors of radical, or products involving floats and radicals and other multiplicands.)

This gets the same form as your showed and named Desired.

restart;

with(LinearAlgebra):

interface(imaginaryunit=j):

Amat := Matrix(2, 2, [[-0.1428571428*K__D, -0.1081971238], [376.9911185, 0]]);

Matrix(2, 2, {(1, 1) = -.1428571428*`#msub(mi("K"),mi("D",fontstyle = "normal"))`, (1, 2) = -.1081971238, (2, 1) = 376.9911185, (2, 2) = 0})

T:=Eigenvalues(Amat);

Vector(2, {(1) = -0.7142857140e-1*`#msub(mi("K"),mi("D",fontstyle = "normal"))`+0.2000000000e-9*sqrt(0.1275510203e18*`#msub(mi("K"),mi("D",fontstyle = "normal"))`^2-0.1019733868e22), (2) = -0.7142857140e-1*`#msub(mi("K"),mi("D",fontstyle = "normal"))`-0.2000000000e-9*sqrt(0.1275510203e18*`#msub(mi("K"),mi("D",fontstyle = "normal"))`^2-0.1019733868e22)})

Desired := sqrt((2.000000000*10^(-10))^2 * (1.275510203*10^17*K__D^2 - 1.019733868*10^21));

(0.5102040812e-2*K__D^2-40.78935472)^(1/2)

evalindets(T,&*(float,`+`^(1/2)),u->signum(op(1,u))*(op([2,1],u)*op(1,u)^2)^(1/2));

Vector(2, {(1) = -0.7142857140e-1*`#msub(mi("K"),mi("D",fontstyle = "normal"))`+sqrt(0.5102040812e-2*`#msub(mi("K"),mi("D",fontstyle = "normal"))`^2-40.78935472), (2) = -0.7142857140e-1*`#msub(mi("K"),mi("D",fontstyle = "normal"))`-sqrt(0.5102040812e-2*`#msub(mi("K"),mi("D",fontstyle = "normal"))`^2-40.78935472)})

Download Q20230110_m1_ac.mw

You can put use these commands to set those as defaults for the session, for 2-D and 3-D plots respectively.

plots:-setoptions('symbol'=':-solidcircle','symbolsize'=12);
plots:-setoptions3d('symbol'=':-solidcircle','symbolsize'=12);

 

The problem for your second example is that the plots:-inequal command is generating one POLYGON and some CURVES structures, that only specify the vertices and endpoints (of lines). So you're seeing the result of transforming those structures, containing transformed values of those vertices and endpoints.

Here is one approach, for that second example. (I threw in a pair of lines for the final "axes", only to get a closer final effect.)

P := plots:-display(
       plot3d(0,s=1..t/5+1,t=0..5,style=surface,
              transparency=0.5,color="Niagara Azure"),
       plots:-spacecurve([t/5+1,t,0,t=0..5],thickness=0,color=black),
       plots:-spacecurve([1,t,0,t=0..5],thickness=0,color=black),
       plots:-spacecurve([s,5,0,s=1..2],thickness=0,color=black)
     ):

plots:-display(
  plottools:-transform((s,t,z)->[s^2*sqrt(t)*cos(t),s^2*sin(t)])(P),
  plottools:-line([0,-4.2],[0,2.2],thickness=0),
  plottools:-line([-5.2,0],[2.8,0],thickness=0),
size=[500,"golden"],axes=boxed);

Are you trying to accomplished something like this?

Multiple_input_ac.mw

(In future, please add followup details to an original Question, instead of spawning a separate Question thread for the same issue.)

I suggest that you use these settings on Linux, which ought to get rid of that problem:

In the GUI's Tools->Options->Display ,
   Input = Maple Notation           (what you showed; should not be a problem)
   Output = 2-D Math Notation   (changed from what you showed; this is the usual default)

You should get these results, from commands,

   interface(prettyprint);     #  you want 3 as the value (the default)

   interface(typesetting);    # you want extended as the value (the default)

Naturally, if you have to make any changes (to get these settings) you would then save "globally" in the popup.

If you have previously set up a customized initialization file then you might check that it doesnt contain interface commands to change any of these values.

ps. The .mw file that was originally attached to the Question is marked as having last been saved in Maple 2021.2.

restart;

f := x*y*z:

constr := x+y+z=6:


method 1)

R := max(extrema(f, constr, {x,y,z}, 'S'));

8

ans := select(s->eval(f, s)=R, S)[];

{x = 2, y = 2, z = 2}

 

method 2)

 

u := eval(f, solve(constr, {z}));

x*y*(6-x-y)

S2 := {solve({diff(u,x), diff(u,y)})};

{{x = 0, y = 0}, {x = 0, y = 6}, {x = 2, y = 2}, {x = 6, y = 0}}

R2 := max(map[2](eval, u, S2));

8

temp := select(s->eval(u,s)=R2, S2);

{{x = 2, y = 2}}

ans2 := temp[] union eval~(solve(constr, {z}), temp);

{x = 2, y = 2, z = 2}

Download exfunction.mw

Your intention is not clear. Are you trying to import this as if it had five columns or data, separated by semicolons?

[edit] I changed it to parse the commas like a period in the data portion.

M := ImportMatrix( "Sdat.txt", delimiter=";" ):

DataFrame( subsindets(M[2..,..],string,
                      u->parse(StringTools:-Subs(","=".",u))),
           columns=M[1,..] );

DataFrame(_rtable[36893628252267267484], rows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], columns = ["t[s]", "scanId", "m/z", "I[A]", "pTot[mbar]"])

Download Ssimport2.mw

There are definitions of iup and idn in the maple.sty LaTeX style file that is usually located in the etc directory of the Maple installation location.

There is a note about this LaTeX style file (ie. that you ought to utilize it) on the Help page for Topic latex.

What are the relevant variables you intend for use with the inverse Laplace transform? (Are you intending ilaplace(U4, s, eta) ??)

What is the value of a[0]? How do you expect to obtain a 2-D plot without supplying that? Did you intend a[0] to be 1/s?

Are you trying to get something like this? TC1_ac.mw

First 54 55 56 57 58 59 60 Last Page 56 of 337