Carl Love

Carl Love

27338 Reputation

25 Badges

12 years, 0 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

nops([StringTools:-SearchAll]("5", sprintf(cat("%d"$2013), $(1..2013))));
                              601

plots:-polarplot([cos(t), sin(t)], t= 0..Pi);

Why do you say that the roots are not real? You can't tell until you plug in values for a1, a2, a3, b1, b2, b3. Just because the symbolic solution has an I in it does not mean that the numerical solution will be non-real. For example:

p:= x^3-x^2-2*x+1;
                        3    2          
                       x  - x  - 2 x + 1
fsolve(p);
     -1.24697960371747, 0.445041867912629, 1.80193773580484
solve(p);
                     (1/3)                                   
1 /            (1/2)\                    14               1  
- \-28 + 84 I 3     /      + -------------------------- + -,
6                                                 (1/3)   3  
                               /            (1/2)\           
                             3 \-28 + 84 I 3     /           
                        (1/3)                                    
  1  /            (1/2)\                    7                1   
- -- \-28 + 84 I 3     /      - -------------------------- + - +
  12                                                 (1/3)   3   
                                  /            (1/2)\            
                                3 \-28 + 84 I 3     /            

             /                     (1/3)
  1    (1/2) |1 /            (1/2)\     
  - I 3      |- \-28 + 84 I 3     /     
  2          |6                         
             |                          
             \                          

                               \                          (1/3)
                 14            |    1  /            (1/2)\     
   - --------------------------|, - -- \-28 + 84 I 3     /     
                          (1/3)|    12                         
       /            (1/2)\     |                               
     3 \-28 + 84 I 3     /     /                               

                                                 /  
                 7                1   1    (1/2) |1
   - -------------------------- + - - - I 3      |-
                          (1/3)   3   2          |6
       /            (1/2)\                       |  
     3 \-28 + 84 I 3     /                       \  

                     (1/3)                             \
  /            (1/2)\                    14            |
  \-28 + 84 I 3     /      - --------------------------|
                                                  (1/3)|
                               /            (1/2)\     |
                             3 \-28 + 84 I 3     /     /

Erik wrote:

I need to declare a parameter, which is a vector of lists.

Usually there's no actual "need" to declare a parameter to have a very specific type, but doing so can help with debugging.

Example of element:

< [3,7,2,4], [-3,6,8,0], [-5,8,4,2]>

There is a quirk (bug perhaps?) with the `<,>` Vector constructor such that the above creates a 3x1 Matrix with list entries rather than a Vector. It can be converted to a Vector with convert(..., Vector).

Vector has n components and each list has k components. I tried declaring it like:

boxVector:=Vector(n,datatype=list());

When you create it like that you need to subvert the default fill, 0, because 0 is not a list. Like this:

boxVector:= Vector(n, fill= [], datatype= list);
or
boxVector:= Vector(n, fill= [0], datatype= list(integer));
or
boxVector:= Vector(n, fill= [0$k], datatype= [integer$k]);

To do type checking, you can compare against the type 'Vector'(list)'Vector'(list(integer)), or 'Vector'([integer$k]).

Pass the remaining equations to fsolve. It will probably use something like Newton's Method, but if it uses something else... so what? as long as you get the solution.

Assign your output to a variable, let's say out.

out:= %:

Then

sprintf("%q", out)[1..1000];

will show the first 1000 characters of the output.

I don't see any problem with the existence of commands to make plots look exactly like you want. You don't have to use them if you don't want to.

Just replace * with `&ast;`. If you want to see it clearly, you can increase the font size with axesfont= [TIMES, ROMAN, 14], or any point size that you want.

plot(x^2, x= -1..1, tickmarks= [[1/2=x^`&ast;`], [1='a']], axesfont= [TIMES,ROMAN,14]);

If you don't want to see a symbol attached to assumed variables, then issue the command:

interface(showassumed= 0);

Regarding your differential equation, it would be best if you did not use I as a variable, as it is reserved for the imaginary unit. (If you really want to use I, there is a way around that.) Here, I use J.

diffeq:= diff(J(b), b) - 2*J(b)*b = -sqrt(Pi)*exp(-2*a*b);

Differential equations are solved in Maple with dsolve, which handles this one quite readily:

dsolve(diffeq);

You wrote:

When I first tried the integration w.r.t. the parameter b (with the assumptions), I could not get the solution shown above. Should I take away the assumptions (which is only logical when differentiang wrt it)? Actually, I got the solution above only after I started formulating this question for this newsgroup. The reason why I started with the assumption is that I did not want any compex solutions (which I got for another problem). So, the question is really if it is possibe to relax the assumptions just for the sake of differentiating the integral?

As far as I can tell, the assumptions make no difference.

The mathematical constant Pi is spelled with a capital P in Maple. If you use a lowercase p, then you get an ordinary variable that prints as the Greek letter. (So there is often no way to visually determine from the output whether the Pi was entered correctly.)

ex:= sqrt(x*y*z)/(x*y*z):
simplify(ex, symbolic);

applyrule(1/sqrt(a::algebraic)*1/sqrt(b::algebraic)= 1/sqrt(a*b), %);

 

For the first problem, I'd do

L:= [[1,3], [5,8], [9,2], [5,12]]:
[seq](x[2], x in L);

For the second problem

L:= [4,2,-1,9,5,6,2,0,14,7]:
['L[2*k]' $ k= 1..iquo(nops(L),2)];

I cut and paste your 6 lines of Cyrillic text into a Windows Notepad document. Then I saved it using encoding scheme UTF-8 (the Save As dialog offers four encoding schemes: ANSI, Unicode, Unicode big endian, and UTF-8). Then I was able to read the entire file in Maple using FileTools:-Text:-ReadLine.

Change y'k':= to y||k:=


You wrote:

I know how to solve this problem in fortran....

I am curious, How do you solve it in fortran? I am somewhat surprised that any third-generation compiled language allows for variable variable names.

For b < 0, it is not true that -b + sqrt(b^2) = 0. But if we make sufficient assumptions on beta and z, Maple will simplify it to 0.

restart:
assume(z>0, beta>0);
b:= 3*beta*Pi*(3-4*cos(z)+cos(2*z))/(16*z):
-b+sqrt(b^2);
                               0

I think that it's fairly impressive that Maple proves, without further prompting (via e.g. simplify or is), that 3 - 4*cos(z) + cos(2*z) >= 0 for all z > 0.

You asked:

which package in maple can I use to solve nonlinear ODEs

Since your next question is about Newton's method, I am guessing that you mean numerical solution. Is that right? There is no separate package for it; it is all handled by command ?dsolve . See also ?dsolve,numeric .

Also, can I use the Newtons Method?

You cannot use it directly, but it can be a component of the solution method. There are 15 solution algorithms for IVPs, four for BVPs, and three for DAE/IVPs. Many of those allow for an implicit option, which is, I guess, like using Newton's method to solve the system for the numeric derivatives.

If you have an object and a procedure that you want to apply to all of its subobjects of a given type, the command for that is subsindets or evalindets.

Round2:= proc(x, n::nonnegint:= 1)
     if x::float then
          parse~(sprintf~(cat("%.",n,"f"), x))
     else
          subsindets(x, float, thisproc, n)
     end if
end proc;

First 349 350 351 352 353 354 355 Last Page 351 of 390