## 9391 Reputation

12 years, 24 days

## when to use cat vs. StringTools:-Join to...

These both work the same way

s1:=StringTools:-Join(["this is a ","test"]);
s2:=cat("this is a ","test");

When should one not use cat() command? It seems much simpler than Join. Are there cases where cat() will not work and Join will work?

## how to set CPU limit on buildin operatio...

according to help on timelimit

"Note: For efficiency reasons, the timelimit bound is ignored while in built-in routines."

Which is not very useful, since I want to limit  int() to some CPU time.

There are some integrals that can hang Maple easily. I'd like to set some CPU time on an int() and
have it terminate with error, but I am not able to find how to do that.

For example this

int((a+a*sin(f*x+e))^(1/2)*(c+d*sin(f*x+e))^(5/2),x)

Will hangs Maple.
Is there a trick some expert here can show to limit the CPU time on a build in operation?
May be some package or other command can do this?

I am only interested in int() now, but if it can work also on dsolve, that will be good.

thank you
ps. Mathematica supports putting time constraint on build-in commands. So I do
not see why Maple can't also do the same.

## what is the syntax for D(x)(0)=value, wh...

related topic is here

Suppose I have 2 differential equations in vector form, and I want to solve them using dsolve. I am not able to figure the syntax for what I would do for scalar ODE to initial its derivative at t=0, which is D(x)(0)=some_value, but do the same when x is a vector.

Here is an example:

restart;
x := t-> <x1(t),x2(t)>;
eq:=diff~(x(t),t\$2) =~ <sin(t),t>;
ic1:=x(0)=~0;

So far so good. Now I wanted to also make initial conditions for derivative at zero to be some value. Only syntax I know is using D(x)(0)=some_value. But this works for scalar ODE. When I tried

ic2:=D(x)(0)=~0;

I got

This does not work:

ic2:=diff~(x)(0)=~0;

any help on the correct syntax to use? I am using Maple 2015

## is it possible to run cmaple giving it o...

To run Maple script, on windows, I type

cmaple.exe   my_file.mpl

and this works well. So if my_file.mpl has the line int(sin(x),x);  the result of the above is:

> int(sin(x),x);
-cos(x)
> quit
memory used=0.9MB, alloc=8.3MB, time=0.05

sometimes, it will be nice to use cmaple to quickly do one time calculation on the fly such as the above, without having to open Maple GUI or write/edit a file. For example, I'd like to be able to do something like

cmaple.exe   "int(sin(x),x);"

but ofcourse the above does not work as is, since it expects its input to be a file. I tried

cmaple.exe   << "int(sin(x),x);"

but that did not work (for obvious reasons, since the input string is not a file name).

I tried different re-directions, as shown in this page for windows, but maple expects the input to be a file.

Is there a way to use cmaple with command directly written as string as above? I am using Maple 2015.

## how to prevent Maple from auto re-write ...

I have this (which finds each Fourier term of a sequence)

term := proc(lst,k::integer)
local n;
n := nops(lst);
seq(lst[m+1]*exp(-I * 2*Pi/n *(k*m)),m=0..n-1);
end proc;

Now I call it as

term([1,2,3],1);

and it returns

So it evaluated and convert the exp(-I * 2*Pi/n *(k*m)) terms. I wanted to keep these as is, so I can compare result with textbook. Then do simplify if I wanted to above output.

I can do that if I use small pi instead of large Pi, like this

term := proc(lst,k::integer)
local n;
n := nops(lst);
seq(lst[m+1]*exp(-I * 2*pi/n *(k*m)),m=0..n-1);
end proc;

and now r:=term([1,2,3],1); return

Which is what I wanted, but with Pi instead of pi.  now how would I evaluate the above?

I tried to use subs to replace small pi with large Pi, but it does not work

subs(pi=Pi,r); #error

Then I tried eval, which worked

eval(r,pi=Pi);

So, I can use the above method.

My question is: Is the above a common way to handle such case? Is there another way to use Pi but at the same time prevent Maple from automatic simplification of the exp() terms?

 First 155 156 157 158 159 160 161 Last Page 157 of 177
﻿