Carl Love

Carl Love

28035 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

You asked:

What is the meaning of the suffix "+0.I"? Does it mean that there are further decimal digits which are not displayed?

I call these "spurious imaginary parts". They occur when an answer is real but its computation uses complex numbers. Consider the cubic p:= x^3 - 3*x - 1. A plot will quickly reveal that it has three real roots. But solve(p, x) will show that complex numbers are used to calculate those roots. The spurious imaginary parts can be safely ignored if you have reason to believe that the solutions are real. The +0.*I parts can be removed with simplify(..., zero).

How do the first and third eigenvalues, which are equal, result in different eigenvectors? As per my understanding, equal eigenvalues should have equal corresponding eigenvectors.

No, that's only true in a rare situation called a defective matrix. Consider: What are the eigenvectors of the 2x2 identity matrix? How about the 2x2 zero matrix? The usual situation is that there are as many linearly independent eigenvectors as the multiplicity of the corresponding eigenvalue.

The earliest date recognized by this system is January 1, 1901. So, to get to January 1, 1900, we need to subtract or add 365.

Finance:-AdvanceDate("January 1, 1901", 23021 - 365);

     "January 12, 1963"

Finance:-DayCount ("January 1, 1901", "January 10, 1963") + 365;

     23019

Apparently, your day count was off by two days. Remember that 1900 was not a leap year.

 


First I'll generate some example data for N and M.

n:= 20:

P:= plot(x^2, x= -2..2, numpoints= n, adaptive= false);

Scramble the example to resemble your situation.

NM:= op([1,1],P)[combinat:-randperm(n), ..]:

(N,M):= (NM[..,1], NM[..,2]) ^~ %T;

N, M := Vector[row](20, {(1) = -1.5880817705263157, (2) = .11571126736842086, (3) = 2.0, (4) = -2.0, (5) = .3093193136842105, (6) = .9570320926315787, (7) = 1.569213945263158, (8) = -.31779058736842103, (9) = -.5321707810526317, (10) = -.7394613410526316, (11) = .5272761178947367, (12) = 1.1485533284210523, (13) = 1.7936296568421048, (14) = -.10409791368421062, (15) = 1.376290602105263, (16) = -.9396565663157896, (17) = -1.1555870778947368, (18) = -1.3725487705263157, (19) = .7461278736842103, (20) = -1.7797340210526316}, datatype = float[8]), Vector[row](20, {(1) = 2.5220037098779975, (2) = 0.13389097396006177e-1, (3) = 4.0, (4) = 4.0, (5) = 0.9567843781807102e-1, (6) = .9159104263267787, (7) = 2.4624324060083653, (8) = .10099085741996604, (9) = .28320574020616807, (10) = .5468030749113564, (11) = .2780201045021443, (12) = 1.3191747482270777, (13) = 3.2171073459035266, (14) = 0.10836375633405365e-1, (15) = 1.8941758214432673, (16) = .88295446262038, (17) = 1.3353814945972966, (18) = 1.8838901274733009, (19) = .5567068038885209, (20) = 3.167453185692169}, datatype = float[8])

I assume that you got a plot like this. It shows the correct points, but they're connected wrong.

plot(N,M);

Kitonum's Answer shows how you can plot this as points:

plot(N,M, style= point);

Here's how to plot it as connected points. We need to sort N in ascending order and sort M using the same permutation.

plot(map(`?[]`, [N,M], [sort(N, output= permutation)])[]);

 


Download sorted_plot.mw

Here's an example:

restart:
ODEs:= {
     diff(x(t),t)=sigma*(y(t)-x(t)),
     diff(y(t),t)=x(t)*(rho-z(t))-y(t),
     diff(z(t),t)=x(t)*y(t)-beta*z(t)
}:
ICs:= {x(0)=0, y(0)=0, z(0)=1}:
params:= {sigma= 10, beta= 8/3, rho= 28}:
n:= 600:  step:= 0.1:
A:= dsolve(
     eval(ODEs union ICs, params),
     numeric,
     output= Array([seq(step*k, k= 0..n)])
):
DesiredOrder:= [t, x(t), y(t), z(t)]:
Column:= proc(e) local p; member(e,A[1,1],p); p end proc:
M:= A[2,1][.., [seq(Column(e), e= DesiredOrder)]]:
ExportMatrix("C:/MyMatrix.csv", M, target= csv):   
 

Note that A[2,1] is the actual output data, and A[1,1] is just a Vector that shows the order by which dsolve arranged the columns in A[2,1].

Is that less confusing than the other answers that you found?

Your Question is ambiguous as to whether you want abs(max(Fm(x))) or max(abs(Fm(x))). Please clarify. In the code below, I assume the latter.

Since you're using Excel, I'm going to guess that you're using Windows. If not, the directions below need to be modified a little.

