tomleslie

13876 Reputation

20 Badges

15 years, 163 days

MaplePrimes Activity


These are replies submitted by tomleslie

Maple correctly performs the substitution given in your second expression, and returns the first expression with the required substitution. What did you expect to happen??!!??

I have to assume that this substitution did not perfom the transformation which you wanted/expected???

Since I have no idea what you wanted/expected, my ability to help is limited. So I am going to make a couple of random guesses (which may be well be nonsense!!)

  1. Your first expression contains the funcion epsilon(), with argument alpha*x(t)^4-beta. Your second expression comtains the symbol/parameter epsilon. Maple will distinguish between a function and a parameter which happen to have the same names. Are they truly distinct entities, or should both be functions (or both be parameters)??
  2. Your second expression describes the function x(t) in terms of two entirely unrelated functions x[1](t) and x[2](t). Are you assuming that the functions x[1](t) and x[2](t) bear any particular relationship to x(t), because I can asure that Maple does not.

 

Maple does a pretty good job presenting data clearly with DrawGraph(), but this is at the expense of restricting the number of options you are allowed to play with.

For example if you offset a label from its associated vertex, then it might end up closer to a different vertex, which would be confusing.

For very simple graphs, you would probably be unlikely to run into problems, but imagine a realtiveely dense graph wit a couple of hundred vertices, and then start shifting the labels around!

Having given the above warnings, it is possible to "draw" your own graph using the objects in plottools() for lines, point, and symbols, together with the PLOT(TEXT) structure to handle the labels.

It is trivial to generate the data for all of these objects because, for a graph G, getVertexPositions(G) will return coordinates of where Maple will put the vertices. Knowing these coordinates and the connectivity from Edges(G), allows you to use a variety of symbols/sizes/colors/etc for the vertices, and a variety of lines (colors, thickness, styles) etc. One can also place the labels (size,color,font) pretty much where you want.

Have a play with the following, based on your original graph

grph.mw

@patient 

It is impossible for me (and I suspect anyone else here) to figure out from your worksheet exactly what it is you trying to achieve. For example, until you last post I had no idea that you were using a Taylor series approximation in your worksheet.

I can appreciate that a lot of work went into the worksheet you posted. However I think that maybe the time has come for you to state your problem (rather than your attempt at a solution).

