Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

The Task model seems inappropriate for the OP's purpose, which is performing a computation three different, independent ways. I see the Task model as being fundamentally recursive. I've implemented Roman's idea in my Answer below, but in the basic Threads model rather than the Task model.

@Axel Vogt The title was my fault, and I've changed it now. I'd assumed that the OP's final line of output was what was being claimed as erroneous, as is usual with a bug report.

@Mariusz Iwaniuk I'm sorry. Your inappropriate use of evalf threw me off. I thought that you meant that the bug was that evalf didn't return 0 like the others. Usually when reporting a bug you should make the final line of output the one that shows the bug, unless some other line of output is explicitly pointed out.

Do you have any initial and/or boundary conditions?

The command evalf doesn't supercede value. After you apply evalf to an inert indefinite integral, you still have an inert indefinite integral. Note that the integral sign is grey, not blue. There is no bug.

@maple2015 You wrote:

Please download the attached file

I did. Your file is difficult to work with because everything is jammed into one execution group, so the output only shows at the end. Please separate it into execution groups with only one significant command per execution group. And please display the results after those significant commands by ending them with a semicolon rather than a colon.

I recommend that you set Digits to 15 until you get the bugs worked out. That way it'll run much faster. And also forget about timing it until the bugs are worked out.

The value of C[2] is assumed to be zero for relative error checking ( as you recommended)

I didn't exactly recommend that you neglect setting the absolute error tolerance. I said that if you were only going to use one of relative and absolute error tolerance, then use relative. When the scale of the problem is on the order of 1, then it makes sense to set both, and to the same value.

1- It is reasonable that by assigning a little value to C[1], the little tolerance of C[1] for little amount of absolute maximum step size in interval [0,1], should be ineffective to the answer. By taking the value C[1]=Float(1,-15) and C[7]=1E-3, the answer is  0.229491 but for C[1]=Float(1.-14) the answer is 0.221455. Is it show the instability of solution?

I don't fully understand lsode. I think that it's not really intended for dynamic use of the solution function. Rather, I think it's primarily intended to integrate the ODEs to a specific stop value. I recommend that you read this recent thread concerning lsode, paying particular attention to the Answer and Replies by Allan Wittkopf.

So, why do you want to use lsode rather than any other of the numerous numeric methods?

2- I use the Implode and Explode commands in line 14. Is there a better way for obtaining the expression from 'RootOf' without using the String Tools?

Yes, it's trivial with the command op:

EX:= op(%);

It's pretty rare that StringTools are the best way to pick apart algebraic output.

3- Can I solve the ode in line 12 directly by maple commands?

Yes, it's easy. It's not really an ODE because it contains only the first-order derivative and doesn't contain the primary function undifferentiated. Thus, you can use ordinary solve to solve for diff(u(y), y).

Indeed, the whole process of solving, interpolating, integrating, and plotting can be reduced to

ode:= U__y^n = -G*(1-y)/mu+tau[Y]*(1-exp(-a*U__y))/mu:
F__EX:= r-> fsolve(eval(ode, y= r), U__y= 0..infinity):
CodeTools:-Usage(
     plot(
          'Int(F__EX, 0..x, epsilon= 1e-5)', x= 0..1, numpoints= 11,
          color= violet, thickness= 2, title= "Laminar Flow Velocity",
          gridlines= false
     )
);

Here it is in a worksheet. Please compare this plot with the plot that you obtained by your means.

restart:

with(CurveFitting): with(LinearAlgebra):
Digits := 15:

C := convert(Array(1 .. 25), array):
C[1] := 0.1e-13: C[2] := 0: C[7] := 0.1e-2: C[10] := 0.1e9:
q := .1: k := .5: beta := -1: Res := 0: Ref := 0: T := 0: G := -1: tau[Y] := .1:
H := 10: n := .999: a := 3000: mu := .5^(.5*(n-1)):
ode:= U__y^n = -G*(1-y)/mu+tau[Y]*(1-exp(-a*U__y))/mu:

F__EX:= r-> fsolve(eval(ode, y= r), U__y= 0..infinity):

CodeTools:-Usage(
     plot(
          'Int(F__EX, 0..x, epsilon= 1e-5)', x= 0..1, numpoints= 11,
          color= violet, thickness= 2, title= "Laminar Flow Velocity",
          gridlines= false
     )
);

memory used=273.47MiB, alloc change=149.35MiB, cpu time=3.46s, real time=3.51s

 

 

 


Download Laminar.mw

 

 

@spreka The purpose of fnormal is to convert numbers that are close to 0 to actually be 0. This makes the remaining numbers, the true eigenvalues, much easier to see in the Matrix.

@acer Thank you for the improvements to my hasty code. They certainly expand its scope of applicability.

