Joe Riel

9530 Reputation

23 Badges

20 years, 26 days

MaplePrimes Activity


These are answers submitted by Joe Riel

You need to use ?dsolve, which is Maple's differential equation solver.  Note that for consistency you need to change y^2 to y(x)^2.  Try it without making that change, dsolve will give an appropriate error message indicating what is wrong.

Alas, I wasn't able to get dsolve to return a solution. One way to work around that is to remove one of the boundary conditions, then pass that to dsolve.  The result is an equation with a constant that you need to solve for.  That can be done with a call to fsolve.

Here's the basic idea,

deq := {diff(y(x),x,x)-y(x)^2=0, (y(0)=100};
dsol := dsolve(deq):
eqC2 := eval(dsol, [x=2, y(x)=1]):
solC2 := fsolve(%, {_C2});
                     {_C2 = -0.4846159078}

Because I'm uncertain how the system is supposed to be configured, I'll describe a simpler system that might be applicable.

Consider a system consisting of a mass connected by a spring to a fixed point.  The spring allows the mass to both rotate and move back and forth.  The mass is constrained to move along the line from the mass to the reference point. This line also defines the single axis of rotation.  You can model that with four multibody components: a fixed reference, a prismatic joint, a revolute joint, and a rigid body.  The joints have parameters for the corresponding spring constants (and dampers, if desired). The rigid body has parameters for mass and moment of inertia.  Align the axis of movement of the prismatic joint with the axis of revolution of the revolute joint (the e_1 parameter is used for each of them).

You could look at what is used in DynamicSystems:

kernelopts(opaquemodules=false):
print(DynamicSystems:-PhasePlot:-unwrap):

It has its uses. For example, following a while loop it can be used to determine the final count.  It also can be use to determine whether a loop exited early.  Given that it has been this way for a long time, and a change would break exisiting code, it is likely to remain.

There are multiple ways to do so.  Two possiblities are ?rtable_dims and ?LinearAlgebra,Dimension.

That is not a solution.  Note the absence of t.

What do you want it to do with, say, a*c*b?  Or a*b*a?  The latter could return either a or -a depending whether the operator is left or right associative.

You can use ?LibraryTools[Browse].  I find it a bit clunky, and it occasionally does not format the code properly, i.e. does not call showstat when it should have, but it has its uses.

To make it easier, I added the source file to the zip file (and fixed a minor bug).  See the original post; the new zip file is version 0.2.  The source isn't the cleanest. I originally wrote this just to have a SHA1 algorithm, then later extended it to SHA2.

M := Matrix(8, [0, 0, 0, 0, 0, 0, 0, 0,
                0, 1, 1, 1, 1, 1, 1, 0,
                0, 1, 0, 0, 0, 0, 1, 0,
                0, 1, 0, 1, 1, 0, 1, 0,
                0, 1, 0, 0, 0, 0, 1, 0,
                0, 1, 0, 0, 0, 0, 1, 0,
                0, 1, 1, 1, 1, 1, 1, 0,
                0, 0, 0, 0, 0, 0, 0, 0
               ]):
with(ImageTools);
ImgM := Create(M):
Preview(ImgM);

You can also you View, but the result is quite small.

Here's a slight variation of Acer's method. 

`++` := proc(x::uneval) x := eval(x)+1; _rest end proc:
cnt := 0:
seq(`++`(cnt,i), i=1..4);
                                  1, 2, 3, 4

cnt;
                                       4

Are you working with a particular package?

Try the ?sprintf function.  For example

filename := sprintf("parameter-name=%a.txt", value);

The error message is explicit; it is expecting an integer.  The only issue is which %d format is not being passed an integer. The answer is 'unitweight', it is a float.  Try changing the particular %d to %f or %a.

The usual way to do this is with ?unapply.  For example,

t := 3:
f := unapply(x*t, x):

However, for that to work one generally needs an expression (here x*t) to convert to a procedure.  That can be a bit tricky when, instead, you have a procedure.  One way is to use the curry procedures (?curry and ?rcurry).

g := (x,y) -> x*y:
t := 3:
f := curry(g,t):

In the template you gave we can do

MyProcedure := proc(list_of_values)
local l_funcs;
l_funcs := map2(curry, SomeFunction, list_of_values);
plot(l_funcs, 0..10);
end proc:
First 53 54 55 56 57 58 59 Last Page 55 of 114