This could be phrased alternatively as

  1. Tell us the problem rather than your  attempt at at a solution, because
  2. If all I/we can see is your solution (and it doesn't work), it really isn't possible for me/us to work out what the question is!!

Getting back to basics, you seem to have a system of differential equations, for which you require solutions, subject to some constraints and/or boundary conditions.

Respectfully suggest that you list

  1. The differential equations whose solutions you require - with no approximations
  2. The boundary conditions for these differential equations- with no approximations
  3. Any other constraint(s) on the form of the solutions, eg range(s) of variables(s) over which solutions are required - with no approximations

 

Agree with Rouben's comment

If you now claim "I wrote plus instead of matrix multplication", this doesn't stack up with your further comment "Right now, if I add A and B," - so you really meant addition not multiplication- which is it??

You have used something vaguely resembling "plus" in two places

"For example, A + B = i*C, etc" and

"A + B returns (1 1 // -1 1)", etc.

Do you mean that in both places you meant matrix multiplication????

Before answering that question, you may want to consider that however I interpret your sloppy symbology for matrices (ie is the entity prior to the // a row or a column?) your A-matrix is always the identity for multiplication: so A.B will never return anything other than B. Hence if I replace '+' in the above two statements with matrix multiplication, then both of the above statements are complete garbage, because both will return B

I suggest that you rewrite your original question very carefully, clearly distinguish between addition and multiplication(and use standard maple syntax to represent matrices),

@patient 

I changed the code for v0 - but

You said earlier that your solutions should never be negative. However if you plot these separately using

p1:=plot([subs(t=0.1, eq30)], z = -10..10, color=red,legend="eq30"):
p2:=plot([subs(t=0.1, eqc20)], z = -10..10,color=blue,legend="eqc20"):
p3:=plot([subs(t=0.1, eqc21)], z = -10..10, color=green,legend="eqc21"):
p4:=plot([subs(t=0.1, eq31)], z = -10..10,color=black,legend="eq31"):
plots[display]([p1,p2,p3,p4], view=[-2..2,-1..1]);

then it is rather obvious that there are some values of z for which all defined (ie non-complex) solutions are negative.

Two possibilities

  1. Either I am failing to understand what you are trying to achieve
  2. There are other bugs in your code which are making it impossible to achieve what you want

@patient 

I modified yout original code to

p:=unapply( piecewise( z<-6^(2/3)/4, simplify(eq30),
                                   z<0,          simplify(eqc20),
                                   z<6^(2/3)/4,  simplify(eqc21),
                                   z>6^(2/3)/4,  simplify(eq31)
                                ),
                   z,t);

just so that I could figure out what was going on!!

If you now just execute

solve( subs(t=0.1, eq30), z);
solve( subs(t=0.1, eqc20), z);
solve( subs(t=0.1, eqc21),z);
solve( subs(t=0.1, eq31),z);

This will give the values of z at which the relevant equation equals zero (for t=0.1). One presumably can exclude some solutions (eg when z is complex). I didn't want to restrict the domain for each of these functions, since you imply that it may be the crossover points whch are wrong

The fourth expression gives no real solutions, just a nasty discontinuity, which is more easily seen with

plot(subs(t=0.1, eq31), z = 0.5 .. 2, color = black)

@Alejandro Jakubi 

Thanks: don't know how I missed that. I thought I had checked aabsolutely everywhere!!

@Alejandro Jakubi 

"More" on the OP post gives me two options, Contact Author and Unsubscribe

"More" on your response gives me the single option Contact Author

Following the link " You go here." takes me to a place I have never seen before - but it looks to be what I want!

Am I being remarkably stupid, or is this a geographic issue?

 

@Alejandro Jakubi 

Well I have tried to find, on this site, a mechanism to report bugs but I can't locate an "SCR form" anywhere. Could be I'm missing something obvious - happens at my age

If I try the general maplesoft site, I get redirected to "local reseller"

Either way I have never managed to report a "bug" in any way which even got an acknowledgement from Maple HQ

NB I'm not expecting a solution or anything significant - just a messge saying "we'll look at this" would make me feel better

I used showstat to have a quick look at dsolve/numeric/DAE/make_proc and decided it was beyond me to locate the problem. These days any procedure more than about two screenfuls in a readable font sixe (>=12pt) is too much for me. I'll be reporting this as a bug. After all I doubt if it is specific to either this particular post or delay differentiall equations in general, but probably affects anything which might be loosely desribed as a differential algebraic equation (system).

Since I'm outside US/Canada, this has to go first to my "local" Maple reseller. Once I've convinced the local technical support that there is an issue, I have to assume that the problem ends up back at Maple HQ, because I lose all sight of it.

Anyone within US/Canada want to report it directly to Maple HQ - feel free.

First of all you need to write the equation correctly. You have

diff(x(t),t) = 3*x(t)^2 + 0.3*x(x-0.03)

which is not a delay differential equation. I assme that you mean

diff(x(t),t) = 3*x(t)^2 + 0.3*x(t-0.03)

Secondly you need an initial value to get things started. I found that setting x(0)=0, meant that the solution x(t) remaned=0 for all t; x(0)=anything_positive caused the solution to head for infinity fairly quickly, but for x(0)=anything_negative, then "well-behaved" solutions could be obtained: thus the system

restart;
eqn1:=diff(x(t),t) = 3*x(t)^2 + 0.3*x(t-0.03);
bc:=x(0)=-1;

can be solved and, and solutions plotted using the standard dolve/numeric approach, as in

sol:=dsolve( {eqn1, bc}, numeric);
plots[odeplot](sol, 0..10);

This really ought to work.  - but Maple 2015.1 throws an error with the above code

Error, (in dsolve/numeric/DAE/make_proc) unable to convert system to first order

I think this is some kind of obscure bug in Maple, because if I convert the above to

restart;
eqn1:=diff(x(t),t) = 3*x(t)^2 + (3/10)*x(t-0.03);
bc:=x(0)=-1;

sol:=dsolve( {eqn1, bc}, numeric);
plots[odeplot](sol, 0..10);

then Maple happily computes the solution.

Although Maple does regard 3/10 as distinct from 0.3 for many/most purposes, I fail to see why it should do so in the case of producing a numerical routine for solving differential equations, in which I would expect everything to be converted to floats, more or less by default

 

@narute 

You want to perform

Fun := Diff(f(x), x);
int(Fun, x = 2 .. 7);

to get

f(7)-f(2)

and Maple, correctly, refuses to do this, because it is only true if f(x) is a continuous function

Acer shows a way to force the issue essentially by declaring that Fun() is continuous, using

Fun := Diff(f(x), x):
int(Fun, x = 2 .. 7, continuous);

Kitonum "clouds" the issue by stating that int(diff(f(x), x), x=a..b) = f(b) - f(a)  is not always true. This statement is known as the fundamental theorem of calculus, and is always true, provided that f(x) is continuous. However, Kitonum cleverly(?) offers as counterexample the function 1/x which has an infinite discontinuity at x=0.

It is actually interesting to consider Kitonum's counterexample, with Acer's method -as in

int(1/x, x=-1..2, continuous);

for which Maple (incorrectly) returns

I*Pi+ln(2)

because it computes ln(-1) as ln(1)-I*Pi=-I*Pi, so ln(2)-ln(-1) becomes ln(2)+I*Pi

However by considering the discontinuity carefully it is actually possible to generate the correct answer by splitting the integral into two parts, around the discontinuity, so that with eps>0,

int(1/x, x=-1..2)

becomes

assume(eps>0):
limit( int(1/x, x=-1..-eps) + int(1/x, x=eps..2), eps=0);

for which Maple returns ln(2), ie the correct answer. This approach will always work for functions which are odd wrt the discontinuity point: ie if function is discontinuous at x0, then f(x0+x)=-f(xo-x): crudely you can think of this as cancellation

The moral of the story is, tat just because you want

Fun := Diff(f(x), x);
int(Fun, x = 2 .. 7);

to return

f(7)-f(2)

Maple won't do it because it is incorrect for discontinuous functions. Trying to force continuity (aka Acer's approach) is fine provided that you absolutely know that Fun() is continuous - but if f(x) is something like 1/x so that Fun() is discontinuous, then declaring it as continuous is only ever going to get you into serious trouble!!!

 

 

 

 

@Wang Gaoteng 

Since you know (or have guessed) that a cubic function fits the data quite well, then you can use linear least squares to fit the data to the model function ax3+bx2+cx+d, since this model function is linear in  the unknown parameters. This is the model function which "I can program on my calculator".

If you really want to use splines then you can do so. Maple can use splines of any degree so if you want to use "arcs", implying quadratics, then you can fit your data using splines of degree 2. This will produce a piecewise function of n-1 elements (where n is the number of datapoints), and the function within each piecewise element is quadratic

The attached worksheet fits your data using

  1. linear least squares with a cubic model function
  2. quadratic splines: produces (n-1)-element piecewise function, where each element is a quadratic - which *might* be what you mean by "arcs"
  3. cubic splines: produces (n-1)-element piecewise function, where each element is a cubic

It also computes the rms fitting error for all three, as well as plotting the fitted model functions and data. As might be expected, the spline fits are more accurate than the linear least squares fit, but the plots show that the linear least squares fit is still pretty good. Also your data is "smooth" enough that there isn't really much inprovement in rms error in going from quadratic to cubic splines

llsFit.mw

If I wanted to transfer the fitted model function to any other software, then I would rather use the cubic model from the linear least squares fit!!!

 

@smith_alpha 

The data can be stored in many ways: the optimal method probably depends on how you want to subsequently access the data. Below is one method which includes the "1" "2" and "****"

with(StringTools):
fn:= "testip.txt":
dA:= Array():
sA:= Array(1..4):
tline:=readline(fn):
for k from 1 while tline<>0 do
      dA(k,1):= parse(tline);
      for j from 1 by 1 to 4 do
          sA[j]:= map( parse, Split(readline(fn)));
      od;
      dA(k,2):=sA:
      dA(k,3):= convert(readline(fn),symbol);
      tline:= readline(fn)
od:
dA:

As you observe, data fits a cubic function pretty much perfectly. I can program this cubic function on my calculator.

So when you say

" it is hard to generate the complex curve (even the function is known) in some software",

which software do you mean?????. I could this kind of cubic on a slide rule!!!!

First 190 191 192 193 194 195 196 Last Page 192 of 207