acer

32405 Reputation

29 Badges

19 years, 346 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

restart:

eq1 :=  x^2-y^2 = a*z^2:
eq2 := x-y = a*z:       

normal(eq1/eq2);        

                                   x + y = z

acer

See this help-page on Maple initialization files.

That file should be a plaintext file (but without .txt as filename extension). It should contain Maple commands in 1D Maple Notation (plaintext).

In this case it should contain a line which redefines the Maple variable libname. For example.

libname:= `c:/maple12/advisor`, libname:

and of course edit that to be the place you actually install it.

acer

Your line of code,

   SetVariables = proc( vars:: list, time )

should be

   SetVariables := proc( vars:: list, time )

so that it is an assignment statement.

Also, the line

   for i from 1 to var N do

in the body of the SetVariables procedure is not valid syntax. It might have been intended as,

   for i from 1 to varN do

acer

restart;

`&as`:=proc(a::uneval) eval(`assuming`([a],[args[2..-1]])); end:

sqrt(x^2) &as (x>0);

                               x

sqrt(x^2) &as (x<0);

                               -x

(sqrt(x^2)*sqrt(y^2)) &as (x>0, y>0);

                              x y

(sqrt(x^2)*sqrt(y^2)) &as (x<0, y>0);

                              -x y

(sqrt(x^2)*sqrt(y^2)) &as (x>0 and y>0);

                              x y

(sqrt(x^2)*sqrt(y^2)) &as (x>0 and y<0);

                              -x y

acer

This weird behaviour seems to have started with Maple 18.00.

restart:

hhh:=400/Unit(1/kg);
                              400       
                       -----------------
                                  / 1  \
                       Units:-Unit|----|
                                  \'kg'/

with(Units:-Standard,`/`,`*`,normal);
                         [/, *, normal]

simplify(hhh);
                     400 Units:-Unit('kg')

normal(hhh); # ???
                                     / 1  \
                     -400 Units:-Unit|----|
                                     \'kg'/

:-normal(hhh);
                              400       
                       -----------------
                                  / 1  \
                       Units:-Unit|----|
                                  \'kg'/

hhh;
                              400       
                       -----------------
                                  / 1  \
                       Units:-Unit|----|
                                  \'kg'/

1/hhh; # ???
                       1                   
                    - --- Units:-Unit('kg')
                      400                  

hhh/1; # ???
                                     / 1  \
                     -400 Units:-Unit|----|
                                     \'kg'/

I will submit a bug report.

acer

Is it a part of your problem that Maple is parsing your input as if it were multiplication, ie, like D(F) * (x) ?

If so and if you are using Maple 2015 then this might be related to the GUI preference for so-called Smart Operators.

acer

@Tycoon51 If plots:-matrixplot satisfies your needs then great. You did state that you wanted the x- and y-axes to be coordinates of the 2-dimensional "array".

It may be worth mentioning that sometimes one wants the coordinate values to be interpreted as if from some pair of x- and y-ranges, rather than just as discrete coordinate values. In such cases the command plots:-surfdata can help, as it also accepts optional arguments to specifiy the x- and y-ranges to be used for generating x- and y-axis tickmarks.

A:=Matrix(1..51, 1..31, (i,j)->evalf( ((j-1-15)*2/30)^2 * sin(2*Pi*(i-1)/50)) ):

plots:-matrixplot(A, axes=box);

plots:-surfdata(A, 1..51, 1..31, axes=box);

plots:-surfdata(A, 0..2*Pi, -1..1, axes=box);

Why do you need each entry to be read back in as an individual assignment statement?

Why not use ExportMatrix to write all the entries to a file at once, after the loop finishes? And then import then all at once using ImportMatrix in your new sessions?

If you prefer you could still export each entry individually using fprintf (or other) inside the loop. But you could still re-import them in bulk, using ImportMatrix (which should be faster as well as simpler).

