nm

8552 Reputation

19 Badges

13 years, 30 days

MaplePrimes Activity


These are questions asked by nm

Should restart always be in separate execution group? I noticed when I write something like

>restart;
  foo:=proc()
  local sys;
  with(DynamicSystems):
  sys := TransferFunction(25/(s^2+4*s+25)):
  print(ResponsePlot(sys, Step(),duration=4));
end proc;
>

then type foo(); in the next execution group, it does not work. The plot is not generated. No matter how many times I evaluate the execution group. The proc() does not seem to be fully defined. But if I do this:

>restart;  #hit return
>foo:=proc()
  local sys;
  with(DynamicSystems):
  sys := TransferFunction(25/(s^2+4*s+25)):
  print(ResponsePlot(sys, Step(),duration=4));
end proc;
>#hit another return

and now calling foo(); then it works, and the proc() returns the plot. Only difference is that restart was in separate group. But also I had to call foo() once, then evaluate the execution group where foo() is defined two times ! for it to work (why two times?) why one time did not work? is it becuase I am loading package inside the proc()?

What are the rules for putting the restart() call? Should it always be in separate group? I put it in the same group, so that I do not have to hit return 2 times, being a lazy person. But it seems to cause problem sometimes.

And related question, why did I have to hit return 2 times in the execution group to have proc() work in the second case above?

 

I'd like to differentiate  3*(r/sqrt(a))+ (r/sqrt(a))^2  w.r.t  r/sqrt(a) and obtain

    3 + 2* (r/sqrt(a))

in otherwords, treat (r/sqrt(a)) as a single variable. This is what I tried:

restart;
v:=r/sqrt(a);    #the single expression to differentiate w.r.t
p:=x->x^2+3*x;
expr:=Diff(p(v),v);
algsubs(v=x,expr);
algsubs(x=v,value(%));

The problem is that when doing x^2 and x is r/sqrt(a), then it become r^2/a and it does not remain (r/sqrt(a))^2, so now the algsubs does not "see" it. I get as final answer

ofcourse, one can now try to simplify the above to the required form, maybe using assumptions or by dividing by sqrt(a) the numerator and denominator of the first term above to get  3+2*(r/sqrt(a)) but this is all requires extra work and can be hard depending on the result.

is there a better way to do the above so it works in general? The problem is in the function p, I need a way to tell Maple now to simplify it somehow. In Mathematica, I can do this like this:

Clear[p, x, r, a]
p[x_] := x^2 + 3*x;
v = r/Sqrt[a];
With[{v = x}, Inactive[D][p[v], v]];
Activate[%];
% /. x -> v

 

 

Using worksheet, in 2015. I have an execution group, such as

>....code
....
...

>... another execution group

 

And want to copy all the code from the first group, using the mouse. Is there another way, other than having to move the mouse by hand and select all the code in order to copy it?  In Mathematica, I can right-click on the cell edge, and select copy. This copies the cell to the buffer, then one can paste the code somewhere else. In Maple, I could not duplicate this behaviour which is annoying when one wants to copy large amount of code.

I found that if I put the code in a "code edit region", ie., do insert->code edit region, then right-click inside the small window of the code edit region, the copy is enabled, so I can copy the whole region without manually select it first.

But this does not work outside the code edit region.

This is really weird.

restart;
eq:=phi(f(x,y(x),diff(y(x),x)),g(x,y(x),diff(y(x),x)));

Does any one see a "||" in the above? I do not. Then why Maple shows this:

r := cat("dsolve(",eq,",y(x))");

       r:="dsolve("||phi(f(x,y(x),y'(x)),g(x,y(x),y'(x)))||",y(x))"

This is Maple 2015 on windows. Running in worksheet mode

Here is screen shot

 

This problem does not show up all the time. For example, this works ok:

 

No "||" added. The problem with all the above, is that I can't make it all as a string in the first example above. I am trying to make a string of   "dsolve(" + ode + "),y(x)"

Here is the display options

 

thank you

Is there a command in Maple that directly divides one equation by another and produce the result as one equation directly? I wanted to verify the text book, where it says

      x^2-y^2 = a*z^2   ----- (1)
      x-y          = a*z       ------(2)
dividing (1) by (2) gives

      x+y = z  ---(3)

So I typed this in Maple:

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

But now what to do? I can see the answer in book is correct by doing

   solve( {eq1,eq2}, {x,y} );

And adding the solution given above, which shows it is z indeed.  But I'd like to get Maple to generate equation (3) above automatically.  Is this possible?

Maple 2015, windows 7

First 139 140 141 142 143 144 145 Last Page 141 of 164