acer

32303 Reputation

29 Badges

19 years, 308 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

This is a known problem with the PDF export of so-called "scrollable rtables", and affects that export of Vectors and Matrices in Maple 2024.1.

The bug has been reported previously to Maplesoft.

In the meantime, it appears that the following workaround (disabling that new feature) allows the PDF export to work OK in Maple 2024.1 .

That edit to one's GUI preferences file has apparently worked successfully (possibly accompanied by increasing rtablesize) for several other people who've reported the same problem here. [1, 2, 3]

Here is one way, taking your semi-regularly spaced data as a text file data.txt

The point is that once you have the data in another format (below, an Array, but there are also listlist possibilities) then you can pass it straight to the plots:-surfdata command.

restart;

Read in that 4 column data.
(Adjust this column indexing if you only store the three x-, y-, and z-columns.

M := ImportMatrix("data.txt", source=csv)[..,2..4]:

Now turn that 28x3 Matrix into a 7x4x3 Array.

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

Now we can pass that Array directly to the surfdata command.

plots:-surfdata(R);

Download some_data_plot_2.mw

You can pass additional options to the surfdata command, for color, style, labels, etc.

That Array's third dimension has size 3. It's first layer R[..,..,1] are the x-values, the second layer R[..,..,2] are the y-values, and the third layer R[..,..,3] are the z-values.

I took your data in the format just as your presented it to us, because I suppose that you have some process that produces it like that. That kind of form/pattern comes up quite often, eg. from nested loops or seq calls, so having a programmatic way to rearrange to the target form it can be useful.

The artefacts of joining of adjacent parts, because they lie together in the same rtable/listlist contained in the plotting structure, can be avoided.

You can split the construction into multiple plot3d calls, by angle, so that the data is in separate rtable/listlist containers even after plots:-display is used to render them together.

It runs faster, because it doesn't need that higher grid setting, no function call is needed at each point, and because it's being more efficient by simply not doing the blank portions.

Your procedures f and rmod are not necessary here. And no function (complicated or otherwise) is called on every input data point.

restart;

p1:=seq(seq(ifelse((i+j)::odd,
                   plot3d(1,t=(i-1)*Pi/4..i*Pi/4,p=(j-1)*Pi/4..j*Pi/4,
                          coords=spherical,scaling=constrained,
                          color="black",grid=[40,40],style=surface),NULL),
            j=1..4),
        i=1..8):

p2:=plots:-sphereplot(0.99,theta=0..2*Pi,phi=0..Pi,color=white,style=surface):

plots:-display(p1,p2);


Download Chessboard_sphere_ac.mw

You have made a mistake, by attempting to pass on to the simplify command a bare sequence of three elements returned by the solve command.

The error message you see arises due to that. If you wrap the sequence result from solve in a list then that error does not occur.

Simplification of very large expressions can take a while. The results coming out of your solve call are very large (you have complicated symbolic coefficients with several parameters).

The following doesn't take a huge amount of time (about 50sec, all told), but does cut down the size quite a bit, relatively speaking.

I've used Maple 2019, which you seem to have.

restart

kernelopts(version)

`Maple 2019.2, X86 64 LINUX, Nov 26 2019, Build ID 1435526`

`πer` := proc (w, delta) options operator, arrow; w*delta*tau2*d+Cepr*tau2*d+l*(1-delta)*tau2*d+Cex*tau01*d-Clr*tau2^2-Aer*tau2*d-Rer*tau2*d+R0er*tau2^2*d^2 end proc

proc (w, delta) options operator, arrow; w*delta*tau2*d+Cepr*tau2*d+l*(1-delta)*tau2*d+Cex*tau01*d-Clr*tau2^2-Aer*tau2*d-Rer*tau2*d+R0er*tau2^2*d^2 end proc

D4er := simplify(subs([tau2 = -(-Cv*delta-delta*s2+delta*w+Cepr-s1)/(2*d*g2*delta^2), tau1 = -d*(Am-Cv+Rm-s1-s2)/(2*(-R0m*d^2+d^2*g1+Clm))], `πer`(w, delta)))

(1/4)*(4*d^2*g2*(d*tau01*g2*Cex+(1/2)*(w-Cv-s2)*(-w+l))*delta^4+2*d^2*((l-2*w+Cv+s2)*Cepr+(Rer-l+s1+Aer)*w+(-Rer+l-Aer)*Cv-l*s1-s2*(Rer-l+Aer))*g2*delta^3+((2*(Cepr-s1)*(-Cepr+Rer-l+Aer)*g2+R0er*(w-Cv-s2)^2)*d^2-Clr*(w-Cv-s2)^2)*delta^2+2*(w-Cv-s2)*(Cepr-s1)*(R0er*d^2-Clr)*delta+(Cepr-s1)^2*(R0er*d^2-Clr))/(d^2*g2^2*delta^4)

D5er := diff(D4er, w) = 0

(1/4)*(4*d^2*g2*((1/2)*l-w+(1/2)*Cv+(1/2)*s2)*delta^4+2*d^2*(-2*Cepr+Rer-l+s1+Aer)*g2*delta^3+(2*R0er*(w-Cv-s2)*d^2-2*Clr*(w-Cv-s2))*delta^2+2*(Cepr-s1)*(R0er*d^2-Clr)*delta)/(d^2*g2^2*delta^4) = 0

simplify(solve(D5er, w))

(-d^2*g2*(l+Cv+s2)*delta^3+2*d^2*g2*(Cepr+(1/2)*l-(1/2)*s1-(1/2)*Aer-(1/2)*Rer)*delta^2+(Cv+s2)*(R0er*d^2-Clr)*delta-(Cepr-s1)*(R0er*d^2-Clr))/(delta*(-2*d^2*delta^2*g2+R0er*d^2-Clr))

D6er := diff(D4er, delta) = 0

(1/4)*(16*d^2*g2*(d*tau01*g2*Cex+(1/2)*(w-Cv-s2)*(-w+l))*delta^3+6*d^2*((l-2*w+Cv+s2)*Cepr+(Rer-l+s1+Aer)*w+(-Rer+l-Aer)*Cv-l*s1-s2*(Rer-l+Aer))*g2*delta^2+2*((2*(Cepr-s1)*(-Cepr+Rer-l+Aer)*g2+R0er*(w-Cv-s2)^2)*d^2-Clr*(w-Cv-s2)^2)*delta+2*(w-Cv-s2)*(Cepr-s1)*(R0er*d^2-Clr))/(d^2*g2^2*delta^4)-(4*d^2*g2*(d*tau01*g2*Cex+(1/2)*(w-Cv-s2)*(-w+l))*delta^4+2*d^2*((l-2*w+Cv+s2)*Cepr+(Rer-l+s1+Aer)*w+(-Rer+l-Aer)*Cv-l*s1-s2*(Rer-l+Aer))*g2*delta^3+((2*(Cepr-s1)*(-Cepr+Rer-l+Aer)*g2+R0er*(w-Cv-s2)^2)*d^2-Clr*(w-Cv-s2)^2)*delta^2+2*(w-Cv-s2)*(Cepr-s1)*(R0er*d^2-Clr)*delta+(Cepr-s1)^2*(R0er*d^2-Clr))/(d^2*g2^2*delta^5) = 0

sols := CodeTools:-Usage([solve(D6er, delta)])

memory used=0.92MiB, alloc change=0 bytes, cpu time=10.00ms, real time=10.00ms, gc time=0ns

`~`[length](sols)

[3598983, 7197328, 7197328]

new := CodeTools:-Usage(`~`[simplify](sols, size))

memory used=282.99MiB, alloc change=48.00MiB, cpu time=3.24s, real time=2.98s, gc time=532.00ms

`~`[length](new)

[93584, 158428, 158428]

new2 := CodeTools:-Usage(map(proc (u) options operator, arrow; simplify(numer(u))/simplify(denom(u)) end proc, new))

memory used=5.34GiB, alloc change=166.32MiB, cpu time=42.85s, real time=36.73s, gc time=9.55s

`~`[length](new2)

[11552, 9879, 9879]

 

``

Download Q_simplify_solv_ac.mw

One reasonable way to do that in your old Maple 2021 is to use the applyrule command.

That is somewhat like a pattern-matching approach. It has the benefits that:
1) You don't have to supply or mention the variable name `x`, yourself. It will figure that out, and also apply the rule to additional candidates like sin(y+z)/cos(y+z) that might appear in the same expression.
2) It doesn't force conversion to tan of other less appropriate trig calls.

