## 3068 Reputation

19 years, 342 days

Doug

`---------------------------------------------------------------------Douglas B. Meade  <><Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.eduPhone:  (803) 777-6183         URL:    http://www.math.sc.edu`

## residue mappings without explicit names...

If I understand your question, here are two ways to approach the problem - without having to give explicit names to the elements of your list of solutions.

`r1 := [seq( residue(f(s),s=t), t=t1 )];`

You can also define a residue function

`R := t -> residue( f(s), s=t ):`

and then map this function onto your list of solutions using either

`map( R, t1 );`

or, in Maple 14 or 15,

`R~( t1 );`

I hope you find one or more of these of use to you.

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183 begin_of_the_skype_highlighting            (803) 777-6183      end_of_the_skype_highlighting         URL:    http://www.math.sc.edu
```

## sum vs. product...

Check your definition of g. You found the partial sum of a series, but your problem involves a partial product. Maple can find a closed form for g, and then the limit is as you report in your original post. The reason for n^(11/2) becomes clear when you look at the closed form for g.

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## evaluating expressions...

There are several ways of doing this.

The most basic approach is to assign a value to x, then all future references to y automatically evaluates using the current value of x:

`restart;y := x+x^2;                                  2                             x + x x := 3;                               3y;                               12x := sin(theta);                           sin(theta)y;                                           2                    sin(theta) + sin(theta) `

The problem with this approach is that ALL future references to y use the current value for x. So, for example, it no longer makes sense to talk about diff(y,x):

`diff( y, x );Error, invalid input: diff received sin(theta), which is not valid for its 2nd argument`

Note that Maple's error message shows that what it's really trying to evaluate is diff( sin(theta)+sin(theta)^2, sin(theta) ) and this does not make any sense to Maple. But, you can ask for a derivative of y with respect to theta:

`diff( y, theta );              cos(theta) + 2 sin(theta) cos(theta)`

If you want to evaluate y for a specific value of x, and keep x as an independent variable, then you would use the eval or subs command:

`restart;y := x + x^2;                                  2                             x + x z := eval( y, x=sin(theta) );                                           2                    sin(theta) + sin(theta) subs( x=3, y );                               12`

Now, note the following derivatives:

`diff( y, x );                            1 + 2 xdiff( y, theta );                               0diff( z, theta );              cos(theta) + 2 sin(theta) cos(theta)`

The first requires no comment. This is exactly what we would hope to see. The second result is obtained because, unlike earlier in this message, there has not been an assignment to create a relationship between x and theta. To find a derivative of y wrt theta we have to work with the output from the eval command that provided a relationship between x and theta.

Between eval and subs I generally prefer to use eval. There are some subtle differences, but eval is generally the one that does what I want, and I like the syntax: eval( y, x=something ) reads nicely as "evaluate y when x=something". On the other hand, subs( x=something, y ) reads as substitute x=something into y.

I hope these examples make sense. Please ask more questions as they arise.

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## I don't see any problem with this. Your ...

I don't see any problem with this. Your commands, using linalg, work you should really be using the newer LinearAlgebra and Vector Calculus packages.

Here's what I did:

`with( LinearAlgebra ):with( VectorCalculus ):F[1] := A-(B+1)*X[1]+X[1]^2*X[2];F[2] := B*X[1]-X[1]^2*X[2];J := Jacobian([F[1], F[2]], [X[1], X[2]]);sol := solve({F[1] = 0, F[2] = 0, Trace(J) = 0}, {B, X[1], X[2]});             /                                  2\              |         2                   1 + A |             < B = 1 + A , X[1] = A, X[2] = ------ >             |                               A   |              \                                   / `

Now, to plug these special values back into the Jacobian matrix:

`JJ := eval( J, sol );                   ev := Eigenvectors(JJ);ev[2][..,1];`

Notice that the out put from Eigenvectors is different, and simpler, than the output from eigenvectors. The first element of the output is the vector of eigenvalues and the second element of the output is the matrix of corresponding eigenvectors. Here, the eigenvalue is I*A with corresponding eigenvector < 1, -(-I*A+A^2)/A^2 >.

I do see that the 2 eigenvector commands report different eigenvectors (eigenvectors has first component 1 and Eigenvectors has second component 1), but it's easy to see that they are equivalent. In fact, the eigenvector is much simpler to work with when it's identified as < -A, A+I >.

Have I missed something?

Doug

`---------------------------------------------------------------------Douglas B. Meade  <><Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.eduPhone:  (803) 777-6183         URL:    http://www.math.sc.edu`

## assuming - an alternate to surgery with ...

While it is possible to tear apart Maple expressions, this type of programming can be unstable - particularly between releases.

I prefer a more mathematical approach that I'll illustrate with the example given above.

The original solution contains four cases:

`sol := solve(b < a*x, x);             /       [ /    b\ ]         [ /b    \ ]      piecewise|a < 0, [{ x < - }], 0 < a, [{ - < x }],              \       [ \    a/ ]         [ \a    / ]                                                            \      And(a = 0, b < 0), [{x = x}], And(a = 0, 0 <= b), []|                                                          /`

