Carl Love

Carl Love

28100 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@Vishal 

  1. This is a new Question, and you should post it as such.
  2. First try to get the integral for a specific finite interval: Change -infinity..ss to -1..0.
  3. Even for -1..0, I've had no luck so far.
  4. A term 10^(-12038)*I is suspect. It looks like simply round-off error from a prior computation.

@Markiyan Hirnyk In Maple 18, evalc doesn't automatically map over matrices, but Re does. So that needs to be evalc~(Re(A)). I can't say if that has changed in Maple 2015.

@mobiusinfi Try ?try.

@mobiusinfi 

vv is correct. NULL isn't the same false. You can check for NULL like this:

r:= fsolve(...);
h[i+1]:= `if`(r = NULL, 0, `if`(r >= 0, 0, r));

The above isn't entirely safe because the fsolve may return unevaluated. Doing a type check is safer.

@mobiusinfi Then you use a try ... catch statement. See ?try.

For example, to apply it to your situation do

for i from 1 by 1 while(i<150 and h[i]<0) do
     p1[i] := #long polynomial omitted
     r:= fsolve(p1[i]-0.312e-1, x, -.2 .. 0);
     try
          if r < 0 then h[i+1]:= r end if
     catch "cannot determine":
          h[i+1]:= 0
     end try;
     print(i, h[i])
end do;

But, in my opinion, it's much better to prevent an error (when possible) than to "catch" it. This particular error is prevented by the code in my Answer: Do a type check before an inequality check:

if expression :: type implies inequality then ...

On the other hand, there are many situations where it's impossible to prevent an error. In those cases, a result may nonetheless be produced by using the try ... catch statement.

@Carl Love 

I'm ready to start writing that code to implement zero-relative indexing for lists as soon as you reply to the above.

@Markiyan Hirnyk The documentation on this point is very subtle: The inequality procedural constraints come before the equality ones. The documentation (as far as I can see) only shows this in the calling sequences at the tops of the commands' help pages. This definitely should be made more explicit. 

If you have only equality constraints, then you need (as far as I can tell) to pass a dummy set of inequality constraints to satisfy this ridiculous syntax. You could just repeat the equality constraints as inequality constraints, or you could pass something like {(x,y)-> -infinity} as the inequality constraints. Either way, it's wasteful because it generates unnecessary procedure calls (remember tables will help some with that), but it's the only way that I can see to do it.

The posted code wouldn't run in Maple 5 either.

Are you the same person who asked this same Question on Stack Exchange last week? If you are, then I guess that you're not satisfied with the Answer that you got there---the same as Preben's Answer below: Use Arrays instead. Is that right? Then you really, really want to do this with actual lists, right? Well, it is possible, despite what someone told you on Stack Exchange. It's done by overloading the indexing operator, which is represented in prefix form as `?[]`. But before I go into all the details of that, I'd like to know why you can't do what you want to do with Arrays. Basically, I'd have to create an object which is as much like a regular list as you need it to be. (Indeed, the underlying structure will be an actual list.) So, I need to know what features of lists you'd be using so that I can implement them.

The OP uses constants as a global variable name. This is a pre-defined global variable that is, very unfortunately, not proctected. It amazes me that MapleSoft would do this with such an obvious name that someone might use as a variable. I don't know exactly what this global variable is for, but its predefined value is 

constants;

     false, gamma, infinity, true, Catalan, FAIL, Pi


Redefining constants doesn't seem to mess up the value of Pi, but constants must exist for some reason, so I wouldn't redefine it unless I was defining a new constant, and, in that case, I'd append to it, not totally redefine it. So, anyway, I wouldn't be at all surprised if this turned out to be the source of the mystery.

Update: I just changed the constants to Constants in the OP's code. It made no difference: Either way, I get the values that Tom reports, not the ones that the OP reports. Still, I recommend that constants not be used as a global variable name, even though that may cause no problem here.

 

@Vishal 

You're welcome. Did you finally get the plot? 

@brian bovril 

If you have a sum of terms Obj, and you want to extract the terms that have x, you can use

select(has, Obj, x);

This is not necessarily the same thing as the terms that have x and no other variable!

@Vishal 

The case of letters is important in Maple. What you have as pi should be Pi.

@Vishal 

The case of letters (as in uppercase/lowercase) is very important in Maple. The variable's name is UseHardwareFloats; you have useHardwarefloats.

@Vishal 

Using the same commands works for me:

UseHardwareFloats:= false:
plots:-complexplot(G, xx= -1e-13..1e-13);

Can you show the commands that you're using that aren't working?

First 456 457 458 459 460 461 462 Last Page 458 of 709