You can make the call to ImportMatrix be done with a single assignment. Eg,

M := ImportMatrix(outfile,...)

So in this way you can have your values be in a data file, rather than in a file of Maple commands.

acer

I'm not really understanding your comments that motivated this, but you can write your own custom `D/A` extension.

I'm not really sure that I understand why you want to have it work for D[...]A(a,b,c) rather than with 2-argument `eval` applied to the result like say eval(diff(A(s,t,m),...),[s=a,t=b,m=c]).

Of course it's up to you to make sure that it does what you want.

I just made up these examples, and the results may or may not make sense. It's just to illustrate the idea.

Here's the first example,

restart;

A:=proc(x,y,m)
  if m>0 then
    return B(x) + B(y) + 'A'(x,y,m-1);
  else
    return 1;
  end if
end proc:

(D[1](A))(1,2,3);

(D[1](A))(1, 2, 3)

`D/A`:=proc(d)
  if nops(d)=1 then
    if d[1]=1 then
      return proc(x,y,m)
        if m>0 then
          return D(B)(x);
        else
          return 0;
        end if
      end proc;
    elif d[1]=2 then
      # Now, how shall we handle the derivative of this returned proc?
      return proc(x,y,m)
        if m>0 then
          return D(B)(y) + eval(subs(__d=d[],'D[__d](A)')(x,y,m-1));
        else
          return 0;
        end if
      end proc;
    end if;
  else
    # You may wish to also handle case of nops(d)>1 , etc.
  end if;

  # default return value
  subs(__d=d[],'D[__d](A)');
  
end proc:

D[1](A);
D[2](A);

proc (x, y, m) if 0 < m then return (D(B))(x) else return 0 end if end proc

proc (x, y, m) if 0 < m then return (D(B))(y)+eval((subs(__d = [2][], 'D[__d](A)'))(x, y, m-1)) else return 0 end if end proc

(D[1](A))(s,t,0);

0

(D[1](A))(s,t,1);

(D(B))(s)

(D[2](A))(s,t,0);

0

(D[2](A))(s,t,1);

(D(B))(t)

(D[2](A))(s,t,2);

2*(D(B))(t)

(D[2](A))(s,t,3);

3*(D(B))(t)

 

Download sometoyD.mw

And here's another example,


restart;

A:=proc(x,y,m)
  if m>0 then
    return B(x) + B(y) * 'A'(x,y,m-1);
  else
    return 1;
  end if
end proc:

(D[1](A))(1,2,3);

(D[1](A))(1, 2, 3)

`D/A`:=proc(d)
  if nops(d)=1 then
    if d[1]=1 then
      return proc(x,y,m)
        if m>0 then
          return D(B)(x) + B(y) * eval(subs(__d=d[],'D[__d](A)')(x,y,m-1));
        else
          return 0;
        end if
      end proc;
    elif d[1]=2 then
      # Now, how shall we handle the derivative of this returned proc?
      return proc(x,y,m)
        if m>0 then
          return D(B)(y) * 'A'(x,y,m-1)
                 + B(y) * eval(subs(__d=d[],'D[__d](A)')(x,y,m-1));
        else
          return 0;
        end if
      end proc;
    end if;
  else
    # You may wish to also handle case of nops(d)>1 , etc.
  end if;

  # default return value
  subs(__d=d[],'D[__d](A)');
  
end proc:

(D[1](A))(s,t,0);

0

(D[1](A))(s,t,1);

(D(B))(s)

(D[1](A))(s,t,2);

(D(B))(s)+B(t)*(D(B))(s)

(D[1](A))(s,t,3);

(D(B))(s)+B(t)*((D(B))(s)+B(t)*(D(B))(s))

(D[2](A))(s,t,0);

0

(D[2](A))(s,t,1);

(D(B))(t)*A(s, t, 0)

(D[2](A))(s,t,2);

(D(B))(t)*A(s, t, 1)+B(t)*(D(B))(t)*A(s, t, 0)

