Carl Love

Carl Love

28155 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@hopereza 

The problem is not with map. As you yourself show in the worksheet, the same error ensues when you try to apply int to an individual array element. What you have found is a bug in the symbolic integration of some functions of the form exp(a*x)*R(x) where R(x) is a rational function. You can get around this by forcing numeric rather than symbolic integration. You do this by replacing

map(int, ...);

with

map(evalf @ IntegrationTools:-Expand @ Int, ...);

Note the capital I in Int. Since you have so many floating-point coefficients, you may improve accuracy if you replace the other, currently working, integration likewise. The error control in Maple's numeric integration is very good.

I see that you tried to use evalm in your code. This command has no use in modern Maple. It is only present so that legacy code continues to work. Please don't ever use it.

 

@hopereza Please post a worksheet where it doesn't work. 

@digerdiga 

plot(Product(1 - q^(5*k+1), k= 0..infinity), q= -1..1);

@Markiyan Hirnyk It seems that `#mn(01)` prettyprints the same as `#mn("01")`, but it is easier to type.

@itsme 

It's a good solution, but it should be noted that

1. The double underscore produces a result that prettyprints the same as an indexed name but which acts programmatically like a symbol, an unindexed name.

2. mu__01 prettyprints the same as mu[`01`], with the 01 in italics. mu[`#mn(01)`] prints with the 01 normal, upright.

@hopereza 

Hmm, the tilde is not working in your worksheet. I don't understand why yet. But I tried this in your worksheet, and it definitely works:

map(int, Phi^%T*f, x= 0..1);

@Markiyan Hirnyk I converted your Reply to an Answer and gave it a vote up. I think that your solution is better than mine.

@Rouben Rostamian  ScalarMultiply multiplies a Matrix or Vector (its first argument) by a scalar (its second argument) according to ?ScalarMultiply.

@itsme In Maple 18, I find no command named Grid:-Set. There is a Grid:-Setup, but this does not seem to have anything to do with copying memory.

@smith_alpha 

C:= ImportMatrix(
     "C:/Users/Carl/Desktop/Matrix.txt",
     skiplines= 1, source= delimited, delimiter= " ", transpose
);

@mthkvv Threads has no problem with trivial operations. In the case of Grid, the entire memory space must be copied to each process, plus a new kernel has to be created.

@smith_alpha 

Read the first line with 

Z:= fscanf(filename, "%d")[];

Technically, the whole file can be read with fscanf because there are scan codes for matrices. But it'll be easier to use ImportMatrix, which just constructs the correct fscanf command for you.

@ 

You wrote:

If Maple solves with rkf45dae it probaly means that is solves dy/dt =f with algebraic equations may be as a constraint.

That is not the understanding that I get from the help page ?dsolve,numeric,DAE_extension. In particular, it explicitly says that the systems can be partially implicit.

Patient, convert all of your equations to dy/dt =f .

That doesn't appear to be possible for this system.

If needed differentiate the algebraic equations,

Patient's system doesn't have any algebraic equations. Nonetheless, it seems to require a DAE solver because of its implicit nature. It is possible that another of Maple's IVP solvers can handle it. I haven't tried yet.

If some one posts *.mws worksheet that works, I will try. ( or at least in that format, 1D math)

The worksheets posted so far in this thread have been in 1D form.

@acer 

Thanks, Acer. Using option threadsafe and using eval to run compiled code inside evalhf were the things that I didn't know about. I made the outer, recursive procedure evalhfable with your suggestion of passing the arguments in an Array and I declared most arguments of the inner, compiled procedure as float. (This was much much faster than the default integer arguments.) With these changes, I made a factor-of-three improvement of your version, coming in at just under six minutes. And I got 100% processor utilization (M18/64 on Windows 8/64). I am curious if you can get 100% utilization on Linux with this. (I also had a version where I only got 65% utilization.) The worksheet is attached.

Note that I was able to use ceil in the compiled code without any threadsafe issues. It makes sense since the compiled C code should be using a completely different ceil. I'd still like to know how evalhf has threadsafe issues when using ceil.

One thing that was a disaster was trying to have one compiled procedure call another compile procedure. In particular, I compiled a version of Ceil, and ran it in parallel. I used threadsafe in both (and they truly were threadsafe). The execution deadlocked immediately: No processor usage, no memory comsumption, no way to kill the program other than killing the kernel. In another case, I didn't use threadsafe in either. This code executed correctly, but much slower than if I had just used uncompiled Maple. So, do you know anything about one compiled procedure calling another?

Download LatticeCountmodif4f.mw

My algorithm is incorrect. (It has a fundamental flaw, not just an error in coding.) The one posted by Kitonum in a separate Post is correct and much faster. So this is probably a moot point. Still, I learned a lot about making programs faster and was able to combine three of the major techniques (evalhf, Compile, and Threads) into one short program.

@momoklala 

One problem is the B in Eq1. It should be B*. The way it is now makes it a function rather than a coefficient. However, making this change, I still don't get what your instructor got. You may still be entering parts of Eq1 incorrectly. Perhaps you should post the original statement of the problem.

First 488 489 490 491 492 493 494 Last Page 490 of 711