acer

28100 Reputation

29 Badges

17 years, 244 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

You could construct an interpolating function from the x-y-z data, which could compute a z-value for any x,y pair within range.

Then you can make any usual kind of plot, and add coloring, options, etc.

For example, using the very small collection of data originally provided, see below.

I forced 20 contour values, but you could just as easily specifiy the contour values in steps of 100 ( ie, seq(...,100) instead of seq(...,numelems=20) ).

restart;

data := [[177.80000,0.,967.3266667],[169.80000,0.,963.5900000],
         [100.00000,0.,188.8933333],[176.92000,17.703000,967.3266667],
         [174.27000,35.230000,967.3200000],[169.90000,52.407000,967.3566667],
         [163.84000,69.064000,967.3366667],[156.15000,85.034000,967.3100000],
         [146.91000,100.16000,967.3366667],[136.20000,114.29000,967.3666667]]:

F := Interpolation:-Interpolate(data[..,1..2],data[..,3]):

P2:=plots:-contourplot(F,min(data[..,1])..max(data[..,1]),min(data[..,2])..max(data[..,2]),
                       contours=[seq(min(data[..,3])..max(data[..,3])*(1-1e-9),numelems=20)],
                       thickness=2, colorscheme=["Blue","Red"]):

plots:-display(
  plottools:-transform((x,y)->[x,y,0])(P2),
  plots:-surfdata(Matrix(data),source=irregular,
                  style=point,shading=zhue,symbolsize=15,symbol=solidcircle)
);

P2;

 

Download interp_cont_data.mw

Using Maple 18.02, since that's the version in which your attachment was last saved.

restart

kernelopts(version)

`Maple 18.02, X86 64 LINUX, Oct 20 2014, Build ID 991181`

A[m] := (x/a)^(i+1)*(1-x/a)^2;B[n] := (y/b)^(i+1)*(1-y/b)^2;w := c[i]*A[m]*B[n];

(x/a)^(i+1)*(1-x/a)^2

(y/b)^(i+1)*(1-y/b)^2

c[i]*(x/a)^(i+1)*(1-x/a)^2*(y/b)^(i+1)*(1-y/b)^2

TPE := `assuming`([(1/2)*(int(int(D__11*(diff(w, x, x))^2+2*D__12*(diff(w, x, x))*(diff(w, y, y))+4*D__66*(diff(w, x, y))^2+D__22*(diff(w, y, y))^2-2*q__0*w, x = 0 .. a), y = 0 .. b))], [i > 0]);

2*c[i]*(-512*a^4*b^4*i^8*q__0-6144*a^4*b^4*i^7*q__0-29184*a^4*b^4*i^6*q__0+36*D__11*b^4*i^8*c[i]+8*D__12*a^2*b^2*i^8*c[i]+36*D__22*a^4*i^8*c[i]+16*D__66*a^2*b^2*i^8*c[i]-69120*a^4*b^4*i^5*q__0+612*D__11*b^4*i^7*c[i]+168*D__12*a^2*b^2*i^7*c[i]+612*D__22*a^4*i^7*c[i]+336*D__66*a^2*b^2*i^7*c[i]-82368*a^4*b^4*i^4*q__0+4257*D__11*b^4*i^6*c[i]+1482*D__12*a^2*b^2*i^6*c[i]+4257*D__22*a^4*i^6*c[i]+2964*D__66*a^2*b^2*i^6*c[i]-38016*a^4*b^4*i^3*q__0+15570*D__11*b^4*i^5*c[i]+7068*D__12*a^2*b^2*i^5*c[i]+15570*D__22*a^4*i^5*c[i]+14136*D__66*a^2*b^2*i^5*c[i]+9824*a^4*b^4*i^2*q__0+31959*D__11*b^4*i^4*c[i]+19386*D__12*a^2*b^2*i^4*c[i]+31959*D__22*a^4*i^4*c[i]+38772*D__66*a^2*b^2*i^4*c[i]+13920*a^4*b^4*i*q__0+36198*D__11*b^4*i^3*c[i]+29352*D__12*a^2*b^2*i^3*c[i]+36198*D__22*a^4*i^3*c[i]+58704*D__66*a^2*b^2*i^3*c[i]+3150*a^4*b^4*q__0+20448*D__11*b^4*i^2*c[i]+19048*D__12*a^2*b^2*i^2*c[i]+20448*D__22*a^4*i^2*c[i]+38096*D__66*a^2*b^2*i^2*c[i]+4320*D__11*b^4*i*c[i]-3648*D__12*a^2*b^2*i*c[i]+4320*D__22*a^4*i*c[i]-7296*D__66*a^2*b^2*i*c[i]-8064*D__12*a^2*b^2*c[i]-16128*D__66*a^2*b^2*c[i])/(a^3*b^3*(256*i^14+7680*i^13+103936*i^12+837888*i^11+4472800*i^10+16609536*i^9+43796912*i^8+81956400*i^7+106195721*i^6+88876434*i^5+38200637*i^4-3705948*i^3-13260492*i^2-5974560*i-907200))

 

