Joe Riel

9660 Reputation

23 Badges

20 years, 5 days

MaplePrimes Activity


These are answers submitted by Joe Riel

Here's one approach to finding a fixed point in psi

fixeq := 1/2*Int(x*y/(y+1)*f(y),y=0..1) + x^3/2 = f(x);
deq := diff(fixeq,x,x);
dsol := dsolve(deq);
F := unapply(rhs(dsol),x);
eq := value(eval(fixeq, f=F));
cfs := coeffs((lhs-rhs)(eq),x);
csol := solve({cfs},{_C1,_C2});
eval(F(x), csol);

 

You are better off using Maple's autocompile option, which generates compiled code.  To use it most effectively, pass in an Array and compute, in a loop, all values from 1 to 300.  Then select the range you are interested in.  For example:

computeS := proc(a::float, n::posint, S::Array(datatype=float[8]))
option autocompile;
local i;
    S[1] := 0.3;
    for i to n-1 do
        S[i+1] := a*S[i]*(1-S[i]);
    end do;
end proc:

t := time():
N := 300:
for i from 800 to 1280 do
    S := Array(1..N, 'datatype=float[8]');
    computeS(evalf(i/320), N, S);
    L[i] := S[200..300];
end do:
time()-t;
                               0.328

You never assigned the Determinant. Currently your code depends on a previous incantanation of with(LinearAlgebra).  Better to do this with a uses statement inside the procedure assignment.  For example

AffineMatEncode := proc(...)
uses LA = LinearAlgebra;
 ...
   Inv := LA:-MatrixInverse(A);
   D := modp(LA:-Determinant(A),p);
...
end proc:

Also, you should not be using evalm, that is for the old linalg package.  You are better off not allowing A and B to be matrix or vectors, but restrict them to Matrix and Vector. This procedure can be improved; look at the LinearAlgebra[Modular] subpackage.

 

 

 

It always a good idea to indent the code, then it would be immediately clear that you are doing a double loop.  Clearly the total time should generally be at least 100=10x10 times greater than a single execution of Powell().  There isn't much else to say without knowing what Powell does...

Should that be S2 := S2+0.2?  The first four conditionals are missing a conjunction (and).

Hmm. Try this http://www.mapleprimes.com/viewfile/3329  If that doesn't work, send me your email address and I'll email it to you directly.

I've uploaded a corrected version, however, I had some trouble pasting a link to it. Look in the recent files section in the right column, it's called 10494_MethodsFixed.mw

You can use simplify with side relations; the output is an expression not an equation:

simplify(b/m, [eq], [b,m]);
                                       g
                                      ---
                                      v_t

See ?simplify,siderels for details

I haven't used Window for several years, so no longer remember.  In Linux there is an X11 resource file for the classic worksheet, one of the settings controls the background color.  The distributed file is located in the maple/X11_defaults directory.

What's the difficulty?  Do you know three different norms for a given vector?  And how to select them?  The Maple help page ?VectorNorm describes the available options.

Alas, there is no way to change the background color of the worksheet.  Strangely, one can change the background color of the help pages.  In the maplerc file, modify the HelpBGColor field (the three numbers are the byte values of the RGB strength).

with(LinearAlgebra):
RowOperation(A, [3,1], 3);

Your first set of nested loops do nothing (other than reassign m and n.  You probably want something like

for n to 3 do
   for m to 3 do
       f := (Q1,Q2) -> m*Q1 + n*Q2;
       A[n,m] := Powell(f);
   end do:
end do:

You can also do this with

A := Matrix(3,3, (i,j) -> Powell((Q1,Q2) -> j*Q1+i*Q2));

 

Here is a modest improvement to the solution I posted. Rather than reinitializing each time, it clears the event.

deq := { diff(y(t),t,t)+sin(t)*diff(y(t),t)+y(t)^2-5*y(t)=0 }:
ic := { D(y)(0)=0,y(0)=1 }:
dsys := deq union ic:
integ := dsolve(dsys
                , 'numeric'
                , 'events'=[NULL
                            , [[y(t)-4=0, diff(y(t),t) > 0], 'halt']
                           ]
               );
Tf := 10:
_Env_in_maplet := true:

data := table():
cnt := 0;
do
    result := map(rhs,integ(Tf));
    if integ('eventstop') <> 0 then
        integ('eventclear');
        cnt := cnt+1;
        data[cnt] := result;
    end if;
    if Tf <= result[1] then break; end if;
end do:

data := rtable(1..cnt, data);

Why is it taking so long?  Regardless, to write to a file you might want to use the FileTools[Text][WriteLine] command.  You do something like the following (I haven't actually run this code, just typed it up):

fd := FileTools:-Text:-Open("data.mpl"):
# Use a try command so that if an error occurs you still close the file and retain some data.
try
  for i to 1000 do
       # create string to save (use sprintf to format data)
       line := sprintf(...);
       FileTools:-Text:-WriteLine(fd, line);
  end do:
finally FileTools:-Text:-Close(fd):
end try;

 

First 84 85 86 87 88 89 90 Last Page 86 of 114