restart

kernelopts(version)

`Maple 2021.2, X86 64 LINUX, Nov 23 2021, Build ID 1576349`

M := sin(x)/cos(x)

sin(x)/cos(x)

applyrule(sin(a::anything)/cos(a::anything) = tan(a), M)

tan(x)

K := 1/sinh(x)

1/sinh(x)

applyrule(1/sinh(a::anything) = csch(a), K)

csch(x)

Q := sqrt(beta[0]/(B[1]*cosh(xi*sqrt(-lambda))))

(beta[0]/(B[1]*cosh(xi*(-lambda)^(1/2))))^(1/2)

applyrule(1/cosh(a::anything) = sech(a), Q)

(beta[0]*sech(xi*(-lambda)^(1/2))/B[1])^(1/2)

 

 

Download identity_change_applyrule.mw

Note that in Maple 2024 you can get those results just using the simplify command.

restart

kernelopts(version)

`Maple 2024.1, X86 64 LINUX, Jun 25 2024, Build ID 1835466`

M := sin(x)/cos(x)

sin(x)/cos(x)

simplify(M)

tan(x)

K := 1/sinh(x)

1/sinh(x)

simplify(K)

csch(x)

Q := sqrt(beta[0]/(B[1]*cosh(xi*sqrt(-lambda))))