You could rearrange that result with various kinds of simplification. For example,

 

collect(numer(TPE), [a, b], factor)/factor(denom(TPE))

((-4*c[i]*q__0*(2*i+7)*(2*i-1)*(2*i+5)^2*(2*i+3)^2*(2*i+1)^2*b^4+18*c[i]^2*D__22*i*(2*i+5)*(2*i+1)*(i+3)*(i+2)*(i+1)*(i+4)^2)*a^4+4*c[i]^2*(2*i+7)*(2*i-1)*(i+4)^2*(i+3)^2*(i+2)^2*(D__12+2*D__66)*b^2*a^2+18*c[i]^2*D__11*i*(2*i+5)*(2*i+1)*(i+3)*(i+2)*(i+1)*(i+4)^2*b^4)/(a^3*b^3*(2*i+7)*(2*i-1)*(2*i+5)^2*(2*i+3)^2*(2*i+1)^2*(i+4)^2*(i+3)^2*(i+2)^2)

collect(TPE, [D__11, D__12, D__22, D__66], factor)

18*(i+1)*i*b*c[i]^2*D__11/((2*i+7)*(2*i+5)*(2*i+1)*(2*i-1)*(i+3)*(i+2)*(2*i+3)^2*a^3)+4*c[i]^2*D__12/(b*a*(2*i+5)^2*(2*i+3)^2*(2*i+1)^2)+18*(i+1)*i*a*c[i]^2*D__22/((2*i+7)*(2*i+5)*(2*i+1)*(2*i-1)*(i+3)*(i+2)*(2*i+3)^2*b^3)+8*c[i]^2*D__66/(b*a*(2*i+5)^2*(2*i+3)^2*(2*i+1)^2)-4*a*b*q__0*c[i]/((i+4)^2*(i+3)^2*(i+2)^2)

Download total_PE_ac.mw

You can insert a new execution group after the current line using either the keyboard shortcut Ctl j, or the main menubar item,
   Insert -> Execution Group -> After Cursor

The keyboard shortcut for inserting before the cursor is Ctl k.

The keyboard shortcut for splitting an Execution Group at the current cursor position is the F3 key.

You can see a listing of the shortcuts on MS-Windows by looking at the Help page for topic
   worksheet,reference,hotwin
Here's the link to that in the online Help (version Maple 2013, not your Maple 18, but these particular shortcuts are unchanged).

For "Mac" (OS X) the variants are shown on the Help page with topic,
   worksheet,reference,hotmac
For example, Cmd j and Cmd k

That can be attained directly by Matrix indexing, eg.

with(GraphTheory):

g:=Graph({{2,3},{1,2}}):

foo:=AdjacencyMatrix(g);

foo := Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 2) = 0, (2, 3) = 1, (3, 3) = 0}, storage = triangular[upper], order = C_order, shape = [symmetric])

ind := [3,1,2];

[3, 1, 2]

foo[ind,ind];

Matrix([[0, 0, 1], [0, 0, 1], [1, 1, 0]])

Download matrix_indexing_ex.mw

If I understand the question correctly then here are two more ways, using reasonably terse syntax.

restart;

A := <<1, 5, 9, 13> | <2, 6, 10, 14> | <3, 7, 11, 15> | <4, 8, 12, 16>>;

Matrix(4, 4, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 3, (1, 4) = 4, (2, 1) = 5, (2, 2) = 6, (2, 3) = 7, (2, 4) = 8, (3, 1) = 9, (3, 2) = 10, (3, 3) = 11, (3, 4) = 12, (4, 1) = 13, (4, 2) = 14, (4, 3) = 15, (4, 4) = 16})

