acer

32627 Reputation

29 Badges

20 years, 45 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Carl Love My mistakes, sorry. Indeed it is a very nice group effort. I have edited the attribution.

@taro yamada Which method you prefer may be a matter of taste, or depend on other as yet unmentioned restrictions.

One weakness of the first approach below is that it presumes knowledge about the equation: which side is a sum of terms, and which not. So it's not robust for blind re-use on other examples, say where the lhs and rhs are interchanged.

restart:
g:=x->int(x,k=0..M):
equ:=p(k)=alpha-gamma*q(k):
g(lhs(equ))=map(g,rhs(equ));

            int(p(k), k = 0 .. M) = alpha M + (int(-gamma q(k), k = 0 .. M))

restart:
g:=x->int(x,k=0..M):
f:=x->`if`(x::`+`,map(g,x),g(x)):
equ:=p(k)=alpha-gamma*q(k):
map(f,equ);

            int(p(k), k = 0 .. M) = alpha M + (int(-gamma q(k), k = 0 .. M))

restart:
define(g,linear,g(x::anything)='int'(x,k=0..M));
equ:=p(k)=alpha-gamma*q(k):
map(g,equ);

             int(p(k), k = 0 .. M) = alpha M - gamma (int(q(k), k = 0 .. M))

It's often better to state up front the specifics of your actual problem.

@taro yamada My earlier `map2` example did match your original description, because you wrote originally that you wanted map(f, lhs(x2)) and so your g:=x->int(x,k=0..M) would get mapped over the operands of the function call p(k). So it now seems that you only want `f` mapped across sums. Is that right?

I mean, I'm not sure that I understand what you want done to the right hand side of `equ`.

Do you want something other than the following?

equ:=p(k)=alpha-gamma*q(k);

                      p(k) = alpha - gamma q(k)

map(int,equ,k=0..M);

      int(p(k), k = 0 .. M) = int(alpha - gamma q(k), k = 0 .. M)

Or do you want the integral of the rhs sum to become a sum of integrals?

@taro yamada The Maple specific term is operands, and the mapping is done over the operands of a set or of an equation.

op( {a, b, c} );
                            a, b, c

op( y = a + b );
                            y, a + b

The `map2` command provides a convenience, and allows a shorter syntax than, say,

map( dummy->map(f,dummy), y=a+b );

                       f(y) = f(a) + f(b)

What has happened here (and in that `map2` example), is that `map` itself is mapped over the operands of the equation.

@Markiyan Hirnyk The question of low a degree a polynomial may approximate (to within a specific tolerance) the given expression on 0..1 is interesting theoretically, because of some potential numerical difficulties at both end-points.

In practice so-called range reduction (which is really domain reduction) could be used. And this allows the target error of 0.01 to be met by using only the restricted domain or 1/2..1 while computing the polynomial, since the mathematical function has a symmetry of reflection about the point (1/2,Pi/4) even if it lacks symmetry by reflection across a line.

If we take p as,

p:=1.135971747717227*x+.1950071341939759+.4815612713662410*(4*x-3)^3
-2.439038982375010*(4*x-3)^4-12.66183100870810*(4*x-3)^5
+41.62555613174249*(4*x-3)^6+164.1652491121847*(4*x-3)^7
+975.5300610456691*(4*x-3)^22+1785.055305607627*(4*x-3)^23
+11358.38836456872*(4*x-3)^18+23013.15164101551*(4*x-3)^19
+26106.22796515134*(4*x-3)^15-14347.77165088372*(4*x-3)^16
-30967.64393191083*(4*x-3)^17+.1043967698939514*(4*x-3)^2
-359.5777009952230*(4*x-3)^8-1176.044314414133*(4*x-3)^9
+1804.767818275263*(4*x-3)^10+5127.986643910732*(4*x-3)^11
-5625.866345976549*(4*x-3)^12-14311.88358476918*(4*x-3)^13
+11225.66738216834*(4*x-3)^14-5070.302621042330*(4*x-3)^20
-9728.730684483163*(4*x-3)^21:

then I believe that arcsin(sqrt(x)) may be approximated to within 0.01 over the doman 0..1 by using the translation evalf((Pi/2)-eval(p,x=1-x),16) for x in 0..1/2.

With Maple 17,

restart:
with(numapprox):
e:=proc(x) Digits:=100; arcsin(sqrt(x)); end proc:
c:=chebpade(e,1/2..1,[23,0]):
Digits:=16:
p:=sort(eval(c(x),T=orthopoly[T]));
sol:=piecewise(x>=1/2,p,evalf(Pi/2)-eval(p,x=1-x)):

Finding the minimal degree polynomial in the Chebyshev basis that meets the target tolerance for even the restricted domain seems tricky if using `numapprox`, and that might be due in part to some hard-coded constants within the `evalf/int/ccquad` procedure. I wonder whether some integrations could be done with more manual control.

