Carl Love

Carl Love

28070 Reputation

25 Badges

13 years, 33 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@awass The quotation marks that you used in this line:

  • Cmnts:= “if time goes by then a=2.1” ;

are not normal ASCII characters. They are not the double quotation marks that I was referring to. The correct double quotation marks have numeric value 34, that is, the 7-bit sequence is 0100010. And it must be the same character at the beginning and end of the string.

It's perfectly legal to have non-ASCII characters inside strings and names, but they can't be the delimiters. Indeed, I recently worked on a package where all the internally generated variable names (such as variables of integration) were Chinese characters. The GUIs (including the command-line interface) and most standard text editors handle them just fine.

 


 

@awass 

There are three types of quotation marks in Maple. All are always used in pairs.

  1. The double quote ": These are used to make strings.
  2. The single backward quote `: These are used to make names, which are very similar to strings.
  3. The single forward quote ': These are to prevent or delay the evaluation of expressions. The usage of these is quite subtle, and often frustrating and mind-boggling, especially when multiple pairs are used.

From your description of the problem, I can only imagine that you are using two pairs of single forward quotes (#3 above). If you are using #1 or #2, there should be no problem.

Regarding the storage of true comments: There is a way that was introduced in Maple 2017 (the most-recent version). If that's what you're using, I'll look it up.

@Joe Riel Thanks for the information about objects and modules. So, it'd be more germane to say that a module is simply a container of persistent local variables rather than that it's a procedure with persistent local variables, right?

I have a question about illegal use of keyword static, and this seems like a good place to ask it. Consider this variation of your Incrementer object:

Incrementer3:= module()
option object;
local 
   cnt:= 0,
   ModuleCopy::static:= proc(self::Incrementer)
      self:-cnt:= 0;
   end proc,
   ModuleApply::static:= proc()
      cnt:= cnt + 1;
   end proc
;
end module:

Based on your explanation of static above, I understand why static can't be used with the ModuleApply. My question is Why isn't the illegal usage detected by the syntax checker? The error message doesn't come until you actually try to use the module.

@maxburakho Your system of equations is linear and nonsingular. For such a system, Newton's method is guaranteed to converge to the exact solution in a single iteration. Newton's method involves solving a system of linear equations at each iteration. If the original equations are linear, that's the linear system that's solved anyway.

@Earl 
 

1. Any number can be used as an operator that returns that number:

2.5(x);

2.5

(1)

2(x);

2

(2)

2. Operators can be combined with symbol operators to form new operators:

SetTo0:= lhs-rhs = 0:

SetTo0(x^2 = y^2);

x^2-y^2 = 0

(3)

(lhs-rhs = 0)(x^2 = y^2);

x^2-y^2 = 0

(4)

3. An operator can be used as the first argument to fsolve. This tells fsolve to search for an argument for that operator which would make the operator return 0, or close to it.

fsolve(sin, -1..1);

0.

(5)

fsolve(sin, 3..4);

3.141592654

(6)

fsolve(sin-1, 1..2);

1.570796327

(7)

 

Download Operators.mw

Does that answer your question?

@lucaud The last thing in my already-posted Answer is the triple integral in cartesian coordinates for the volume. Is this not what you need? In set notation (which doesn't have much practical value in Maple), the volume can be described as

{(x,y,z)  in R^3 | -sqrt(1-y^2) <= z <= sqrt(1-y^2), -sqrt(1-x^2) <= y <= sqrt(1-x^2), -1 <= x <= 1}

OMG, I was wrong. Thanks for setting me straight. For positive b, or abs(b), the parabola's vertex and maximum is in the first quadrant.

@Kitonum The points G and H in the original diagram are part of the boundary of the convex hull, but they are not wanted by the OP.

For real b, maximize((b-x)*x, x) is b^2/4, but adding the domain restriction x >= 0 changes that! The maximum of ((abs(b)-x)*x) on x= 0..infinity is easily seen to be 0 because the parabola's vertex is in the second quadrant and the parabola passes through the origin. Unfortunately, Maple's maximize doesn't understand this:

maximize((abs(b)-x)*x, x= 0..infinity) assuming b::real;

returns unevaluated.

I don't fully understand your actual practical problem. In particular, I don't know if it has symbolic constants (such as the b above). If the constants have numeric values, I think that you can solve the problem with Optimization:-QPSolve.

Awesome! It hadn't occurred to me that morphing polygons would be so easy.

@vv I didn't mean to imply that extending to rational functions would involve simply changing A to rational functions. You need to multiply each row by the LCM (or just the product) of its denominators, make an estimate for the upper bound of the degree of the determinant of the new matrix (you can use the sum of the max of the degrees in each row), compute the determinant by the present process (with the number of imaging points determined by that degree estimate), and divide the result by the product of the LCMs.

@Rouben Rostamian  Yet the following shows how to using imaging and interpolation to compute the determinant of a 170 x 170 dense matrix of linear univariate polynomials with integer coefficients in 40 seconds:

restart:
n:= 170:
A:= LinearAlgebra:-RandomMatrix((n$2), generator= (()-> randpoly(x, degree= 1))):
Af:= (x::integer)-> rtable(eval(A, :-x= x), datatype= integer):
DET1:= CodeTools:-Usage(
   CurveFitting:-PolynomialInterpolation(
      [seq([k,LinearAlgebra:-Determinant(Af(k))], k= -iquo(n,2)..iquo(n,2)+1)],
      x
   )
):

memory used=0.82GiB, alloc change=48.03MiB, cpu time=39.88s, real time=40.29s, gc time=218.75ms

This can be easily distributed over multiple cores, like this (my present machine has 4 cores):

save DET1, `DET1.m`: #So we can compare results.
restart:
n:= 170:
A:= LinearAlgebra:-RandomMatrix((n$2), generator= (()-> randpoly(x, degree= 1))):
DET2:= CodeTools:-Usage(
   CurveFitting:-PolynomialInterpolation(
      [Grid:-Seq['tasksize'= 1](
         [k, LinearAlgebra:-Determinant(rtable(eval(A, x= k), datatype= integer))], 
         k= -iquo(n,2)..iquo(n,2)+1)
      ], x
   )
):

memory used=23.61MiB, alloc change=0 bytes, cpu time=1.02s, real time=18.02s, gc time=625.00ms

(That "memory used" and "cpu time" must only be measured for the master process, but the "real time" is real.)

read `DET1.m`:
evalb(DET1 = DET2);

     true

Extending this idea to A's entries being univariate rational functions with rational coefficients is not significantly more complicated.

This is essentially Rouben's method, but using only one line of code after the solve:

((F,B)-> eval(B, lhs~(F) =~ 0))(selectremove(evalb, sol_full));

 

Please post that code in plaintext so that I can copy-and-paste it. If you copy-and-paste directly from Maple to MaplePrimes, and you don't select "as image", that should do it.

@grzybs It's unfortunate that the conversion of a definite iterated integral to a different coordinate system requires several meticulous steps.

First 350 351 352 353 354 355 356 Last Page 352 of 709