Carl Love

Carl Love

28100 Reputation

25 Badges

13 years, 107 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@Alejandro Jakubi That's a good question, Alejandro. It is based on my experiments. So, the validity of this might be limited to Windows.

restart:
st:= kernelopts(cputime):  t:= st:
while t = st do  t:= kernelopts(cputime)  end do:
t - st;
                        0.0156250000000000
convert(%, rational);
                               1
                               --
                               64

If you use time(), that value will be reported as 0.016.

@Andriy Your file did not attach. This is a bug in MaplePrimes. Please try attaching it again.

That's enough information about H. It seems big enough to make using Grid worthwhile.

Your problem with using Grid is probably due to the use of global variables. Consider one of our previous examples with Threads:-Seq:

N:= 4:
elem:= `*`:
A:= Matrix(N, N, shape= symmetric):
for i to N do
     A[i, i..N]:= < Threads:-Seq(elem(i,j), j= i..N) >
end do
:

If we replace Threads with Grid, it seems to object to the global variable N. To make it work, change N to a parameter by changing the key line to

     A[i, i..N]:= (N-> < Grid:-Seq(elem(i,j), j= 1..N) >)(N)

I do not know why it does not similarly object to global variable i.

@Andriy You can still use Grid:-Seq, which does parallel processing without a shared-memory environment, hence there are no "safety" issues. But Grid has a much higher overhead. It definitely wouldn't be worth it for something as trivial as that Bessel example. How big is the matrix H? And how complex are psi1 and psi2?

@Axel Vogt Don't worry about hijacking.

WolframAlpha seems able to handle this situation gracefully, with no special operators needed. I would guess that the same is true of Mathematica, but I don't have it to test.

@Markiyan Hirnyk 

I am sorry, MaplePrimes will not let me edit the messed up Replies. This time, I'll just give the Maple input, and you can generate the output on your own.

diff(f(u(x,y),v(x,y)), x);
convert(%, Diff);

diff(f(u(x,y),v(x,y)), x, x);
convert(%, Diff);

@Markiyan Hirnyk 

I cannot edit the last Reply, which MaplePrimes really messed up. Trying the upload again.

diff(f(u(x,y),v(x,y)), x);

(D[1](f))(u(x, y), v(x, y))*(diff(u(x, y), x))+(D[2](f))(u(x, y), v(x, y))*(diff(v(x, y), x))

convert(%, Diff);

(eval(Diff(f(t1, v(x, y)), t1), {t1 = u(x, y)}))*(Diff(u(x, y), x))+(eval(Diff(f(u(x, y), t2), t2), {t2 = v(x, y)}))*(Diff(v(x, y), x))

diff(f(u(x,y),v(x,y)), x$2);

((D[1, 1](f))(u(x, y), v(x, y))*(diff(u(x, y), x))+(D[1, 2](f))(u(x, y), v(x, y))*(diff(v(x, y), x)))*(diff(u(x, y), x))+(D[1](f))(u(x, y), v(x, y))*(diff(diff(u(x, y), x), x))+((D[1, 2](f))(u(x, y), v(x, y))*(diff(u(x, y), x))+(D[2, 2](f))(u(x, y), v(x, y))*(diff(v(x, y), x)))*(diff(v(x, y), x))+(D[2](f))(u(x, y), v(x, y))*(diff(diff(v(x, y), x), x))

convert(%, Diff);

((eval(Diff(f(t1, v(x, y)), t1, t1), {t1 = u(x, y)}))*(Diff(u(x, y), x))+(eval(Diff(f(t1, t2), t1, t2), {t1 = u(x, y), t2 = v(x, y)}))*(Diff(v(x, y), x)))*(Diff(u(x, y), x))+(eval(Diff(f(t1, v(x, y)), t1), {t1 = u(x, y)}))*(Diff(Diff(u(x, y), x), x))+((eval(Diff(f(t1, t2), t1, t2), {t1 = u(x, y), t2 = v(x, y)}))*(Diff(u(x, y), x))+(eval(Diff(f(u(x, y), t2), t2, t2), {t2 = v(x, y)}))*(Diff(v(x, y), x)))*(Diff(v(x, y), x))+(eval(Diff(f(u(x, y), t2), t2), {t2 = v(x, y)}))*(Diff(Diff(v(x, y), x), x))

 


