Carl Love

Carl Love

28020 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@janhardo Maple's large-integer arithmetic is done by GMP (it's just a coincidence that that is spelled similar to GIMPS). GMP is a 3rd-party open-source library which is highly optimized for different processors. It's likely that it makes significant use of your processor's cache memory (memory on the processor chip itself), which is much faster than your regular "internal" memory plugged into the motherboard. The bottleneck operation for the Lucas-Lehmer test (LLT) is the s:= s^2 (or its workaround s:= `*`(s,s)), where s is essentially an array of approximately ceil(p/64) 64-bit "words" (the conversion of s to base 2^64). I think that it's fairly easy to keep this array cached, or at least partially cached if the cache is small. For the largest known Mersenne prime, the array would be about 1.4 million words, which is not extremely large compared to other numeric arrays that are routinely handled by Maple.

@ArashMhasani The method that I showed has a brutal, unforgiving syntax where the only feedback that you'll get from the system is a simple echoing of your input if you make the slightest syntax error[*1]. So, Rouben's method is definitely the way to go when it works. However, that method will not work with arguments because the application of an operator to arguments takes precedence over exponentiation. Thus A^b(c) is interpreted as having b(c) in the exponent, whereas the system will refuse to display (A^b)(c) without parentheses around A^b.

The trick to get around this and many other printing dilemmas is to construct a symbol (a form of name) which Maple's mathematical/computational "kernel" (aka "engine") will treat as just a symbol but which displays as a more complicated mathematical object. That's where MathML comes in. 

[*1] I mean if you make a syntax error between back quotes `...`. That part is not analyzed by the kernel. 

@vv Yes, I enjoyed writing it. Here it is:

CyclSum:= (f, x::name, n::posint)->
    local j,k; add(f(seq(x[1+irem(j+k-2, n)], j= 1..n)), k= 1..n)
:   
CyclSum(`*`@(()-> args^~(p,q,r)), x, 3);
       p     q     r       p     q     r       p     q     r
   x[1]  x[2]  x[3]  + x[2]  x[3]  x[1]  + x[3]  x[1]  x[2]

@The function 

For the spherical and hemispherical tanks, the tank's constant height and radius R (as opposed to the fluid's variable height h and top radius r(h)) are the same, H=R, so only is used.

I know from your other posts that you're pursuing a self-education in calculus (and perhaps other math subjects). Are you using Maple merely as an aid to learning calculus? Or are you trying to obtain a good knowledge of Maple as well? If it's just an aid, I wouldn't put too much effort into studying all of my code above, because the non-calculus parts are too deep. Specifically, the too-deep parts are

  1. handling tank types in an object-oriented way with Record,
  2. processing an array of tanks with single operations using elementwise operators (those containing the character ~),
  3. tabular formatting of the output using the Matrix/Vector constructors <...> and <...|...>,
  4. using MathML to format the tanks' names via nprintf(`#mn("%s")`, T:-name).

Anyway, any questions that you have about it are welcome.

@nm You wrote in another thread but referring to this thread:

  • I will test your code there [in this thread] now and see how it works. I am sure it will work well.

I'm not 100% confident that it (i.e., object-method overriding and polymorphism) works perfectly. That's why I was so eager to get a response regarding your testing. Please let me know if your testing reveals anything.

@nm Thank you for responding.

I wholeheartedly agree that Stackexchange has numerous features along these lines that MaplePrimes lacks.

Re email subscriptions: The box that Rouben mentioned used to be pre-checked, which is commonly called an "opt-out" option. I believe that Canada enacted a law or regulation requiring "opt-in" for email subscriptions, which is why that box is no longer pre-checked.

I'll put a response specifically related to the other thread in that thread.

I have no problem with people asking purely mathematical Questions here, i.e., Questions without obvious Maple content; so this Reply is not meant as a criticism of your posting etiquette. Anyway, it's obvious that Maple has the ability to manipulate the objects that you asked about.