@Thomas Richard I emphasize that those FAQs apply only if the error occurs when starting Maple. The vast majority of kernel connection errors are caused by kernel bugs, not by firewall or configuration issues. Indeed, I've never seen a case of the latter, nor seen a personal report of such a case in any public forum.

@Joe Riel Pausing the output with a simple readstat could be useful because it lets you read the output that has been generated so far. This could be especially useful if the program has several traces and infolevels set---my primary debugging tools---generating reams of output.

There are a great many possible reasons for that. You'll need to post your code. Usually it is caused by an improperly trapped error in the internal Maple code (the kernel code) that causes the death of the kernel.

You asked:

When we use the relative and absolute errors (C[1] and C[2]) simultaneously it leads to the more accuracy or using absolute error is sufficient?

There's no easy answer to that. There is a correspondence between the relative error and the number of significant digits. Specifically, a relative error of .5*10^(-d) corresponds to d significant digits. If the magnitude of a result is less than one, then the relative error tolerance is more constraining than the absolute error tolerance; if the magnitude is greater than one, then that is reversed. I'd recommend never setting the relative error tolerance greater than .5e-4. The setting of the absolute error tolerance must depend on the scale (magnitude) of the expected results. If you were going to use only one of the two, I'd recommend using the relative. (I welcome any arguments to the contrary.) Note, however, that when the result is 0, achieving a certain relative error can be difficult or impossible.

Why after solution C[12] to C[21]  (the components of array corresponding to output data) are zero?

I see what you mean, but I don't have any answer. I think that it's a bug. I think that lsode is not frequently used, so not much maintenance is done on it. If it were being maintained, then Arrays (instead of arrays) would've been allowed many, many years ago.

@spreka After the iteration, the eigenvalues are not "randomly placed around the diagonal." Their placement is highly structured, as this shows:

 

restart:

C:= Matrix(8, [[6,14,7], [1, 13, 7, 3]], scan= band[5,5], datatype= float[8]):

C:= C + C^+:

evalf[5]~(simplify(LinearAlgebra:-Eigenvalues(C), zero))^+;

Vector[row](8, {(1) = -20.296, (2) = 20.296, (3) = -9.0162, (4) = 9.0162, (5) = -3.9546, (6) = 3.9546, (7) = -.37725, (8) = .37725})

(1)

for i to 100 do
     (Q,R):= LinearAlgebra:-QRDecomposition(C);
     C:= R.Q
end do:

evalf[5]~(fnormal~(C));

Matrix(8, 8, {(1, 1) = -0., (1, 2) = -20.296, (1, 3) = -0., (1, 4) = 0., (1, 5) = -0., (1, 6) = -0., (1, 7) = -0., (1, 8) = -0., (2, 1) = -20.296, (2, 2) = 0., (2, 3) = -0., (2, 4) = 0., (2, 5) = 0., (2, 6) = 0., (2, 7) = -0., (2, 8) = 0., (3, 1) = 0., (3, 2) = -0., (3, 3) = -0., (3, 4) = 9.0162, (3, 5) = -0., (3, 6) = -0., (3, 7) = 0., (3, 8) = -0., (4, 1) = 0., (4, 2) = 0., (4, 3) = 9.0162, (4, 4) = 0., (4, 5) = 0., (4, 6) = -0., (4, 7) = 0., (4, 8) = -0., (5, 1) = -0., (5, 2) = -0., (5, 3) = -0., (5, 4) = -0., (5, 5) = -0., (5, 6) = 3.9546, (5, 7) = 0., (5, 8) = 0., (6, 1) = -0., (6, 2) = -0., (6, 3) = -0., (6, 4) = 0., (6, 5) = 3.9546, (6, 6) = 0., (6, 7) = 0., (6, 8) = 0., (7, 1) = 0., (7, 2) = -0., (7, 3) = -0., (7, 4) = 0., (7, 5) = 0., (7, 6) = 0., (7, 7) = 0., (7, 8) = -.37725, (8, 1) = 0., (8, 2) = 0., (8, 3) = -0., (8, 4) = -0., (8, 5) = -0., (8, 6) = 0., (8, 7) = -.37725, (8, 8) = -0.})

(2)

 

 

Download QR.mw

@spreka Again, please provide a small example of such a matrix C.

@acer (I'm sure that you know this already; this is just for other readers.) The referenced code from Stack Exchange has a severe bug. There, the iteration is equivalent to

while not stopping criterion do    
     (Q,R):= LinearAlgebra:-QRDecomposition(C);
     C:= Q^+.R.Q
end do;

However, in the OP code, the iteration is correct.

 

First 424 425 426 427 428 429 430 Last Page 426 of 709