acer

32587 Reputation

29 Badges

20 years, 37 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Try,

[op(indets(mat,name))];

and if you have Pi, gamma, etc,

[op(indets(mat,name) minus {constants})];

acer

Did you forget a multiplication sign between (1-t) and the other terms?

...or, if in 2D Math input mode, a space between the (1-t) and other terms in order to denote multiplication implicitly?

With pairs of round bracketed terms side-by-side as in (y/A))(1-t) it gets parsed as function application y(1-t)/A(1-t) which contains unevaluated function calls to y and A with argument 1-t.

acer

It's possible that the integral isn't being computed accurately enough for fsolve (which is basing its own accuracy demand on the value of Digits). I'm not yet sure whether that's the issue. But this seems to work,

restart:
F := Int(sqrt((2.138+0.3e-2*exp((4.2^2-z^2)/d^2))^2-2.141^2), z=0 .. 4.2) = .5:
f:=unapply((lhs-rhs)(F),d):

#plot(f,2.0..6.0);

RootFinding:-NextZero(f,2.0);

                          3.957142935

acer

The proc T does not know the beta that you passed to g. Perhaps you meant to pass beta as a thrid argument to T.

Also, you may have intended the first conditional (the `and) to be different (missing a minus sign?).

Lastly, you might want to reduce the accuracy for the numerical integration, so that it succeeds across more values. You may have to play with that a bit...

restart;

Delta := proc(beta) options operator, arrow; sqrt(1-1/beta^2) end proc;

T := proc(`ε`, Z, beta) options operator, arrow;
 piecewise(`&epsilon;` < Delta(beta) and -Delta(beta) < `&epsilon;`,
 2*Delta(beta)^2/(`&epsilon;`^2+(Delta(beta)^2-`&epsilon;`^2)*(2*Z^2+1)^2),
 `&epsilon;` < -Delta(beta) or Delta(beta) < `&epsilon;`,
 2*abs(`&epsilon;`)/(abs(`&epsilon;`)+sqrt(`&epsilon;`^2-Delta(beta)^2)*(2*Z^2+1)))
end proc;

g := proc(V, Z, beta) options operator, arrow;
 1/(Int(T(`&epsilon;`, Z, beta)*beta*exp(beta*(`&epsilon;`-e*V))/
(exp(beta*(`&epsilon;`-e*V))+1)^2, `&epsilon;` = -infinity .. infinity,
 ':-epsilon'=1e-4, method = _NCrule)) end proc;

e := 1;

plot('g'(V, .1, 10), V = -4 .. 4);

acer

The attached worksheet tries a couple of methods to control output display size, but are not about PDF export per se.

scaleout1.mw

acer

You can use the Statistics:-Moment command.

You could do this starting with a random variable produced wih the RandomVariable command. But you mentioned getting there from the pdf, so let's start with that:

restart:
with(Statistics):

assume(sigma::real):
pdf:=(1/2)*2^(1/2)*exp(-(1/2)*(t-a)^2/sigma^4)/(Pi^(1/2)*sigma^2):

X:=Distribution(PDF=unapply( pdf, t )):

Moment(X,5);
                 5       3      4             8
                a  + 10 a  sigma  + 15 a sigma 

restart:
with(Statistics):

pdf:=(1/2)*2^(1/2)*exp(-(1/2)*(t-a)^2/sigma^4)/(Pi^(1/2)*sigma^2):

X:=Distribution(PDF=unapply( pdf, t )):

Moment(X,5):
simplify(%)  assuming sigma::real;

                 / 4       2      4           8\
               a \a  + 10 a  sigma  + 15 sigma /

acer

rtable(1..4,1..5,random(0..1),subtype=Array,datatype=float[8]);

                            [0.  0.  0.  0.  0.]
                            [                  ]
                            [1.  1.  1.  1.  0.]
                            [                  ]
                            [0.  1.  0.  0.  0.]
                            [                  ]
                            [1.  1.  0.  1.  1.]

rtable(1..4,1..5,random(0..1),subtype=Array,datatype=integer[1]);

                               [0  0  0  0  1]
                               [             ]
                               [0  0  0  1  0]
                               [             ]
                               [1  0  1  0  1]
                               [             ]
                               [0  1  1  0  1]

The integer[1] datatype will use the smallest amount of memory to store your huge Array.

If your huge Array is still too big to fit into memory then you could consider rewriting your program so that it only needed a chunk of it at any one time. In recent Maple versions the Statistics:-Sample command accepts an optional argument which is an rtable to be re-ued and re-populated with data. In this way you can use a great many input values while only ever needing to store a smaller amount of input values at any given time (keeping total allocation lower). Eg,

restart:
with(Statistics):

m:=Vector[row](1..6,datatype=float[8]):  # the re-usable container

X:=RandomVariable(EmpiricalDistribution([0,1])):

for i from 1 to 3 do
  # first, re-populate rtable `m`
  Sample(X,m);
  # now `m` is ready to re-use, and has fresh values
  print(m);
end do:
                          [1., 1., 0., 1., 1., 0.]
                          [0., 1., 1., 1., 0., 1.]
                          [1., 0., 1., 0., 0., 1.]

acer

Q: "Does it really means that there are 32950 digits between the two parts of the expression?"
A: Yes.

You can get the number of digits in a various ways. For positive integer `x` you could try length(x) or something like  ceil(log[10](x*1.0)) but you should probably test those first smaller values.

If you really want to print out all the digits then you could lineprint them (without special 2D Math output typesetting) using the `lprint` command, or if you feel brave you could try and bump up the Standard GUI's term elision threshold. But be warned that both of those (lprint, less so) can drive the Standard GUI into a nearly inoperable state. You should be able to change the term elision threshold using either the main menubar's Tools>Options (and choosing the "Precision" tab in the pop-up window) or the `interface` command.

Another possibility, for printing out a posint with bery many digits, might be to use the `writeto` command to remporarily redirect output to a plainttext file.

acer

solve(identity(a*x+b*y=2*x+5*y,x),[a,b]);

                                 [[a = 2, b = 5]]

acer

The limits as you approach A3(3) from each side are +infinity and -infinity. Which result you get, as you compute in floating-point, might depend upon the working precision (Digits) due to numerical error.

restart:
alpha_p:=1: p:=2: mu0:=4*Pi*1e-7: Br:=1.12:

A1:=unapply(sin((n*p+1)*alpha_p*Pi/(2*p))/((n*p+1)*alpha_p*Pi/(2*p)),n):

A2:=unapply(sin((n*p-1)*alpha_p*Pi/(2*p))/((n*p-1)*alpha_p*Pi/(2*p)),n):

M1:=unapply((Br/mu0)*alpha_p*(A1(n)+A2(n)),n):

M2:=unapply((Br/mu0)*alpha_p*(A1(n)-A2(n)),n):

M3:=unapply(M1(n)+n*p*M2(n),n):

A3:=unapply(((n*p-1/(n*p))*M1(n)/M3(n)+1/(n*p)),n):
evalhf(A3(3));
                                         15
                     4.595173115007179 10  
A3c:=Compiler:-Compile(A3):
A3c(3);
                                         15
                     5.514207738008614 10  
for i from 10 to 20 do
  Digits:=i;
  q:=A3(3.0):
  printf("\nDigits: %ld   evalf(A3(3)): %e\n",Digits,evalf(q));
end do:

Digits: 10   evalf(A3(3)): -2.292637e+09

Digits: 11   evalf(A3(3)): -1.604846e+11

Digits: 12   evalf(A3(3)): -8.024228e+11

Digits: 13   evalf(A3(3)): -2.292637e+12

Digits: 14   evalf(A3(3)): -2.292637e+13

Digits: 15   evalf(A3(3)): 2.674743e+14

Digits: 16   evalf(A3(3)): 1.458951e+15

Digits: 17   evalf(A3(3)): 1.604846e+16

Digits: 18   evalf(A3(3)): -4.012114e+17

Digits: 19   evalf(A3(3)): 1.783162e+18

Digits: 20   evalf(A3(3)): -3.209691e+19

A3(3);
                                     (1/2)    
                    Float(infinity) 2        1
                  - ---------------------- + -
                               2             6
                             Pi               

limit(A3(x),x=3,left);
                        Float(infinity)

limit(A3(x),x=3,right);
                        -Float(infinity)

plot(A3, 2.5..3.5);

acer

What is the value for (D@D)(f)(0) ? Is it known, as an initial condition at eta=0? Or, might you want to have it be treated as another parameter?

d2f0.mw

acer

The question asked for integer solutions so, while 0 is not allowed (due to division) and -1 is not allowed to forbid 0=2, other negative values are ok?

> restart:
> e:=(1 + 1/x)*(1 + 1/y)*(1 + 1/z) = 2:               

> simplify((rhs-lhs)(expand(eval(e,[x=1,y=-z-1])/2)));
                                       0

So for x=1 then all y=-z-1 are ok, except of course {y=0,z=-1} and {z=0,y=-1}.

In a somewhat simiular way, if a=x+1 (and a<>0 and a<>1 due to restrictions on x) then for any other integer a we want integer solutions for y and z in,

> solve((rhs-lhs)(eval(expand(e),x=a-1)),y):

> y=numer(%)/collect(denom(%),z);           
                                     a (z + 1)
                               y = -------------
                                   (a - 2) z - a

But I don't know anything better to do with that than pump in a=2,3,4,...

acer

Note that even 'linear' alone would not give phi(a+x) -> phi(a) + phi(x) if `a` is unassigned. [edit: oops, not what I intended to convey. see followup below]

Also, not that map(phi,x) evaluates to phi(x) under Maple's normal mode of evaluating arguments of a procedure call. The single right-quotes used below delay this.

> restart:

> define('phi',phi(sigma)=sigma,phi(x::{`*`,`+`})='map'(phi,x));

> phi(a*y*sigma*z);                                             

                          phi(a) phi(y) sigma phi(z)

> phi(a+y+sigma+z);

                       phi(a) + phi(y) + sigma + phi(z)

I'm not sure that I understand the behaviour you want. For unassigned `a` and `z` what do you want phi(a+z) to do? And phi(a+4*sigma+z)? [edit: oops, not what I intended to ask. see followup below]

acer

normal((3*h^2+12*h)/h);

                                           3 h + 12

acer

V:=Vector[row](8,(i)->i);

                        V := [1, 2, 3, 4, 5, 6, 7, 8]

with(ArrayTools):

m1:=Reshape(V,[2,4]);

                                   [1  3  5  7]
                             m1 := [          ]
                                   [2  4  6  8]

m2:=Alias(V,[2,4]);

                                   [1  3  5  7]
                             m2 := [          ]
                                   [2  4  6  8]

V[3]:=17:

m1[1,2]; # V and m1 do not share data

                                      3

m2[1,2]; # the difference, V and m2 share data

                                     17

whattype(m1), whattype(m2);

                               Matrix, Matrix

acer

First 259 260 261 262 263 264 265 Last Page 261 of 338