acer

32313 Reputation

29 Badges

19 years, 310 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

It seems that one has to supply initial values for either all variables, or for none.

> fsolve({x-y = 1, x+y = 1}, {x=1,y=1}, {x = 0 .. 1});
                               {x = 1., y = 0.}

If that is preceded by trace(fsolve) then one can see that it's setting up the x-range and initial values as specified, and leaving the y range as -infinity..infinity.

acer

In Maple, it is lowercase infinity, not uppercase Infinity.

 sum(1/((6*n)^2-1), n = 1 .. infinity);
                                           1/2
                                       Pi 3
                                 1/2 - -------
                                         12
 
> sum((-1)^(n+1)/(2*n+1), n = 1 ..infinity);
                                        Pi
                                   1 - ----
                                        4

> S := sum((-1)^n/(6*n+5), n = 1 .. infinity);
                                                         11
                  S := - 1/5 - 1/12 Psi(5/12) + 1/12 Psi(--)
                                                         12

> combine(value(combine(convert(S,Int))));
                                                     1/2
                     Pi                1/2      2 + 3
                    ---- - 1/5 - 1/12 3    ln(- ---------)
                     6                                1/2
                                                -2 + 3
 
> kernelopts(version);
            Maple 12.01, X86 64 LINUX, Sep 23 2008 Build ID 363216

acer

Do it four or five times, by hand, and look for a pattern. Then code up the pattern.

Adjust accordingling, if you need to account for constants of integration (which maple does not add in).

acer

This is the sort of task where, for selecting a "good" method, it can make a big difference whether you want just a few values (digits), or many or most of them.

Suppose that you want just a few values. You could do something quite simple like this,

> p := proc(n) Rounding:=0; op(1,evalf[n](Pi)) mod 10; end proc:

> st:=time(): p(30000); time()-st;
                                       7
 
                                     0.065

The above code is "ok",  if just a few digits are wanted. But it's not efficient if you want many digits. The above example, for the 30000th digit, may not be representative of the timing since Maple might have that many digits hard-coded.

Also, the above routine `p` has its efficiency affected by whether one starts with the lower or the higher digits (on account of the evalf remember table allowing lower digits to be computed more quickly by chopping the previously computed higher accuracy results). For example,

> restart:
> p := proc(n) Rounding:=0; op(1,evalf[n](Pi)) mod 10; end proc:
> kernelopts(printbytes=false):
> st:=time(): [seq(p(i),i=49900..50000)]: time()-st;
                                    17.909
 
> restart:
> p := proc(n) Rounding:=0; op(1,evalf[n](Pi)) mod 10; end proc:
> kernelopts(printbytes=false):
> st:=time(): [seq(p(i),i=50000..49900, -1)]: time()-st;
                                     0.196

If you wanted them all, up to some Nth place, then you could just use convert/base (or an improved variant on that, possible using repeated irem calls, say).