Directions for installing a Maple package:

  1. Go to the Maple Applications Center and download the DirectSearch package
  2. Create a folder somewhere on your computer to hold Maple packages. In my case, that folder is named "C:/Maple_packages".
  3. From the zip folder, select the subfolder of your desired language: English or Russian.
  4. Copy the files DirectSeach.mla and DirectSearch.help to the new folder. Then copy the whole zip folder to the new folder, just in case you ever need it (unlikely).
  5. If you have a Maple initilization file, open it with Notepad. If you don't have one, create a file named "C:/Program Files/Maple 2016/lib/maple.ini" (this assumes that you have Maple 2016) and open it with Notepad.
  6. Put in that file the line libname:= "C:/Maple_packages", libname; using the folder name you created in step 2. Save the file. If you already have a Maple initialization file, then it doesn't matter where in the file you include the above line. Make sure that you spell the second libname correctly. If you don't, you won't be able to use Maple at all until you fix this.
  7. If you have Maple open, then close and re-open it. If you use Maple strictly through Excel, then I guess there's no need for this step. But we need to insure that your Excel is starting a fresh Maple session. So close Excel and reopen it.

The Maple command to find the maximum is

DirectSearch:-GlobalOptima(abs(Fm(x)), [x = a..b], maximize)[1];

To find the minimum, change maximize to minimize.

 

For example,

eq4:= dsolve({eq2, incs}, numeric, method= rosenbrock, range= 0..10, maxfun= 0);
plots:-odeplot(eq4, [t, y(t)], 9..10, numpoints= 10000);

Please don't include irrelevant plaintext output in your Questions. It makes them difficult to copy-and-paste.

Use IntegrationTools:-Expand.

The command

plots:-complexplot3d(f(z), z= a+b*I..c+d*I);

is equivalent to

plot3d(
     abs(f(x+I*y)), x= a..c, y= b..d,
     color= (argument(f(x+I*y))+Pi)/2/Pi, labels= [Re('z'), Im('z'), ""]
);

Thus, to achieve what you want, you can use

plot3d(
     abs(f(x+I*y)), x= a..c, y= b..d,
     color= (-argument(f(x+I*y))+Pi)/2/Pi, labels= [Re('z'), Im('z'), ""]
);

I wish that this could be done by manipulating the color option in complexplot3d, but I can't make it work.

Edit:I updated the plot3d commands based on an analysis of the actual code of `plots/complexplot3d`.

The sum of any infinite sequence of positive integers obviously diverges. But it's easy to get a closed form for the partial sums of the Fibonacci sequence:

rsolve({f(n)= f(n-1)+f(n-2), f(0)=2, f(1)=3}, f(n));
sum(%, n= 0..N);

The IVP is apparently "stiff". The numeric solution can be obtained very quickly with a stiff solver. I used method= rosenbrock, the default stiff solver. (You can also select this by specifying stiff= true.) Having a little bit of skepticism about the solution, I tried another stiff method, method= lsode[backfull]. This produced the same result. The plot of y(t) can be obtained by

plots:-odeplot(eq4, [t, y(t)], 0..2);

To extract the procedure for numerically evaluating y(t), it's more robust (than your method) to use

test:= eval(y(t), eq4);

This is the normal behavior of seq: It first substitutes numeric values for the index, then it evaluates the expression. The first of those steps leads to

sum(f(0,y), y= 0..1);

which, of course, is undefined because of the ln(0).

What you need is to first evaluate the expression, then substitute numeric values for x. In that case, use $ instead of seq:

sum(f(x,y), y= 0..1) $ x= 0..5;

 

Change abs(G) to abs~(G). The ~ makes it equivalent to map(abs, G) (when G is a list, set, table, or rtable (Vector, Matrix, Array)).

Your second line of code is bloated. It can be shortened to

=maple("G:= evalf(Fm~([A]))")

It's almost the same in Maple as Matlab. For example,

K__V:= 0.2:
plot(x^2, x= -2..2, legend= typeset('K__V' = K__V));

There's nothing unclear to me about the Question. It's up to the user to verify that conditions for convergence are met. Maple can just manipulate the symbols, thus:

J:= Int(Sum(f(x,k), k= 1..infinity), x= 0..X);

`convert/InttoSum`:= J-> op([1,0],J)(op(0,J)(op([1,1],J), op(2..,J)), op([1,2..],J)):

convert(J, InttoSum);

 

Use a :- prefix to specify the general LinearAlgebra package:

restart:
with(Maplets[Examples]):
A := Matrix(2,2,[1,2,3,4]):
:-LinearAlgebra:-Transpose(A);

You asked:

In Maplets[Examples] there is a subpackage named LinearAlgebra. Could it be the reason of this observed behaviour?

Yes, that's the problem exactly.

Is there any way to fix that other than copying from Maplets[Examples] the only pieces of code I need avoiding thus its complete loading?

There are two other ways: 1. Use :- as detailed above. 2. Avoid using with entirely; use the so-called long-form names instead. Number 2 is my personal preference.

          More generally: Is it possible to load a package "partly" by discarding some of its subpackages?

Yes, you could use, for example,

with(Maplets:-Examples, GetEquation, GetExpression);

if those were the only two items from the package that you wanted to load. Or, to load everything except LinearAlgebra (the one from the package), use

with(Maplets:-Examples, ({Maplets:-Examples:-_pexports()[]} minus {LinearAlgebra})[]);

First 221 222 223 224 225 226 227 Last Page 223 of 395