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

@pik1432 The code that I gave must be done before you use with(DEtools). (That's why I said "Then proceed with the code that you already had"---though I do realize that I should've stated that more clearly; so, sorry about that.)

Since your curve is not a function in the usual mathematical sense (exactly one y-value for every x in its domain), it's not clear what you mean by "area under this function".

@pik1432 

DEtools[diffop2de] was not written to work on equations. This is a simple issue of syntax rather than a mathematical reason why it doesn't work. So, it's very easy to overload it so that it will work:

unprotect(DEtools):
DEtools[diffop2de]:= L-> 
    `if`(L::algebraic, `DEtools/diffop2de`, curry(map, procname))(args):
protect(DEtools):

Then just proceed with the code that you already had.

What is the origin of this problem? It puzzles me that someone took the trouble to come up with the interesting coefficients 1/3, 1/9, 2/3, 4/9 even though they play no role in the solution.

And why do you want to use RK2 specifically? This problem too trivial to highlight any differences between methods. Most numerical ODE solvers (including all the RKs) start by algebraically solving the system for the highest-order derivatives. In this case, that gives

diff(A[0](t), t) = 2*A[2](t),
diff(A[1](t), t) = 0, #for all t
diff(A[2](t), t) = 0 #for all t

@Rouben Rostamian  The three minima that she[*1] is referring to are the critical points of the restriction of the objective function to a steepest-descent line, not critical points of the objective itself. Using the initial point (x,y) = (-1,1), this restricted objective is P:= t-> 16*(2*t - 1)^2*(1600*t^2 + 1). This has three critical points: two minima and one maximum. So, yes, the statement that there are three minima is indeed incorrect, but I don't think that it's incorrect in the way that you were thinking. There is still a need to pick one of them.

[*1] I guess that the OP is a woman based on the name Zeineb, which is a female name of Arabic origin.

@Rouben Rostamian The objective function here is the Rosenbrock function (see Wikipedia link), which is a standard test case for numerical minimization techniques. It's intentionally designed to have a unique local (and also global, but that's not as relevant) minimum that's trivial to compute symbolically "by hand" yet difficult numerically, especially for gradient-based techniques. Thus it's clear to me that the OP is attempting to code and test a numerical technique and is not a student taking a first course in multivariable calculus (where that "by hand" method is taught).

@Axel Vogt Sorry, I wasn't trying! to correct you. My interpretation was wrong also. I now see that the OP has the confusing habit of putting the expressions to be input on the right sides of equations and the desired output on the left. The OP also consistently mentions the desired output before mentioning the input in every sentence where both are mentioned. Both of those habits are the reverse of the usual writing style. So, I asked "Do you have it reversed?" But it turns out that you had the direction of conversion that the OP intended. It just needs to be converted from regular BesselJ to SphericalBesselJ, which seems pretty easy, although we'd need to define SBesselJ as a new symbolic mathematical function.

@Carl Love I can't think of any good reason to not split that 3rd subsequence in two: Replace f[3] with

f[3]:= n-> 4*n-1:
f[4]:= n-> 4*n:

That should make the analysis easier. The fact that these two appear so close to each other on the graphs is not a good reason to keep them together when it's obvious that 4-cycles are key to understanding the overall sequence.

@anthei If you want to use Logic:-Dual in your version of Maple, you can replace it with a corrected procedure, like this:

restart:
unprotect(Logic:-Dual):
Logic:-Dual:= proc(e)
uses L= Logic;    
local
    o,
    O:= [
        `&and`, `&or`, `&not`, `&iff`, 
        `&xor`, `&nand`, `&nor`, `&implies`
    ],
    D:= [
        true= false, L:-`&and`= L:-`&or`, 
        L:-`&iff`= L:-`&xor`, L:-`&nand`= L:-`&nor`
    ]
;    
    evalindets(
        eval(
            subs(seq(cat(``,o)= L[o], o= O), e),
            [
                D[], (rhs= lhs)~(D)[], 
                L:-`&implies`= ((p,q)-> L:-`&not`(L:-`&implies`(q,p)))
            ]
        ),
        (L:-`&not`@@2)(anything), op@@2
    )
end proc:
protect(Logic:-Dual):

 

@Axel Vogt My interpretation of the Question is that the desired direction of conversion is from BesselJ to an elementary function.

What Maple version are you using? In Maple 2019, this conversion happens automatically (here using n=9/2 for example):

BesselJ(9/2, x);
             

@anthei Maple 18 is not the same as Maple 2018. The chronological sequence of annual Maple version numbers since Maple 10 has been 10, 11, ..., 17, 18, 2015, 2016, ..., 2021, 2022.

@David Sycamore I have explicit index formulas (what you referred to as f(n) in your most-recent Reply) for the three subsequences:

f[1]:= n-> 4*n - 3:
f[2]:= n-> 4*n - 2:  
f[3]:= n-> 2*n + (1 - (-1)^n)/2:

That formulation of f[3] makes it seem a bit more complicated than it really is. It's just an arithmetic cycle modulo 4 with the 4*n-1 and 4*n terms grouped together as the 3rd subsequence.

To plot them together as distinct subsequences (e.g., with different colors), you could do

Subseq:= proc(L,J,N) 
local n,j; 
    [seq]([j,L[j]], j= [seq](J(n), n= 1..N))
end proc
:
m:= 4000:
L:= [seq](a(n)/n, n= 1..m):
plot(
    [Subseq(L, f[1], m/4), Subseq(L, f[2], m/4), Subseq(L, f[3], m/2)],
    color= [red, green, black], 
    style= point, symbolsize= max(1, trunc(64/(1+ilog2(m))))
);

Or, applying the same indexing to a(n) rather than a(n)/n:

L:= [seq](a(n), n= 1..m):
#Exactly the same plot command works.

@Arastas If is any matrix, vector, array, list, set, or table, (which I'll call the "basic containers") and com is any command of a single argument that you could apply to the elements of A, then you can use com~(A) to apply it to all the elements. If com is one of those commands that maps itself automatically, you can still safely use com~ anyway. If you need to pass extra arguments to com, you can also pass them to com~ as long as none of the extra arguments is a basic container. (In acer's example, the exp is an extra argument for convert that's being passed to convert~.) If one or more of the extra arguments is a basic container, then you need to make minor syntax adjustments with mapcurry, and/or rcurry.

Whether A contains symbolic expressions is irrelevant to the use of tilde.

@Arastas You're currently using the best guide that exists: MaplePrimes.

It's well known by mathematicians that sometimes better results can be achieved by replacing a constant with a symbolic variable, doing some manipulation, and then putting the constant back in for the variable. The same thing applies to CAS. The art and craft of it---which only comes with practice---is having the intuition to guess when it's a good time to try that. @Mariusz Iwaniuk is very crafty.

Keep in mind that this is just a "trick" that makes the simplification easier. The end result is exactly the same as acer's slightly more involved simplification. On the other hand, tricks such as these often make the difference between simplifications that take an unreasonable or a reasonable amount of time and/or memory.

First 94 95 96 97 98 99 100 Last Page 96 of 708