tomleslie

13876 Reputation

20 Badges

15 years, 169 days

MaplePrimes Activity


These are replies submitted by tomleslie

I had a brief look at this, and thanks to the input interface selected by the user,

  1. (s)he has managed to produce the function lcos() in the first expression - this is almost certainly intended to be l*cos()
  2. (s)he has managed to produce the variable walpha in the second expression - this is almost certainly intended to be w*alpha
  3. the third expression looks OK, but the fourth is a real lulu, amongst others, it contains variables with names lambda__1Lcos(sigma)sin(gamma), lambda__2Lsin(sigma)sin(gamma), lambda__2tan(gamma), walpha (again!), lcos(gamma): presumably these are meant to be lambda__1*L*cos(sigma)*sin(gamma), lambda__2*L*sin(sigma)*sin(gamma), lambda__2*tan(gamma), w*alpha, l*cos(gamma)
  4. Don't you just love this 2-D input interface

Looks like you have some serious spaghetti code.

If I stick with your immediate problem

  1. You execute the command BasisFunc(1), which defines assorted vector dimensions (amongst other things), in terms of the (global?) variable 'OptK'.
  2. the only place that the quantity 'OptK' might be determined is within the procedure SigFigEi(): however the procedure SigFigEi() is not called by anything, hence is never executed, hence OptK is undefined, so BasisFunc() can never be executed since it requires the creation of vectors of unknown dimension
  3. If you don't believe me, try typing xxx:=Vector(yyy) at the maple prompt; this will return an identical error message, for exactly the same reason: you cannot define a Vector of unspecified dimension
  4. BTW, in the procedure SigFigEi(), since OptK is declared to be global, you do not need to return it: this s simply superfluous

 

What is 'h' ?

What is 'T' ?

The normal way to produce plots of this type would be to use the fieldplot() command.

Check ?fieldplot and explain why this does not fulfil your requirements.

Since you do do not post the vectors which you wish to plot (along with their anchor points), really can't help much more

I have just tried this for a range of values of the variable NumSteps with no real problem

 

NumSteps  Execution Time

     5                  2.23

    10                 3.32

    20                 5.71

In all cases the T1 and AF arrays were populated with numerical values (although obviously I have no way of knowin whether these were correct)

I suppose it could be a version problem - I am running Maple2015.1. Which version are you running

if you use

fopen(fname, READ, TEXT);
line readline(fname);

the readline() command will discard both the C/R and the L/F at the end of the line. On the other hand, if you use

fopen(fname, READ, BINARY);
line readline(fname);|

the readline() command discards the L/F but retains the C/R (Have to admit this surprised me a little - I thought it would always discard both!)

SO if you use

  restart;
  with(StringTools):
  fd:=fopen("J:/Users/TomLeslie/myMaple/projectEuler/utilities/digGet.mpl", READ, BINARY):
  A:=readline(fd);
  while A<>0 do
      B:=Ord~(Explode(A));
      A:=readline(fd):
  od;

The StringTools commands above will "explode" the line into a list or characters, and then return the ASCII codes of the individual characters. When I try this on my simple text file, the final entry in the ASCII list is always '13'

Since B is now a list of ASCII codes you could write something which checks this list for any other "unusual characters" - except that I am not sure what readline() would do with "control" characters embedded within the line, which is why (I think) I would prefer to use the readbytes() approach which I originally suggested.

It is relatively easy to convert the readbytes() output back to text using the stringTools commands 'Char' and 'Implode', as in

 restart;
  with(StringTools):
  fd:=fopen("J:/Users/TomLeslie/myMaple/projectEuler/utilities/digGet.mpl", READ, BINARY):
  A:=readbytes(fd, infinity);
  Implode(Char~(A));

Your basic problem seems to be that you do not know which is your independent variable and which is your dependent variable

The attached worksheet takes your two lists of "data" and performs fits/plots both ways round. One of these has to be correct (?!). You just have to decide which!

