Carl Love

Carl Love

28050 Reputation

25 Badges

12 years, 335 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

The k-values need not be evenly spaced nor in order. Like this:

#any real-valued algebraic expression depending only on x and k:
y:= (x,k)-> x+k:
 
#any real numbers; order doesn't matter:
K:= [1.1, 1.3, 1.7, 2.0]:
 
plot(y~(x,K), x= -2..2, legend= K, caption= "Legend shows k-value");

Maple chooses the colors, but you can choose your own colors and linestyles (dash, dot, etc.) to ensure sufficient visual variation (especially helpful for a large number of lines or curves).

The command parse is by far the most common way (and I think also the most efficient way) to convert a string of digits to its corresponding integer. And parse also has other far more arcane uses for which you can ignore the help for now.

However, an easy way to completely avoid the issue of strings (i.e., to do the work with pure arithmetic) is

convert(x, base, 1000)

This will order the 3-digit integers from least significant (on the left) to most significant (on the right). This is usually the most convenient order for programming (despite looking weird for purely cultural non-mathematical reasons), but if you don't like it that way, do

ListTools:-Reverse(convert(x, base, 1000))

It's a much more fundamental bug in evaluating 0*infinity cases. The following two also return undefined:

int(0, [x= 0..1, y= 0..infinity]);
int(0, [y= 0..infinity, x= 0..1]);

Having cos in the exponent in your code line

x := (u, v) -> a^cos(u)*sin(v);

seems unusual to me. Didn't you intend that to be

x := (u, v) -> a*cos(u)*sin(v);

?

The following uses the permutation selection criterion that no player from either team appears in consecutive matches. There are 9! = 362,880 "raw" permutations of the 9 matches. There are only 1512 that meet that criterion, and this lists them all:

T:= Array(0..8, [[A, X], [A, Y], [A, Z], [B, X], [B, Y], [B, Z], [C, X], [C, Y], [C, Z]]):
Perms:= [
    for p in Iterator:-Permute([$0..8]) do 
        q:= iquo~(p,3); r:= irem~(p,3);
        for k to 8 while q[k]<>q[k+1] and r[k]<>r[k+1] do od;
        if k=9 then [seq](T[[seq](p)]) fi
    od
];

This code relies on the specific order of the "master permutation" T, so don't change that. Specifically, if two indices of T have the same quotient when divided by 3, then the first team member is the same; if the remainder is the same, then the second team member is the same.

See the command Finance:-BrownianMotion (help page ?Finance,BrownianMotion).

There are three major problems with your code:

1. In the piecewise command, the boolean conditions (i.e., the inequalities in this case) must come before their corresponding expressions, even though they appear after in the standard forms of display (whether in Maple or just typeset mathematics).

2. You can't use x both as a vector and as a symbolic variable (such as a variable of integration). Below, I've changed the symbolic x to xi.

3. Variables that appear in expressions after an arrow -> are not evaluated at the time the function (procedure, arrow expression) is defined. They aren't evaluated until the function is called. This could be corrected with unapply (as suggested by VV above), but I think that it's better to eliminate the loop entirely.

To correct these problems, delete the entire loop where phi is defined. Replace it with this single function definition:

phi:= (k::posint, X::Vector(realcons), h::algebraic)->
    x-> piecewise(Or(x < X[k], x > X[k+2]), 0, x <= X[k+1], x-X[k], X[k+2]-x)/h
:

And change the int command to

F[k]:= int(sin(Pi*xi)*phi(k,x,h)(xi), xi= 0..1)

It's quite simple, and nothing needs to be done implicitly:

ode:= diff(f(x),x)*exp(f(x)-x^2-1) = 2*x:
dsolve({ode, f(0)=1});
                                 2    
                         f(x) = x  + 1
int(rhs(%), x= 0..1);
                               4
                               -
                               3

By the way, note that the ODE is separable as 

int(exp(y), y) = C+int(2*x*exp(x^2+1), x)

where y= f(x).

The Optimization package is for numeric solutions. It can't give solutions for one variable in terms of other variables.

The radius for 4 points is obviously 1/sqrt(2). A set of four points satisfying the conditions is {[1/sqrt(2), 0], [0, 1/sqrt(2)], [-1/sqrt(2), 0], [0, -1/sqrt(2)]}.

For any n, the radius r can be determined by solving the equation

sol:= solve(1=(r-r*cos(2*Pi/n))^2+(r*sin(2*Pi/n))^2, r)

and taking the positive branch of the square root. The result (very easy to obtain by hand also) is

r = 1/sqrt(2 - 2*cos(2*Pi/n))

That can be simplified via a half-angle identity to 

r = csc(Pi/n)/2

A list of n concyclic points satisfying the condition is then

[seq](r*~[cos,sin](2*Pi*k/n), k= 1..n) 

with as given above.

Any three non-collinear points uniquely determine a circle (and, of course, a triangle). (That existence and uniqueness of the circle was surprising to me when I first learned of it, so many decades ago.) So, we just need the center and radius of the circle determined by the vertices of the triangle. This can be done easily with the geometry package. Below, I generate three points at random, find the circle, and plot the circle, triangle, and circumcenter.

restart:
R:= rand(-9..9):
G:= geometry:
G:-circle(C1, G:-point~([A,B,C], '['R()'$3]'$2)):
Triang:= G:-coordinates~([A, B, C, A]);
         Triang := [[5, -8], [3, 2], [-4, -6], [5, -8]]

Ccen:= G:-coordinates(G:-center(C1));
                              [109  -305]
                      Ccen := [---, ----]
                              [86    86 ]
R:= G:-radius(C1);
                      1         (1/2)     (1/2)
                R := ---- 124865      3698     
                     3698                      
plot(
    [[(R*~[cos,sin](t) +~ Ccen)[], t= -Pi..Pi], Triang, [Ccen]], 
    style= [line$2, point], symbol= solidcircle, scaling= constrained,
    thickness= 5
);

If you want to work through (with Maple) the algebra that underlies the computations done by geometry above, let me know; it's not terribly complicated.

One way is like this:

x:= <1, 2, 3, 4>;
k:= Matrix(4, 4, (i,j)-> x[i]+x[j]);

Nested for loops could also be used, but it's not ideal.

Do you want the matrix to contain only the coefficients of the power-3 terms of the equations? In that case, do

KKNL:= Matrix((nops(EqML), nops(Var[4])), (i,j)-> coeff(EqML[i], Var[4][j]))

Acer's Answer is good. I just want to add what I think may have contributed to your original confusion about type indexed versus type symbol: When option symbol= a is used with a Matrix command, the nonzero entries of the resulting matrix are type indexed, not type symbol. It is the a (alone) which is the symbol; not the entries such as a[1,1].

Your desired form of the solution contains several factors that don't depend on t. These factors could be absorbed into the constants of integration without changing the correctness of the solution.

First 53 54 55 56 57 58 59 Last Page 55 of 395