Carl Love

Carl Love

28025 Reputation

25 Badges

12 years, 311 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

Are the time values evenly spaced?

@Carl Love I should add that the functional way is not always the best way to plot a numeric integration. It can prevent Maple from being able to choose the most efficient numeric algorithm. In particular, if you have an analytic expression for the integrand, then you should not use a procedure as the integrand. You can do this:

plot(z-> Int(x-floor(x), x= 0..z), -4..4);

Jay's method of solving a differential equation and using DEplot is also a fine idea when the plotting variable is one of the limits of integration. But if the plotting variable appears as a parameter in the integrand, that can be difficult or impossible to implement.

@Carl Love I should add that the functional way is not always the best way to plot a numeric integration. It can prevent Maple from being able to choose the most efficient numeric algorithm. In particular, if you have an analytic expression for the integrand, then you should not use a procedure as the integrand. You can do this:

plot(z-> Int(x-floor(x), x= 0..z), -4..4);

Jay's method of solving a differential equation and using DEplot is also a fine idea when the plotting variable is one of the limits of integration. But if the plotting variable appears as a parameter in the integrand, that can be difficult or impossible to implement.

@N00bstyle 

[] means "take the brackets off of a set or list".

So, if L = [a,b,c], then L[] = a,b,c.

Let's go through how the parser interprets rhs(test[2][]). Index expressions associate to the left (*footnote), so the first thing is test[2]. That means the second item of list test. That item is itself a list. The [] means "take the brackets off that", leaving the equation t = number. Then the rhs selects number. In the case of test[2][1], it means "take the second item, then take the first item of that". It could also be expressed test[2,1].

*footnote: "Associates to the left" means that test[2][] is parsed the same as (test[2])[] and not as test([2][]).

Is that a sufficient explanantion?

@N00bstyle 

[] means "take the brackets off of a set or list".

So, if L = [a,b,c], then L[] = a,b,c.

Let's go through how the parser interprets rhs(test[2][]). Index expressions associate to the left (*footnote), so the first thing is test[2]. That means the second item of list test. That item is itself a list. The [] means "take the brackets off that", leaving the equation t = number. Then the rhs selects number. In the case of test[2][1], it means "take the second item, then take the first item of that". It could also be expressed test[2,1].

*footnote: "Associates to the left" means that test[2][] is parsed the same as (test[2])[] and not as test([2][]).

Is that a sufficient explanantion?

@tobsam Please post your worksheet.

@Markiyan Hirnyk Your timings and memory data are confounded by the fact that simplify is using remember tables. Here's a more accurate comparison:

(**)

f:= x^5+a*x^4+b*x^3+c*x^2+d*x+e:

(**)

st:= time():
to 10^4 do
     simplify(f, {x^3=1});
     forget(simplify)
end do:
time()-st;

7.831

(**)

st:= time():
to 10^4 do
     algsubs(x^3=1, f);
     forget(algsubs)
end do:
time()-st;

14.555

(**)

st:= time():
to 10^4 do
     rem(f, x^3-1, x);
     forget(rem)
end do:
time()-st;

7.675

(**)

macro(CTU= CodeTools:-Usage):

(**)

CTU(simplify(f, {x^3-1}));

memory used=12.90KiB, alloc change=0 bytes, cpu time=0ns, real time=0ns

e+b+(a+d)*x+(c+1)*x^2

(**)

CTU(algsubs(x^3=1, f));

memory used=34.76KiB, alloc change=0 bytes, cpu time=0ns, real time=1000.00us

e+b+(a+d)*x+(c+1)*x^2

(**)

CTU(rem(f, x^3-1, x));

memory used=18.67KiB, alloc change=0 bytes, cpu time=0ns, real time=0ns

e+b+(a+d)*x+(c+1)*x^2

(**)

 

 

Download algsubs_vs_rem.mw

 

@Markiyan Hirnyk Your timings and memory data are confounded by the fact that simplify is using remember tables. Here's a more accurate comparison:


(**)

f:= x^5+a*x^4+b*x^3+c*x^2+d*x+e:

(**)

st:= time():
to 10^4 do
     simplify(f, {x^3=1});
     forget(simplify)
end do:
time()-st;

11.031

(**)

st:= time():
to 10^4 do
     algsubs(x^3=1, f);
     forget(algsubs)
end do:
time()-st;

17.766

(**)

