Carl Love

Carl Love

28035 Reputation

25 Badges

12 years, 321 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@nahid200 I don't understand what you want in your most-recent question. The code snippet that you showed would create independent Wiener processes on the interval 0..1 discretized into subintervals. Of course, and m are necessarily positive integers. Any of those Wiener processes could be evaluated at 0.8 or 0.2 (since those are in the interval 0..1); but why do you want the simultaneous evaluation at both numbers that's implied by B(0.8, 0.2)? Why does your r start at 0 but k starts at 1?

Is there a reason that you want to use spline interpolation rather than the linear interpolation that I already showed? I don't have any specific reason for preferring one over than other; I'm just curious. 

@tomleslie Thanks for correcting my Maple-version mistake. Statistics:-CumulativeSum is a fine alternative to ArrayTools:-ScanAlongDimension.

@nahid200 The "unable to parse" error that you reported couldn't possibly be due to the error that Tom found. It seems related to the method you used to copy-and-paste the code into your worksheet, and possibly that's due to using 2D Input (as opposed to the plaintext 1D input). Anyway, if you can run Tom's correction of my code, then use that.

@nm There are conflicting definitions of output being used implicitly in this thread, and conflating them is the source of your contention. The output of a function could mean either

  1. the things displayed on the screen (or some other file) after invoking the function; 
  2. the return value of the function, which could be assigned to a variable.

I totally agree with you that "we all learned at school" that a function's output should depend only on its input; however, in that rule "output" is only meant in sense 2 above. If we want to strictly use output in that sense, then what userinfo[*1] produces is called side effects, not output.

Some purists teach you "at school" to avoid side effects. That's a great discipline to learn in one's early stages of learning, but efficiency requires one to use side effects sometimes.

[*1] The command that produces the sense-1 output being discussed in this thread is userinfo; the table infolevel is only a means of passing information to userinfo. Thus, you should call it the output of userinfo, not the output of infolevel.

@mmcdara I assumed ordinary Maple integers 0..999 were what the OP wanted. If instead they want something that displays in an upright font (like an ordinary integer), doesn't have quotes, and has commas inserted in the usual way, then I can write a procedure for that.

VV's Answer gets to the heart of the issue (vote up!), which is that what you're seeing is an entry retrieved from a remember table without evaluation. I have three "furthermores" to add to that:

  1. It doesn't matter whether you use W(x):= ... or assign(...); either will lead to the issue that you reported.
  2. The _C1 that you still see after setting _C1:= 0 is indeed 0; it just hasn't been evaluated yet (because it's a remember table retrieval). When that expression is next evaluated, its _C1 will be explicitly set to 0. You can verify this by doing
    W(x); %;
    and noting that the two expressions are different and the 2nd has no _C1.
  3. It doesn't matter whether you use _C1:= 0eval(..., _C1= 0), or subs(_C1= 0, ...); the issue is caused by assigning to W(x), and it'll remain regardless of how you specify a value for _C1.

So, don't make assignments to W(x) unless you truly intend to make a remember table assignment (which is unlikely if you haven't assigned a procedure to W itself). Do this instead:

W:= unapply(rhs(sol1), x);
W__particular:= unapply(
    eval(rhs(sol1), indets(sol1, suffixed(_C))=~ 0), x
);

@alaindika5 Options is on the Tools menu.

@Mariusz Iwaniuk For this to work, it requires that the inner integrals done before the improper one do NOT cause the integrand to become explicitly 0. One may not have that knowledge a priori in practical cases.

Also, it requires that the limits of integration on the inner integral that gets moved outward be constant with respect to the variables of integration that become inwards to it.

@Carl Love The bug only seems to affect multiple integrals expressed with a single int. So, a much better workaround than using limit is to use an old-style nested integral:

int(int(int(
    exp(-2*r)*cos(theta)^3*r^2*sin(theta), 
    phi= 0..2*Pi), theta= 0..Pi), r= 0..infinity
)

or to specify the nesting implicitly with foldl:

foldl(
    int, exp(-2*r)*cos(theta)^3*r^2*sin(theta), 
    phi= 0..2*Pi, theta= 0..Pi, r= 0..infinity
)

@brian bovril This way of using Iterator:-Permute (to get the same 2592 permutations) is not significantly faster than the above, but it's simpler and perhaps easier to understand. In particular, it doesn't use the modular arithmetic.

T:= [[A,X],[A,Y],[A,Z], [B,X],[B,Y],[B,Z], [C,X],[C,Y],[C,Z]]:
S:= {op~(T)[]};
                    S := {A, B, C, X, Y, Z}