(beta[0]/(B[1]*cosh(xi*(-lambda)^(1/2))))^(1/2)

simplify(Q)

(beta[0]*sech(xi*(-lambda)^(1/2))/B[1])^(1/2)

Download identity_change_M2024.mw

ps. I marked your Question as being for Maple 2021, since all your Questions's attachments are last saved by you using that version. As you can see, it matters. Please mark your furture Questions with the specific version yourself.

pps. Here's a bad way to get those same effects:

restart

M := sin(x)/cos(x)

sin(x)/cos(x)

convert(M, tan)

tan(x)

K := 1/sinh(x)

1/sinh(x)

convert(K, csch)

csch(x)

Q := sqrt(beta[0]/(B[1]*cosh(xi*sqrt(-lambda))))

(beta[0]/(B[1]*cosh(xi*(-lambda)^(1/2))))^(1/2)

convert(Q, sech)

(beta[0]*sech(xi*(-lambda)^(1/2))/B[1])^(1/2)


Note that all those ways are pretty useless, because:
1) You have to supply the target function yourself
2) They also affect other trig calls in the expression, which
can actually make them far less simple.

For example,

convert(M+sin(x), tan)

tan(x)+2*tan((1/2)*x)/(1+tan((1/2)*x)^2)

convert(K+cos(x), csch)

csch(x)-I/csch(I*(x+(1/2)*Pi))

convert(Q+tan(x), sech)

(beta[0]*sech(xi*(-lambda)^(1/2))/B[1])^(1/2)-sech(I*x)/sech(I*(x+(1/2)*Pi))

Download identity_change_care.mw

Try NULL instead of your null.

That is the empty value/statement which you mentioned. It will be seen an nothing by the display command.

