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

@herclau without the thin option, U and V are padded out to be square.  The thin option is useful if your input is has dimensions, say, 10000 by 100.  Without option thin, U would be 10000 by 10000 (with only the first 100 columns being meaningful since there are only 100 non-zero singular values).  With option thin, U would be returned as a 10000 by 100 matrix and its 100 columns will be identical to the first 100 columns of the non-thin U.

Here is a small 3x2 example.

LinearAlgebra:-SingularValues(<1.0,2.0;1.0,2.1;2.0,4.1>, output='U');

vs.

LinearAlgebra:-SingularValues(<1.0,2.0;1.0,2.1;2.0,4.1>, output='U', 'thin');

solve writes answers using RootOf to give a compact representation for solutions to (sometimes) simpler problems without expanding them.  In this case, the RootOfs represent roots of quadratic polynomials (the _Z is part of the RootOf representation).  The allvalues command can be used to rewrite the solutions explicitly in terms of radicals in this case:

sol := solve({Wy,Wz},[q3,q4]);
map(allvalues, sol);

Since the case:

solve({Wx,Wy,Wz},[q3,q4]);

is a parametric problem with more equations than variables, I suspect that a solution like 'sol' is computed, but then Maple is unable to guarantee that that solution satisfies the third equation.

 

John

 

The ListTools package has a routine for doing just this: ListTools:-MakeUnique

(**) L := [1,2,3,4,3,2,3,4,5,4,3,4,5,6];

               L := [1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 4, 5, 6]

(**) ListTools:-MakeUnique(L);

                             [1, 2, 3, 4, 5, 6]

John

Are you also evaluating "f" or do you want it as a parameter to appear in the solutions?

John

Maple 13 solves these over 1 period:

> solve({cos(x)<1});
                     {x < 0, -2 Pi < x}, {0 < x, x < 2 Pi}

> solve({cos(x)>=1});
                       {x = -2 Pi}, {x = 0}, {x = 2 Pi}

John

Since the equations are polynomials, another option here is to use some of the various RootFinding package commands.

# All isolated solutions:

RootFinding:-Homotopy({e1,e2,e3});

# All isolated Real Solutions:

RootFinding:-Isolate({e1,e2,e3},[x,y,a]);

John

for i from 1 to 5 do cat(`f_`,i) := x -> i; end do;

John

The first problem is your parentheses.  Get rid of the one before "int" and get rid of one of the four right before ",t=0.."and that should get rid of the error.

John

This sort of thing can happen if there are no unconditional solutions. That is, the solutions depend on the values of the parameters.  At some point we will get to beefing up solve for parameters, but that is fundamentally difficult and thus is a big project.

In the mean time, here are a couple of things to try:

# solve with variables in a list, variables first, followed by parameters.
sol := solve({eq},[p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11, 
    pi01, pi00, pi10, pi11, sigma10, sigma01, sigma11, sigma00]);


[
p0 = -p1 + pi01, 
p1 = p1,
p2 = pi11 + sigma11 + sigma10 - pi01 - sigma01 - sigma00, 
p3 = 0,
p4 = -sigma11 - sigma10 + sigma01 + sigma00, 
p5 = 0,
p6 = 1 - pi11 - sigma11 - sigma10,
p7 = 0,
p9 = -sigma01 + sigma11, 
p10 = -p11 + sigma10,
p11 = p11,
# omitting equations like parameter=parameter
pi00 = -pi01 + 1 - sigma01 - sigma00,
pi10 = 1 - pi11 - sigma11 - sigma10
]

Notice.  p1 and p11 are free variables, and there are only solutions if parameters satisfy the last two equations.

Or write as a matrix:

eq := {eq}; vars := {p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11};
M:=LinearAlgebra:-GenerateMatrix(eq, vars, augmented=true):
# The REF:
LinearAlgebra:-GaussianElimination(M);

# Looking at the last two columns:
# 1. the solutions space is two dimensional
# 2. there are solutions only if the parameters satisfy:
0 = sigma00 - sigma10 - pi11 + pi01 + pi00 - pi10 + sigma01 - sigma11

(notice this equation is the sum of the last two equations that solve gave)

John
Math Software, Maplesoft

 Double integrals can also be given with the ranges as a list in a single Int call:

Int(1,[rbar=0..RootOf(f(r,z)-1,r),z=0..1]);

evalf will sometimes be able to compute things in a smarter fashion when iterated integrals are given this way.

John

If you are trying to grab the kth decimal digit, you could use mod like this:

f := (x,k) -> ((x mod 10^k) - (x mod 10^(k-1)))/10^(k-1):
> f(345792,2);

                                       9

> f(345792,5);

                                       4

John

Are these homework problems from a course?  If so, in the future, you should be posting in the student forums.

John

This sort of thing is hard to do completely automatically in general.

algsubs seems like it should do the first one directly, but it does not:

> algsubs((x+1)^2 = a, (x+1)^6+2);      
                                        6
                                 (x + 1)  + 2

But, you can stack calls to do it:

> subs(z=x+1,algsubs((z)^2 = a, algsubs(x+1=z, (x+1)^6+2)));
                                         3
                                    2 + a

For the second one, it is trickier, you could probably use subsindets first:

> subsindets((x^2+2*x+1)^3+2, `^`, factor);
                                        6
                                 (x + 1)  + 2

 

John

Depending on how you call solve, you will either get RealRanges or inequalities for your output. If it would be more useful to have inequalities, enclose your variable in a set.  e.g.

> solve(x<2,x);      
                         RealRange(-infinity, Open(2))

> solve({x<2},{x});
                                    {x < 2}

If you really just need to process real ranges, you can use op:

> foo:=RealRange(Open(-1.345464), Open(4.5343535));
              foo := RealRange(Open(-1.345464), Open(4.5343535))

> op([1,1],foo);
                                   -1.345464
> op([2,1],foo);
                                   4.5343535

John

Indeed there is.  Take a look at: ?LinearAlgebra,SubMatrix

For simple examples you can also used ranged indexing.  For your examples: A[2..3,2..3];

John

First 6 7 8 9 10 11 Page 8 of 11