(D[2](A))(s,t,3);

(D(B))(t)*A(s, t, 2)+B(t)*((D(B))(t)*A(s, t, 1)+B(t)*(D(B))(t)*A(s, t, 0))

 


Download anothertoyD.mw

acer

A result that agrees with that of member vv, but via a change of variables rather than by switching the order of integration.

restart;

with(VectorCalculus):

v1 := x^2 + y - sin(z):

v2 := x^2 + 1/y - 2*z:

v3 := y^2 + 3*x + z:

vv := VectorField(<v1, v2, v3>, 'cartesian'[x, y, z]):

NULL

G := Flux(vv, Sphere(`<,>`(0, 0, 0), r), inert);

Int(Int(-sin(phi)*(sin(phi)*cos(theta)^3*cos(phi)^2*r^3+sin(phi)*cos(theta)^2*sin(theta)*cos(phi)^2*r^3-cos(theta)^2*cos(phi)^3*r^3-sin(phi)*cos(theta)^3*r^3-r^3*sin(phi)*cos(theta)^2*sin(theta)+cos(theta)^2*cos(phi)*r^3+cos(theta)*sin(theta)*cos(phi)^2*r^2+cos(phi)^3*r^3-3*sin(phi)*cos(theta)*cos(phi)*r^2+2*r^2*cos(phi)*sin(phi)*sin(theta)+sin(phi)*cos(theta)*sin(r*cos(phi))*r-cos(theta)*sin(theta)*r^2-cos(phi)^2*r^2-cos(phi)*r^3-1)*r, phi = 0 .. Pi), theta = 0 .. 2*Pi)

``

This is easier if the dummy variables of integration are not escaped locals.

 

G := subsindets(G, name, convert, `global`):

 

Do a change of variables on the inner integral, then  get its value.

 

value(IntegrationTools:-Change(op(1, G), cos(phi) = t, t));

-r*(-(3/8)*Pi*cos(theta)^3*r^3-(3/8)*Pi*cos(theta)^2*sin(theta)*r^3-(4/3)*cos(theta)*sin(theta)*r^2-(2/3)*r^2-2)

 

Replace the inner integral with that result. Then get the value of the outer integral.

 

value(subsop(1 = %, G));

(4/3)*Pi*r^3+4*Pi*r


Download flux3.mw

acer

Is ImageTools:-Complement what you're looking for? Eg,

with(ImageTools):

img:=Scale(Read(cat(kernelopts(datadir),"/images/rollercoaster.jpg")),0.6):

Embed([img,Complement(img)],exterior=none,interior=none);

img:=Scale(Read(cat(kernelopts(datadir),"/images/tree.jpg")),0.6):

Embed([img,Complement(img)],exterior=none,interior=none);

That's `color inversion' in this sense (in the RGB colorspace): green<->magenta, blue<->yellow, red<->cyan.

acer

Another technique, the earliest use of which I'm aware is by Alec Mihailovs (and used inside plots:-shadebetween I believe):

 

restart;

(f,g):=2,1/sqrt(1-x^2):
plottools:-transform(unapply([x,y+g],x,y))(plot(f-g,x=0..sqrt(3)/2,filled=true));

 

 

Download shadeb.mw

acer

Is Example 4 on this page the kind of thing you mean? (Also see the trig identity example here.)

Another way to manipulate expressions (and equations) and see steps taken is to use the Equation Manipulator.

Or are you trying to achieve step-by-step integration? If so, see the this tutor or this overview.

acer

You can use plots:-spacecurve to plot this in your Maple 18.

And you can Explore the spacecurve, to see how the parameters affect the curve. See the attachement below.

spacecurve.mw

acer

How about something like this? You'd apply it to your expression or name, instead of applying numelems.

nelems := e->`if`(e::indexable,numelems(e),0):

acer

First 218 219 220 221 222 223 224 Last Page 220 of 336