Joe Riel

9660 Reputation

23 Badges

20 years, 17 days

MaplePrimes Activity


These are replies submitted by Joe Riel

Maple can handle an endpoint of an integral with a variable identical to the (dummy) variable of integration.  So

y := int(-(2/3)*exp(4*t)/(exp(4*t)+t), t=t..0); 

is permissible and usually behaves as you would like. You can even use eval on such an (unevaluated) expression to change the endpoint, eval is smart enough not to change the dummy variable.  That isn't the case with subs, which is purely syntactic.
 

Maple can handle an endpoint of an integral with a variable identical to the (dummy) variable of integration.  So

y := int(-(2/3)*exp(4*t)/(exp(4*t)+t), t=t..0); 

is permissible and usually behaves as you would like. You can even use eval on such an (unevaluated) expression to change the endpoint, eval is smart enough not to change the dummy variable.  That isn't the case with subs, which is purely syntactic.
 

You could use ImageTools:-Entropy to do this computation. For example,
 

M := LinearAlgebra:-RandomMatrix(100,density=1,generator=0..1.0): 
Img := ImageTools:-Create(M):                                    
ImageTools:-Entropy(Img);                                        
                                  7.982864178

He has been posting recently; sporadically.

He has been posting recently; sporadically.

Use exp(x), not exp(1)^x (though Maple handles either form with this integral).  However, exp(x) is not, in general, the same as exp(1)^x. 

 int(exp(-q^2*x^2),x);
                                    1/2
                                  Pi    erf(q x)
                              1/2 --------------
                                        q

Use exp(x), not exp(1)^x (though Maple handles either form with this integral).  However, exp(x) is not, in general, the same as exp(1)^x. 

 int(exp(-q^2*x^2),x);
                                    1/2
                                  Pi    erf(q x)
                              1/2 --------------
                                        q

An efficient way to do that is to store the intermediate results in a table, and then convert the table to a list:

T := table():
T[0] := 1.:
for i to 20 do
    T[i] := exp(-T[i-1]/2);
end do:
convert(T, 'list');

An efficient way to do that is to store the intermediate results in a table, and then convert the table to a list:

T := table():
T[0] := 1.:
for i to 20 do
    T[i] := exp(-T[i-1]/2);
end do:
convert(T, 'list');

The DifferentialGeometry package can be effectively used here, however, that doesn't help with the reparametrization of the domain, which is Jacques' issue (here it is trivial):

with(DifferentialGeometry):
DGsetup([x,y], R2):
DGsetup([r,theta],P2):
phi := Transformation(P2,R2,[x=r*cos(theta),y=r*sin(theta)]):
alpha := exp(-x^2-y^2)*dx &wedge dy;
                                       2    2
                        alpha := exp(-x  - y ) dx ^ dy

beta  := Pullback(phi, alpha);
                                      2
                        beta := exp(-r ) r dr ^ dtheta

IntegrateForm(beta, r=0..infinity, theta=0..2*Pi);
                                      Pi

Here's another variation, which is more clearly done in a few steps, though of course it can be done in one:

iter := `/`@sqrt@exp:
iter20 := iter@@20:
iter20(1.); 
                            0.7034674229

Using the original form, this can be done as

iter := x -> exp(-x/2):
iter20 := iter@@20:
iter20(1.);
                            0.7034674227

I expect (and have verified for x=1.) that the iterator exp(-x/2) is "more accurate" than 1/sqrt(exp(x)).

While foldl is quite useful in its own right, it really isn't warranted here (it composes a binary function rather than a unary function).  Note that the function `/` is n-ary; here it is being used as a unary function (inversion).

Here's another variation, which is more clearly done in a few steps, though of course it can be done in one:

iter := `/`@sqrt@exp:
iter20 := iter@@20:
iter20(1.); 
                            0.7034674229

Using the original form, this can be done as

iter := x -> exp(-x/2):
iter20 := iter@@20:
iter20(1.);
                            0.7034674227

I expect (and have verified for x=1.) that the iterator exp(-x/2) is "more accurate" than 1/sqrt(exp(x)).

While foldl is quite useful in its own right, it really isn't warranted here (it composes a binary function rather than a unary function).  Note that the function `/` is n-ary; here it is being used as a unary function (inversion).

We can use foldl here to do this in one line

foldl(x->exp(-x/2),1.$20);
                                 0.7034674218

More amusingly, as

foldl(exp@curry(`*`,-1/2),1.$20);
                                 0.7034674218
or even

foldl(1/sqrt@exp@(()->args[1]),1.$20);

Here's a ridiculous method:

 `@`(seq('`/`,sqrt,exp',i=1..20))(1.);
                                 0.7034674229

The slightly different answer is because the previous versions, uses foldl, actually do only 19 iterations.

We can use foldl here to do this in one line

foldl(x->exp(-x/2),1.$20);
                                 0.7034674218

More amusingly, as

foldl(exp@curry(`*`,-1/2),1.$20);
                                 0.7034674218
or even

foldl(1/sqrt@exp@(()->args[1]),1.$20);

Here's a ridiculous method:

 `@`(seq('`/`,sqrt,exp',i=1..20))(1.);
                                 0.7034674229

The slightly different answer is because the previous versions, uses foldl, actually do only 19 iterations.

> a:=(3+4*i)/(7-6*i);
                                      3 + 4 i
                                 a := -------
                                      7 - 6 i

> b:=simplify(a);
                                       3 + 4 i
                                b := - --------
                                       -7 + 6 i

> scalefrac(b,-1);
                                    3 + 4 i
                                    -------
                                    7 - 6 i


First 140 141 142 143 144 145 146 Last Page 142 of 195