One might imagine/hope that the size option or a background image on a 2D plot might allow one to force an aspect ratio of the axes. If that were the case, and since plottools:-getdata can pretty much obtain the extent of the axes, then we could programatically force agreement with the textplot rotation angle.

Alas these things appear disconnected, because the size option controls only the inline bounding box dimensions, and is thrown off by caption, axes labels and tickmark width/heights.

restart;

with(plots):

 

plot(-x^2, size=[400,200]);

We can see that the next red curve extends
over a wider portion of the inline box.

display( plot(x^2, size=[400,200]),
         axes = none );

Now it's even smaller than the first one,
because the tickmarks take up space in the
inline box.

display( plot(x^2, size=[400,200]),
         axes = boxed );

The labels can also take up space.
Notice that the in the following rendering
the aspect ratio of the axes box is not the
same as that of the bounding box.

Since we therefore not use the size option to
control the aspect ratio of the axes then we cannot
programatically get force the aspect ratio of the
axes to match appropriately with the rotation angle
of a textplot.

(I feel that this incompatibility is a design mistake.)

display( plot(x^2, size=[400,200]),
         labels = [rrrrrrrrrrrrr,uuuu],
         labeldirections = [vertical, horizontal],
         axes = boxed );


Download plot_box_dims.mw

Next, here's a worksheet showing and explaining how the things mentioned above will affect matching a textplot with rotation. (Sorry, the site's not letting me display that here. So, download only.)
2024-10-15_text_not_always_parallel_ac.mw

As for rotated text in an image, well it's hard to get that right because the GUI and your OS don't know that the pixels represent text and so cannot anti-alias, etc. It's hard to have the rotated text be legible without making it thick and chunky.

Having said that, FWIW here, in modern Maple versions you can make such rotated text images entirely with ImageTools.

restart;

with(ImageTools): with(Draw):

f := 3.3*x:

img := Create(700,700,channels=1,background=white):

Text(img, 325, 350, "parallel piece of text", rotation=Pi/4,
     font_size=16, font=12, weight=2, color="Black"):

plot(f(x), x=0..461, background=img);


Download img_text_plot_rot.mw

A 12pt font character (say, "m") is about 16 pixels wide, at 100% zoom factor.

That's approximate, and it'll vary by font (esp. variable width font, by character, of course). But you can easily find such information on the interwebs, eg. here. (note also this kind of thing)

The size info is used by the GUI to set the dimensions of the inlined plot bounding box. So things like caption, the difference in height of x-axis labels/ticks vs y-axis label/tick (including their orientation) will all throw off the actual aspect ratio of the rendered axes.

I mean to mention some of that to you in response to your recent rotated text Question, but got busy with other things, sorry. I'll try and do that soon.

You have mistakenly entered your expression assigned to F, in 2D Input.

You have terms like l(...) and m(...) without either a space or an explicit multiplication sign between the first term and the opening bracket.

That makes those terms be function calls, instead of products of terms. It's just like having f(x+y) a function call of f with argument x+y, instead of f*(x+y) a product of two terms.

simplify_b_ac.mw

Using Maple 2022.2, I get the following,

restart

s := -2*B1*(A1^2*B2^2*exp((-(2*I)*exp(2*beta2*t)*lambda2^2+2*x*lambda2*(a*beta1-beta)*exp(beta2*t)+beta1*t*beta2)/beta1)-2*A1*A2*B1*B2*exp(((2*I)*(beta1-2*beta2)*lambda2^2*exp(2*beta2*t)+2*x*lambda2*((a*beta2+beta)*beta1-2*beta*beta2)*exp(beta2*t)+beta2^2*t*beta1)/(beta1*beta2))+A2^2*B1^2*exp(((4*I)*lambda2^2*(beta1-3*beta2*(1/2))*exp(2*beta2*t)+(2*((a*beta2+2*beta)*beta1-3*beta*beta2))*x*lambda2*exp(beta2*t)+beta2^2*t*beta1)/(beta1*beta2)))*(beta1-beta2)*B2*lambda2/(sigma*(-A2*exp(2*exp(beta2*t)*lambda2*(beta1-beta2)*(I*exp(beta2*t)*lambda2+beta*x)/(beta1*beta2))*B1+A1*B2)^3)

