dharr

Dr. David Harrington

5712 Reputation

21 Badges

20 years, 344 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

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

@Carl Love Thanks.

@Ronan Thanks for pointing that out. The help says "Tables created with a list initializer, for example, table([a=A, b=B, c=C]), are created such that the assignment of the table entries proceeds from left to right.  That is, the first element of the list is inserted into the table first, the second is inserted second, and so on." But assigning them in that order separately as on the attached works differently, and as I would expect.

I think converting the tables to lists preserves the order in eval(Popvs), though perhaps I should have some more robust code for that as well. Edit: fixed so now either initialization method works.

Q_23-12-22_Test_Graph_indices4.mw

@zenterix If I copy @Carl Love's code, click on your document to start new input, type ctrl-M (cmd-M on Mac) and then paste it in, it works. 

code.mw

Edit: here is a 2-D version. I separated the restart and interface lines out from the proc. For the  `print/Trans` and Trans(M) .%  M lines I entered them in 1-D and converted to 2-D input with the right-click menu.

code2d.mw

@Otttimor @mmcdara uses the usual output from dsolve, and converts it to a vector. Another way would be to use the output=Array option of dsolve. I would use Norm from the LinearAlgebra package, or just add.

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

restart

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))

8

Shorter form

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

8

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)

2*2^(1/2)

2*2^(1/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)

2

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.

foo:=proc(expr)
  local A;
  uses plots;
  A:=plot(expr);
  display(A)
end proc;

foo(x^2);
foo(x^3);

 

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

@astroverted Here the 3D plots as well

DQ4.mw

First 23 24 25 26 27 28 29 Last Page 25 of 58