B := <17,18,19,20>;

Vector(4, {(1) = 17, (2) = 18, (3) = 19, (4) = 20})

`<|>`(B$4)/~A

Matrix(4, 4, {(1, 1) = 17, (1, 2) = 17/2, (1, 3) = 17/3, (1, 4) = 17/4, (2, 1) = 18/5, (2, 2) = 3, (2, 3) = 18/7, (2, 4) = 9/4, (3, 1) = 19/9, (3, 2) = 19/10, (3, 3) = 19/11, (3, 4) = 19/12, (4, 1) = 20/13, (4, 2) = 10/7, (4, 3) = 4/3, (4, 4) = 5/4})

`<|>`(seq(B/~A[..,i],i=1..4))

Matrix(4, 4, {(1, 1) = 17, (1, 2) = 17/2, (1, 3) = 17/3, (1, 4) = 17/4, (2, 1) = 18/5, (2, 2) = 3, (2, 3) = 18/7, (2, 4) = 9/4, (3, 1) = 19/9, (3, 2) = 19/10, (3, 3) = 19/11, (3, 4) = 19/12, (4, 1) = 20/13, (4, 2) = 10/7, (4, 3) = 4/3, (4, 4) = 5/4})

Download mvdivelem_ex.mw

Those don't use any functionality new to only recent Maple versions.

ps. If you haven't already assigned the number of columns of Matrix A (here, the value 4) to some name, then it can be obtained as op([1,2],A) .

This is fiddly, but...

Typesetting:-mrow(Typesetting:-mo("Y"),
                  Typesetting:-mspace(width="-1.2em"),
                  Typesetting:-mo("&#x25CB;",mathsize=18));

"Y &cir;"

Download ts_negmspace.mw

Here is an example that you might find useful.

I'm using Maple here. I don't understand what you might want that's make it different for Maple Flow.

And I'm not sure what generality you're after.

restart;

x := T -> (A-1/T)/C;

proc (T) options operator, arrow; (A-1/T)/C end proc

y := x -> sqrt(1/27*8^3/C^3+1/4*x^2);

proc (x) options operator, arrow; sqrt((512/27)/C^3+(1/4)*x^2) end proc

R := (x,y) -> exp((y-1/2*x)^(1/3)-(y+1/2*x)^(1/3));

proc (x, y) options operator, arrow; exp((y-(1/2)*x)^(1/3)-(y+(1/2)*x)^(1/3)) end proc

R(x(T),y(x(T)));

exp(((1/18)*(6144/C^3+81*(A-1/T)^2/C^2)^(1/2)-(1/2)*(A-1/T)/C)^(1/3)-((1/18)*(6144/C^3+81*(A-1/T)^2/C^2)^(1/2)+(1/2)*(A-1/T)/C)^(1/3))

# The same result
R( (x,y@x)(T) );

exp(((1/18)*(6144/C^3+81*(A-1/T)^2/C^2)^(1/2)-(1/2)*(A-1/T)/C)^(1/3)-((1/18)*(6144/C^3+81*(A-1/T)^2/C^2)^(1/2)+(1/2)*(A-1/T)/C)^(1/3))

comp := t -> R( (x,y@x)(t) ):

comp(T);

exp(((1/18)*(6144/C^3+81*(A-1/T)^2/C^2)^(1/2)-(1/2)*(A-1/T)/C)^(1/3)-((1/18)*(6144/C^3+81*(A-1/T)^2/C^2)^(1/2)+(1/2)*(A-1/T)/C)^(1/3))

Download comp_ex2.mw

I'll mention that I'm not really sure that I've understood you precise goal. Here is a variant that might be closer to what you want.

restart;

x := T -> (A-1/T)/C;

proc (T) options operator, arrow; (A-1/T)/C end proc

y := x -> sqrt(1/27*8^3/C^3+1/4*x^2);

proc (x) options operator, arrow; sqrt((512/27)/C^3+(1/4)*x^2) end proc

Rexpr := exp((y-1/2*x)^(1/3)-(y+1/2*x)^(1/3));

exp((y-(1/2)*x)^(1/3)-(y+(1/2)*x)^(1/3))

