acer

32348 Reputation

29 Badges

19 years, 330 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@HuanLuong A brief description of a data collection with "blank cell data" is not an example of a data collection with "blank cell data".

@HuanLuong If you replace each "blank cell data" value with either undefined or Float(undefined) then the plotting command should exclude it from the rendered surface.

I cannot state precisely how to do the replacement programmatically, since you haven't given an example of such a data collection with "blank cell data".

@Grigoriy Yashin Your second example demonstrates how one can get into a muddle by using several unnecessary layers of operators. It makes it less easy to tell how it has gone wrong, with diff being called on names rather than function calls in t. For example, you need to apply wrt t and get x(t) before calling diff and not afterwards.

Also, the intial, short operators like x:=t->x are wrong (and near meaningless).

But your whole second example can be handled simply with no operators at all (at least, not for this task -- and you could always unapply the final result, say with respect to t).

I suggest that you stop using operators in the original way, as it obscures what is going on, and is overly confusing.

By the way, your input contains two names which can appear like `l__2c` but which are not the same. In one of them the "c" seems to be a UTF-8 encoding, perhaps `\321\201`. Anyway, they are not the same name, and I suspect that is an oversight or typo. I have made them the same, below. Of course, if you really intended them to be different then you can change it. The important thing is that all you really need here is expressions.

restart``

V__2six := diff(x(t), t)-(l__1*sin(`θ__si`(t))-l__2c*sin(`β__si`(t)+`θ__si`(t)))*cos(psi(t))*(diff(psi(t), t))-sin(psi(t))*(l__1*cos(`θ__si`(t))*(diff(`θ__si`(t), t))-l__2c*cos(`β__si`(t)+`θ__si`(t))*(diff(`θ__si`(t), t)+diff(`β__si`(t), t)))

diff(x(t), t)-(l__1*sin(theta__si(t))-l__2c*sin(beta__si(t)+theta__si(t)))*cos(psi(t))*(diff(psi(t), t))-sin(psi(t))*(l__1*cos(theta__si(t))*(diff(theta__si(t), t))-l__2c*cos(beta__si(t)+theta__si(t))*(diff(theta__si(t), t)+diff(beta__si(t), t)))

V__2siy := -l__1*sin(`θ__si`(t))*(diff(`θ__si`(t), t))-l__2c*sin(`β__si`(t)+`θ__si`(t))*(diff(`θ__si`(t), t)+diff(`β__si`(t), t))

-l__1*sin(theta__si(t))*(diff(theta__si(t), t))-l__2c*sin(beta__si(t)+theta__si(t))*(diff(theta__si(t), t)+diff(beta__si(t), t))

V__2siz := diff(z(t), t)+(l__1*sin(`θ__si`(t))+l__2c*sin(`β__si`(t)+`θ__si`(t)))*sin(psi(t))*(diff(psi(t), t))-cos(psi(t))*(l__1*cos(`θ__si`(t))*(diff(`θ__si`(t), t))+l__2c*cos(`β__si`(t)+`θ__si`(t))*(diff(`θ__si`(t), t)+diff(`β__si`(t), t)))

diff(z(t), t)+(l__1*sin(theta__si(t))+l__2c*sin(beta__si(t)+theta__si(t)))*sin(psi(t))*(diff(psi(t), t))-cos(psi(t))*(l__1*cos(theta__si(t))*(diff(theta__si(t), t))+l__2c*cos(beta__si(t)+theta__si(t))*(diff(theta__si(t), t)+diff(beta__si(t), t)))

V__2si := simplify(V__2six^2+V__2siy^2+V__2siz^2, size)

(-l__2c*cos(psi(t))*(diff(psi(t), t))*sin(beta__si(t)+theta__si(t))-l__2c*sin(psi(t))*(diff(theta__si(t), t)+diff(beta__si(t), t))*cos(beta__si(t)+theta__si(t))+l__1*cos(psi(t))*(diff(psi(t), t))*sin(theta__si(t))+l__1*sin(psi(t))*cos(theta__si(t))*(diff(theta__si(t), t))-(diff(x(t), t)))^2+(l__2c*sin(beta__si(t)+theta__si(t))*(diff(theta__si(t), t)+diff(beta__si(t), t))+l__1*sin(theta__si(t))*(diff(theta__si(t), t)))^2+(-l__2c*sin(psi(t))*(diff(psi(t), t))*sin(beta__si(t)+theta__si(t))+l__2c*cos(psi(t))*(diff(theta__si(t), t)+diff(beta__si(t), t))*cos(beta__si(t)+theta__si(t))+l__1*cos(psi(t))*cos(theta__si(t))*(diff(theta__si(t), t))-l__1*sin(psi(t))*(diff(psi(t), t))*sin(theta__si(t))-(diff(z(t), t)))^2

