acer

32510 Reputation

29 Badges

20 years, 12 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Perhaps it's time to program efffectively with procedures.

It's probably much easier to call a Maple command to compute the y-value for exactly x=2, than it is to use something as crude as a point-probe.

Show us your example.

I was talking only about dense, hardware float[8] linear algebra, called properly.

Sparse linear algebra is another story. If you want to ask a specific question you should branch it off this thread.

@itsme I having been doing performance testing of the key computations of dense numeric Linear Algebra, Mma vs Maple, for years, on multicore hardware.  I have also used (close) revisions of the scripts for it obtained from the Wolfram site mentioned. For datatype=float[8] Matrices, properly done, I consistently see almost no significant difference between the products across a wide range of sizes, getting both to their MKL as fast as reasonably possible. I have found this to hold, for 64bit Linux/OSX/Windows, since at least Maple 2015. 

The results cited by that Wolfram document (which is usually revised yearly), reports slower timings than I obtain, often by a factor of about 3-4, each year.  I suspect the discrepency  is due to incompetence at best, disingenuousness at worst. The performance factor discrepency (between what they claim and what I see) is usually off by an amount similar to the gain I see due to parallelism -- I try a few different quad-core CPUs on each of the three named platforms.

Perhaps they have found some CPU for which the parallel MKL isn't kicking in properly. But for hardware float[8] LU decomposition, linear solving, symmetric and nonsymmetric eigensolving, svd , QR decomposition, matrix multiplucation done *properly*, I almost always see a very close match.

@manon22lr Ok, thanks for the definition of tensdBe.

You wrote, "I tried something with "proc", I found on Maple Help Page." And you define Be11Num as a procedure.

But you misuse it, since you only use Be11Num as a parameter(!) name in the fitted objective. And even if Be11Num were to be called with values it is not written to call ode_sol at all. So the ODE parameter values are not being altered, and the Be11 values from the numeric ODE solution are not being used. So this needs rewriting.

You need objective PK to depend on ODE parameters a and eta, by virtue or their explicit presence in the PK expression. You need PK to contain calls to Be11Num as a function of a, eta, and t, and you need those calls to return unevaluated if its arguments are not numeric. It's a moderately advanced Maple programming task.

I already have a revision that does the above. And it can be done in such a way that (internally stored) dsolve,numeric structures/info are not thrown away each time the ODE parameters a and eta get set (ie. when re-set to the very same previous values).

And it can be used with (local optimization) NonlinearFit command or the routines from the (global optimization) DirectSearch package.

But it would be much better if you could state reasonable numeric ranges for the parameters, especially a and eta.

Put your followup details and queries about solving your system (or derived systems) here, rather than in a separate Question thread.

@Mohamed19 I hope to be able to look at your followup soon, perhaps tonight. (I have been busy.)

@9009134 Please keep your followup example here, instead of in a new Question.

You are missing the code that define Lens and Distance. Please include all the user-defined code necessary to reproduce the problem. You could upload and attach a worksheet.

@Mohamed19 And what difficulty did you have in entering that in Maple?

Is your Maple Help system not working? Which parts of the syntax did you not understand? Something else?

[I am not interested in playing games, like this Question thread in which it took you more than 10 submissions before you came to your main points.]

Your expression has three independent variables, u, v, and alpha.

What kind of plot do you want?

Do you want to animate 3D plots of the real and imaginary parts of the expression (as a function of real u and v), animated by a real parameter alpha?

Do you want to animate 3D plots of the modulus of the expression, colored by its complex argument (as a function of real u and v), animated by a real parameter alpha?

Either of the above, for just a fixed real value of alpha?

Something else?

 

@rookie Do you mean something like this?

restart;

K := proc(ee::algebraic, f::function)
  local m,n,v1,v2;
  if nops(f)<>2 or (not [op(1..2,f)]::list(name)) then
    error "second argument f is not a function call of two names";
  else
    (v1,v2) := op(1,f),op(2,f);
  end if;
  n := PDEtools:-difforder(ee,v1);
  m := PDEtools:-difforder(ee,v2);
  Matrix(m+1,n+1,(i,j)->frontend(coeff,[ee,diff(f,[v1$(j-1),v2$(i-1)])]));
end proc:

 

expr := f0(x,y) + f1(x,y)*diff(z(x,y),x)
         + f2(x,y)*diff(z(x,y),y) + f3(x,y)*diff(z(x,y),x,x):

K(expr, z(x,y));

