Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

Are you trying to write an equation that'll be solved for a variable, possibly x31? Then use = rather than :=.

Another option---not mentioned by Georgios and midway between the options that he did mention---is a Code Edit Region. This is an embedded component in a worksheet that gives you a fairly standard WYSIWYG plain-text code editor with syntax highlighting. You can get it by placing your cursor where you want the embedded component, then using the menu Insert => Code Edit Region. You execute (or syntax check) the code by right-clicking in the region and selecting Execute Code. Estimated locations of syntax errors are shown by tiny red squiggles in the code. They're a bit difficult to see if you're not used to them (at least if you use Zoom Factor 75%). I tend to use these Regions for codes of between 50 and 500 lines. 

Warning: There may be some bad behavior if you leave the first line blank. So, at least put a comment on the first line of your Code Edit Region.

From the menus in Maple, do Tools => Check for Updates. If there's an update available, then the dialog box will give you the option to download and install it.

VV's Answer addresses the major mathematical issue of your Question. In addition, I've noticed several little things that could be done better:

  1. The assume is unnecessary; evalc and the numeric integrators handle this automatically.
  2. Important: You should replace Re(evalc(...)) with evalc(Re(...)) in both places that you use it. This will produce much simpler expressions.
  3. Both f1 and f2 are even functions of x, so you can integrate from to infinity and double the result.
  4. The two integrands can be added and done as a single integral.

There are two workarounds: interface(showassumed= 0) or interface(showassumed= 2). With either of these, you'll also no longer see the trailing ~.

Hints:

1. A function from R to R^3 can be conveniently defined by r:= t-> [t, t^2, t^3].

2. Given (1), the tangent line at t=a can be defined by D(r)(a)*~(t-a)+~r(a) (where t is the free and independent variable). (This syntax requires Maple 2019 or later. For earlier versions, see Replies below.)

3. Functions from R to R^3 are called space curves and the command to plot them is plots:-spacecurve

4. Multiple plots can be combined with plots:-display.

As far as I can tell, there is no connection between the plot in your PDF and the code that you show. Whether you use logplot or regular plot makes no difference because the vertical range is so narrow that the two commands produce nearly identical plots.

Observe the result of the following command and generalize it:

plot([[x, 1, x= 1..3], [2, y, y= 1..3]], thickness= 3, view= [0..5, 0..5]);

