Carl Love

Carl Love

28015 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@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.

@David Sycamore Just replace a(n) with a(n)/n in the previous plotting commands:

m:= 3000:
L:= [seq](a(n)/n, n= 1..m):
plots:-listplot(       
    L, style= point,  
    symbolsize= max(1, round(16/(1+ilog2(m))))
);

@Arastas I think that this simplified example may show you the crucial difference that makes it work. Compare the results of these two sum commands:

sum(t^2, t= k..k+13);
sum(t^2, t= k..k+n);

The 2nd uses symbolic summation; the 1st just crudely adds 14 terms together. The 1st could've used symbolic summation, but it chose not to. When the number of terms is specifically known to sum (as in the 1st case), it uses a heuristic to decide between symbolic summation and simple addition. For the case at hand, that heuristic turns out to not make the best choice.

The procedure pellsolve is missing from your posted code. Please provide it.

@stud_8013 Due to some bug in MaplePrimes, the number of Replies is shown as 0 for this Question (and it'll likely be shown as 1 after I post this), so I don't know if you saw that your Question has been Answered. And if you did see the Answer, I expected some sort of Reply (like whether it works for you).

@David Sycamore The sequence a(n)/n appears to have three distinct convergent subsequences, two converging to 3/2 (guess), one from above and one from below, and one converging to 3/4 (guess) from below.

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