## 1505 Reputation

18 years, 206 days

```--------------------------------------
Mario Lemelin```
```Maple 14.00 Win 7 64 bits
Maple 14.00 Ubuntu 10,04 64 bitsmessagerie : mario.lemelin@cgocable.ca
téléphone :  (819) 376-0987```

## An interesting fact...

HI Acer,

Thanks for the adjustment.  In exploring Taylor5, I realise, in the particular ODE I am using, that I have to choose N in a way that T[i] don't equal zero since in the term  expression of  X[i-1] := X[i]+add(evalf((eval(S[k]))*(-h)^k/factorial(k)), k = 1 .. 5), you find terms  1/T[i], wich cause the solution to explode.  In fact, if you do

P := Taylor5({ci, deq}, x(t), t = -1 .. 4, 25)

and compare it with the exact solution, it's a perfect match.  But if I use N=100 in Taylor5, the solution explode at t=0, just like the following command:

p := dsolve({ci, deq}, x(t), type = numeric, range = -1 .. 4)

plots[odeplot](p)

in fact you can compare

```> p(-1);

[                                       13]
[t = -1., x(t) = -5.57493882889566640 10  ]
> P[1];

[-1.00000000000000000000000, -12.0000000000000000000802]

```
```> solex := rhs(dsolve({ci, deq}, x(t)));

13     9  2    3
solex := -- t - - t  + t
2      2

```
```> subs(t = -1, solex);

-12

```

So you have to be aware of these facts, especially if you don't have the exact solution to compare with.

Now, all I have to do is program so you can do P(a) and have the value at this point and my goal will be reach.

## Maybe you could use...

the procedure this way

```> MyProc := proc (p::polynom, M)
```
``` local opts;
```
``` opts := [M];
```
``` if has('output = graph', M) then
```
``` plot(p, x = -1 .. 1);
```
``` else
```
```proc (a) subs(x = a, p) end proc:
```
``` end if:
```
``` end proc;
```
```
> eq := 3*x^2+3*x-4;

2
eq := 3 x  + 3 x - 4
> P := MyProc(eq, output = graph);

>eval(P);
- the graph -

> P := MyProc(eq, output = number);

P := proc(a)  ...  end;
> P(2);

14

```

## HUM! Still missing one thing...

Like Acer said:

"But why not substitute into the S[i-1] (to get "new" S[i-1] formulae) outside of the 'i' loop? That is to say, get your hands on fully explicit algebraic substitution formulae, newS[i],i=1..5, just once outside the loops. And then use just a single call to eval(X[i]*F||i(t),[..newS[i]=..] inside the loop. It would run much faster, I suspect."

That I have done.  The gain in computation time is small.  But I still have the problem of finding X(t[a]) for a particular value "a" that I DON'T KNOW before doing the list

One way I try is the procedure inside a procedure like:

