2713 Reputation

9 Badges

1 years, 332 days

MaplePrimes Activity

These are answers submitted by vv

I think that readstat being  an I/O command, it may need time to complete before calling it again.
Inserting some Sleeps makes it work.
dt depends on the speed of the computer.

fun:=proc(n)  local a, b, i, x;
a:=readstat("insert a");
b:=readstat("insert b");
for i to n do
x[i]:=readstat("insert x");
end proc:


sqrt (the principal branch) is af course well defined, the branch cut is arbitrary (-oo,0); it could be any "arc" from 0 to oo.

But it is possible to define a custom sqrt. Here is one with a branch cut along negative imaginary axis.

mysqrt:=z -> piecewise(argument(z)>-Pi/2,sqrt(z),-sqrt(z)):


limit(mysqrt(-1-t*I), t=0, left), limit(mysqrt(-1-t*I), t=0, right); #continuous
                              I, I
limit(sqrt(-1-t*I), t=0, left), limit(sqrt(-1-t*I), t=0, right);     #discontinuous
                             I, -I
limit(mysqrt(-I-t), t=0, left), limit(mysqrt(-I-t), t=0, right);     #discontinuous

limit(sqrt(-I-t), t=0, left), limit(sqrt(-I-t), t=0, right);        #continuous        

(1/2)*sqrt(2)-I*sqrt(2)*(1/2), (1/2)*sqrt(2)-I*sqrt(2)*(1/2)

simplify(convert(z, arcsin)) assuming x>-a,x<a;

works in Maple 2017.



X := RandomVariable(Normal(0,1)):

f:=t->PDF(X, t);

proc (t) options operator, arrow; Statistics:-PDF(X, t) end proc





L:= unapply( int( (t-z)*f(t) , t=z..infinity), z ); # (unit) loss function

proc (z) options operator, arrow; (1/2)*(z*Pi^(1/2)*erf((1/2)*z*2^(1/2))+2^(1/2)*exp(-(1/2)*z^2)-z*Pi^(1/2))/Pi^(1/2) end proc


plot(L, 0..3.5);


fsolve(L(z)=1/5, z);



Download loss.mw

Compilable procedures are very restrictive. See ?compile.

- Arrays can only appear as parameters of a procedure and must have datatype=float or integer
- No symbolics; for example (in your case) int(...), orthopoly[...](...)  are out of the question. Also W(...) is not allowed.



The symbol O has nothing special, except it is protected,  to prevent it from being modified.

letters:=map(convert,[seq("A".."Z"), seq("a".."z")], symbol);
    letters := [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R,  S, T, U, V, W, X, Y, Z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z]
select(type, letters, protected);
[D, O]

Edit. The symbol I (the imaginary unit) is a special one, not detected above.



It is strange that convert(...,tanh) does not work as expected.
For example, convert(sinh(x), tanh)  works but convert(exp(x), tanh) does not.

  simplify(eval(ex, exp = (t -> (tanh(t/2)+1)/(1-tanh(t/2)))))






PerfectRandom := proc()
  return 4  # Chosen by fair dice roll, guaranteed to be random
end proc:



Output:=Array(-10..10,-10..10, (i,j)->i^2+j^2):

Let f be a real function defined on [a,b].

If f has an antiderivative F (on [a,b]) then F is by definition differentiable, hence continuous.
But f could have infinitely many discontinuities and could be non-integrable (Riemann or even Lebesgue).

Note that there exist other (generalized) integrals such as Denjoy; in this context f becomes integrable
and Newton-Leibniz applies. However the Denjoy integral is not usually considered even at a university level.

The simplest example of a function not integrable (Riemann or Lebesgue) but having an antiderivative
is  f(x) = F'(x), F(x) = x^2*sin(1/x^2), x∈[-1,1]∖{0}, F(0) = 0. Note that f is discontinuous at 0.


(Using Rouben's suggestion.)

save(`convert/elsymfun`,fn):  close(fn):
sf:=StringTools:-Subs([") local vars," = ", vars::set(name)) local ", "elsy"="Elsy", "vars := indets(p);"=""], sf): 

u := a*(x+y) + b*(x^2+y^2) + a*b*(x^3+y^3):
convert(u, elsymfun);
      Error, (in convert/elsymfun) polynomial is not symmetric
convert(u, Elsymfun, {x,y});



Maybe something like this.

imagefile := cat(kernelopts(datadir), "/images/fjords.jpg"):
plot3d(1-x^2-y^2,x=-1..1,y=-1..1, image = imagefile);

Note that the image file can be obtained from any plot/plot3d.

select(u->type(convert(u,symbol),procedure), convert([seq(33..127)],compose,bytes,list));

        ["$", "*", "+", "-", ".", "/", "<", "=", ">", "@", "D", "^", "~"]





diffeq := diff(y(t),t,t,t,t)+10*diff(y(t),t,t)+169*y(t)=0:

ic:= y(0)=0, D(y)(0)=1;

y(0) = 0, (D(y))(0) = 1


(D(y))(infinity) = 0



y(t) = (1/3-(4/3)*_C4-_C3)*exp(-2*t)*sin(3*t)-_C4*exp(-2*t)*cos(3*t)+_C3*exp(2*t)*sin(3*t)+_C4*exp(2*t)*cos(3*t)








map(limit,[op(Y1)], t=infinity);

[0, 0, 0, 0, undefined, undefined, undefined, undefined]



2*_C3*exp(2*t)*sin(3*t), 3*_C3*exp(2*t)*cos(3*t), 2*_C4*exp(2*t)*cos(3*t), -3*_C4*exp(2*t)*sin(3*t)


Ysol:=eval(Y,[_C3=0,_C4=0]); #otherwise Y'(infinity) does not exist


Sievert := proc (B)
local a, b, denom, m, X;
a := sinh(B)*u; b := cosh(B)*v;
denom := sinh(B)*((cosh(2*a)-cos(2*b))*cosh(2*B)+2+cosh(2*a)+cos(2*b));
m := cosh(B)*<sinh(a), sin(b)*cos(v), sin(b)*sin(v)> + <0, -cos(b)*sin(v), cos(b)*cos(v)>;
X := <u, 0, 0>-8*cosh(B)*cosh(a)*m/denom;
end proc:


1 2 3 4 5 6 7 Last Page 1 of 34