The assuming command can be use to extract the solution corresponding to a specific case:

`sol assuming a<0;                          [ /    b\ ]                          [{ x < - }]                          [ \    a/ ]`

or to a subset of the original cases:

`sol assuming a=0;            piecewise(b < 0, [{x = x}], 0 <= b, [])`

This approach is easier to read (mathematically) and is more likely to be consistent across versions.

The assuming command is one of my favorite additions to Maple over the years.

I hope this has been helpful.

Doug

`---------------------------------------------------------------------Douglas B. Meade  <><Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.eduPhone:  (803) 777-6183         URL:    http://www.math.sc.edu`

## Be careful!...

Be careful.

Using  evalf or Digits affects the number digits used to perform the floating-point computations. While this will work most of the time, there are times when it will lead to problems.

If it's really only the display you are trying to control, the comments about displayprecision are appropriate. An older way of managing this is to use either fnormal or printf (or one of its cousins: fprintf, sprintf, nprintf. Please consult the online help for explicit syntax and examples.

Good luck!

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## series of a series and convert( ..., pol...

If you have one series and want to extract some of the leading terms of that series, you could just use the series command as follows:

`Y10 := rhs(dsolve( {ode,ic}, y(x), series, order=10 ));                          2    3    4    5    6    7    8    9    / 10\     1 + x + x  + x  + x  + x  + x  + x  + x  + x  + O\x  /series( Y10, x=0, 9 );                             2    3    4    5    6    7    8    / 9\        1 + x + x  + x  + x  + x  + x  + x  + x  + O\x /`

And, if you want to convert a "series" to a polynomial, I'd recommend using convert( ..., polynom ):

`convert( Y10, polynom);                  2    3    4    5    6    7    8    9         1 + x + x  + x  + x  + x  + x  + x  + x  + x `

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
</pr```

Please see the responses under the  topic urgent help needed! Supernovae graphs

Doug

`---------------------------------------------------------------------Douglas B. Meade  <><Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.eduPhone:  (803) 777-6183         URL:    http://www.math.sc.edu</pr`

## Variable names, function definitions, an...

The first problem is that you can't use an asterisk in the name of a variable.

Next, you have not given a proper definition of r as a function of x, y, and z. What you want is

`r := (X, Y, Z) -> sqrt( X^2+Y^2+Z^2 );`

You will need something similar for the definitions of the functions x, y, and z.

Next, it's not clear from the formatting on this page how you entered what appears to be delta[0]. There are situations where using the indexed name can be problematic; I'd recommend using delta0. And, again, you need to give a proper definition of the function delta0. Maybe:

`delta0 := (X, Y, Z) -> piecewise( r( X, Y, Z)<=30, 10, 0 );`

Note that it makes no sense to plot u=delta0(X,Y,Z) - this would be a graph in 4 dimensions.

You should realize that D is a pre-defined operator in Maple (for differentiation of functions).

I've identified quite a few problems with your code. You need to look at this, consult some of the Maple references (and examples!!). I encourage you to start with a simpler problem, maybe involving only one spatial variable.

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## allvalues to the rescue...

You probably want to use the allvalues command. When you do, you will see that Maple has found two solutions, one with Y(0)=+sqrt(2)/4 and one with Y(0)=-sqrt(2)/4 - and all other components zero.

In general, the RootOf form is used to represent one of several solutions to an equation. In this case, the roots of 2*z^2-1=0, that is z^2=1/2. The label= argument is used to tell Maple to think of this solution as a multi-valued object. This is why allvalues gives two solutions. (Note that the label= is not needed in this example. See the online help for allvalues and RootOf for examples showing the use of label= .) The complement to label= is index= which provides a way to refer to a specific solution of the equation involved.

Doug

`---------------------------------------------------------------------Douglas B. Meade  <><Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.eduPhone:  (803) 777-6183         URL:    http://www.math.sc.edu</pr`

## solve,identity...

This is a classic question, with an easy solution.

eq := A*cos(10*x) + B*sin(10*x + Pi/3) = M*cos(10*x + phi);
/       1   \
A cos(10 x) + B sin|10 x + - Pi| = M cos(10 x + phi)
\       3   /
solve( identity(eq,x), [M,phi] );
[[                          (1/2)              /
[[    / 2    2        (1/2)\                   |
[[M = \B  + A  + A B 3     /     , phi = arctan|
[[                                             |
[[                                             |
[[                                             \

(1/2)        \
B                       2 A + B 3             |
- -----------------------------, -----------------------------|
(1/2)                          (1/2)|
/ 2    2        (1/2)\         / 2    2        (1/2)\     |
2 \B  + A  + A B 3     /       2 \B  + A  + A B 3     /     /

]  [                           (1/2)              /
]  [     / 2    2        (1/2)\                   |
], [M = -\B  + A  + A B 3     /     , phi = arctan|
]  [                                              |
]  [                                              |
]  [                                              \

(1/2)        \
B                         2 A + B 3             |
-----------------------------, - -----------------------------|
(1/2)                            (1/2)|
/ 2    2        (1/2)\           / 2    2        (1/2)\     |
2 \B  + A  + A B 3     /         2 \B  + A  + A B 3     /     /

]]
]]
]]
]]
]]
]]