indets(%, name)

{l__1, l__2c, t}

``

Download equations_ac.mw

If you are interested in rearranging your result with some particular form in mind then I suggest that you also look at the collect command. That command accepts a third parameter which specifies how to treat the resulting coefficient term. For example,
   collect(V__2si, [l__1, l__2c], u -> simplify(u, size));
   collect(V__2si, [diff], u -> simplify(u, size));
   collect(V__2si, [diff(theta__si(t), t), diff(beta__si(t), t)], u -> simplify(u, size));
   collect(V__2si, [diff(x(t), t), diff(z(t), t)], u -> simplify(u, size))

and so on. There are many variations. It wasn't clear to me what form you prefer.

Also, you might prefer to have the output of certain function calls (with respect to t) appear in suppressed form. And you might prefer a prime notation for derivatives. This is only a suggestion. You might find it easier to see the structure of the terms in the output if your document starts with one or both of these commands:
   PDEtools[declare](theta__si(t), beta__si(t), psi(t),x(t),z(t));
   PDEtools[declare](prime = t);

 

@dharr You can speed that up quite a bit by adding the options method=_d01ajc,epsilon=1e-5 to the Int call assigned to intt.

This is also reasonably quick (turning off adaptive plotting could make it even faster...).

It also includes a dotted asymptote for m=1.4, and you could add such for the other m values, if you please.

restart;
ig := 2*sqrt((a^2 + 1)/(x^2 + 1))
         /sqrt((x^2 + 1)*exp(4*m*(arctan(a) - arctan(x))) + (-a^2 - 1)):
H:=Int(ig,x=a..X,method=_d01ajc,epsilon=1e-5):
Mvals:=[0.8, 1.0, 1.2, 1.3, 1.35, 1.4]:
plots:-display(
  plot(evalf(Int(eval(ig,[a=3,m=1.4]),x=3..infinity)),
       X=3..200,linestyle=dot,color=gray),
  plot([seq(eval(Re(H),[a=3]),m=Mvals)],X=3..200,
       legend=Mvals)
);

What is this!? The dummy variable of integration is x, and the range is set by you with the value given for a and infinity.

As given the integral doesn't contain any free variable with respect to which to plot, once evaluated at the given numeric values of the two parameters a and m. As you gave it, the integral has a constant value.

Did you intend for the upper limit of integration to be some free name, instead of infinity as you wrote it? In such a case you could plot for the value of the integral versus that name.

@sunit If you are going to manipulate integrals (including doing numeric integration) in Maple then I suggest that you read some relevant Help pages.

The capitalized Int represents an inert representation of the integral, so that you can manipulate it (eg, create it, then substitute values for parameters, then compute numerically, etc).

If you use the lowercase int command then when you create it, and each time you substitute parameter values or manipulate it, Maple will repeatedly try and do the symbolic integration. That's just an expensive waste of time here. Using floating-point integration ranges can make that even worse.