_rtable[18446884361775252054]

expr := f0(x,y) + f1(x,y)*diff(z(x,y),x)
         + f2(x,y)*diff(z(x,y),y) + f3(x,y)*diff(z(x,y),x,x)
         + f4(x,y)*diff(z(x,y),x,y) + f5(x,y)*diff(z(x,y),y,y)
         + f6(x,y)*diff(z(x,y),x,x,y,y,y)
         + f7(x,y)*diff(z(x,y),x,x,x,y,y,y):

K(expr, z(x,y));

_rtable[18446884361700863998]

 

Download simple_dcoeff2.mw

The above procedure K also finds any nonzero coefficient for z(x,y), if such a term is present. It's easy to adjust K if you'd prefer the [1,1] entry to always be identically 0.  Let me know.

And in your original Question you wrote, "first term in vector always for diff((y(x),x)". So your earlier examples' results omitted a coefficient of 0 for y(x) itself. It would be a simple adjustment to earlier procedure H, to include it. For example,

restart;

H := proc(ee::algebraic, f::function)
  local i,n,v;
  if nops(f)<>1 or (not op(1,f)::name) then
    error "second argument f is not a function of a name";
  else
    v := op(1,f);
  end if;
  n := PDEtools:-difforder(ee,v);
  < seq( frontend(coeff,[ee,diff(f,[v$i])]), i=0..n) >;
end proc:

z := f0(x)*y(x) + f2(x)*diff(y(x),x,x) + f4(x)*diff(y(x),x,x,x,x):

H(z, y(x));

_rtable[18446884076432032342]

 

Download simple_dcoeff3.mw

@manon22lr What is tensdBe[1,1] supposed to be? You seem to have omitted its definition. What is the derivative in your ode?

@Gillee You wrote, "The fix is to append datatype-float[8] to each of the Arrays" [within the followup example, which didn't use Statistics:-Sample].

Yes, that was the meaning of my previous three Replies.

Your Reply used the phrasing, "Lets determine the datatype of the first entry of dat". That phrasing and your ensuing methodology are technically invalid. Scalar objects (numeric values) do not have a "datatype". You can test them for various types but the word datatype in Maple is a technical term that applies to Vectors,Matrices, and Arrays but not to their entries if first extracted as scalar objects.

You should never use a word that is only a technical term as if it were a compound of non-technical terms. You should never refer to the "datatype" of a scalar as if you were referring to a particular type satisfied by a piece of data. Doing so unnecessarily confuses Maple technical terms with vernacular.

The Maple term datatype is different from the Maple term type. The term datatype refers to a restriction on rtables as to what they may contain.

Contrary to what your commentary suggested, it is not true that an Array would have a particular datatype just because an entry you extracted from it satisfies a particular type.

A := Array([17.0],datatype=float[8]);

                  A := [17.]

type(A[1], float[8]);

                    true

B := Array( [HFloat(17.)] );

                  B := [17.]

type(B[1], float[8]);

                    true

rtable_options(A, datatype);

                   float[8]

rtable_options(B, datatype);

                   anything

So you cannot "confirm" that the datatype of an Array is float[8] just because one of its extracted scalar entries satisfies a particular type. That simply does not follow, and the above is a counter-example.

I didn't write the original Question example, which used Array(1..100,SX(100)). In that example the result from SX(100) is a Vector[row] that has datatype=float[8].

The rtable constructors such as the Array command implement inheritance of hardware datatypes, unless dictated otherwise by the settings of UseHardwareFloats and Digits. So Array(1..100,SX(100) will inherit the same hardware datatype as SX(100).

restart;
X:=Statistics:-RandomVariable(Uniform(0,1)):
SX := Statistics:-Sample(X):
op(0,SX(100));

                 Vector[row]

rtable_options(SX(100), datatype);

                   float[8]

op(0, Array(1..100,SX(100)));

                    Array

rtable_options(Array(1..100,SX(100)), datatype);

                   float[8]

I do not know why the the Original Poster of the Question decide to cast each Vector[row] rtables from SX(100) into an Array. But he did. I simply wrote a compilable procedure that would accomodate that.

I would agree with the sentiment that it is confusing that the Help page for Statistics,Sample doesn't explain clearly what datatype the result will have (it only has an explanation of a special calling sequence, where one supplies the container for in-place computation).

@r66 But do you think that you had the equations correct, as you really did intend?

First 160 161 162 163 164 165 166 Last Page 162 of 595