(I've changed the numbers from those that are relevant to your particular question.)

Go to menu Tools => Options => Display. The first question is "Input display". Set the answer to "Maple Notation". Go to the next menu tab, Interface. The 4th question is "Default format for new worksheets". Set the answer to "Worksheet". Click on "Apply Globally".

As I showed in my Answer to your copy-and-paste-from-Mathematica Question, using expand for the product of two thousand-term polynomials can be done in seconds as long as you don't try to display the result on screen.

What's happening is that the copy-and-paste operation is overwhelming Maple's GUI component because it's trying to construct a prettyprinted on-screen representation of the polynomial. But, as long as you don't try to display it, Maple's kernel component (aka the "mathematical engine") performs operations on thousand-term polynomials nearly instantaneously and million-term polynomials in seconds. The following session transcript confirms this:

restart:

#Creating a pair of thousand-term polynomials is nearly instantaneous:
Px:= CodeTools:-Usage(add((-1)^k*k^2*x^k, k= 1..1000)):

memory used=295.18KiB, alloc change=0 bytes, cpu time=0ns, real time=3.00ms, gc time=0ns

Py:= CodeTools:-Usage(add((-1)^k*(k+1)*y^k, k= 1..1000)):

memory used=255.81KiB, alloc change=0 bytes, cpu time=0ns, real time=4.00ms, gc time=0ns

#Expanding their product to a million-term polynomial takes less a second:
Pxy:= CodeTools:-Usage(expand(Px*Py)):

memory used=15.26MiB, alloc change=15.26MiB, cpu time=359.00ms, real time=112.00ms, gc time=0ns

#Saving that product to a plain-text takes less than 2 seconds:
currentdir("C:/Users/carlj/desktop/"):
st:= time():
save Pxy, "BigPoly.txt":
time()-st;

1.484

Px1:= eval(Px, x=1);

500500

Py1:= eval(Py, y=1);

500

eval(Pxy,[x=1,y=1]) = Px1*Py1;

250250000 = 250250000

#Count terms:
nops(Pxy);

1000000

#Start new Maple session:
restart:

#Verify that no prior knowledge is in kernel memory:

Px,Py,Pxy,Px1,Py1;

Px, Py, Pxy, Px1, Py1

#Reading in that million-term polynomial takes about 10 seconds:
currentdir("C:/Users/carlj/desktop"):
st:= time():
read "BigPoly.txt":
time()-st;

9.812

eval(Pxy, [x=1, y=1]);

250250000``

 

 

 

Download BigPoly.mw

So, what you should do is copy-and-paste your Mathematica polynomials to a plain-text file, for example a Notepad file if you're using Windows. I'm guessing that Mathematica's plain-text syntax is acceptable, but I'm not sure that it is.[*1] Make the first characters of the file P:=  (or any other variable name). Make the last character of the file a colon (:). Then save that file, and use Maple's read command as shown above.

[*1] Primer on Maple's plain-text (generalized) polynomial syntax:

  1. There is no implied multiplication via juxtaposition. All multiplication should use *. Do not use dot (.) for multiplication. Although it is acceptable to Maple syntax, it changes the meaning.
  2. Constructions such as 2(x + y) are acceptable to Maple syntax, but they don't mean 2*(x+y)!
  3. Exponentiation can be done with or **. Although these mean exactly the same thing in Maple syntax, there can be no white space (white space includes line breaks) between the characters of a two-character operator such as **.
  4. The only acceptable algebraic grouping symbol is round parentheses ( ). Mathematica's square brackets [ ] and curly braces { } are not correct. Although these will be accepted by Maple's syntax, they will change the meaning of the expression, and it won't be a polynomial.
  5. Addition is +.
  6. Integers are sequences of digits optionally preceded by + or -, but two operators cannot be juxtaposed (even with white space). So, for example x^(-1) is acceptable, but x^-1 and x^ -1 are not.
  7. If you must include white space where it isn't otherwise allowed, precede each such character with backslash \. So, this can precede a line break.
  8. Division is /.
  9. Precedence of operators is exponentiation, followed by multiplication and division, followed by addition and subtraction.
  10. */+, - are associative left-to-right. is not associative. So, for example, x/2/3 equals x/6, (x^3)^2 equals x^6, and x^3^2 is a syntax error.
  11. (Ultimately, anything can be used as a variable name in Maple if it's properly quoted. I won't cover those rules here.) Any sequence beginning with a alphabetic character and followed by alphanumeric characters can be used as a variable. A few of these that have pre-defined meanings that you should be aware of are D, I, OPiBetagammaGAMMABetaZeta, and Psi.

1. Use Pi instead 3.14159 for the numeric solution. You should never use an explicit numeric approximation for Pi in Maple (unless you're writing an article about approximations of Pi).

2. Remove the inequalities from the analytic pdsolve command.

3. Define Ana via Ana:= unapply(rhs(sol), (x,t));

4. Define Sub via Sub:= (X,T)-> evalf(Ana(X,T) - eval(u(x,t), RT(X,T))); 

All of the techniques that you show (genfuncrsolve) are for finding an exact recurrence pattern. The likelihood of being able to do that with data from nature is pretty slim. Instead, what you want to find is a statistical pattern. This a where the TimeSeries package might help. You should also change (negative) to -1(positive) to 1, and (neutral) to 0. "Neutral" not being between the poles is ridiculous.

Several points:

1. If you want standard matrix arithmetic, then you must declare them with Matrix (or its equivalent with rtable, etc.), not Array. The dot operator performs elementwise multiplication on Arrays.

2. Yes, for compiled code, you'd need to write explicitly the multiplications loops.

3. The arithmetic of dense matrices of hardware floats is already highly optimized in Maple. You'll not gain anything by compilation unless you can exploit some special structure particular to your matrices. For example, it's possible to speed up some operations on tri-diagonal matrices. (I wrote an Answer for this case (compiled code for tri-diagonal matrices). I put a link in a Reply.) 

4. Here are three ways to transpose a matrix or vector A:

  1. LinearAlgebra:-Transpose(A)
  2. A^+
  3. A^%T 

There are many different ways that you could animate that. Here's one:

plots:-animate(
    plots:-shadebetween, 
    [sin(x+t), cos(x-t), x = 0 .. 2*Pi, positiveonly], 
    t= -Pi..Pi, frames= 200, gridlines, thickness= 3, labels= ["", ""]
);

Is that what you wanted?

First 115 116 117 118 119 120 121 Last Page 117 of 395