Carl Love

Carl Love

28150 Reputation

25 Badges

13 years, 351 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@subzero I'm sorry to learn that it doesn't work for you. What Maple version are you using?  Although I'm not aware of using any of the numerous relatively new Maple features in that code, someone else here might recognize something. 

Please run this diagnostic: After entering the procedure code, give the command

trace(specdifforder);

Then define the expression that has the derivatives, and run at least one case that works and at least one that doesn't. There'll be a lot of hard-to-understand output (which'll nonetheless be very useful for me). Save the worksheet and post it here as an attached file. Files can be uploaded and attached by using the green uparrow on the toolbar. If you get an error message during the upload, just ignore it and proceed; it's likely that the attachment will work anyway.

@mmcdara You asked, rhetorically:

  • But the things are not that simple...
    As changing 0.5 to 1/2 "works", one can ask ourselves  if, for instance, a*X1 + (1-a)*X2 still "works" when a is a rational between 0 and 1 (infering this doesn't work if a is a floating point number between 0 and 1)?

In the case of a any exactly represented number in 0..1 (whether rational or irrational), it is indeed "that simple": Maple will correctly compute PDF(a*X1 + (1-a)*X2, t) and the floating-point evaluators used by plot will be able to achieve the required precision over the whole interval.

@vs140580 So what makes this output any different from an ordinary Maple matrix? Why won't you give an example worksheet?

Okay, from your other Questions, I'm guessing that Python output always appears in Maple as a string? Is that right? Or at least it's always a string the way that you do it. So, do you simply want to write one of these strings, which represents a matrix, to a text file? Or do you want to convert it to a Maple matrix and then write that to a file? 

@P2prod You wrote

  • So the above expression is not a function but a value depending on x and y (piecewise). Isn't it?

No, quite the opposite. The expression does not depend on x or y, and the fact that piecewise is involved is irrelevant.

  • If I write evalf(A) I get 2.956602889

Try that again, starting from a restart. The exact value is 0, and evalf(A) returns 0. for me. Plotting the integrand may make that obvious:

plot3d(
    2*piecewise(x < 1, x, 1 < x, 2 - x) * 
        piecewise(y < 3/2, y, 3/2 < y, 3 - y) *
        sin(Pi*x/2)*sin((2*Pi*y)/3), 
    x= 0..2, y= 0..3
);

Do you also find the following surprising?

int(piecewise(x<0, x, x > 0, -x), x= -1..1);
                               -1
int(x, x= -1..1);
                               0
int(-x, x= -1..1);
                               0

It seems to me to be totally analogous to your double integral.

Other than the trouble with evalf(A) (hopefully you'll get 0 next try), the issues that you're struggling to understand are 100% mathematical. I will be happy to explain those mathematical issues. Start by plotting the following 3 functions on the interval -1..1:

f1:= x:
f2:= -x:
f_pw:= piecewise(x < 0, x, x > 0, -x):

Looking at each plot, determine (purely from geometric considerations) what its integral from -1 to 1 should be. I have a feeling that just doing this exercise will cause "a lightbulb to go off in your head", and you'll understand the whole issue. Either way, let me know.

Please provide a Maple worksheet that produces and contains an example of the matrix. In light of your other Questions today, I don't yet see what. if anything at all, makes these any different from ordinary Maple matrices.

@P2prod Using variable upper limits of integration, I get this:

plot3d(
    (2*Int(3*piecewise(x < 1, x, 1 < x, 2 - x) * 
           piecewise(y < 3/2, y, 3/2 < y, 3 - y) *
           sin(Pi*x/2)*sin((2*Pi*y)/3), 
           [y = 0 .. a, x = 0 .. b])
     )/3, b = 0 .. 2, a = 0 .. 3
);

@roethlisalayna 

If A is the set of odd numbers, then

select(isprime, A)

@vs140580 You didn't answer my second question: Does trunc~(A) do what you want?? If that doesn't help, how about

trunc~(rtable(A, datatype= anything));

@AmirHosein Sadeghimanesh You wrote:

  • Recently a colleague showed me that it is better to use `__i` instead of `[i]` for indexed variable names.

I wouldn't categorically say that one is better than the other: They each have their uses. One thing that you can never do is make independent assignments to both x and x[i], but you can do it with x and x__i.

Your cat(j, '__', i) can be replaced by cat(j__, i). One drawback to using cat is that the variables so constructed are always global. This is true of all programmatically constructed names, regardless of whether the construction is done with cat, nprintf, ||, or parse.

@lcz I certainly expected some comments on this procedure.

@dharr You wrote:

  • Code Edit Regions are similar regions embedded in the worksheet, with full error messages (but not error location).

Embedded Code Edit Regions also use the red wiggly underlines, although they may be small and difficult to see.

Perhaps you need to specify where on your computer "networkx" is stored.

1. Could you show in a Maple worksheet an example of the type of Python output you're referring to?

2. Does trunc~(A) do what you want?

Did you mean for x to be k? In that case the product is n!. If not, the product is x^n, but x is undefined. 

First 130 131 132 133 134 135 136 Last Page 132 of 711