Both look more or less plausible - probably an indication that with relatively few data points and enough fitting parameters, almost anythig can be made to "look" acceptabel

fits.mw

Your original expression contains a mixture of indications for multiplication - sometimes the '*' symbol appears and sometimes it doesn't. This might be a feature of the dreaded 2D math input, or it might be a whole set of syntax errors. Since you post a "picture" of you code, rather than the code itself I cannot tell - but I suggest you check this aspect very carefully

In your first expression you use both pi and Pi - I suspect you mean Pi in both cases

Ooops - looks like Markiyan got here before me with the same comment

Whenver I see a problem with "solving" an integral I have this irresistible impulse to plot the integrand - after all if the integrand is a really *difficult* function then I would expect problems in performing the integration.

This plot shows the the integrand has what seems to be multiple infinities, so I suspect that a closed-form solution is not possible. (I have tried it numerically and that did not work either - no surprise!)

See the attached to examine the integrand: note the vertical scale on the plot.

badInt.mw

If you are writing the LU decomposition code as a learnng exercise - absoultely fine. Carl has probably fixed most of your simple synax errors: you can now work on any logical errors in your algorithm (if any exist!). However you should be aware that LU-decomposition is built-in to Maple, so if you are more interested in the result than the process, then you can use the built-in commands.

Define a matrix

A := <<0,-2,0,3>|<1,3,0,1>|<1,1,0,0>|<-3,4,1,0>>;

Perform the LU decomposition

(p, l, u) := LinearAlgebra[LUDecomposition](A);

which will return the permutation, lower triangular, and upper triangular matrices.

If nothing else you can se this to check the results of your own algorithm

@mostibra 

When uploading code, use the big green uparrow in the MaplePrimes toolbar - that way the result should be legible. I don't even plan to try reading your previous post!

You use 'pi' in a lot of places - If you are referring to the quantity 3.14159...... then you mean Pi

The last line in the code oou have cut/pasted is

solve := phi, B.cs1, Bcs2, Bcs3;

