Dr. David Harrington

4108 Reputation

17 Badges

18 years, 217 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a professor of chemistry at the University of Victoria, BC, Canada, where my research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity

These are replies submitted by dharr

@Otttimor Maybe the meaning of 2-norm isn't clear to you? If that is the case, maybe this will help.


Take Rouben's two sets of numbers - one could be from a simulation, the other could be from experiments

vals1 := Vector([1, 3, 5, 6, 6, 6, 7, 5, 3]); vals2 := Vector([1, 3, 4, 5, 6, 8, 7, 4, 4])

The most common measure of deviation would be to take the differences, square them and add them up.

This residual sum of squares (RSS) would be what would be minimized in a least-squares fit.

RSS := add((vals1[i]-vals2[i])^2, i = 1 .. numelems(vals1))


Shorter form

RSS2 := add(`~`[`^`](vals1-vals2, 2))


The square root of this is also a measure of the deviation. In linear algebra, summing the squares of the entries of a vector and taking the square root is called the  l__2 norm (or just 2-norm) or Euclidean norm.

dev := sqrt(RSS); dev2 := LinearAlgebra:-Norm(vals1-vals2, 2)



The p-norm (for any p >= 1) raises  the absolute value of each entry to the power of p, adds them and then takes the pth root (raises to power 1/p).
The infinity norm finds the maximum of the absolute values of the elements. So for deviations it focuses on the how far the worst data point is from its prediction.

dev3 := LinearAlgebra:-Norm(vals1-vals2, infinity)


Download devs.mw

@lcz I expected the order of the plot elements in the display command to determine this, but that doesn't seem to be happening here, even if I put them in a list or use redraw=false. Sorry, I don't have a solution; hope someone else can help.

@acer Thanks, that's helpful.

@acer I often put a number here as an initial value (especially 1), so my expectation was the same as the OP's. type(undefined,algebraic) and type(1,algebraic) both return true. On the other hand other symbols act like undefined...

@acer I stand corrected. I checked in the 2015 help, and assumed it wouldn't return in later versions. My new 2022 version will arrive soon...

@PaulNewton fi is a short form for end if. In older Maple these backward spellings were standard - also od for end do. Now they are no longer documented, but can still be used.

(The FAIL is the result of the else clause, that is returned if there is no match.)

@Carl Love The OP pointed out that when using save there are linebreaks that make it unreadable by matlab.

@PaulNewton You can also use the "Insert code snippet" icon (the one with <> in a box).

Not sure if this is your problem since you didn't upload a worksheet/document. However, you should not use with(plots)within a procedure. Instead put uses plots; at the beginning of the procedure.

  local A;
  uses plots;
end proc;



(Not sure what A:=Array(1) is doing.)

@astroverted Here the 3D plots as well


@astroverted Nice work on the faster method. Use display to combine plots of all kinds.


For a 3D plot, I think you will have to use the output=Array option of dsolve, and then use matrixplot or surfdata. I'll try that later when I have a little more time.

The help page for type/float suggests there is support only for double precision. In that case you can do things like in the attached.

Download float.mw

Edit: see my other response for a solution.

@AHSAN Your solution has no variable y. Do you mean x? For phase plots like you show using the commands @tomleslie mentioned, you would need to supply the DE and the initial condions you are interested in.

@mmcdara Sorry if I misunderstood what you meant. I was initially confused about what the OP wanted. My understanding of epsilon is that the contour integration has to be along the real axis but has to include the pole at the origin (the only pole along the real axis in this case). I would write this with integration limits x=-infinity+I*epsilon..+infinity+I*epsilon and leave the epsilon out of the integrand, with the assumption that you need to take the limit as epsilon tends to zero from above. 

Doing it by residues bypasses the details of the contour other than making sure the poles along the real axis are included. I think to do it the hard way would mean having a small semicircle around the poles (into the upper half plane) and taking the limit as their radii went to zero. 

Having said that, I'm still not clear that this is the right definition of the FT, but there seem to be many variations.

Edit: Now I thnk about it, maybe the contour is for the upper half plane excluding the poles along the real axis. That solves the sign problem.

4 5 6 7 8 9 10 Last Page 6 of 39