## 5177 Reputation

9 years, 243 days

## Well...

1. You could try reading the manual, or
2. You could try Vector( 101, i->(i-1)*10);

## looks the same to me...

Well if I do a quick check using

restart;
#
# Get Maple solution from dsolve()
#
eqn:= diff(y(t),t\$3)-12*diff(y(t),t\$2)+48*diff(y(t),t)-64*y(t)=12-32*exp(-8*t)+2*exp(4*t);
mapleSol:=dsolve(eqn);
#
# Type in "hand" solution *very carefully*
# NB I have changed c1, c2, c3 in OP's
# original to _C1, _C2, _c3 respectively
#
handSol:=y(t)=_C1*exp(4*t)+_C2*t*exp(4*t)+_C3*t^2*exp(4*t)-3/16+(1/54)*exp(-8*t)+(1/3)*t^3*exp(4*t);
#
# Check whether handSol=mapleSol
#
is(simplify(mapleSol)=simplify(handSol));

The output of the final command is 'true', indicating that the Maple solution is equal to the "hand" solution

PS This probably ought to be in the MaplePrimes/Questions section, rather than MaplePrimes/Posts

## If I understand correctly...

1. You want a recursive definition of p(t) in terms of p(t-1).
2. In order to achieve this there has to be some kind of "start" condition, otherwise the recursion is infinite.
3. I have (arbitrarily) decided  that p(-1)=0, so that only arguments >=0 can be used.

Given the above, the following will work

restart;
#
# Create recursive function definition
#
p:=x-> `if`( x=0,
m[tau]/(1-psi*(beta-1)),
m[tau]/(1-psi*(beta-1)) - psi*(beta-1)*p(x-1)/(1-psi*(beta-1))
);
#
# compute/assign the first 6 entries for the
# table 't'
#
seq( assign(t[j], p(j) ), j=0..5);

There are more "efficient" ways to do this (using a recursive procedure with a 'remember' table rather the simple function above), but unless you are going to calculate an *lot* of terms, you probably won't notice the difference

I have not attempted to make any simplifications oon the expressions which are generated as table entries

## Overcomplicated...

Seems like you have a very complicated way to achieve what seem to want.

You generate tables, convert to lists, then vectors. This isn't wrong but it does make things unnecessily complicated.

So far as I can tell, the following generates, fits, and plots, the same data

restart;
with(Statistics):
loopStart:=0:
loopEnd:=2:
loopStep:=0.01:
sz:=loopEnd/loopStep:
myt:= Array( 0..sz, i->loopStep*i):
myA:= Array( 0..sz, fill=0.):
for j from 1 by 1 to sz do
myA[j]:=myA[j-1]+0.01*(loopStep*j)^2;
od:
p1:=plot( myt, myA, style=point, color = red):
poly1:=PolynomialFit(10, myt, myA, time):
p2:=plot(poly1, time=0..2, color=blue):
plots[display]([p1,p2]);

NB I don't think you need a 10-th order polynomial to fit a curve this smooth.

## Use unassign...

Your outer loop contains the statement

q:=rhs(sol[3]);

The second time you execute the outer loop, the statement

ics:=q(0)=1, p(0)=n;

will therefore be equivalent to

ics:=rhs(sol[3])(0)=1, p(0)=n;

and since sol[3] was also assigned in the first loop iteration, then rhs(sol[3])(0) will evaluate, and return 1.0, so that this is equivalent to

ics:=1.0=1, p(0)=n;

which is of course meaningless as boundary condition.

'Minimal change' fix is probably to add the statement

unassign(q);

immediately prior to the 'end do' statement of the outer loop. Loop will now execute - does for me anyway.

NB Suggest you change the semicolons on the 'end do' statements to colons - otherwise you are going to generate an awful lot of verbiage you don't really need

Answers I obtained for  F, F1, S, S1, T, T1 are 247, 500, 271, 500, 1322, 4000 respectively. Obviously I have no idea whether these are correct (or what you expect), since I have not reallly anysed what you are trying to achieve

## Hmmm...

So far as I can tell, fsolve() is unable to find a solution, so the command returns unevaluated, which breaks all the subsequent code.

The DirectSearch package did return a solution, namely

A = -.6839299669509255427872547,
B = -.7058228818317920507398118,
C = .2983804370023421519862147,
E = -1.000000000023554794609445

Residuals are a little on the high side, though

## Well...

If I ignore all the superfluous statement, you problem is with the statement

bcs2 := eval[recurse](convert(ds[1], D), `union`({y = 0}, bcs3));

In particular with the part y=0. Before or after the conversion of ds[1], it contains several terms whose denominator is either y, y2, y3,or even y4.

Now with y=0, what do you expect to happen to these terms in ds[1]?

## Well, according to the manual...

N:=infinity;

ought to work.

I have just tried it - know what, it does work!

## Try very hard not to demonstrate how dum...

The attached shows how to use the scaletorange option in the densityplot() command, to achieve what I suggested earlier. This does not produce an error.

I have never used this option before. I guess the difference between us is that I read the manual to figure out how to do it, and you did/could not

densPlot2.mw