This assigns th sequence of quantities phi, B.cs1, Bcs2, Bcs3 to the name 'solve'. However 'solve()' is a command in Maple - you cannot assign to it. (Well technically you can, if you play some tricks, but -  trust me - you don't want to do this)

Since you post a "picture" of code rather than any kind of code which I can edit/execute/whatever, I will take the easy way out ans suggest you use the Maple builtin commands for the Nevelle algorithm, as in

with(Student[NumericalAnalysis]):
f:= X-> 2^X:
vals:= [ seq( [j, f(j)],
                     j in [-2,-1, 0, 1, 2]
                 )
          ]:
L:= PolynomialInterpolation
      ( vals,
         independentvar=x,
         method=neville
      ):
expand(Interpolant(L)):
eval(%, x=0.5);

which returns 1.412109375 - which you have to admit is pretty close to sqrt(2.0)

Let us start with your first assertion, namely

i have a problem finding the constants c1, c2, c3, c4 everytime i apply the B.Cs i get errors

 phi=sin(alphaX)*{C1cosh(alphaY)+C2sinh(alphaY)+C3Ycosh(alphaY)+C4Ysinh(alphaY)}

where alpha= Pi/4

The first issue that you have is that, within Maple, curly braces, ie {} designate a set, and I am pretty certain that you are not interested in sets, so the above should be written as

i have a problem finding the constants c1, c2, c3, c4 everytime i apply the B.Cs i get errors

 phi=sin(alphaX)*(C1cosh(alphaY)+C2sinh(alphaY)+C3Ycosh(alphaY)+C4Ysinh(alphaY))

where alpha= Pi/4

The second issue is that this uses variables such as alphaX and alphaY, whihc are neiether defined previously, nor used subsequently - so I am going to make the (possibly ridiculous) guess that hwen you write alphaX, you mean alpha*X (similarly for alphaY), so the above should be written as

i have a problem finding the constants c1, c2, c3, c4 everytime i apply the B.Cs i get errors

 phi=sin(alpha*X)*(C1cosh(alpha*Y)+C2sinh(alpha*Y)+C3Ycosh(alpha*Y)+C4Ysinh(alpha*Y))

where alpha= Pi/4

The third issue is that the above expression uses several functions which are unknown to Maple, namely C1cosh(), C2sinh(), C3Ycosh(), C4Ysinh(). Once agian I make a guess about what you mean and assume that these functions ought to be written as C1*cosh(),  C2*sinh(), C3*Y*cosh() and C4*Y*sinh(), so that the above should be written as

i have a problem finding the constants c1, c2, c3, c4 everytime i apply the B.Cs i get errors

 phi=sin(alpha*X)*(C1*cosh(alpha*Y)+C2*sinh(alpha*Y)+C3*Y*cosh(alpha*Y)+C4*Y*sinh(alpha*Y))

where alpha= Pi/4

The fourth issue in this statement is that you want to finf the constants c1, c2, c3, c4, but your subsequent eqpressions does not contain these "constants"! It contains the constants C1, C2, C3, C4 and Maple is case-sensitive, so if we are trying to achieve some kind of consistency, tehn one shoul write the above as

i have a problem finding the constants c1, c2, c3, c4 everytime i apply the B.Cs i get errors

 phi=sin(alpha*X)*(c1*cosh(alpha*Y)+c2*sinh(alpha*Y)+c3*Y*cosh(alpha*Y)+c4*Y*sinh(alpha*Y))

where alpha= Pi/4

We now move on to what I think is your attempt to define differentials, as in

 sigmax=d^2phi/dY^2

which actualy divides the variable d, raised to the power of the variable 2phi, and divides this quantity by the variable dY raised to the power 2. With this syntax, absolutely nothing will be differentiated with respect to anything. I am guessing (again) that if yu want the second differential of phi with respect to y, then first of all you have to make phi an assignment (or a function definition - I only show the former), so one would have (note use of := rather than =)

 phi:=sin(alpha*X)*(c1*cosh(alpha*Y)+c2*sinh(alpha*Y)+c3*Y*cosh(alpha*Y)+c4*Y*sinh(alpha*Y));

sigmax:=diff( phi, Y, Y)

Similarly               

SigmaY=d^2phi/dX^2       partial deravitive

sigmaXY=-d^2phi/dXdy    partial deravitive

(probably) ought to be written as  (note difference betwee = and :=)

SigmaY:=diff( phi, X, X)      partial deravitive

sigmaXY:=-diff( phi, X, Y)   partial deravitive

Now at this point you define boundary conditions, as

boundry conditions:

at x=0, x=20    sigmax=0

at y=-9        sigmaxy=0,  and  sigmay = -Asin(alphax)

at y=9          sigmaxy=0, sigmay =0

Unfortunately the preceding code has not defined sigmaxy or sigmay - perhaps you mean sigmaXY and sigmaY??

And is alphax a typo for alpha*x: and -Asin(alphax) is -arcsin( alpha*x) or possibly -A*sin(alpha*x), or given that until this point no lower-case x has been used as a variable, it could -Asin(alphax) could be -Asin(alpha*X), -arcsin(alpha*x) or -A*sin(alpha*X)

At this point I concluded that you have far too many typos/syntaxErrors for me to fix your problems. Please post a worksheet whihc makes sense

@shoghian 

After fixing a few syntax errors, and selecting bcs carefully, the best I can do (so far) is to produce the error

Error, (in pdsolve/numeric/par_hyp) input system is too far from a 'standard' form (see ?pdsolve,numeric for more detail)

I don't know any way to get around this, but it would be a good idea if you checked my code (attached), to make sure that when I fixed the syntax errors in your original, I came up with the set of pdes which you intended

pdeProb.mw

Read comments in file to understand what I was doing at each stage

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