Carl Love

Carl Love

28045 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

Try

interface(verboseproc= 2);

before the copy.

@raazia You're the one who said that R was a constant. You need to show me some code.

Please post your code that doesn't work every time.

@KCPower My guess is that Grid doesn't have access to all of gobal memory, even if that's read-only access. In this case, that means that it doesn't have access to t. The simple workaround is to pass t as a parameter:

t:= 1;
A:= proc(n) local i; add(i^2, i= 1..n) end proc;
GS:= proc(t) local k; Grid:-Seq(A(k), k=t..t+4) end proc;
GS(t);

Although it doesn't seem to be necessary, I made i and k local also. It can't hurt.

This is a good time to warn you against using the with command to load commands that will be used inside procedures.

@Oatesy94 If you post the code that you have so far plus a link to a formal description of the algorithm, I can help.

@bordplate To return the portion under the sqrt to 1/r + 1/mu, follow the commands given by Preben with expand(%).

The code formatting in your post is unusual (with the quotation marks) and thus difficult to read. I need to see how the code appears in your worksheet. Please upload your worksheet by using green uparrow in the editor. If you get an error message, make the post anyway. I may still be able to download it.

To summarize the mathematical point that I'm trying to make in a single sentence:

The ODE a*diff(y(t),t$2) + b*diff(y(t),t) + c*y(t) = (d+e*t)*exp(f*t) (a, b, c, d, e, f all complex constants, a<>0, e<>0, f<>0) will have a term of the form t^2*exp(f*t) in its solution only if a*f^2 + b*f + c = 0.

Until you can account for that, the physics are irrelevant.

@tsunamiBTP

I'm just a private citizen who posts here on MaplePrimes. Anyone else who's reading this is welcome to jump in. The counter says that 30 people have read this thread so far. I only understand the mathematics of solving constant-coefficient linear IVPs with polynomial and exponential forcing functions by the Laplace transform method and the method of undetermined coefficients; I don't understand the physics involved in your situtation. Nonetheless, the IVP problem that you present is purely symbolic mathemathics, and it should be possible to solve it without making any reference to the physics.

Here is a worksheet illustrating the situation that I'm talking about. Note that there's a t^2 term in the first solution and no t^2 term in the second solution. Yet the second solution was supposed to be a generalization of the first.

Download Laplace.mw

@emendes Yes, you got that right. I don't have the time to go into details right now, but see what you can learn from the help pages ?Grid. You do not need to address things to specific cores; that part is handled behind the scenes by the package. I find that the easiest way is to set things up as if they were going to be done with a seq command, and then replace it with Grid:-Seq. That's all there is to it! If you have a situation where the input to one command doesn't depend on the output of another, then this is almost always very easy to do.

@KCPower Suppose that you need to sum the first 1000 integers. The symbolic approach is to first derive a formula for the sum of the first n integers and then substitute n=1000. The formula is n*(n+1)/2. The numeric approach is the straightforward addition of the 1000 numbers. If you were doing the problem without a computer, then the symbolic approach would be better if you knew how to derive the formula.

But you do have a computer. In Maple, the symbolic approach would be

eval(sum(k, k= 1..n), n= 1000),

and the numeric approach would be

add(k, k= 1..1000).

The latter is many times faster than the former! But, obviously there is some n above which the symbolic approach is faster. Deciding when to switch between symbolics and numerics is often the key to efficient programs.

@tsunamiBTP I didn't say that either Z = tau was a special case; I said that either Z = -1/tau was a special case. Your failure to make the distinction between the two is a bad sign.

Now I suppose that you'll say that neither Z can equal -1/tau either. But then why is there a t^2*exp(-t/tau) term in your particular solution? I believe that such a term can only occur if Z[1] or Z[2] equals -1/tau.

@KCPower Wow, you learn Maple quickly!

There are only two things to improve that I see immediatey:

  • When symbolic summation isn't possible, but regular addition is, use add instead of sum. The syntax is the same, so just change sum to add.
  • Factor sqrt(2) outside the sum and make it sqrt(2.).

I don't have time right now, but it'd be worth thinking about the "big picture". Is there any part of the computation that's being redone unnecessarily? Are there parts that can be done symbolically so that the numeric part becomes simply substituting for a parameter?

@tsunamiBTP You are trying to do everything with generic coefficients. I don't know why you'd want to do this: It seems like a lot of tedious work to obtain a not very interesting result. Yet, I don't think that you've made it tedious enough: There are numerous special cases that need to be handled. Consider your partial fraction decomposition. It is only valid if Z[1] <> Z[2]. So you need to handle Z[1] = Z[2] as a special case. Then in the undetermined coefficients, there are special cases that ensue if Z[1] or Z[2] or both are equal to -1/tau.

@Matt C Anderson It's true. Let n, x, y be positive integers. If x*y = n, then there are three possibilities:

  • x < sqrt(n), y > sqrt(n)
  • x > sqrt(n), y < sqrt(n)
  • x = y = sqrt(n)

Furthermore, y is uniquely determined by x, so the divisors can be put into pairs, except for the x = y = sqrt(n) case.

First 372 373 374 375 376 377 378 Last Page 374 of 709