You really should avoid making stupid remarks such as "MATLAB is much stronger". I started using Matlab in 1988, and Maple in 1995, and have been using both (off and on) since those dates. In my working life I have written a lot more Matlab code than Maple code - and no Matlab is not "stronger"

I am prepared to admit that since I have been using both of these programs for so long I am in no position to work out which is easier for a "beginner". However "beginners" are in no position to comment on the relative capabilities of these two programs - so don't.

As a MAple begiiner, I recommend that you type tutorial in the search box for Maple help - then work your way through the 10 basic tutorials which show up

## No...

Have you ever tried reading the manual?

## I see three possibilities...

As a general rule I would consider it extemely painful to construct a partial solution in Maple/Matlab and then swap to the other for subsequent processing, sso the first two of the following would be my preferred options

1. (Probably get me lynched on this site but) Matlab has a pretty good solver for pde's - check out pdepe/pdeval. So I would give serious consideration to constructing the whole problem in Matlab
2. Maple can definitely solve your pde, so when you say "I am trying to manipulate this data but am struggling with it" then maybe somewhere here can help. Bear in mind that Maple can definitely solve your pde, and we/you have access to all the solution data: I feel pretty sure that however you want to manipulate this data, it can be done. We just need to know what your problems are
3. OK! The option I would not recommend. You *can* use the plotools[getdata]() command to get all relevant data for an individual plot. Note that thsi will include all sorts of guff about axis labels, captions etc, but somewhere within the data structure returned by plottools[getdata]()  will be a matrix of the x-y values which are being plotted.

You can try this third option with the "toy" example

p1:=plot(x^2, 0..10);
plottools[getdata](p1);

where the third entry will be the matrix of values which are to be plotted. In principle, this matrix can be extracted and  exported to matlab. A similar process could be applied to a sequence of plots - as in your animation - so exporting  a sequence of matrices to matlab.

I probably wouldn't be using the pds:-plot or pds:-animate methods, but rather the pds:-value method, which will just generate data directly without going throgh the whole" plot" stage. The admitted drawback of this approach is that this will inevitably result in data being being generated at a fixed number of "range" points which you will have to specify. And will you get the data spacing "suficiently" small to generate "smooth" curves? - probablty only by experiment. The flip side of this issue is that if you use the pds:plot+getdata() approach, then the data spacinig is adaptive: if the curve is changing "rapidly", then more points will be generated. It is therefore highly unlikely that the matrices generated by this approach for a sequence of plots would be the same size. So will export differetn size matrices to matlab - now this can be handled, you just have to be aware of it.

If you decide to go with this third approach, then I have no doubt it can be done - just lots of awkward details whch you will have to deal with.

Given my choice, I'd prefer to go with either (1) or (2) in the above list

## Ugly, but works(?)...

Your first question is relatively simple - just use combine().

I was amazed how awkward it was to implement your second question. I thought that there must be some buil-in simplification which would handle this.

I ended up writing a little procedure to do it. This works for all the test cases I have tried, but it is pretty ugly, and it *may* be possible to construct a summand or range definitions for which it will operate incorrectly. I can't help thinking that there must be a better/easier way!

See the attached for details

sumProbs.mw

The answer in your picture is correct, although presented in a rather odd way. Read/execute the attached file for details

cubicSol.mw

## Some basics...

The first thing you have to appreciate is that you don't need filler spaces - every formatted print statement in every programming language developed since the year dot allows you to specify a "field width". Given a fieldWidth of (say) 10, then applying it to the integer '1', will print nine leading spaces, followed by the value '1' - so forget "fillers"

The first thing you have to do is examine all of your data to find out the maximum "length" of any integer you have to print, and then set the fieldWidth to this value+1. After that you just need to figure out how much data, eg rows in a matrix or table, entries in a listlist whatever. The following works for data as a listlist, and could be easily modified for any other 2D data representation

restart;
#
# Set up some toy data to be printed
#
slf:= [ [  1, 100, 1000, 100000000],
[ 99, 9999,  9,  9999],
[ 23456, 12, 237, 9]
]:
#
# Based on the number of entries in an
# individual "row" of whatever data is
# supplied, construct an appropriate
# format string, allowing for the maximum
# length which might be required
#
ff:= cat
( seq
( cat
( "%",
max
( map
( length~, slf )
)+1,
"d"
),
j=1..numelems(slf[1])
),
"\n"
):
#
# Now print all the data
#
seq
( printf
( ff, slf[j][] ),
j=1..numelems(slf)
);

## Not a big user of components - but...

I don't really think that you problem is specific to Maple: if you define a table in, for example, MSWord then you will see the same issues: namely that alignment of "entries" within cells can only be done on a row or column basis, not on an individual cell basis. This becomes problematic when cells are merged - obvious example

If I merge several cells in a column, and then choose to set cell-content alignment across rows, which row determines the alignmennt with the merged cells??? Hint: it will generally be ether the top or bottom of the merged cells, and can depend on how you selected them!! As in "select the bottom cell, swipe up and merge", can result in different behaviour from "select the top cell, swipe down and merge"

On a purely pragmatic basis, I tend to set my row and column alignments to "center". This seems to avoid most issues

 First 99 100 101 102 103 104 105 Last Page 101 of 115
﻿