tomleslie

13876 Reputation

20 Badges

15 years, 163 days

MaplePrimes Activity


These are replies submitted by tomleslie

@Carl Love 

I noted the change to the plot options - but I still don't understand why the same command, ie

plot(L0[() .. (), 1], L0[() .. (), 2], axes = box, size = [600, 320]);

works differently in Maple 18 and 2015.

I produced (strictly by experimentation) a "workaround" using the dataplot() command with option symbol=point. The OP produced another workaround using  style= pointline.

However the OP's original question is perfectly posed and absolutely accurate - I ran his original code in Maple18 and 2015 and got the same answers (s)he did. This means that there is some fundamental difference between the two releases on a basic operation such as plotting a list of y-values against a list of x-values. I have no idea why this should happen: I cannot find any documented change in the behaviour of the plot() command.

For this reason, I think (s)he has a justified gripe

@Carl Love @Spinosaurus

Although your imediate problem has been solved, I can't ee any reason why your original command

plot(L0[() .. (), 1], L0[() .. (), 2], axes = box, size = [600, 320]);

works differently in Maple 18 and 2015

You have workarounds - not explanations, which presumably could only be provided by Maple techies

@fmutunga 

I checked your original code on Maple2015, and as I said it worked perfectly. I'd like to see a Maple worksheet in 2015  which demonstrating this error. Could you upload one (using the big green up-arrow, right hand end, second row of toolbar icons))

@Rouben Rostamian  

As previous authors have said this code works flawlessly - so I tried a few experiments. One "simple" way to produce this error is to write the procedure definition as

game := proc(); # note semicolon, this is a syntax error

which produces the error

Error, unexpected `local` declaration in procedure body

Maybe you have this (or a similar typo) in your worksheet somewhere???

 

 

@sami131 

If you want help, then answer the questions in my original response

I thought I had seen something like this before - and I have. You have been posting very similar requests, with very similar code (all crap) for about the last six weeks. I have even responded to a couple!!!

However spending about six weeks on about 20 lines of code and getting nowher is waaaay bad. I have a radical suggestion. Instead of posting your attempts at a solution, post the question (homework/book/whatever). If the question is interesting enough, then someone here might solve it for you

@bfathi 

I have never has the misfortune to see such a random collection of Maple commands strung together in such a haphazard way. This code is beyond help (certainly from me).

Your worksheet contains four independent sections separated by restart commands. Now each of thee sections seems to have errors/warnings, which you ignore.

Do you want all sections fixed or only one of them?
Break the problem down into manageable pieces.
Figure out which of these totally independent sections (ie between restart commands) you want fixed, and post that section here along with some kind of description of what the code is supposed to achieve

You have to help us to help you!

 

First problem is with the line

y1, y2 := eval([y1, y2], Ns(t1), Ns(t2));

since Ns() is undefined in your code excerpt this cannot be evaluated. In any case eval only ever takes 2 arguments - you have three. I might guess that you mean