st:= time():
to 10^4 do
     rem(f, x^3-1, x);
     forget(rem)
end do:
time()-st;

10.562

(**)

macro(CTU= CodeTools:-Usage):

(**)

CTU(simplify(f, {x^3-1}));

memory used=12.90KiB, alloc change=0 bytes, cpu time=0ns, real time=0ns

(c+1)*x^2+(a+d)*x+b+e

(**)

CTU(algsubs(x^3=1, f));

memory used=34.76KiB, alloc change=0 bytes, cpu time=0ns, real time=1000.00us

(c+1)*x^2+(a+d)*x+b+e

(**)

CTU(rem(f, x^3-1, x));

memory used=18.67KiB, alloc change=0 bytes, cpu time=0ns, real time=0ns

(c+1)*x^2+(a+d)*x+b+e

(**)

 


Download algsubs_vs_rem.mw

@Xucu Sorry, I have no ideas about your problem.

Why not just do two substitutions, one to get rid of the W[n](t) and the other to get rid of the A?

 

pdsolve(..., numeric) is very fussy about how you put the extra equations into the system, much more so than dsolve. I can't describe precisely what makes it work; I need to play with it. So, you should post your system and say which second derivative you want.

This is with Digits = 15, and all dsolve options (other than method, of course) at their defaults.

Method     digits of accuracy

adaptive
methods

dverk78            5
taylorseries       4
rosenbrock        2
ck45                1
gear                 1
rkf45                0
mebdfi              0
lsode               -3

classical
methods

rk4                    7 (!!!)
abmoulton          6  (!!)
adambash           6 (!!)
impoly                4
rk3                    4
rk2                    4
foreuler              0

For the lsode, my -3 means that the answer was wrong by three orders of magnitude!

Can anyone explain why these classical fixed-step-size methods with no modern error control fare so much better? Could it be that they are using a very small stepsize?

This is with Digits = 15, and all dsolve options (other than method, of course) at their defaults.

Method     digits of accuracy

adaptive
methods

dverk78            5
taylorseries       4
rosenbrock        2
ck45                1
gear                 1
rkf45                0
mebdfi              0
lsode               -3

classical
methods

rk4                    7 (!!!)
abmoulton          6  (!!)
adambash           6 (!!)
impoly                4
rk3                    4
rk2                    4
foreuler              0

For the lsode, my -3 means that the answer was wrong by three orders of magnitude!

Can anyone explain why these classical fixed-step-size methods with no modern error control fare so much better? Could it be that they are using a very small stepsize?

Unfortunately, those tags don't survive editing. To make the example below, I edited your post, cut the whole thing, cancelled the edit, then pasted it into this post. Notice that although the formatting stays the same, the tags are gone.

Example:

i noticed members use such tags in their post very rarely in mapleprimes

and i am confused whether ?

there is a list of special html tags that are supported in "HTML Source Editor" of mapleprimes

that are compatible with it ? or all tags described in html5 or html4 are compatible ?

i just tested a few of those tags and they work excellent ...

i used these tags from wikipedia

 ascii art 
  (\=,   
 //  .\  
(( \_  \ 
 ))  `\_)
(/     \ 
 | _.-'| 
  )___(  
 (=====) 
 }====={ 
(_______)

text

text

 

@jaytreiman wrote:

Why does this example do any numerical integration?

Using capital I guarantees that it will use numeric integration, even if it knows the antiderivative. You can verify that it is using numeric integration by setting infolevel[evalf]:= 1 (or higher).

You are still using a function that has an antiderivative that is known to Maple.

It is not known to my version of Maple (17.01). Notice the double exponential: exp(-exp(x^2)). If you can get Maple to produce an antiderivative for that, I'd like to see it.

Since Maple usually tries to evaluate the function to be plotted before any plotting is done, I do not see the difference.

Under the normal evaluation rules, capital I Int is just a dummy function---just a name. It remains unevaluated. You can verify this by entering eval(Int) and seeing that there is no procedure or module by that name. It is only when evalf or value is applied to it that anything happens.

Your method works without the Int.  You can use int instead.

That is true. But with int it will waste time trying to find an antiderivative. It is not much time in this particular case, but could be a substantial amount of time for other integrands. If you know that you want numeric integration, you should use Int from the start. There are also cases where int won't work---it will cause an error---such as when the integrand involves a call to fsolve, a common situation.

 

 

 

First 632 633 634 635 636 637 638 Last Page 634 of 708