Carl Love

Carl Love

28055 Reputation

25 Badges

13 years, 3 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

You wouldn't do this with nested if statements. Every practical computer language (above the level of assembler) has a looping command that increments an index variable (i in your case) for each pass through the loop. That command in Maple is for, as used in John Fredsted's Answer below.

To directly answer the question that you pose in your title: Yes, that has happened to me a few times. I can't recall how it got fixed, but it did.

You should upload your worksheet as a file attachment rather than as a screenshot. To do that, use the green uparrow on the toolbar in the MaplePrimes editor.

@weidade37211 If R is your random variable, try Statistics:-DensityPlot(R) (*footnote). That'll give you a plot of vertical columns whose heights are the probabilities and whose horizontal coordinates are the "support" (i.e., data values). If that's not what you want, let me know.

The plot command that you suggest doesn't work very well because the ProbabilityFunction is only nonzero at discrete values (which plot won't be able to deduce because it's discontinuous). But ultimately it can be done with plot using some finesse to get exactly what you want.

*footnote: Although "density" is used in the command's name, it actually uses either the PDF or the ProbabilityFunction, whichever is appropriate. The needed information is stored in the module that encodes the random variable.

@Jasagredo Nearly all writers who write lengthy Maple code store that code in plaintext files rather than worksheets. Those plaintext files can be handled by Git. There are two main ways to then use that code in a worksheet: The first is to store it in a library; the second is to read it into the worksheet with the read command (see ?read). I recommend that you start with the second way.

To teach yourself Maple, as I myself have done, I recommend that you start with the help pages whose names begin Programming Guide (see ?ProgrammingGuide). These pages used to be distributed in book form, but, sadly, they no longer are.

@Cryme You can express the inverse function symbolically with RootOf. Then Maple will know how to take the derivative, and it'll still be able to do numeric things like plotting.

f:= x-> ln(x)+x;
g:= y-> RootOf(f(x)=y, x, 0..10);
D(g)(2);
D(g)(2.);
plot(g, 1..10);

 

@Markiyan Hirnyk 

I wrote "algebraic expression e that needs to be interpreted as an equation", NOT "algebraic expression e, which needs to be interpreted as an equation". In English that comma makes a huge difference in the meaning. In the former "that needs to be..." is called a restrictive clause; in the latter "which needs to be..." is called a non-restrictive clause. A restrictive clause defines a proper subset of the set described by its antecedent noun phrase; a non-restrictive clause applies to the whole set. To reduce the confusion, some writers, myself included, always introduce a restrictive clause with that rather than which, although the formal rule allows either, which makes the presence of the comma the only definitive difference. See the Wikipedia article "English relative clauses".

So, regarding your example diff(x^2, x), my statement from my previous Reply says nothing about it at all because it is not an expression that needs to be interpreted as an equation. On the other hand, in solve(diff(x^2, x), x), it is an expression that needs to be interpreted as an equation, so the correct interpretation is 2*x = 0.

Please stop reading and interpreting my posts as if you thought that I was an idiot. Only an idiot would say that diff(x^2, x) should in general be interpreted as 2*x = 0. If you are drawn to such a conclusion, then you should suspect that your interpretation of what I wrote is wrong.

In any situation in Maple where one has an algebraic expression e that needs to be interpreted as an equation, the interpretation is e = 0. I think that this is what Markiyan has been trying to convey to you.

@Jasagredo You asked:

  • I noticed that Irreduc works with mod, yet it is undocumented at ?mod. How can I find all such functions?

Any function X that works with mod corresponds to a procedure named `mod/X`, which corresponds to an entry named "mod/X.m" in the library. The following finds all such entries:

map(
   x-> nprintf("%s", x[1][5..-3]), 
   select(x-> x[1][1..4] = "mod/", LibraryTools:-ShowContents())
);

That yields 136 results for me (in Maple 2016). There are probably many of those, particularly among the ones with compound names, for which it doesn't make sense to use them at the top level.

  • Do I need to follow all arithmetic with a call to Expand to reduce high powers of the field extension element?

By itself, mod only reduces the coefficients. You need to have a call to something to reduce the exponents. If you don't have anything else that you need to call, then it might as well be Expand. Note that instead of

a*b mod p;
Expand(%) mod p;

you could simply use

Expand(a*b) mod p;

  • What does $ mean?

The $ is a binary infix operator expressing repetition. So x $ 2 is the same as x, x. See ?$.

  • What does 2: mean?

Don't make the mistake of assuming that if two characters appear together offset by whitespace that they are a syntactic unit. In this case, the 2 is the second argument of $. The : is just like a ;, and it means in addition that the display of the output of the proceeding command is to be suppressed.

  • I thought that % referred to the output of the preceeding command.

It does.

  • What does <%> mean?

Enclosing something in < > makes it a column vector (which'll display neatly as a column). For display purposes only, I wanted the output of the preceeding command, the two random polynomials, to display as a column.

 

@Jasagredo If you'll take some pedagogic advice from a tutor with over 40 years experience and 17 years experience with Maple: Set aside all your current work with modp1, modp2, Domains, and GF. Build a prototype for your algorithms using just mod and its associated functions documented at ?mod. Everything that you need is there. The only question is whether it's efficient enough. If you decide that you want to make it more efficient, then we'll go back to the current code.

@arman Why do you say that it's not useful for large systems? It can factorize a 100 x 100 Matrix of floats in less than 0.1 seconds.

A:= LinearAlgebra:-RandomMatrix((100,100), datatype= float[8]):
CodeTools:-Usage(LinearAlgebra:-LUDecomposition(A));

 

@Jasagredo If your finite field elements are in the modp1 representation, then polynomials over those fields should be in the modp2 representation. See ?modp2.

@guest Maple's LineInt corresponds to a line integral of a vector field (see Wikipedia https://en.wikipedia.org/wiki/Line_integral).

Yes, a vector field can be integrated over a curve and give a number. For example

VectorCalculus:-LineInt(
   VectorCalculus:-VectorField(<-y^2,x^2>, cartesian[x,y]),
   Path(<t, t^2>, t= 0..2)
);

You don't need the equation of the intersection. The whole purpose of Lagrange multipliers is that it lets you find the highest and lowest points of the intersection without needing an equation for the intersection. And if you had such an equation, then you wouldn't need to use Lagrange multipliers.

You should post the details of your ellipsoid problem.

@Muhammad Usman Include an option such as this in the options of the plot command:

legend= [f__1a, f__2a, f__3a, f__1b, f__2b, f__3b, f__1c, f__2c, f__3c]

See legendstyle under ?plot,options for how to adjust the font, placement, etc.

@Muhammad Usman Sorry, I didn't have M set to 100. I failed to see that N and M were independent, so I had M = 5 and N = 100. The only other differences were that I had Digits set to 15, and I changed the fsolve command to include the eval:

[fsolve(
   eval(
      {seq(seq(Eq1[i, j], j = 0 .. N-1), i = 1 .. M-1), 
       seq(seq(Eq2[i, j], j = 0 .. N-1), i = 1 .. M-1),
       seq(seq(Eq3[i, j], j = 0 .. N-1), i = 1 .. M-1)
      }, {alpha = .4}
   )
)]:

I don't think that you should pursue any larger solutions with fsolve until you check out the sparse iterative techniques.

First 345 346 347 348 349 350 351 Last Page 347 of 709