y1, y2 := eval(Ns(t1), eval(Ns(t2));

but with Ns() undefined I obviously can't make this work.

Somewhat concerned by your later assignment

yx := rhs(Ns(tx)[c2]):

which will never work because c2 is undefined, but suggests that Ns() is a procedure/function which accepts the argument tx, and returns a list/array of equations from which you select the c2-th entry and then take the right hand side. But if Ns()is an array of equations, then the first statement

y1, y2 := eval([y1, y2], Ns(t1), Ns(t2));

looks even weirder.

Perhaps if you had included the definition for Ns() in you rcode I might be able to make better guesses

 

@Kitonum That'll teach me not to post code when it's past my bedtime!

@Mokusko 

Fixing the problem of storing the solutions is easy: outside your for loops just define F to be an array as in
F:=Array(1..50, 1..50, fill=0);

Then change the assignment inside the loops to

F[i,j]:=dsolve(blah,blah,)

It will work - but do you really want to do this???  Assuming one finds the solutions (currently impossible - see below) are you really going to plot 2500 graphs!!!???

Can you actually find a solution - well no, not in the current form of your equations. You say

"But I don't need to solve y[j](z) from this equations. I just need to find x(z), y[i](z)" - but the ODE system contains an unknown function of z (ie y[j](j). Do you think you could solve a differential equation containing an unknown function, other than in a formal sense - ie containing integration signs

BTW you seem to have some confusion about analytic versus numeric solutions. You state

*If finding some analytic solution is impossible, then I need just to plot this solution like a graph."

your dsolve command contains the 'numeric' option so you are already looking for numeric solutions - and since y[j](z) has no known numeric value, your equations cannot be solved numerically.

 

Overall, I thnk you need to reconsider how your problem is formulated. As currently set up, it is insoluble, either numerically or analytically. (and even if it were soluble - I'd love to know what you are going to do with the 2500 solution graphs!!!!)

Agree with Dr. Venkat Subramanian, but adding a couple of further issues you have to address

  • The statement i <> j;  does nothing! It will return true or false, but since nothing subsequently depends on the truth or falsity of this statement, then it is redundant. Maybe(?) you mean something like

if i <> j;
then d1 := diff(x(z), z) = -G*x(z)*y[i](z)/IC-alpha*x(z);
       d2 := diff(y[i](z), z) = G*y[i](z)*y[j](z)/IC-alpha*y[i](z);
       dsys := {d1, d2};
       F := dsolve({ICon, op(dsys)}, [x(z), y[i](z)], numeric);
fi;

  • Since you are computing 2500 solutions (well maybe 2450 - see the first bullet) for 2500 (2450) different(?) differential equations you should be aware that as written each value of dsolve({ICon, op(dsys)}, [x(z), y[i](z)], numeric); will overwrite the previous one and at the end of the exercise, F will contain the solution to one differential equation with i=50 and j=50 (or possibly i=50 and j=49 - see  first bullet). Seems like an awful lot of work just to throw away the answers

@Kitonum 

The OP originally posted

 \int_{a}^{b} f(x) \, dx \approx \tfrac{3h}{8}\left[f(x_0) + 3f(x_1) + 3f(x_2) + 2f(x_3) + 3f(x_4) + 3f(x_5) + 2f(x_6) + ... + f(x_n)\right] .

I want to write a procedure for the simpson 3/8 rule using the above formula I took from wikipedia :

Unfortunately (s)he missed the next line in the Wikipedia entry which states that (emphasis added)

Note, we can only use this if n is a multiple of three.

The OP's code does not enforce this requirement (so neither does yours). Since either code accepts any number of points, neither is implementing Simpson's 3/8 rule, unless the number of points happens to be a multiple of 3

A trivial amendment to either code will ensure that it will always implement Simpson's 3/8 rule: a modified version of your code is shown below

simp38:=proc(f,x0,xn,nn)

local  n:=3*nn, h:=(xn-x0)/n,  x:=i->x0+i*h;

3*h/8*(f(x0)+f(xn)+3*add(f(x(1+3*i)), i=0..(n-2)/3)+3*add(f(x(2+3*i)), i=0..(n-3)/3)+2*add(f(x(3+3*i)), i=0..(n-4)/3));

end proc:

A similar modification will also work for the OP's code. With this modification, one can compare with maple's built-in command for an arbitrary function with arbitrary end-points using

kit:=n-> simplify(simp38(f,a,b,n));
maple:=n->Student[Calculus1][ApproximateInt](f(x), a..b, method=simpson[3/8], partition=n);
seq( testeq(kit(j)=maple(j)), j=1..10)

Part(a) can be proved by induction on k although I think the limits on the sum should be 1,k. Consider what the OP's original gives when k=1!

   restart:
   bc:=Q*exp(-c*T):
   A:=k->sum( Q*exp(-n*c*T), n=1..k):
#
# Check base case for induction
#
   testeq(bc=A(1));
#
# test inductive step
#
   testeq( A(k)*exp(-c*T)+A(1) = A(k+1) );


@escorpsy 

If you take your 2 differential equations (or do all 5 if you want), and define odesys:={de1,de2}, then use odetest(puta, odesys), you will get a list of 2 (or 5) residuals. You can then use Preben's technique (solve/identity) to generate sets of solutions for each of the residuals.

What you are then looking for is an element which is common to both (or all 5) sets. For a variety of reasons this might be a bit ugly to do (possible, but ugly). However while experimenting with this, I discovered that one of your residuals is only ever satisfied when lambda=0, and the other would seem to have only non-zero values (unless one can require a value for w - ie treat is as a parameter in the same way as a,alpha, beta,gamma1,lambda).

See attached worksheet

de3.mw

So either

  1. typo(s) in ODEs
  2. no solution with given trial functions
  3. 'w' has to be treated as a parameter in residuals

You have three second-order differential equations. As a general rule of thumb this would require 6 initial conditions, and you only have 4 - not good :-(

Your initial conditions contain functions such as u(R(z)/R[0]) = 0: what is R(z)/R[0]??? Possibly R(z)/R(0), note parentheses: but then what does R(z)/R(0) mean?? basically that u(some_unknown_value)=0. As an "initial condition", that is about as useful as a chocolate teapot

Your differential equations contain the variable 'i' in a few places. Whilst 'i' is perfectly acceptable as a variable name, I hope you don't mean the square root of -1, which in MapleSpeak would be I

 

First 195 196 197 198 199 200 201 Last Page 197 of 207