Myproc := proc (args1,args2,....)
........
calculation
.........
[seq([T[i],X[i]]];

proc (a)
....
calculation
....
X[a];
end proc:
end proc:

But it must be done in a way that I can do:

P:=Myproc(...)

and having the list so I can plot it.  And beeing able to do

P(a)

and having X(a).  And you must not forget that if T[i]=a, it is purely luck

## Here is the problem......

Hi,

You will find the programmation I have done and a more specific detail of my questions

Thanks

## To be more precise...

I have a ODE of firts order with condition X(T[0])=X[0].  What I am doing is solve it numerically with the Taylor method.  Of course, I could do:

p:=dsolve({deq,ic},x(t),type=numeric,method=taylorseries):

But my goal is to program a simple procedure (Taylor4) that can do that.  My problem is that it generate a lot of data.  I would like to be able to do two things:

1 - Plot the data (like I can do with plots[odeplot])

2 - Find a value of p(a), where a is a value of T in particular

For 1, I can create a list [  [t[0],X[0]], [t[1],X[1]], ....] that I can plot with plots[pointplot]

But for 2,  I want X(a) but since the calculation of T[i] depends on the parameter h, the chance of having a =T[i] for a certain value of i is almost nul.  FOr the moment, the only thing I manage to do is to do the calculation for t=T[0]..a and then look at the last output.  But then, if I want to plot the numerical solution from T[0] to another value, I have to re-do the calculations.  So to resume, I want to be able to do:

p:=Taylor4(......)

p(a)

plots[odeplot](p)

## It was a simple question of order...

I frequently forgot that subs is from left to right, I was doing:

> subs({x(1) = -4, (D(x))(1) = F(1)}, d2);

2
-13 - 8 x(1)
Yes, my goal is to be able to create a procedure that will automate that routine up to n, wich is the order of the Taylor series, knowing the initial conditions.

Thanks

## I forgot to say this......

My goal is to be able to do it for a general function like this

> G := t -> f(t, x(t));
G := t -> f(t, x(t))
> d1:=D[1](G);

d1:= t -> D[1](f)(t, x(t)) + D[2](f)(t, x(t)) D(x)(t)
>d10:=d1(1);

>d2:=D[1,1](G);

>d20:=d2(1);

etc.

with all those substitutions I talk in the preceding posting.

## Oups! sorry for the bad output...

Let me retry again.

First of all, thanks you Jacques.&nbsp; Secondly, while on the subject of dsolve(...,numeric,..), I am wondering how Maple can give exactly, say, p(1/2) when the ics are x(a)=b. I know how to go from the ics to the left and from the ics to the right.

But, on the choice of h, nothing can assure me that I will be right on the spot (t=1/2). Does Maple redo the calculation with h = (a - 1/2)/N? This way, I am sure that the last calculation will be x(1/2)=something, wich is what I am looking for.

## While we are on the subject...

First of all, thanks you Jacques.  Secondly, while on the subject of dsolve(...,numeric,..), I am wondering how Maple can give exactly, say, p(1/2) when the ics are x(a)=b.  I know how to go from the ics to the left and from the ics to the right.

But, on the choice of h, nothing can assure me that I will be right on the spot (t=1/2).  Does Maple redo the calculation with h = (a - 1/2)/N?  This way, I am sure that the last calculation will be x(1/2)=something, wich is what I am looking for.

## An error in typo...

The 6 th line should read:

p:=dsolve( {ode,ic},x(t),numeric)

sorry!

## What I am suggesting...

HI Paul,

One way to learn about Maple is to go in the menu, choose help -> take a tour of Maple.  You will learn a lot about Maple.  As for working with clickable math,  you will need to enter your functions and equations by hand firts before doing anything with the mouse.  Like Doug suggest, learning to write the command will help you to better understand what's happening when you click.  Step by step, it's the only way and it's not only for Maple but to any new software.  If you have others questions, don't hesitate.  MaplePrimes is there for that.

## Here is how I would do it...

Hi,

For 1)

```> y := (x) ->  x^3+3*x-8; # this is an arrow procedure.

3
y := x -> x  + 3 x - 8
> y(a);

3
a  + 3 a - 8
> with(Student[Calculus1]);

> Tangent(x^3+3*x-82, x = 2, output = slope);

15
> y(2);

6

```

Then for 2)

> y := (x)  -> x^3-6*x^2-34*x-9

3      2
y := x -> x  - 6 x  - 34 x - 9
> Tangent(y(x), x = x, output = slope);

2
3 x  - 12 x - 34
> sol := solve(% = 2, x);  #wher % mean the last output

sol := 6, -2
> y(6);

-213
> y(-2);

27

then for 3)

```> y := (x) -> x^5

5
y := x -> x
> Tangent(y(x), x = -2, output = slope);

80

```

Hoping this will help.  Of course, I hope that you understand the theory before letting Maple does the calculation.  It's YOUR responsability!

## HUM.... I am still wondering...

When you look at:

```f(t,k)=int(1/sqrt(1-k^2*sin(s)^2),s=0..phi)
```

I found in Maple something confusing.  Look at the Assistants -> SpecialFunction

Select the special function InverseJacobiAM and explore the integral_form.  You will see that it's in fact the integral I have to solve and that there is no restrictions on k and phi (that's what is written).  So I should write:

```
> f(t, k) = InverseJacobiAM(phi, k);```

But there is no way to arrive to the solution I am suppose to find.  For a beginner like me about special function, this is quite confusing.

## That's exactly what I needed. Thanks Al...

mario.lemelin@cgocable.ca

 First 10 11 12 13 14 15 16 Page 12 of 19
﻿