Carl Love

Carl Love

28015 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

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;

Just guessing here, because I don't have time to test this right now. I think that you need to divide each color number by 256, and possibly do an evalf also, to put it in the 0..1 floating-point form that Maple plots expect.

Code occuring inside procedure or function definitions is not evaluated until the procedure is called. In your case, the i is not being evaluated at the time you create the arror (->) expressions. The way around this is to use ?unapply , which evaluates the expression first and then makes it into a procedure.

procVec3:= proc(U::~Vector(realcons))::list(procedure);
local i::posint, u::symbol;
 
     [seq](unapply(piecewise(u < U[i-1], 0, u < U[i], 1), u), i= 2..numelems(U));
end proc;

Some other pointers:

  1. It is a bad practice (very inefficient) to assign to list entries, although Maple will begrudingly allow it for lists with fewer than 101 elements. The alternative is to assign to a Vector, table, or Array. These can be easily converted to a list when you're done assigning.
  2. There is no need to contruct a list or to initialize its entries to 0 before assigning it or to its entries. Vectors and Arrays need to be constructed (and are automatically initialized to 0). It's a good idea to construct a table before assigning, though not strictly necesary. Tables are not initialized to 0 unless sparse is specified in the constructor.
  3. There is no need to return something which was the last expression evaluated; it is automatically returned.
  4. It is a bad idea to use explicit compound conditions (e.g. conditions with and or or) directly in piecewise. Compound conditions can be expressed in inert form, And(..., ...), or just use the natural left-to-right number-line order like I did above (see ?piecewise ).
  5. There is no need to declare the type of every variable, although it will help with debugging. In the above procedure, I went a bit overboard with the type declarations just to show what is possible.

How about a single command rather than a do loop?

f||(1..99):= 'randpoly([y||(1..99)])+`+`(y||(1..99))' $ 99:

Now your functions are named f1, f2, ..., f99.

As Markiyan said, these variables are not subscripted, strictly speaking.

If you expand the expressions "by hand", you will see that all the t's cancel.

t*x + (1-t)*x = t*x + x - t*x = x.

I will give an example of inputting a piecewise function, but I don't know what you mean by "solve a piecewise function". The general pattern is

piecewise(cond1, piece1, cond2, piece2, ..., condN, pieceN, piece_otherwise);

where cond1, ..., condN are Boolean expressions (typically simple inequalities in one variable), and piece1, ..., pieceN, and piece_otherwise are algebraic expressions (typically with the same variable being considered the independent variable).

Example:

f:= piecewise(x < 0, x^2, x < 1, x+1/2, x < 2, 1, 1.25);
plot(f, x= -1..3, discont, symbol= solidcircle, symbolsize= 15);

Note that at each condition, going left to right in the command, it is assumed that the conditions to the left have already been rejected, so the second condition in the example can be simply x < 1; there's no need to make it a compound condition such as 0 <= x and x < 1. (If you must enter compound conditions, see ?piecewise for details on the inert form required.)

Once you have f input, you can use it like any other algebraic expression in Maple: You can incorporate it into a more-complicated expression, and you can apply commands such as solve, diff, int, limit etc., and, to a limited extent, dsolve.

Assign the solution from QPSolve to a variable. For example,

Sol:= QPSolve(...);

Now, whenever you want one of the variables from Sol, use eval(... , Sol[2]); For example,

x1:= eval(x1, Sol[2]);

or

eval(y, Sol[2]) + eval(z, Sol[2]);

Just place a list of 6 colors in the cuboid command:

rand256:= rand(0..255):
RandColor:= ()-> COLOR(RGB, evalf(['rand256()/256' $ 3])[]):
C:= plottools:-cuboid([0$3], [1$3], color= ['RandColor'() $ 6]):
plots:-display(C, transparency= 0.5, axes= none);

In your eq16 you missed transcribing the leading minus sign from eq15.

Continuing from that point, you should have

eq16:= subs(C= -hmax*ln(-hmax), eq13);
eq17:= solve(eq16, h);

#Include initial condition in dsolve solution.
eq11_1:= dsolve({eq10, h(0)=0}, implicit);
eq12_1:= solve(eq11_1, h(t));

simplify(eq12_1 - eq17);

And you should get 0 (I did) indicating that the two methods are equivalent.

@esbestan 

M is a matrix that you can work with. But the interface, by default, does not display large matrices, even though the matrix still exists in the computer's memory. You can change the default behavior with the command

interface(rtablesize= infinity);
M;

and you will see all of M. You can also view submatrices. For example, to see the 1st through 10th rows and the 10th through 20th columns,

M[1..10, 10..20];

Well, obviously, you can't just use ... and expect Maple to figure out the pattern; you have to use seq. But there is a problem with using the seq with the vertical bars | ... |. To get around this, we use the vertical bar Matrix constructor in prefix form, `<|>`(...), like this:

restart:
m:= 32:
for i from 0 to m-1 do  h[i]:= unapply(t^i)  end do:
H:= unapply(< seq(h[i](t), i= 0..m-1) >, t):
M:= `<|>`(seq(H(i/m), i= 0..m-1));

First 354 355 356 357 358 359 360 Last Page 356 of 394