tomleslie

13876 Reputation

20 Badges

15 years, 169 days

MaplePrimes Activity


These are replies submitted by tomleslie

Markiyan's code execute correctly in Maple 2015, but the command ElementOrder() does not exist in your version (Maple18).

If you can't upgrade to Maple 2015, then it looks somebody is going to have to compute the order of each element explicitly :-(

About three posts ago, you loaded

Newton := proc (f, po, TOL, N)
                        local i, p; i := 1;
                        while i <= N do
                                p := po-f(po)/(D(f))(po);
                                if      abs(p-po) < TOL
                                then return p
                                else  i := i+1;
                                       po := p
                                end if;
                        end do;
                        printf("The method failed after N iterations,N=%d", N)
                 end proc;

and Carl said

make a local p1 and initialize it to p0. Then never use p0 again.

But you absolutely refuse to do what you are told - why????? And since you ignore the advice you are given, why should anyone here help???

Because if you modify the code above to

Newton := proc( f, p0, TOL, N)
                         local p,
                                 i:= 1,
                                 p1:=convert(p0, float);
                         while i <= N do
                                 p := p1-f(p1)/(D(f))(p1);
                                 if      abs(p-p1) < TOL
                                 then return p
                                 else i := i+1;
                                 p1 := p
                                 end if
                         end do;
                         printf("The method failed after N iterations,N=%d", N)
               end proc:

Then it works perfectly

Mapleprimes provide you with a simple mechanism for uploading your code - it is the big green up-arrow in the MaplePrimes editor

Posting "pictures" of your code is not going to get you very far for a couple of reasons

  1. resolution is too low for your code to be legible. Now I could copy the image into a decent graphics program, and then play around with a few sharpening functions to render your code legible
  2. then I could carefully retype all of it into Maple in order to test precisely what your problem is

Think carefully and figure out why I won't be doing either (1) or (2) above, when you could just upload code in readable/executable way

Acer is correct: it is possible to utilises the 'uses' command in the way that you specify. However, I can only think of some rather limited situations in which such usage would be helpful/necessary: I would recommend that you avoid such complicatiions unless you are really sure that you need them.

I have eliminated this issue and commented upon many other logical/syntactical problems in the procedure which you have posted. My comments/corrections are shown in the attached, which is still incomplete, mainly because I do not know the nature of some of the arguments which you are going to supply (and because I cannot resolve some of the logical issues - because I know that what you have is incorrect, but I cannot *guess* what your intent is)

jacobiProc.mw