This question should be added to the FAQ. This answer is not one that most users come across unless someone shows it to them.

I hope this is useful,

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## Bessel functions...

I doubt you'll find too many other forms for the closed form of the solution to yoru problem. Your only real choice is a series solution.

You probably need to give some additional thought to your boundary and initial conditions.

Because BesselY is unbounded at the origin, your IC forces _C1 to be 0. But that leaves 2 BCs to determine the one remaining unknown coefficient.

Are rho and Diff both positive? If so, note that  the second argument to BesselJ is purely imaginary the solution can be written in terms of the modified Bessel function: BesselJ(n,i*x) = BesselI(n,x).

There are lots of references to Bessel functions (online and in print).  You'll probably do well to look at one of more or these to figure out exactly what you want for your problem.

I hope this has been helpful,

Doug

`---------------------------------------------------------------------Douglas B. Meade  <><Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.eduPhone:  (803) 777-6183         URL:    http://www.math.sc.edu</pr`

## cool, yes, but not quite what the OP req...

The assume (and assuming) features are nice, but they don't quite do what the original poster requests.

Another example would be to declare a variable as not allowed to equal 0. Then, if it gets set to zero, Maple raises an error, or prohibits it, or something. Get it?

Maple does have the type NonZero, but this appears to be something that is not well documented. I'll have more to say about NonZero at the end of this post.

Let's see if Maple does what the OP requests:

`restart;about( a );a:  nothing known about this objectassume( a, NonZero );about( a );Originally a, renamed a~:  is assumed to be: Non(0)`

So far, so good. Now, let's see what happens when a is assigned a numeric value.

`a := -1;                               -1`

The OP's question suggests he would liek Maple to raise an error at this point. Maybe a warning would be better. The message should say something about the fact that the value assigned to a is inconsistent with its previous assumptions.

To finish this example, let's now look at what Maple know about the name a:

`about( a );-1:  All numeric values are properties as well as objects.  Their location in the property lattice is obvious,  in this case integer.`

It does make sense, a has the value -1 and -1 is a numeric value. This is not what the OP wants to see.

The OP's request is a reasonable one. I can see that adding these checks could be time consuming. I wonder if there is a way to set an option / flag / environment variable to indicate times when strict assumption checking might be appropriate.

NonZero is mentioned in ?property . It is implemented as Non(0), and information about Non can be found on the help page for And, Or, and Not () ?type,And - where you will learn that Non is just the same as Not - but you learn this only if you read very closely.

I hope this is helpful, to users as well as the developers.

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## Please clarify - and possible first step...

What are you trying to "solve"?

`eq1 := i(t) = kc*ip*(exp(-a1*t)-exp(-a2*t));             i(t) = kc ip (exp(-a1 t) - exp(-a2 t))`

The other conditions that you give us are

`eq2 := tp = i/(a2-a1)*ln(a2/a1);                                  /a2\                              i ln|--|                                  \a1/                         tp = --------                              a2 - a1 eq3 := kc = 1/(exp(-a1*tp)-exp(-a2*tp));                                  1                             kc = -------------------------                      exp(-a1 tp) - exp(-a2 tp)`

When you wrote "d/dt(i)=0" were you saying that di/dt=0 (in Maple: diff( i(t), t ) = 0;)? If so, here is how that might look:

`eq4 := diff( eq1, t );        d                                                      --- i(t) = kc ip (-a1 exp(-a1 t) + a2 exp(-a2 t))        dt                                              `

If you want to find the value of t when this condition is satisfied:

`solve( rhs(eq4)=0, t );                               /a1\                              ln|--|                                \a2/                             --------                            -a2 + a1`

Because ln(a1/a2)/(a1-a2)=ln(a2/a1)/(a2-a1), this is, in fact, (almost) consistent with your value for tp (in eq2). The only thing I cannot explain is the "i" in the numerator.

Other than this, I'm not really sure what you are trying to do. If you could please give us some more information, someone should be able to give you more feedback.

Doug

Doug

`---------------------------------------------------------------------Douglas B. Meade  <><Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.eduPhone:  (803) 777-6183         URL:    http://www.math.sc.edu`

## numerical integration from data - homewo...

@hermitian I agree with Preben. It sounds like what you are asking is what you are supposed to be thinking about for the assignment. What you are asking about is very doable, and it's not that difficult. But, I'm not going to give you a solution. What I will do is encourage you to think about what a definite integral represents in terms of the graph of a function on an interval and then how your given information can relate to this.

Doug

 First 6 7 8 9 10 11 12 Last Page 8 of 44
﻿