As written above the `nthpi` routine will not produce all correct results. The first incorrect digit it produces is the 12th, I think. (That's because round-up can affect more than just the previous digit...)

acer

See here.

acer

The problem is that a space (for implied multiplication), or an explicit multiplication sign (ie, *) is missing between (4*sigma^2-x^2-y^2) and the next bracket that follows it.

There is also a missing multiplication indicator after the second instance of signa^2, right before (x^2+y^2).

Without either of those, the 2D Math parser is interpreting these input parts as function calls. Hence the erronous output with things like 2(something), 1(something), and 6(something), after substituition.

acer

plots:-listplot( [seq(X[i],i=1..50)] );

acer

You could post the actual example.

Do you want exact, or floating-point results? Is it a polynomial of one variable or of several variables? If it is univariate, then you could pass it to fsolve for floating-point results. If the problem is that the form of the exact results from solve don't appear to match your expectation, then suggestions might be made if you post the example.

acer

Have a look at the help-page for rtable_scanblock. That routine can find max/min and locations for Matrix/Vector/Array.

> V:=<1,4,8,2>:

> rtable_scanblock(V, [1..3],
>                  (val,ind,res) -> `if`(val > res[2],[ind,val],res),
>                  [[1],V[1]]);
                                   [[3], 8]

> op(%[1]);
                                       3

Note that your [1,4,8,2] is a list, not a Vector.

acer

plot( 23*sin(x) + x - 1, x=-35..35 );

RootFinding:-Analytic(23*sin(x)+x-1, x=-100-0.1*I..100+0.1*I );

seq(eval(23*sin(x)+x-1,x=t), t in [%]);

acer

Powell := (M,N) -> (first(M,N),second(M,N)):
Powell(4,5); # for example

MyMat := Matrix(100,2):

for N from 1 to 10 do
  for M from 1 to 10 do
    MyMat[10*(N-1)+M,1],MyMat[10*(N-1)+M,2] := Powell(M,N);
  end do:
end do:

interface(rtablesize=100):
MyMat;

The interface(rtablesize) call only needs to be done once, and only serves if you wish to get the entries printed out to the Maple interface.

For the other aspect, of selecting just some of the values, you could use the following technique,

> Powell := (M,N) -> (first(M,N),second(M,N),third(M,N),fourth(M,N),fifth(M,N)):
> g:=[Powell(7,11)];
 g := [first(7, 11), second(7, 11), third(7, 11), fourth(7, 11), fifth(7, 11)]

> g[2],g[3];
                          second(7, 11), third(7, 11)

That is to say, the double loop might look like this,

for N from 1 to 10 do
  for M from 1 to 10 do
    g:=[Powell(M,N)];
    MyMat[10*(N-1)+M,1],MyMat[10*(N-1)+M,2] := g[2],g[3];
  end do:
end do:

The Matrix() constructor also admits an operator as an initializer, and that could likely be made to work here too (without all that looping). But maybe you have other things that you'd eventually want to happen inside your loop. And it's useful to get familiar with the loop and assignment syntax.

acer

How far have you gotten with any of these, so far?

Write down the cosine law (and/or the sine law). Fill in some of the variables with the information you're given. Figure out which of the other variables relate to the piece that you're asked to find. Solve for that variable.

acer

> expr := (beta*p-beta-p)*alpha/(p*(beta-1)):

> simplify(expr-(alpha+beta/p),{alpha=1-beta});

                                       0

> eval(collect(expr,p),beta=1-alpha);
                                       1 - alpha
                               alpha + ---------
                                           p

> collect(simplify(simplify(expr,{alpha+beta=1})),p) assuming alpha>0, beta>0;
                                       1 - alpha
                               alpha + ---------
                                           p
 
> subsindets(%,identical(1-alpha),t->beta);
                                         beta
                                 alpha + ----
                                          p

> subsindets(collect(expr,p),identical(beta-1),t->-alpha);
                                         beta
                                 alpha + ----
                                          p

acer

You forgot spaces before the opening round-brackets, when you typed in

d(27*d^2-40)^3

and

x(3*x^3-9*x^2+20)

Without the space (to imply multiplication) Maple interprets those as function calls to x() and d().

acer

The Matrix formed from those three vectors will have zero as its determinant when that Matrix has a rank of less than three.

> (u,v,w) := <-2,-5,5>, <1,7*a,-2>, <3,3,a>;

                                     [-2]  [ 1 ]  [3]
                                     [  ]  [   ]  [ ]
                          u, v, w := [-5], [7 a], [3]
                                     [  ]  [   ]  [ ]
                                     [ 5]  [-2 ]  [a]
 
> with(LinearAlgebra):

> values := [solve( Determinant( <u|v|w> ) )];
                                        1/2               1/2
                                    2962              2962
                values := [- 25/7 - -------, - 25/7 + -------]
                                      14                14
 
> seq( Rank( eval(<u|v|w>,a=values[i]) ), i=1..nops(values) );
                                     2, 2

acer

First 301 302 303 304 305 306 307 Last Page 303 of 336