John May

Dr. John May

3026 Reputation

18 Badges

17 years, 320 days
Maplesoft
Pasadena, California, United States

Social Networks and Content at Maplesoft.com

Maple Application Center
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

I haven't really dug into the source of eliminate, but it looks like it is trying to preserve the variables in the lhs of the original equations as much as possible in the output equations.

It looks like you can trick it into given the form you want by having it eliminate the squares of the original equations:

elm:=eliminate({x^2=(cos(v) *cos(u))^2, y^2=(cos(v)*sin(u))^2, z^2=sin(v)^2},{u,v});

The downside to this, is that it gives 4 answers with different substitions (but with the same output "eliminated" equation) which makes the output slightly annoying to process. In this case, this works:

op(map2(op,2, {elm}));

 


John May
Mathematical Software
Maplesoft

Actually, the solutions returned in Maple 9.5 are not complex, they just happen to be written in terms of complex numbers.  If you want to get the solutions written without complex numbers you can do something like:

sol:=[solve(x^3-8*x^2+12*x-4,x)];
evalf[50](sol); # Imaginary parts show up, but they are numerically 0.
sol:=simplify(map(evalc,sol));
evalf(sol); # no imaginary parts

In Maple 11, the fact that RealDomains package has a hard time figuring out that all the roots are real and it only returns the ones that it can tell for sure are actually real. This is a weakness in the RealDomains package (it doesn't use evalc).


John May
Mathematical Software
Maplesoft

If you change your '.'s to '*', it should work fine (as long as you change eq1 to eqn1 in the call to solve).

eqn1 := x + y + z = 0;
eqn2:= a*x + b*y + c*z=0;
eqn3:= b*c*x+c*a*y+a*b*z=1;

solve( {eqn1,eqn2,eqn3},{x,y,z} );

The easy answer to the question:

So the question is, how do I get ReducedRowEchelonForm to stop doing this?

is probably this:

with(LinearAlgebra):
A:=<<27.6,3100,250>|<30.2,6400,360>|<162,23610,1623>>;
evalf(ReducedRowEchelonForm(convert(A,rational)));

I don't think you can avoid at least some discussion of the difference between exact numbers and floating point numbers, however.  That is, to Maple (and most computer software), 27.6 is very different from 276/10.


John May
Mathematical Software
Maplesoft

You can convert the piecewise function into a list.  Look at ?convert,pwlist

In this list every other entry will be a function, and the others will be the bounds.  Depending on whether the domain of the piecewise function is bounded, the first entry of the list may be a function or a bound.  Assuming the first entry is a polynomial, you can do the following:

#f is your original piecewise function
ftmp:=convert(f,pwlist);
flist:=[seq](ftmp[i], i=1..nops(ftmp), 2); #may need to start at i=3 instead
# flist is a list of all the polynomials.

John May
Mathematical Software
Maplesoft

solve() isn't really the right tool for this, but it should be able to find the same solution that fsolve does: P = 0.5772706212 (instead of finding nothing).

Solve works on equations with floats by running convert/rational on them, then running evalf on the output.  Part of what trips this process up is the numerical error in the argument to tan() in the input expression.    If the input expression is written only in terms of cosine:

.2666845389e-11*Pi^2/(.1450695744e-10*Pi+.1281254481e-13*Pi*cos(.5637758661e-1 *P^(1/2)))=P

then solve works.


John May
Mathematical Software
Maplesoft

If you are only interested in computing over the real numbers, you can use: with(RealDomain): at the beginning of your Maple session.  This package redefines a number of Maple commands, including solve, to ignore complex answers.


John May
Mathematical Software
Maplesoft

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".)
First 8 9 10 11 Page 10 of 11