In contrast, the following is simple and very quick. It is otherwise close to your original in the sense that it too first creates the integrals, then substitutes for parameters, and then computes numerically. You can keep that flow and still attain the result. (Ie. You don't have to assign numeric values to the parameters up front, which someone else showed in an Answer.)

I use default Digits here, to demonstrate that you don't have to raise working precision to avoid the numeric difficulties. (But you could set Digits:=100 if you really want the longer result.)

restart

Digits := 10

10

y1 := C1[1, 1]*sin(alpha*x)+C1[1, 2]*cos(alpha*x)+C1[1, 3]*sinh(beta*x)+C1[1, 4]*cosh(beta*x)

C1[1, 1]*sin(alpha*x)+C1[1, 2]*cos(alpha*x)+C1[1, 3]*sinh(beta*x)+C1[1, 4]*cosh(beta*x)

y2 := C1[2, 1]*sin(alpha*x)+C1[2, 2]*cos(alpha*x)+C1[2, 3]*sinh(beta*x)+C1[2, 4]*cosh(beta*x)

C1[2, 1]*sin(alpha*x)+C1[2, 2]*cos(alpha*x)+C1[2, 3]*sinh(beta*x)+C1[2, 4]*cosh(beta*x)

fun1 := Int(y1^4, x = 0 .. 5*(1/100))+Int(y2^4, x = 5*(1/100) .. 1);

Int((C1[1, 1]*sin(alpha*x)+C1[1, 2]*cos(alpha*x)+C1[1, 3]*sinh(beta*x)+C1[1, 4]*cosh(beta*x))^4, x = 0 .. 1/20)+Int((C1[2, 1]*sin(alpha*x)+C1[2, 2]*cos(alpha*x)+C1[2, 3]*sinh(beta*x)+C1[2, 4]*cosh(beta*x))^4, x = 1/20 .. 1)

val_fun1 := evalf(expand(subs(alpha = 3.093676148361444, beta = 1.136458914000455*10^2, C1[1, 1] = 1.000000000000000, C1[1, 2] = 0, C1[1, 3] = -0.22069165109e-4, C1[1, 4] = 0, C1[2, 1] = .764799945371359, C1[2, 2] = 0.36674613077895e-1, C1[2, 3] = .95132568684786, C1[2, 4] = -.95132568684786, convert(fun1, exp))))

.1308832004

NULL

Download question_ac_2.mw

@emendes The option bytesused for the kernelopts command refers to how much memory has been processed by the garbage-collector. It does not refer to how much memory the Maple kernel has currently taken from the operating system, so it is unrelated to how much RAM your machine has.

The option bytesalloc for the kernelopts command refers to a snaphot value of how much memory has been allocated by the Maple kernel from the operating system. The running value of this does relate to how much memory your machine has.

The CodeTools:-Usage command displays differences, for each of bytesused and bytesalloc, from beginning to end of the computation. The difference in bytesused is an estimate of how much memory has been processed by the garbage collector over the given computation. The difference in bytesalloc is a difference in OS memory allocation, but can be tricky to interpret because (as of several Maple versions ago) the garbage collector can now free some significant amount of memory back to the operating system.

None of these values will tell you the greatest memory allocation over the course of a particular computation. That is, none will inform you of whether your operating system had to start using swap memory.

Examples: A computation that involves no garbage collection, a large memory allocation, and a long time duration could incur almost zero bytesused or difference thereof. A computation with a small memory footprint (allocation) at any particular moment, a long time duration, and which burns through creation/disposal of much structures could have a high bytesused or difference thereof. (Hence, bytesused tells you little to nothing about how much OS memory had to be allocated, or how big your computation ever gets.)

[edit] Carl Love's description above of kernelopts(bytesused) and its dimensions is wrong.

@vv I sent a message to one of the developers who manages int, and he replied that he was already looking at it.

@HuanLuong You also have several options for coloring. You could also interpolate the data (either within surfdata, or outside that using ArrayInterpolation).

Some examples,

restart;

M := ExcelTools:-Import("PlotTest.xlsx"):

(a,b,c,d) := M[1,2],M[1,-1],M[2,1],M[-1,1];

.5, 1.5, 1.25, 3.0

data := M[2..,2..]:

C := ["LightBlue","Orange","Grey","Yellow","Blue"]:
L := ((lo,hi)->seq(lo..hi,(hi-lo)/(nops(C))))(min(data),max(data)):
V := [-infinity..L[1]=C[1],
      seq(L[i]..L[i+1]=C[i], i=1..nops(C)),
      L[-1]..infinity=C[-1]]:

 

plots:-surfdata(data, a..b, c..d, source=regular,
                gridsize=[300,300],
                style=surface, glossiness=0.0,
                colorscheme=["valuesplit",V]);

plots:-surfdata(data, a..b, c..d, source=regular,
                gridsize=[300,300], interpolation=[method=cubic],
                style=surface, glossiness=0.0,
                colorscheme=["valuesplit",V]);

plots:-surfdata(data, a..b, c..d, source=regular,
                gridsize=[300,300],
                style=surface, glossiness=0.0,
                colorscheme=["zgradient",[C[1],C[],C[-1]]]);

plots:-surfdata(data, a..b, c..d, source=regular,
                gridsize=[300,300], interpolation=[method=cubic],
                style=surface, glossiness=0.0,
                colorscheme=["zgradient",[C[1],C[],C[-1]]]);

 

Download surfexample2.mw

The popup interface shown by LibraryTools:-Browse() is written in Maplets and is not that complicated. It should be possible to modify it for your goal.

For example, a filter on results (eg. modules/procedures/all etc) might be helpful. And its current Edit/View functionality could be utilized, but not all the rest. And its first argument might be accepted as a specific archive (eg. maple.mla) rather than a directory.

@Carl Love I may have not been clear, sorry. Sometimes it would be nice to control all nested if...then indenting irrespective of line-width.

ps.I'd like something for modules too, as alternative to convert(...,string), though it could get tricky.

Please stop submitting duplicates of this theme, where your numeric integrals have difficulty computing. Put you close follow examples here (or in one of your other duplicates of this theme) instead of in a separate thread.

Please stop submitting duplicates of this theme, where your numeric integrals have difficulty computing. Put you close follow examples here (or in one of your other duplicates of this theme) instead of in a separate thread.

Please stop submitting duplicates of this theme, where your numeric integrals have difficulty computing. Put you close follow examples here (or in one of your other duplicates of this theme) instead of in a separate thread.

First 178 179 180 181 182 183 184 Last Page 180 of 592