Rouben Rostamian

MaplePrimes Activity


These are replies submitted by Rouben Rostamian

@Seb1123 Your definition of f says that f(n) is the sum of all previous values of f.  If your suggested answer of 1,2,6,18,54 were correct, then 18=1+2+6, which may be true in some other universe, but not where I live.

If you really want to get the sequence 1,2,6,18,54, then you need to insert a factor of 2 in your formula, as in

f:=n->piecewise(n=0,1,n>=1,2*sum(f(k),k=0..n-1));

and then modify it as Joe Riel has explained.

 

@tomleslie Try a simple plot, such as
plot(x^2, x=-1..1);
and then export it as PDF.  You will see that the picture is placed in the upper left corner of a 11in x 8.5in paper, with a lot of whitespace around it.  I am absolutely at a loss to see the utility of that.  What in the world is the use of an  8.5'' x 11'' export?   Shouldn't exporting to PDF honor the plot's bounding box as exporting to all other image formats do?

I have complained to support@maplesoft about this repeatedly, and each time I have gotten an acknowledgement saying that, yes, that's dumb, and they will look into it, but nothing has happened over the last five or six years.

@tsunamiBTP For the integral of cos(n*t) Maple produces sin(n*t)/n, which is what is expected, as that is what we would normally do when we do the calculation by hand.  To be very pedantic, however, the proper answer should be

                            

That's the way Macsyma did it in the 1980s, but that gets too tiring after a while. Maple only gives the general answer sin(n*t)/n. That works correctly most of the time, including in the case of the series calculation that I showed earlier.

But you are right in being super-careful about seeing that the software is doing what we expect it to do.

 

@Ramakrishnan That error message is due to badly formed expressions in your document. That is a common problem with Maple's Document mode and 2D input because these make such errors difficult to detect.  Many people prefer the Worksheet mode and 1D input for that reason.  You may want to give that a try. See:

Configuring Maple

Please note that this configuration will not convert any previous documents that you may have made under Maple's original settings. Sorry. It applies only to new worksheets that you will make after this configuration.

@Kitonum Parentheses and square brackets have different evaluation rules as you must certainly know; see

?Indexing Arrays, Matrices, and Vectors

That's the source of his problem.  He needs to change the parentheses to square brackets.

@carriewong Have a look at this modified worksheet.

Qmaple-modified.mw

 

@carriewong I think I know where your difficulty lies but it will be easier for me to explain the problem if you show me your equations first.  Then I will explain how to do it the right way.

The expression you have provided evaluates to a simple sum.  I see no brackets in the result.  You must be doing something else.

A note on Maple terminology:

An object of the form [a,b,c,...] (in square brackets) is called a list.
An object of the form {a,b,c,...} (in curly braces) is a set.

They behave quite differently.  Don't get them mixed up.

@tsunamiBTP 

Maple wouldn't yield the result = 1.862645149e-08 because the correct result is 1.931384967026*e-8 as I showed before.

As to why Maple produces 0. by default, consider this.  We have K = 25888158.4218766, therefore within 10 digits of accuracy, we have K^2 = 6.701967464e14.  Therefore within 10 digits of accuracy K^2 - 1 is the same as K^2 because taking away 1 affects digits beyond the level of accuracy that are being carried.  Consequently we get K = sqrt(K^2-1) = 0. which is the correct answer if we perform floating point calculations with 10 digits of accuracy.

If you increase the digits of accuracy, then you get the correct result of 1.931384967026*e-8, as I showed before.

Aside:

The problem that we are faced in that calculation is due to subtracting two large and almost equal numbers.  The usual way to avoid that is to note that

K - sqrt(K^2-1) = (K - sqrt(K^2-1)) * (K + sqrt(K^2-1)) / (K + sqrt(K^2-1))

which simplifies to 1 / (K + sqrt(K^2-1)).  This expression is algebraically equivalent to the original, however it now involves adding, rather than subtracting, two large numbers, and therefore it avoids the earlier numerical truncation issue.  With Maple's default 10 digits of accuracy we see that:

restart;
K := 25888158.4218766;
1 / (K + sqrt(K^2-1));
    1.931384967*10^(-8)

 

Many years ago George Pólya wrote a book titled How to Solve It. In it he says:

If you cannot solve the proposed problem, try to solve first some related problem. Could you imagine a more accessible related problem?

Which is the simplest finite difference problem that you know how to solve? Try that one first before you attempt this.

@vv By my note I meant to demonstrate a curious construction rather than a serious solution.  Your solution is definitely the right answer to the question.

@ProfJP I am guessing that what you are asking is for the values of x(tt), y(t), x'(tt), y'(t), x''(tt), y''(t), evaluated at a prescribed sequence of times, and where the results are stored as rows of a matrix A.

If that is correct, then start with dsol as I explained earlier, and then do:
dat := [seq(eval([
    x(t), y(t), diff(x(t),t), diff(y(t),t), rhs(de1), rhs(de2)
], dsol(s)), s=0..1, 0.1)];
A := Matrix(dat);

Here time goes from 0 to 1 in steps of 0.1.  Change as needed.

Alternatively, tomleslie's solution may be used for that but I am unable to tell where your difficulty lies from reading your message.  Try to be more clear in what you write.

 

 

Cramer's formula shows that each unknown in the solution of a linear system is the ratio of two determinants.  The determinant of an n×n symbolic matrix is the sum of n! terms.  But since
    170! = 7257415615307998967396728211129263114716991681296451376543577798900561843401706157852350749242617459511490991237838520776666022565442753025328900773207510902400430280058295603966612599658257104398558294257568966313439612262571094946806711205568880457193340212661452800000000000000000000000000000000000000000
you will have to wait a bit for your calculation to end.

Preben, that is a very nice construction.  It is particularly interesting that you are able to fit two boundary conditions to a first order ODE.

A slight variant with neater algebra is provided by the ODE diff(y(x), x))^2 = 1-y(x)^2, that is

whose general solution is y(x) = sin(x+c), as well as y(x)=±1.  By piecing together these functions we may fit a solution to the boundary conditions y(0)=a,  y(L)=b (where -1 ≤ a, b ≤ 1).   To guarantee the construction, we need L ≥ 2π.   The solution obtained this way is not unique in general.

For illustration, let's take y(0)=1/2,  y(3π)=sqrt(3/2).  Then it turns out that the function

is a solution for any value of the parameter t in the range 0 to 5π/6.   This animation shows what these solutions look like for varying t:

bvp-for-first-order-ode.mw

 

@Earl I suspect that the numerical difficulty in solving these equations is due to expressing the solution curve as a function of x.  We should be able to express the solution curve parametrically, as in <x(s), y(s), z(s)> where 0 ≤ s ≤ 1, together with the constraint x'(s)^2 + y'(s)^2 + z'(s)^2 = constant.  I spent a couple of hours today trying to figure out how to do that but did not get anywhere.

If I make any progress in that direction, I will post again.

First 68 69 70 71 72 73 74 Last Page 70 of 99