P:= output((J:= Iterator:-Permute((``@op)~(T)))):
ps:= [seq](ArrayTools:-Alias(P, k, [3]), k= [0, 3, 6]):
Perms:= eval(
    [in J do if andmap(p-> {seq}(op~(p)) = S, ps) then [seq](P) fi od],
    ``= `[]`
):

A bug in Permute causes it to give incorrect results if the elements being permuted are themselves lists. The code above works around that by temporarily converting sublists of the form [a,x] to ``(a,x).

This produces the same 2592 permutations as Kitonum's latest, but done with Iterator.

restart:
T:= Array(0..8, [[A, X], [A, Y], [A, Z], [B, X], [B, Y], [B, Z], [C, X], [C, Y], [C, Z]]):
z3:= {0,1,2}:
Perms:= [
    for p in Iterator:-Permute([$0..8]) do 
        q:= iquo~(p,3); r:= irem~(p,3);
        for k by 3 to 7 while {seq}(q[k..k+2]) = z3 and {seq}(r[k..k+2]) = z3 do
        od;
        if k=10 then [seq](T[[seq](p)]) fi
    od
]:

 

@BigGeorge Here's a formula for the surface area of an ellipsoid:

#Surface area of ellipsoid with semi-axes a, b, c. 
#Assumes that a, b, c > 0, c < a, c <= b.
SA__Ellipsoid:= (a, b, c)->
local A:= a/c, B:= b/c, s:= sqrt(A^2-1), z:= s/A, k:= A/B/s*sqrt(B^2-1);
    2*Pi*c^2*(1+B*(EllipticF(z,k)/s + s*EllipticE(z,k)))
:

Using this in your case (I divide by 2 because your integral only covers half the ellipsoid):

(a, b, h):= (213/2, 144/2, 46):
SA__Ellipsoid(a, b, h)/2;
        / 
2116 Pi |1
        \ 

     144           /11     (1/2)   71      (1/2)    (1/2)\ 
   + ---- EllipticF|--- 305     , ----- 305      767     | 
     3355          \213           40260                  / 

     (1/2)
  305     

     99     (1/2)          /11     (1/2)   71      (1/2)    (1/2)\
   + --- 305      EllipticE|--- 305     , ----- 305      767     |
     529                   \213           40260                  /

  \
  |
  /

evalf(%);
                          34384.48452

which agrees with the previous result.

I hope that someone can derive the formula for SA__Ellipsoid in Maple by integration.

@BigGeorge You wrote:

  • But it still freezes up

There's a difference between "freezing up" and proceeding with a lengthy computation---perhaps one so lengthy that it won't finish in any reasonable time. When I do int(jf, [u= -Pi..Pi, v= 0..Pi/2]), I see it performing a lengthy computation, as evidenced by the changing "Memory: ..." and "Time: ..." values shown in the bottom right of the window.

Doing a preliminary simplification of the integrand helps, and changing the order of integration helps more, but neither help enough to completely finish the integration:

jf2:= simplify(jf) assuming real;
int(jf2, [v= 0..Pi/2, u= -Pi..Pi]);
#Note change in u,v order.

The integral with respect to v is done for me, leaving a messy integral with respect to u

Unless you have some reason to think that you "should"[*1] be able to get an exact result, you should settle for a numeric result, the 34384. that you already got (and I've confirmed that by applying evalf to the remaining integral).

  • ...and then deletes all of my random variables.

I don't understand what you mean by "delete". If you enter a does it not return the numeric value of a? Are you using the stop sign on the tool bar to stop the integration? You should.

  • Also, when I do jf = sqrt(jac[1]^2+...), does it create the Jacobian as a simple equation/sum, or does it somehow confuse it with a vector column or something?

It's a simple scalar expression, the square root of a sum. (By scalar in this context, I mean "not a vector", as you probably know.)

Edit: 
[*1] I realize that you're trying to compute the surface area of half an ellipsoid. There is a formula for that, although it's complicated. So, you do have a good reason to expect that the integral "should" be done. It would be good if Maple could derive the formula. I'm writing a followup on the formula.

@ssgmckv The command for 2D contour plots is plots:-contourplot.

It is clear that the Answers given so far are sufficient to solve the resistance problem for any finite simple graph and any resistances. Thus, you shouldn't post new Questions that are no more complicated than that.

@mehdibgh It's not possible to express a nonlinear function as multiplication by a matrix. This is a mathematical limitation, not a limitation of Maple.

First 99 100 101 102 103 104 105 Last Page 101 of 708