This has the same problem as I corrected in your earlier post - it should read (and no I haven't tested this!)

 

Jacobi:=proc(A::Matrix,b::Vector,x,epsilon,m)  

uses LinearAlgebra;  

local      i,k,n:= RowDimension(A),    

        x:= Vector(n),    

        p:= Vector(n);  

k:=1;

 while  k<=n do      

       for i to n while i<>j do          

          x[i]:=1/(A[i,i])*(-add(A[i,j]*p[j],j=1..n)+b[i]);       end do;      

        if abs(x-p)<epsilon do return x; end if;    

       k:=k+1;    

       p:=x;

 end do;  

x;  

end proc:

@sunflower 

when you have the  'uses' statement, you no longer need the longform versions to access commands within the linearAlgebra package - and in fact the way you were doing it was incorrect anyway.

It is better to 'return' the values computed by a procedure, rather than 'print' them.

See the attached

llCorr.mw

The penultimate line in your procedure, ie

L[n,n]:=(A[n,n]-add((L[n,k])^(2),k=1..n-1)^(1/(2))

has unbalanced parentheses. Based on the form of some of your earlier expressions, I'm guessing that it ought to be

L[n,n]:=(A[n,n]-add((L[n,k])^(2),k=1..n-1))^(1/(2));

Note extra parenthesis.

I agree with Acer though - you are going to have to wathc out for divide-by-zero problems. Ignoring this possibility for the moment, the following at least executes

restart;
LL:=proc(A::Matrix)
         uses LA= LinearAlgebra;
         local i, j, k, n:= LA:-RowDimension(A), L:= Matrix(LA:-Dimensions(A));
         L[1,1]:=sqrt(A[1,1]);
         for j from 2 to n do
             L[j,1]:=(A[j,1])/(L[1,1]);
         end do;
         for i from 2 to n-1 do
             L[i,i]:=(A[i,i]-add(L[i,k]^(2),k=1..i-1))^(1/(2));
             for j from i+1 to n do
                 L[j,i]:=(1/L[i,i])*(A[j,i]-add(L[j,k]*L[i,k],k=1..i-1));
             end do;
         end do;
         L[n,n]:=(A[n,n]-add((L[n,k])^(2),k=1..n-1))^(1/(2));
         L;
    end proc:
LL(Matrix( <<1,1>|<1,1>>));

 

@red1eco 

Like I said in my original reponse, your system of equations *appears* to have no analytic solution.

It is relatively simple to get a power series solution (ie x(t), y(t), E(t), in terms of x(0), y(0), E(0)) using

dsolve(sys2, {x(t), y(t), E(t)}, series )

but you probably don't want to read this!!

Just because you have what seems to be a relatively simple set of equations, does not mean that an analytic solution exists. Even if an analytic solution exists, Maple be unable to find it. Do you have any reason to suspect that an analytic solution exists? - eg is this a "textbook" example??

Given values for all of the parameters, and three initial conditions, it will probably be possible to obtain a numeric solution - you may have to settle for this

@Markiyan Hirnyk 

Your point is what?

OP's differential equation (with a=1, b=1) is

and yiu have solved the differential equation

Are these two equations meant to be equivalent in some way I don't understand???

Since the worksheet you supply

  1. Contains no numeric values for K__1, A, or l__1
  2. Contains no indication of how you are attempting to control the output numeric format

This means that no-one can replicate your problem - and hence it is highly unlikely that anyone will be able to solve it

You have the equation

edo:=-b*y(x)*(diff(y(x), x))^2*x-a*y(x)*x+(diff(diff(y(x), x), x))*x+2*(diff(y(x), x)) = 0,

which with x=0 reduces to

2*(diff(y(x), x)) = 0

which in turn would require that

diff(y(x), x)=0.

However you specify the boundary condition that

diff(y(x), x)=1

Hence your boundary condition is inconsistent with your differential equation - I suggest you fix whichever is incorrect

  1. Why do you post a Maple problem in MSWord format? Surely as someone who has "been using MapleSoft since 2013 to solve mathematical problem" it would not be too difficult to pose the problem in a Maple-readable manner: such as a .mw(s) file

  2. The second part of your MSWord document define six functions P1()...P6(), none of which occur in the definitions of your differential equations. So, presumably, I can assume that these are completely irrelevant. If not, please indicate what the relationship between the six functions P1()...P6() and your original equations actually are
  3. Given three first-order differential equations in three unknowns, and no viable boundary/initial conditions, only an analytic solution in terms of three arbitrary constants *might* be available. But if one exists, Maple cannot find it. This suggests that a numeric solution may be necessary. In turn this implies not only that (at least) three boundary conditions need to be specified, but also that numeric value are supplied for all other parameters in your differential equations

Attached is a worksheet which comes up with a "simpler" (ie "shorter") answer than the one you posted, although (so far as I am aware the calculation is identical except for the use of PI, instead of 3.14, and the odd, judiciously placed, simplify() command.

This results in much simpler final expressions, but does contain a couple of float(undefined) values. However the expressions are now simple enough to see why the undefined values occur, and that having such undefined values s technically correct - a more detailed argument id given in the final comment section of the attached worksheet

case5Corr.mw

Perhaps if you posted the expression which you are trying to plot, someone might be able to help?

The big green uo-arrow (for uploading code) in the Mapleprines edit window, is your friend

First 170 171 172 173 174 175 176 Last Page 172 of 207