Carl Love

Carl Love

28025 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@nm Time has been measured in minutes, so your last number should be "a little over 1/2 a minute". Otherwise, Vote Up.

@manju It wasn't me who posted that. However, that would be part of a command that sets all variables other than x and y in expression U to 1. The first part of the command would be eval(U, ...).

@mmcdara Yes, thanks for spotting that. I meant f(5). My error was the result of copying-and-pasting the old code and editing it (as is often the case with my posted errors). I'll correct the Reply above.

Type appliable is more general than type procedure, but it's often too-much-more general.

@Maple_lover1 Okay, my next guess is that the numbers that become strings are stored by Excel in some non-numeric format. If that is the case, the underlying issue cannot be addressed from the Maple side; however, it can be ameliorated by parse, as already shown.

@mmcdara Yes, I do prefer your "double-arrow procedure" method, and indeed I personally use that much more often than I use an indexed procedure.

So to apply this to the OP's situation:

div5:= proc(f) local x; unapply(f(x)/5, x) end proc:
f:= i-> x-> x^2+i:
div5(f(5));

Or, better yet, add some argument type checking, which isn't available for indexed procedures:

div5:= proc(f::appliable) local x; unapply(f(x)/5, x) end proc:
f:= (i::algebraic)-> (x::algebraic)-> x^2+i:
div5(f(5));

I see that the OP is using 2D Input. If instead they'd use 1D input (aka Maple Input), the 1st line could become (in Maple 2019 or later):

div5:= (f::appliable)-> local x; unapply(f(x)/5, x):

@Kitonum Thank you for catching my error.

But there's no way that having unapply inside piecewise will do what the OP wants. The return value must be a procedure.. Also, you should make local.

@gst I think there are some problems wih Kitonum's procedure. The unapply and piecewise should be switched and all the is should be ks. Try this:

divide5_new:= proc(g, k)
local x;
    if k::numeric then `if`(k<3, 0, unapply(g(k, x)/5, k, x))
    else unapply(piecewise(k<3, 0, g(k, x)/5), k, x) 
    fi
end proc:

 

@manju Why can't you see that the issues that you raise regarding this 3D plot are exactly the same as the issues you raised yesterday regarding a plot of differential equations? The solutions are exactly the same: Explorerand, etc.

@gst There's nothing fundamentally problematic with doing what you just said. The error that you had is simply due to attempting to evaluate the truth of i < 3 for symbolic i. You could instead write

if k::numeric and k < 3 then 0 else ... fi;

That would work fine.

@nm The majority of the code in my procedure above is to compensate for Matlab's weird argument order. The argument is optional; if it appears, it comes before the required argument Y. The sensible way to do it is to put optional arguments after required arguments.

What options are there other than the third argument, dim?

@gst All I can say about that is "Of course it doesn't work. How could you possibly expect it to work?" The procedure divide5 requires its parameter k to be passed a numeric value, yet you've passed it symbolic i. In order to give you a better answer, I need to know what you want the output of divide5(f,i) to be.

@Kitonum Note that pi and ithprime are inverse functions, so pi(p) = q - pi(q) implies p = ithprime(q - pi(q)). Thus, by making the outer loop iterate on q, the corresponding p (if it exists) can be found in one step, without needing an inner loop. This is many times faster than your double-loop method.

@mmcdara I really like your use of *ML. Your use of parse and double quotation marks is redundant and can be replaced by

code:= (k,N)-> cat(`#mrow(mfrac(mo(`, k, `),mo(`, N, `)))`);

@BrettKnoss I guess that you have an older Maple version than I do. Try this:

restart:
s:= convert((x-1)/(x+2), FormalPowerSeries);
S:= subsindets(s, specfunc(Sum), s-> Sum(op(s), formal= false));
for x in [-2,2] do evalf(S) od;

If the above works for you, then we're okay. If it doesn't, please post the full worksheet of the above as an attached file. Use the green uparrow on the toolbar to attach a file.

@BrettKnoss This is a bit tricky because Maple seems quite reluctant to detect and/or report oscillatory divergence. But it can be done:

(evalf@eval~)(
    subsindets(s, specfunc(Sum), s-> Sum(op(s), formal= false)),
    x=~ [-2, 2]
);
              [-Float(infinity), Float(undefined)]

Which shows divergence at both and -2.

First 146 147 148 149 150 151 152 Last Page 148 of 708