Googling "circular polynomials" hasn't revealed to me anything relevant. Is there perhaps another name for these polynomials?

What, if any, Maple operations would you like to perform with these? 

Although I'm sure that you're capable of writing your own constructor, here's mine: 

CircPoly:= (x::name, n::And(posint, Not(1)), E::[algebraic,algebraic])->
    inner(zip(`^`~, (index~)~(x, [[$1..n], [$2..n, 1]]), E)[]) 
:
CircPoly(x, 3, [p, q]);

                p     q       p     q       p     q
            x[1]  x[2]  + x[2]  x[3]  + x[3]  x[1] 

It doesn't matter whether p and q are instantiated before or after the construction or at all.

@lcz When used in a procedure, _rest is a keyword for arguments, if any, that were passed in but weren't declared as parameters.

@mmcdara Although it apparently hasn't happened in this particular case (for a reason given below), the method that you show is almost as prone to catasthrophic roundoff as the original expression. Kitonum's method completely avoids the roundoff by reducing the number of floating-point computations to just one, the final division.

The reason that you avoided the problem is that the simplify caused an extreme reduction in degree, which seems like quite a nonstandard circumstance.

(degree@~[numer,denom])~([expr, simplify(expr)]);
                     
[[28, 36], [8, 16]]

I'm sorry to post here about an unrelated Question, but you've either missed or ignored my Reply to you on this other thread "provide way to override variable and method in base class by classes that extend base class?" If you won't write a meaningful response to my Answer there, then I won't take the time and effort to respond to any more of your Questions (which are usually good questions). I am very disappointed by the lack of responses from you and others.

@janhardo Are you proposing to use an SSD instead of your primary memory because it might be faster that way? I'd be surprised if that worked, but I suppose it's theoretically possible if the primary memory is significantly older technologically than the SSD. 

@Nimd_at In this code snippet

DirectSearch:-DataFit(
    ffit2(etaL, L0, t)
  , [eta_L=0.0001 .. 0.1, L0=1.5e10 .. 1.7e10]
  , X0, Y0, t
  , strategy=globalsearch
  , evaluationlimit=30000, initialpoint=[L0=1e10, eta_L=0.006]
);

you've used both etaL and eta_L. I don't see how both could be correct.

@The function You wrote:

  • For ever height down, the radius grows with 1/4 the height. The formula for the volume of a cone according to google is: V=Pi*(r^2)*h/3, and that gives the formula volume V=Pi*((x/4)^2)*x/3. Its as easy as that. Nothing more to explain there.

But the volume of the cone is irrelevant. The horizontal slice at height x and infinitesimal thickness dx should be considered a cylinder. Its volume does matter. That volume is Pi*(x/4)^2*dx. That volume is lifted a distance of (2-x) to get it out of the tank. So the work done just getting that slice out is rho*g*Pi*(x/4)^2*(2-x)*dx (where rho is the density and g is the acceleration due to gravity). Integrate that from 0 to 2.

Parts b and c should also be done as horizontal slices, which will also be cylinders. The only difference from part a is the height-radius relationship.

@janhardo The number of base-10 digits of M_n = 2^n-1 (regardless of whether that's prime) can be quickly computed with logarithms without needing to actually compute M_n, like this

MersenneDigits:= (n::posint)-> ceil(evalf[2+ilog10(n)](n*log10(2))):
MersenneDigits(82589933);

                           
24862048

Maple has no trouble computing M_n itself; however, I warn you not to display it onscreen!! Use a colon to suppress the output!

@lijr07 I think that this'll work in Maple 2019:

TypeTools:-RemoveType('Monomial'): #avoid silly warning
TypeTools:-AddType(
    'Monomial',
    proc(e)
    local Var:= 'Y'[integer $ 2], Pow:= {Var, Var^rational};
        e::Pow or 
        e::'specop'(
            {Pow, Not({constant, 'satisfies'(e-> hastype(e, Var))})},
            `*`
        )
    end proc
)
:
First 109 110 111 112 113 114 115 Last Page 111 of 708