Download convertDiff.mw

 

@Markiyan Hirnyk 

Agreed, it is untidy.

In your transcription of the example at ?convert,diff , you missed the [2] in the last term.

Here is what the OP meant as input (although I don't know whether he will be pleased with the voluminous output).


diff(f(u(x,y),v(x,y)), x);

(D[1](f))(u(x, y), v(x, y))*(diff(u(x, y), x))+(D[2](f))(u(x, y), v(x, y))*(diff(v(x, y), x))

convert(%, Diff);

(eval(Diff(f(t1, v(x, y)), t1), {t1 = u(x, y)}))*(Diff(u(x, y), x))+(eval(Diff(f(u(x, y), t2), t2), {t2 = v(x, y)}))*(Diff(v(x, y), x))

diff(f(u(x,y),v(x,y)), x$2);

((D[1, 1](f))(u(x, y), v(x, y))*(diff(u(x, y), x))+(D[1, 2](f))(u(x, y), v(x, y))*(diff(v(x, y), x)))*(diff(u(x, y), x))+(D[1](f))(u(x, y), v(x, y))*(diff(diff(u(x, y), x), x))+((D[1, 2](f))(u(x, y), v(x, y))*(diff(u(x, y), x))+(D[2, 2](f))(u(x, y), v(x, y))*(diff(v(x, y), x)))*(diff(v(x, y), x))+(D[2](f))(u(x, y), v(x, y))*(diff(diff(v(x, y), x), x))

convert(%, Diff);

((eval(Diff(f(t1, v(x, y)), t1, t1), {t1 = u(x, y)}))*(Diff(u(x, y), x))+(eval(Diff(f(t1, t2), t1, t2), {t1 = u(x, y), t2 = v(x, y)}))*(Diff(v(x, y), x)))*(Diff(u(x, y), x))+(eval(Diff(f(t1, v(x, y)), t1), {t1 = u(x, y)}))*(Diff(Diff(u(x, y), x), x))+((eval(Diff(f(t1, t2), t1, t2), {t1 = u(x, y), t2 = v(x, y)}))*(Diff(u(x, y), x))+(eval(Diff(f(u(x, y), t2), t2, t2), {t2 = v(x, y)}))*(Diff(v(x, y), x)))*(Diff(v(x, y), x))+(eval(Diff(f(u(x, y), t2), t2), {t2 = v(x, y)}))*(Diff(Diff(v(x, y), x), x))

 


Download convertDiff.mw

@Markiyan Hirnyk In your first example, f is a function of two variables, and you have not specified the variables with respect to which to take its derivatives. Perhaps such a situation should generate an error message. Regardless, the situation is different than the one the OP is asking about, for which convert(..., Diff) does work fine.

In your second example, D1 is just a meaningless symbol to Maple.

In your third example, the convert(..., Diff) works fine for me. You might need to do a restart; it seems as if f is already defined for you.

@Markiyan Hirnyk Your test range is too small to detect the difference. The differences that you are seeing are just noise. Try this

CodeTools:-Usage({seq(13^k mod 100, k= 1..100000)}):
memory used=4.32GiB, alloc change=9.37MiB, cpu time=41.67s, real time=41.34s

CodeTools:-Usage({seq(13 &^ k mod 100, k= 1..100000)}):
memory used=8.40MiB, alloc change=0 bytes, cpu time=157.00ms, real time=143.00ms

@Kitonum Note the difference in efficiency between 13^k mod 100 and 13 &^ k mod 100.

@J4James That's the point of the exercise: contrast. Procedures and expressions are different. In eval(f), the x is a procedure parameter, and it is not affected by the assignment to global x.

The presence of a subscript is insignificant. You'll get the same error if you use just P^q+R^q.

@Durre 

1. There is no practical difference between evalf(Int(...)) and int(..., numeric). I think that the former is the more common usage.

2. I picked _d01ajc because the help said that it was for badly behaved integrands. I guess if _d01akc works, you can use it.

@Joe Riel I thought that he meant 4 groups with 7 members each.

@Luka A vector can be considered a 1 x n matrix.

Only square matrices have eigenvectors, but the eigenvectors themselves are not square.

First 570 571 572 573 574 575 576 Last Page 572 of 709