R := unapply(subs(x='x(t)',y='y(x(t))',Rexpr),t);

proc (t) options operator, arrow; exp((y(x(t))-(1/2)*x(t))^(1/3)-(y(x(t))+(1/2)*x(t))^(1/3)) end proc

R(T);

exp(((1/18)*(6144/C^3+81*(A-1/T)^2/C^2)^(1/2)-(1/2)*(A-1/T)/C)^(1/3)-((1/18)*(6144/C^3+81*(A-1/T)^2/C^2)^(1/2)+(1/2)*(A-1/T)/C)^(1/3))

Download comp_ex2b.mw

Yet another possibility is that all your shown operators are actually starting off for you as just expressions, and you're trying to figure out how best to turn it all into the final (partially composed) operator.

For instance, you originally showed R as,
   R := T -> exp((y-1/2*x)^(1/3)-(y+1/2*x)^(1/3));
where the parameter of that operator is T, which is not used within the body. As it stands that doesn't make syntactic sense. I can't tell whether you want that attempt to be fixed or to be accomodated.

Yet another possibility is that you're mostly trying to get (expressions or) operators to be legible when displayed. In that case you might be interested in commands such as PDEtools:-declare, so that the functional dependence of x & y upon T is visually suppressed. 

Please let us know what you're really after.

You can see the Help page for the ExportMatrix command, for exporting the Matrix M.

restart;

v_0 := 1: vstar := 10: r_0 := 1: k := 0.1: m := 0.1:

PDE := diff(v(r, t), t) = k*(diff(v(r, t), r, r) + diff(v(r, t), r)/r):

BC1 := eval(v(r, t) - v_0 = 0, r = 20):

BC2 := D[1](v)(0, t) = 0:

IC := v(r, 0) = v_0 + (vstar - v_0)*exp(-0.5*(r - r_0)^2/m^2)/(m*sqrt(2*Pi)):

sol := pdsolve(PDE, {BC1, BC2, IC}, numeric, time = t,
               range = 0 .. 20, spacestep = 0.1, timestep = 0.1):

P := sol:-plot3d(r = 0 .. 10, t = 0 .. 20):

data := op(indets(plottools:-transform((x,y,z)->[x,y,z])(P),
                  specfunc(anything,MESH))[1]):

M:=Matrix([seq(seq(data[i,j,..],j=1..25),i=1..25)]);

_rtable[36893628714180531972]

#  ?ExportMatrix

Download pds_export.mw

Another possibility is that you only want the heights (ie. v-values) from the plot P. You can get that using the plots:-getdata command applied to the plot assigned to P above. That relates to evenly sampled x- and t-values, for the number of data points (25 in each dimension, here), evenly sampled across their ranges. The central point here is that you haven't described the format you want for the exported data.

You seem to be concerned with prime factors. Is that right? (I'm supposing so. You didn't use that specific word. But you mentioned ifactor.)

