Rouben Rostamian

MaplePrimes Activity


These are questions asked by Rouben Rostamian

I have a table whose indices and entries are strings, as in:

    T := table(["green" = "gruen", "red" = "rot", "blue" = "blau"]);

Thus, T["green"] evaluates to "gruen" but T["asdf"] evaluates to T"asdf".

What is a good way to detect that "green" is a predefined index into the table but "asdf" is not?  I do it in a somewhat clumsy way, as in:

> has("green", [indices(T, 'nolist')]);
        true

> has("asdf", [indices(T, 'nolist')]);
        false

I suspect that there ought to be a less elaborate way of doing that.

I wish to evaluate the expression

knowing that

where a is a constant.  It is not hard to see, assuming enough differentiability,  that the expression evaluates to

I know how to do this when all the derivatives are expressed in terms of the diff() operator.  Here it is:

eq := diff(u(x,t),t) = a^2*diff(u(x,t),x,x);
expr := diff(u(x,t),t,t);
eval['recurse'](expr,[eq]);

However, I would prefer to do the computations when all derivatives are expressed in terms of the D operator but cannot get that to work.  What is the trick?

Consider

> z := Int(f(t-s), s=0..1);

Int(f(t-s), s = 0 .. 1)

The result is clearly a function of t (and definitely not a function of s, which is a dummy variable).  Let's define

> F := unapply(z, t);

proc (t) options operator, arrow; Int(f(t-s), s = 0 .. 1) end proc

Then

> F(q);

Int(f(q-s), s = 0 .. 1)

as expected.  However:

> F(s);

Int(f(0), s = 0 .. 1)

which is not correct, as this confuses the argument s of F with the dummy integration variable s.  How would you salvage the situation?

 

In the following, the diff operator calcuates the derivative correctly, but the D operator doesn't.  A bug?

restart;

f := x -> a[1][2]*x;    # the double index on a[][] is intended

proc (x) options operator, arrow; a[1][2]*x end proc

 

diff(f(x), x);

a[1][2]

 

D(f)(x);

(D(f))(x)

 


Here is a worksheet containing the commands above in case you want to try it yourself: mw.mw

In the (r,t) polar coordinates, the graph of the equation r = 1/cos(t) should be a straight vertical line segment but Maple produces junk.  What is going on?

plot(1/cos(t), t=0..Pi/3, coords=polar);

The parametric version

plot([1/cos(t), t, t=0..Pi/3], coords=polar);

produces the same thing.

First 13 14 15 16 17 Page 15 of 17