@Preben Alsholm Does this get an error better than 0.016? Is it about 0.01543?

.785398163397445*T(0, 2*x-1)+.638238282327978*T(1, 2*x-1)
+0.723739716042111e-1*T(3, 2*x-1)+0.271442813438863e-1*T(5, 2*x-1)
+0.147364292749009e-1*T(7, 2*x-1)+0.969627362219072e-2*T(9, 2*x-1)
+0.722513270043944e-2*T(11, 2*x-1)+0.590232940948517e-2*T(13, 2*x-1)
+0.519621737331440e-2*T(15, 2*x-1):

Or how about,

.78539816339744830960*T(0, 2*x-1)+.63823828232797760017*T(1, 2*x-1)
+0.72373971604211358200e-1*T(3, 2*x-1)+0.27144281343886350513e-1*T(5, 2*x-1)
+0.14736429274900909502e-1*T(7, 2*x-1)+0.96962736221907198717e-2*T(9, 2*x-1)
+0.72251327004394449383e-2*T(11, 2*x-1)+0.59023294094851786867e-2*T(13, 2*x-1):

which might do better than 0.015?

@Carl Love Ok, it seems that in Maple 17 the hue proc is getting passed a hardware float value (for the right end-point of the input range 0..1) which is slightly larger than 1.0, when the hue proc is run under evalhf (the default). This results in a negative value of very small magnitude being produced, and that seems to trigger a rescaling of all the computed hue data to fit the range 0..1.

So, another kludge to workaround the problem, for this particular example, might be to instead use something like,

   (x,y)-> abs(1-x)^Gamma/3

or

   (x,y)-> (1-min(1.0,x))^Gamma/3

as the hue proc.

I suppose that the input values for x are being produced by some formula involing the end points and the x-grid size, and that this is resulting in a roundoff problem such that the computed last value is not the same double-precision float as the end-point might be.

So, what changed between releases was the default grid size, which went from [25,25] to [49,49]. Using 40 for the x-component of the `grid` option reproduces the problem in Maple 14, 15, etc.

One can compare these two,

plot3d(0, 0..1, 0..1,
       color=[proc(x,y) eval(printf("%y\n",x)); (1-x)^1.0/3; end proc,
              (x,y)-> 1, (x,y)-> 1,
              colortype= HSV], grid=[39,2]);

plot3d(0, 0..1, 0..1,
       color=[proc(x,y) eval(printf("%y\n",x)); (1-x)^1.0/3; end proc,
              (x,y)-> 1, (x,y)-> 1,
              colortype= HSV], grid=[40,2]);

@Carl Love The problem seems to have been introduced between Maple 15.01 and 16.02. (I don't have 16.00 or 16.01 on hand to double check, right now.)

I suspect something to do with the `color` option procs running under evalhf. (Perhaps an exception not handled the same? I haven't dug in yet.) Making the hue proc be un-evalhf'able seems to get the expected result. Ie, since lists are not supported in evalhf,

   proc(x,y) []; (1-x)^Gamma/3 end proc

Perhaps another hint: grid=[39,40] does ok with the evalhf'able hue proc, but grid=[40,40] does not.

What exactly do you mean by, "math clickable popup"?

acer

How about just scaling the input and using custom tick marks?

acer

You added other suggestions to a list entitled 16+2, a year ago.

acer

@nicholasfbennett Yes, my answer was just to get your original design to work. I made the comment about having a checkbox instead of a button because I was guessing that what you really wanted was this other behaviour.

Here is a revised Document, with that check box idea.

Parabolascb.mw

Note that the action codee behind all 4 components (3 sliders and the checkbox) is exactly the same. You could make future editing easier if you defined a short procedure in the StartUp code of the Document which made this action. Then you could put just a single call to that procedure as the action for each component. This would centralize your code.

@Markiyan Hirnyk I think that the key issue is how can we get numerical roots out of a general RootOf. Or, perhaps more the point, how can we request that? The `evalf/RootOf` routine and its interoperation with `allvalues` is complicated. If there are infinitely many solutions then what might help is a better or new way to specify the request, eg. some way to request all roots within a finite range, or the ith root moving left/right from a particular starting points, etc. I think that your question raises some very important points about how Maple's functionality could be improved.

RootOf's can be utilized for some purposes other than this kind of numerical requests, so I don't quite see why difficulties with computing them should in itself bring into question the purpose of SolveTools[Engine].

How would you like the Sliders laid out?

As if you had repeatedly hit the Slider entry from the EmbeddedComponents palette? Ie, left to right in an input line?

Or, perhaps, laid out in a Table?

What should trigger the insertion? Some Button press, which reads the content of the TextArea component? Or a call of a procedure (of your authoring)?

acer

The short answer is... yes.

It's the weekend, sorry, and I won't be able to write a short procedure for it until this evening or tomorrow evening.

acer

First 366 367 368 369 370 371 372 Last Page 368 of 597