simplify(expand(s))

-2*(beta1-beta2)*B1*B2*exp(2*x*lambda2*exp(beta2*t)*a+beta2*t)*lambda2/((A1*B2*exp(2*lambda2*exp(beta2*t)*(I*exp(beta2*t)*lambda2+beta*x)/beta1)-A2*exp(2*lambda2*exp(beta2*t)*(I*exp(beta2*t)*lambda2+beta*x)/beta2)*B1)*sigma)

(1)


The above is zero is any of these (individually) is satisfied:

`~`[remove](evalb, solve(%, [A1, A2, B1, B2, beta1, beta2]))

[[beta1 = beta2], [B1 = 0], [B2 = 0]]

(2)


Download ss_ac.mw

(We can also get solution lambda2=0 from the numerator, by eye or by a more general solve. You could also find conditions for which the denominator of the above is zero, using solve.)

ps. Not everone has Equation Labels enabled in their GUI preferences. So your mentioning Eq (1). is not immediately useful to everyone. (I don't see such labels even when I merely Open your .mw file. I have to go to GUI Options, enable that, then reexecute the whole sheet, and hope nothing was Cut since your own last execution. Luckily this example is simple enough to guess or re-do.) If you mean the expression assigned to s, then it's more immediately helpful to state that, thanks.

With the assumptions provided later in a Reply by the OP, a single result for eliminating {h, v1, t} can be obtained directly from solve.

restart;

kernelopts(version);

`Maple 2024.1, X86 64 LINUX, Jun 25 2024, Build ID 1835466`

solve({v1^2 = 2*g*(h - h1), 1/2*g*t^2 = h2, v1*t + 1/2*g*t^2 = h1},
      {h, t, v1}, useassumptions) assuming g > 0, t > 0;

{h = (1/4)*(h1^2+2*h1*h2+h2^2)/h2, t = 2^(1/2)*(g*h2)^(1/2)/g, v1 = (1/2)*(h1-h2)*g*2^(1/2)/(g*h2)^(1/2)}


Download solve_pos_ex.mw

nb. The OP has not indicated whether he prefers to eliminate g rather than t, or vice versa. These equations can be solved explicitly for [h,v1,t], or for [h,v1,g], but we don't (yet) know which the OP would prefer.

What is a candidate/typical value for your a parameter? What range for the r parameter?

Have you looked at the IterativeMaps package? (It can be fast, but finicky, and sometimes unstable.) You might start with the Bifurcation command [here, or here], or the more flexible command. Eg. some_bif_ex.mw

You could also try modifying earlier code variants to get the usual Logistic map image (but some done more like plots). [more references..]

If you want it colored/shaded, rather than monotone, then nice rescaling of values can get tricky.

@Susana30 For your followup question:
[Alternative to these below which both restrict the viewing range, you could play with a restricted domain for the red curve.]

restart;

with(plots):

 

display(polarplot([$1..12], color="LightGray"),
        plot([seq(x/tan(i*Pi/6), i=[$-2..-1,$1..2])], color="LightGray"),
        polarplot([4+4*sin(theta), 3/(1-sin(theta))],
                       color=["Green","Red"]),
        axiscoordinates=cartesian, scaling=constrained,
        tickmarks=[[seq(i=String(i),i=-9..6)],
                   [seq(i=String(i),i=-4..10)]],
        font=["Times",7],
        view=[-9..7, -5..10.6]);

polarplot([4+4*sin(theta), 3/(1-sin(theta))],
          color=["Green","Red"],
          coordinateview=[0..11,default]);

 

 

Download pol_fun.mw

This followup action line-prints the variable=value pairs, and formats the display of a procedure body with line-breaks and indenting.

You should be able to copy&paste that line-printed display of the proc (as 1D Maple input, aka Maple Notation). Or you could use fprintf instead, to write it straight to a text file.

(If you still have trouble, you might zip up the .m file and then upload and attach it here.)

restart;

foo,bar := blah,17:

 

show := proc(f::string)
  local temp := {anames(':-user')};
  read f;
  map(u -> parse(String(u)) = eval(u),
      {anames(':-user')} minus temp);
end proc:


The following returns the set of name=value pairs.
 

res := show("mydotfile.m");

{blech = proc (f, t) local i, n, r, x, f0; option `Copyright (c) 1993 by the University of Waterloo. All rights reserved.`; global D; if nargs < 2 or not (args[-1])::'list' then error "invalid arguments" elif type(f, 'function') then f0 := op(0, f); if type(f, 'constant') and type(f0, 'mathfunc') then f elif f0 = '`@`' then n := nops(f); if type(t, '[function]') and type(op(0, t[1]), 'anything@@anything') and op(n, f) = op([0, 1], t[1]) then (`@`(op(1 .. n-1, f)))((op(n, f)@@(op([0, 2], t[1])+1))(op(t[1]))) else r := op(t); for i from n by -1 to 1 do x := op(i, f); if (x = 'eval' or sprintf("%a", x) = "eval") and nops([r]) = 2 then r := x(eval(r[1], 1), r[2]) else r := x(eval(r, 1)) end if end do; eval(r, 1) end if elif f0 = '`@@`' then n := op(2, f); if type(t, '[function]') and op(0, t[1]) = op(1, f) then (op(1, f)@@(n+1))(op(t[1])) elif type(t, '[function]') and type(op(0, t[1]), 'anything@@anything') and op(1, f) = op([0, 1], t[1]) then (op(1, f)@@(n+op([0, 2], t[1])))(op(t[1])) elif type(n, 'integer') then if 0 <= n then r := t; for i to n do if type(r, [('specfunc')(op(1, f))]) then break end if; r := [(proc (F, X) F(args[2 .. -1]) end proc)(op(1, f), r[])] end do; if n < i then r[] else (proc (f) ('f')(args[2 .. nargs]) end proc)(op(1, f)@@(n-i+2), op(r[])) end if else subsop(1 = op(t), 'f(x)') end if elif nops(t) = 1 and type(op(1, f), '{identical(D), specindex(D)}') and (t[1])::'{`=`, algebraic}' then r := op(1, f); if r = D then r := setattribute(D[`$`(1, n)], f) else r := D[seq(`$`(i, n), i = op(1, f))] end if; i := r(t[1]); if op(0, i) <> r then if i = 'i' and i::'{table, `D/procedure_or_applyable_module`}' then eval(i, 2) else i end if else ('f')(op(t)) end if else ('f')(op(t)) end if elif f0 = 'DESol' then if not type(f, 'DESol(operator)') then error "cannot apply non-operator differential equation" end if; `DESol/apply`(f, t) elif type(f0, 'name') then userinfo(1, evalapply, `general function case`, [f, t]); n := f0; if type(n, 'indexed') then r := `evalapply/` || (op(0, n)); if type(r, 'procedure') then try r[op(n)](f, t) catch: error  end try else ('f')(op(t)) end if else r := cat('`evalapply/`', n); if type(r, 'procedure') then r(f, t) else ('f')(op(t)) end if end if elif f0::'{identical(D), specindex(D)}@@nonnegint' and nops(f) = 1 then return `evalapply/@@/D`(op(f0), op(f), t) else ('f')(op(t)) end if else subs(x = op(t), 'f(x)') end if end proc, x = 4, y = 3.1}


The following line-prints the entries of that set using printf, where
the %P format to get nice line-breaking of a saved procedure.
 

interface(verboseproc=2):
map[2](printf,"%P\n",eval(res,1)):

blech = (proc(f, t)
    local i, n, r, x, f0;
    global D;
    option `Copyright (c) 1993 by the University of Waterloo. All rights\
     reserved.`;
    if _npassed < 2 or not _passed[-1]::'list' then
        error "invalid arguments";
    elif type(f, 'function') then
        f0 := op(0, f);
        if type(f, 'constant') and type(f0, 'mathfunc') then
            f;
        elif f0 = '`@`' then
            n := nops(f);
            if type(t, '[function]') and
            type(op(0, t[1]), 'anything@@anything') and
            op(n, f) = op([0, 1], t[1]) then
                `@`(op(1 .. n - 1, f))(
                    ((op(n, f))@@(op([0, 2], t[1]) + 1))(op(t[1])));
            else
                r := op(t);
                for i from n by -1 to 1 do
                    x := op(i, f);
                    if (x = 'eval' or sprintf("%a", x) = "eval") and
                    nops([r]) = 2 then
                        r := x(eval(r[1], 1), r[2]);
                    else
                        r := x(eval(r, 1));
                    end if;
                end do;
                eval(r, 1);
            end if;
        elif f0 = '`@@`' then
            n := op(2, f);
            if type(t, '[function]') and op(0, t[1]) = op(1, f) then
                ((op(1, f))@@(n + 1))(op(t[1]));
            elif type(t, '[function]') and
            type(op(0, t[1]), 'anything@@anything') and
            op(1, f) = op([0, 1], t[1]) then
                ((op(1, f))@@(n + op([0, 2], t[1])))(op(t[1]));
            elif type(n, 'integer') then
                if 0 <= n then
                    r := t;
                    for i to n do
                        if type(r, ['specfunc'(op(1, f))]) then
                            break;
                        end if;
                        r := [(proc(F, X) F(_passed[2 .. -1]); end proc)(
                            op(1, f), r[])];
                    end do;
                    if n < i then
                        r[];
                    else
                        (proc(f) 'f'(_passed[2 .. _npassed]); end proc)(
                            (op(1, f))@@(n - i + 2), op(r[]));
                    end if;
                else
                    subsop(1 = op(t), 'f(x)');
                end if;
            elif
            nops(t) = 1 and type(op(1, f), '{identical(D), specindex(D)}')
             and t[1]::'{`=`, algebraic}' then
                r := op(1, f);
                if r = D then
                    r := setattribute(D[1 $ n], f);
                else
                    r := D[seq(i $ n, i = op(1, f))];
                end if;
                i := r(t[1]);
                if op(0, i) <> r then
                    if i = 'i' and
                    i::'{table, `D/procedure_or_applyable_module`}' then
                        eval(i, 2);
                    else
                        i;
                    end if;
                else
                    'f'(op(t));
                end if;
            else
                'f'(op(t));
            end if;
        elif f0 = 'DESol' then
            if not type(f, 'DESol(operator)') then
                error "cannot apply non-operator differential equation";
            end if;
            `DESol/apply`(f, t);
        elif type(f0, 'name') then
            userinfo(1, evalapply, `general function case`, [f, t]);
            n := f0;
            if type(n, 'indexed') then
                r := `evalapply/` || (op(0, n));
                if type(r, 'procedure') then
                    try r[op(n)](f, t); catch: error ; end try;
                else
                    'f'(op(t));
                end if;
            else
                r := cat('`evalapply/`', n);
                if type(r, 'procedure') then
                    r(f, t);
                else
                    'f'(op(t));
                end if;
            end if;
        elif f0::'{identical(D), specindex(D)}@@nonnegint' and nops(f) = 1
        then
            return `evalapply/@@/D`(op(f0), op(f), t);
        else
            'f'(op(t));
        end if;
    else
        subs(x = op(t), 'f(x)');
    end if;

end proc)
                                     x = 4
                                    y = 3.1


Download read_ex1.mw

First 13 14 15 16 17 18 19 Last Page 15 of 336