For a given k, do you want to do this for all of the prime factors of k, or just some of them, or just one of them? (If you have a large number of examples, etc, then you might want an especially efficient approach that scales well. I don't know how you intend to use the information.)

If you want them all, and want to look up those values repeatedly, then you could turn the results from ifactors into a table.

Below, the procedure p scans the list g until it finds the entry (here, sublist) whose own first entry equals b. Then it stops and returns the second entry of that, ie. the corresponding multiplicity. I'm presuming that you will be calling it only for a b that you know is a present (you could adjust if you need a graceful fail, otherwise, or other sanity checking).

restart;

p := (b,g)->ListTools:-SelectFirst(u->u[1]=b,g)[2]:

 

G :=ifactors(24)[2];

[[2, 3], [3, 1]]

p(2,G);

3

H := ifactors(114345000)[2];

[[2, 3], [3, 3], [5, 4], [7, 1], [11, 2]]

p(3,H);

3

p(5,H);

4

T := table(map(u->u[1]=u[2],H)):

T[3], T[5], T[11];

3, 4, 2

Download facst.mw

But if your situation is that you want to test only a small number of factors for a number (that is, say,relatively expensive to factor completely) then you might wish to avoid ifactors altogether. I don't know your situation.

The Help page for the Play command of the AudioTools package has an example like that.

That example is preceded closely by a statement that one must insert a Speaker component.

How's this?

Styrkelære2regneopgaver_ac1.mw

(There might be a missing input just after the line with the text "indersiden af beholderen har vi", in subsection "Opgave 12".)

@Tycho Brahe You can download the installer for the Maple 2022.2 update here.

It helps to use another range.

restart;

TWeq := 2.96736996560705*10^(-12)*p^2+1.31319840299485*10^(-13)*t^2
        -8.89549693662593*10^(-7)*p+8.53128393394231*10^(-7)*t
        -3.65558815509970*10^(-30)*p*t-1 = 0:

plots:-implicitplot(TWeq, p = -2e6 .. 2e6, t = -1e7 .. 1e7,
                    scaling=constrained);

Download ellipse_rng.mw

It's not entirely clear to me what you mean.

But you could use add, or a do-loop, as follows.

restart;

S1 := 441;
S2 := 1109;
S3 := 511;
S4 := 900;
S5 := 2904;
S6 := 285;

441

1109

511

900

2904

285

S2 + S3 + S4 + S5 + S6;

5709

add(S||i, i=2..6);

5709

S[1]:=0;
for i to 5 do
    S[i+1]:=S[i] + S||(i + 1);
end do;

0

1109

1620

2520

5424

5709

S1 + S2 + S3 + S4 + S5 + S6;

6150

add(S||i, i=1..6);

6150

S[1]:=S1;
for i to 5 do
    S[i+1]:=S[i] + S||(i + 1);
end do;

441

1550

2061

2961

5865

6150

Download simple_sum.mw

You recently mentioned that SMTLIB was not working properly on your Windows 10 machine. 

The command SMTLIB:-Satisfiable gets called on your example(s), returning false on my Maple 2023.0 for Linux.

I suspect that you might be seeing that FAIL result in consequence. Here is the trace of that command for the last example.

restart;

kernelopts(version);

`Maple 2023.0, X86 64 LINUX, Mar 06 2023, Build ID 1689885`

_EnvTry := hard:

assume(Or(n < 0, 1 <= n), n*(n - 1)/2 < m);

is(m<0);

false

is(m>0);

true

trace(SMTLIB:-Satisfiable):

coulditbe(m,0);

{--> enter SMTLIB:-Satisfiable, args = {Or(1 <= n_2, n_2 < 0), m_1 = 0, 0 < m_1-(1/2)*n_2^2+(1/2)*n_2}, timelimit = .25

["sat.random_seed" = "736602622344", "smt.random_seed" = "329844591802"]

.25

["sat.random_seed" = "736602622344", "smt.random_seed" = "329844591802", "timeout" = "250"]

"(declare-fun V1 () Real)
(declare-fun V2 () Real)
(assert (and (or (<= 1 V2) (< V2 0)) (= V1 0) (< 0 (+ V1 (* (* V2 V2) (/ (- 1) 2)) (* V2 (/ 1 2)))) (<= 1 V2) (< 0 (+ V1 (* (* V2 V2) (/ (- 1) 2)) (* V2 (/ 1 2))))))
(check-sat)
(exit)
", symtab, typetab

false

<-- exit SMTLIB:-Satisfiable (now in \`is/internal/SMTLIB\`) = false}

{--> enter SMTLIB:-Satisfiable, args = {Or(1 <= n_2, n_2 < 0), m_1 = 0, 0 < m_1-(1/2)*n_2^2+(1/2)*n_2}, timelimit = .25

["sat.random_seed" = "559705322288", "smt.random_seed" = "759661297346"]

.25

["sat.random_seed" = "559705322288", "smt.random_seed" = "759661297346", "timeout" = "250"]

"(declare-fun V1 () Real)
(declare-fun V2 () Real)
(assert (and (or (<= 1 V2) (< V2 0)) (= V1 0) (< 0 (+ V1 (* (* V2 V2) (/ (- 1) 2)) (* V2 (/ 1 2)))) (< 0 (+ V1 (* (* V2 V2) (/ (- 1) 2)) (* V2 (/ 1 2)))) (< V2 0)))
(check-sat)
(exit)
", symtab, typetab

false

<-- exit SMTLIB:-Satisfiable (now in \`is/internal/SMTLIB\`) = false}

false

Download Unable_to_prove_ac.mw

3 4 5 6 7 8 9 Last Page 5 of 292