John May

Dr. John May

2571 Reputation

18 Badges

16 years, 23 days
Pasadena, California, United States

Social Networks and Content at

I have been a part of the Mathematical Software Group at Maplesoft since 2007. I have a Ph.D in Mathematics from North Carolina State University as well as Masters and Bachelors degrees from the University of Oregon. I have been working on research in computational mathematics since 1997. I currently work on symbolic solvers and visualization as well as other subsystems of Maple.

MaplePrimes Activity

These are answers submitted by John May

Can you post a worksheet with your g values? Instead of setting _EnvAllSolutions, you can also trying calling solve as: solve({f[j]=0,g[j]=0},[a[j],b[j]],AllSolutions); It does the same thing, but is easier to type and less prone to side effects.
By default, the fundamental theorem of calculus definite integrator will take the limit from the right of the the lower limit (0+), so Doug's instructions should only be necessary if you want the integral from 0-.
For what it is worth, the construct you are looking at is called an arrangement of lines in the plane by folks in computational geometry. It seems like some sort of topological sweep should be able to get you what you are looking for. Sadly, it's been a while since the computational geometry class I had back in grad school or I could help with more than just names of things.
You can also use the Explicit option to solve (see ?solve,details) to write explicit radical forms for RootOfs that can reasonably be expanded: solve({y=2*x-5,y=2*x^2+2*x-21},{x,y},Explicit); {x = -2*2^(1/2), y = -4*2^(1/2)-5}, {x = 2*2^(1/2), y = 4*2^(1/2)-5}
Part of the problem is that fsolve behaves differently for non-polynomial systems. In ?fsolve
- For a general equation or system of equations, the fsolve command computes a single real root.
However, if you know one root, you can use the avoid option to look for others: fsolve(x^3-exp(x), x,avoid={x=1.857183860}); 4.536403655 (check out ?fsolve,details)
I did A:=Array(1..100); for i to 100 do tt:=time():Feynman_random_rho(5):A[i]:=time()-tt; end do; convert(A,list); and the time used pretty steadily increased from 2 seconds to 5 seconds. My suspicion was that this was due to Garbage collection (there are some good sized matrices being created and destroyed). When I bumped up the garbage collection interval by a factor of 100 (kernelopts(gcfreq=100000000);) it ran pretty much consistently at 1.5s. So, yup.
piecewise() takes alternating conditionals and expressions. Look at the examples in the help page (in fact, the example are usually the first thing I look at in the help pages!) I think this will do what you want (assuming a and b are functions): c:=x->piecewise(x<0, undefined, x<=5, a(x), x<=10, b(x), undefined); Or a little more compactly: c:=x->piecewise(x>=0 and x<=5, a(x), x>5 and x<=10, b(x), undefined);
My documentation (Maple 9) says: "if m and n are integers then irem returns r such that m = n*q + r, abs(r) < abs(n) and m*r >= 0"
Basically this says that if you give a negative dividend m to irem, you will get a negative remainder r. This is how the % (mod) operator works in C and Java. On the other hand, mod (when set to the default 'modp' (see ?mod)) will always return a positive value so it give the values a Mathematician would expect. (You can also set it to 'mods' instead and that it returns a value between -p/2 and p/2 -- the "symmetric representation".)
If you are not looking for a (approximate) numerical result, you should put your input as an exact fraction: d:=9/10; Even though d:=0.9 looks exact, it gets treated as an approximate numerical value. Maple will do different things for exact and numeric inputs and that is probably causing your problem here.
You want to use evalc (the complex evaluator):
> evalc(a*exp(I*x)+a*exp(-I*x));                      
                                  2 a cos(x)

> simplify(evalc(-I*(1-exp(-2*I*x))/(1+exp(-2*I*x))));

                                   sin(2 x)
                                 1 + cos(2 x)

> expand(%);

If you have a list with a lot of zeros and want to get rid of them you can do something like this:
min(op(foo)), max(op(foo));
#      0, 42
foo:=remove(`=`,foo,0); # removes x in foo with x=0 
#      [12,11,42,13,7]
min(op(foo)), max(op(foo));
#      7, 42
If you are doing this numerically, you might want to get rid of small values instead of just the zeros. In that case you could do something like:
remove(z->abs(z)<10^(-Digits+1), foo); 
From your code, it looks like points4 is a sequence of pairs [x,y]. If you want to filter just based on the x value, you could do:
remove(z->abs(z[1])<10^(-Digits+1), [points4]);
Hope that helps.
First 8 9 10 Page 10 of 10