Carl Love

Carl Love

28015 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

You still have exp^(-3*x[i]). You need to remove the ^ from that.

It can be done by repeating the first point in the plot command, like this:

Matrice:= [[-2,-3],[-1,2],[3,4],[1,-2]]:
plot([Matrice[], Matrice[1]]);

 

You need to use hastype instead of has, like this:

if pdext_simplified::`+` then
    (expr, other):= 0, pdext_simplified;
    for k from -1 to 1 do
        (yes, other):= 
            selectremove(hastype, other, u(anything$2, identical(n+k)));
        expr:= expr + ``(yes)
    od
fi:
expr;

This produces an expression with subgroupings enforced by ``(...), which should be adequate for display purposes. The ``(...can be removed by expand(expr), but this will return it to its original term order. It is possible to sort, but it's a bit more complicated.

Like this:

is(SetOf(RealRange(-5,2)) subset SetOf(RealRange(-10, Open(infinity))));
                              true

is(SetOf(RealRange(-5,2)) subset SetOf(RealRange(Open(-5), Open(infinity))));
                             false

@Newie It looks like you're trying to find the stationary vector of a Markov chain. So, I'll assume that M is a 7x7 stochastic matrix (all entries nonnegative; each row sums to 1). For convenience, I'd like to also assume that no entry is exactly 1. (It's not forbidden for an entry to be 1; it just might require a different solution approach.)

Let's ignore that equation for the moment. The remaining 8 equations in 7 variables should be uniquely solvable. One way is to get an eigenvector of MT corresponding to eigenvalue 1 (see help page ?LinearAlgebra,Eigenvectors). Then divide that vector by the sum of its entries to enforce the 8th equation.

Now for z: It's not really an "equation" (in the sense of a constraint); rather, it's a function definition. Knowing the values of the other 7 variables, just compute z.

Only considering upto the first loop, you have 3 syntax errors:

  1. In Cond, the last item is spelled Thata instead of Theta.
  2. notation rather than diff must be used in initial and boundary conditions. So, the last item in Cond should be 
    D[1](Theta)(1,tau) = 0. The [1] here indicates differentiation with respect to the 1​​​st variable, which is X.
  3. In the loop, the eval command should be
    eval([OdeSys, Cond], Nr= NrVals[j])[].

In the next loop (the generation of the numeric points), the eval needs to be replaced with
Ans[k]:-value, and you need to specify values of X and tau to use. Remove the (j); you can't do evaluations of pdsolve(..., numeric) solutions as if they were ordinary functions. The value when used in this way is documented on help page ?pdsolve,numeric.

Yes, as you said, sometimes there's no feasible solution. In those cases, the solve returns [] (the empty list), which cannot be indexed by [1]. Your procedure needs to be prepared to handle that. I recommend that you change your command with eval and solve to this, where the "..."s represent what you already have:

...:= eval(..., solve(...)[])[];

Now the procedure will always return 9 values, and in the infeasible cases those values will be symbolic.

That's curious. I don't know what causes the problem, nor have I investigated it, because there's an easy workaround by which you can add "global" options to any plot or group of plots. By "global", I mean options that apply to the overall plot rather than the mathematical options that specify how to calculate points and colors for the plot. The command that does this workaround is plots:-display:

display(
    fieldplot3d(
        [0, 0, -y], x= -2..2, y= -2..2, z= -2..2, arrows= `3-D`, fieldstrength= maximal(0.5),
        font= [Times, bold, 16], grid= [4, 4, 4], labels= ['x', 'y', 'z']
    ),
  #end of fieldplot command
    labelfont= [Times, bold, 40]  #additional global option
)

The axes labels being "cut off" immediately above is just caused by the transfer of the plot from my worksheet to MaplePrimes. They appear normal in the worksheet.

I could've also considered the options font and labels to be "additional global options", but I didn't because they were working as is.

The display command can also be used to combine multiple plots into one presentation. See help page ?plots,display.

The ".mtx" (aka MatrixMarket) file format is a matrix format, not necessarily a graph format. Since the entire mathematical structure of a graph is encoded in its weight matrix (or adjacency matrix if you don't care about weights), this doesn't present any serious difficulties; you just need the tiny additional step of creating a Matrix when going from Graph to ".mtx" file or vice versa.

The example file that you linked is a sparse representation likely suitable for the vast majority of graphs. It's not necessary that you understand the representaion in order to use this. Only nonzeros are represented. The 1st column is the row numbers, the 2nd is the column numbers, and the 3rd is the weights. As you said, the 3rd column could be all 1s, making it an adjacency matrix.

To go from a Maple Graph G to a ".mtx' file, use

ExportMatrix("my_graph.mtx", GraphTheory:-AdjacencyMatrix(G));

To go in the other direction, use

G:= GraphTheory:-Graph(ImportMatrix("my_graph.mtx"));

The GraphTheory:-Graph command doesn't care whether you pass it an adjacency matrix or a weight matrix; either case will be handled correctly without you needing to specify which one it is.

You have three errors:

  1. The syntax of pdsolve(..., numeric) requires you to change {ICs}, BCs to 
    {ICs, BCs[]}
  2. You have the expression exp(-1000*(x-l)^2) several times. What is x? I guess it should be y.
  3. You have 8 BCs; it wants 6. I removed the 1st and 3rd (arbitrarily).

Making these changes, the pdsolve command itself runs without error. You may still encounter numeric errors when you try to get output. Indeed, I think that it's likely that you will.

I'd use grid= [33, 129]. So, that's 33 r values and 129 theta values. It takes 50 seconds on my computer:

CodeTools:-Usage(
    plot3d(
        [A,B,C], r= 1/5..4/5, theta= -Pi..Pi, view= [(-8..8)$3],
        shading= zhue, grid= [33, 129], style= surface, axes= none
    )
);

You have Vectors named err1 and err2 to hold your errors. The command LinearAlgebra:-Norm is akin to an "absolute value" for vectors---it's a way to assess their magnitude as a nonnegtive real number. So, use 

if LinearAlgebra:-Norm(err1, 2) < tol then ...

The 2 indicates the 2-norm (aka Euclidean norm). Other common norms are 1 (sum of abs of elements) and infinity (max of abs). See ?LinearAlgebra,Norm.

Like this:

local D:= Matrix(A, shape= diagonal);
(L,U):= map2(Matrix, A-D, shape=~ [triangular[lower], triangular[upper]])[];

By setting

Digits:= 50;

and adding option complex to your fsolve command (and no other changes), I get this solution in under 2 seconds:

{A = -2.7553365135418814642586082436429575890825402826031,
B = -0.70285804987973303586180028708027467941012949957141}

Note that this solution is real and didn't require initial specification of intervals.

Using the 3rd-party package DirectSearch (available for free download from the Maple Applications Center), and using its command SolveEquations with option AllSolutions, I get 2 solutions: the same one that I show above, and the one reported by Rouben. I'm not confident that this program, or any numeric method, can guarantee the number of solutions to a system of more than 1 non-polynomial equation, even when all univariate restrictions are meromorphic (as is the case here).

@Rouben Rostamian  The procedure can be shortened like this:

tangent_plane:= P-> [P, (sign*primpart@sort@`.`)((<1,3,5>, <x,y,z>)-~'<P>') = 0]:
tangent_plane~(L);

@Laurenso: For your purposes here, the single command sign is equivalent to your signum@lcoeff, but is faster and more robust. It is designed for this type of operation (exact work on polynomials); signum is not.

First 20 21 22 23 24 25 26 Last Page 22 of 394