C_R

1187 Reputation

18 Badges

3 years, 251 days

MaplePrimes Activity


These are answers submitted by C_R

You clould use alias this way

indets(f__4, 'specfunc(RootOf)');
alias(seq(r || i = %[i], i = 1 .. nops(%)));
f__4;

to compact further [edit:] for better readabilty

It's always good to post an example. Maybe this could work for you

expr := sin(x) + ln(x);
series(expr, x = 0);
convert(%, polynom);

Update:

I think what you want to achieve is not exactly possible.

Here it is stated that a logaritmic function is a transcendental function and further:

a transcendental function is an analytic function that does not satisfy a polynomial equation

degree(fin, Psi)

 in the for loop does not evaluate to a number.

I converted your post to a question which increases the likelyhood that you get an answer. Here is mine

B := Matrix([[AA, BB, CC], [EE, DD, 0], [GG, 0, II]]);
Evalues := LinearAlgebra:-Eigenvalues(B);
zip((x, y) -> x = y, B, A);
convert(%, set);
subs(%, Evalues);

I have also added the TAG Eigenvalue. Consider deleting unspecific TAGs like Maplecloud.


Update: If you inspect the intermediate martix B you will see why the output becomes so large. The ouput from Eigenvectors is even larger (it contains eigenvalues and eigenvectors) and also with my suggestion the output limit is exceeded. You can still use Eigenvectors with a colon at the end and assign the command to a name and manipulate the single elements which are still large.

Eigen_Values_with_intermediate_Matrix.mw

to get the output you want.

Note that strictly speaking f(x,y) becomes f(x) and y a constant y0 of f (i.e. y is not an independend variable of f any more). 

A

f(x, y)

f(x, y)

(1)

diff(f(x, y), x)+diff(f(x, y), y)

diff(f(x, y), x)+diff(f(x, y), y)

(2)

subs(f(x, y) = f(x, y0), diff(f(x, y), x)+diff(f(x, y), y))

diff(f(x, y0), x)+diff(f(x, y0), y)

(3)

simplify(diff(f(x, y0), x)+diff(f(x, y0), y))

diff(f(x, y0), x)

(4)

 

 

B

expand(Eval(diff(f(x, y), x)+diff(f(x, y), y), y = y0))

Eval(diff(f(x, y), x), {y = y0})+Eval(diff(f(x, y), y), {y = y0})

(5)

Eval(diff(f(x, y), y), {y = y0}) = 0

Eval(diff(f(x, y), y), {y = y0}) = 0

(6)

subs(Eval(diff(f(x, y), y), {y = y0}) = 0, Eval(diff(f(x, y), x), {y = y0})+Eval(diff(f(x, y), y), {y = y0}))

Eval(diff(f(x, y), x), {y = y0})

(7)

value(%)

diff(f(x, y0), x)

(8)

 

NULL

Download Ellimiate_derivative.mw

Find attached a fix with

Don't ask me what's wrong with R.

Update: I have just seen that you found it.

Download MY_Code_fix.mwMY_Code_fix.mw

For a solution including C add this to the end of your worksheet

restart;
C = ((np/Kp + nw/Kw + ng/Kg)/(`ρg`*ng + `ρp`*np + `ρw`*nw))^(1/2);
isolate(%, ng);

The restart removes the assignement to C which is the reason for the output 0=0, which is a strange way of saying that the left hand side and the rigth hand side of the equation are identical.

The solution of your first isolate statement is correct

((np/Kp + nw/Kw + ng/Kg)/(`ρg`*ng + `ρp`*np + `ρw`*nw))^(1/2);
isolate(%, ng);
simplify(subs(%, `%%`));

 

Assuming that C is real valued there are 3 solutions if and only if C>1.

You can see this in the intersection points of the two curves.

There is no explicit for solution for the equation and therefore Maple returns the RootOf expression

eq := X = sin(C*X)

X = sin(C*X)

(1)

subs(C = 2, eq)

X = sin(2*X)

(2)

plot({lhs(X = sin(2*X)), rhs(X = sin(2*X))}, X = -1 .. 1)

 

solve(X = sin(2*X), X)

sin(RootOf(_Z-2*sin(_Z)))

(3)

solve(evalf(X = sin(2*X)), X, allsolutions)

.9477471335, -.9477471335, 0.

(4)

NULL

Download x_eq_sin_cx.mw

Update:

To be more precise I should have added that when C is increased fruther more roots apprear (with an increment of 2) as solutions in the interval -1..1.

 

  1. Use OCR text recognition to create a text file. Pay close attention to characters that may appear similar, such as D, O, Q, and 0.

  2. Preserve the first six characters for the comment character C and line numbers, as these are important for the goto jumps.

  3. Convert the Fortran code to C using a tool that eliminates all gotos. f2c is a commonly used tool for this purpose and supposed to replace gotos by flow statement (if while, ...). I have never used it.

  4. After translating to C, manually convert the code to Maple statements, as there seems to be no import feature for this.

Or see if the attached file (without OCR proofreading) makes any sense and can be used

LocalMin := proc (f::function, a::numeric, b::numeric, eps::numeric, t::numeric) local sa, sb, x, w, v, e, fx, fw, fv, m, tol, t2, r, q, p, u, fu; sa := a; sb := b; x := sa+.381966*(S8-sa); w := x; v := w; e := 0.; fx := f(x); fw := fx; fv := fw; m := .5*(sa+sb); tol := eps*abs(x)+t; t2 := 2.0*tol; while t2+(-1)*.5*(sb-sa) < abs(x-m) do r := 0.; q := r; p := q; if tol < abs(e) then r := (x-w)*(fx-fv); q := (x-v)*(fx-fw); p := (x-v)*q-(x-w)*r; q := 2.0*(q-r); if 0 < q then p := -p else q := -q end if; if q*(sa-x) < p and p < q*(sb-x) then d := p/q; u := x+d; if u-sa < t2 or sb-u < t2 then d := abs(tol) end if else if m <= x then d := sa-x else d := sb-x end if; d := .381966*d; u := x+d end if; if abs(d) < tol then u := x+abs(tol)*sign(d) end if else if m <= x then d := sa-x else d := sb-x end if; d := .381966*d; u := x+d; if abs(d) < tol then u := x+abs(tol)*sign(d) end if end if; fu := f(u); if fu <= fx then if x <= u then sa := x else sb := x end if; v := w; fv := fw; w := x; fw := fx; x := u; fx := fu else if u < x then sa := u else sb := u end if; if fu <= fw or w = x then v := w; fv := fw; w := u; fw := fu else if fu <= fv or v = x or v = w then v := u; fv := fu end if end if end if end do; return fx end proc

proc (f::function, a::numeric, b::numeric, eps::numeric, t::numeric) local sa, sb, x, w, v, e, fx, fw, fv, m, tol, t2, r, q, p, u, fu, d; sa := a; sb := b; x := sa+.381966*(S8-sa); w := x; v := w; e := 0.; fx := f(x); fw := fx; fv := fw; m := .5*(sa+sb); tol := eps*abs(x)+t; t2 := 2.0*tol; while t2+(-1)*.5*(sb-sa) < abs(x-m) do r := 0.; q := r; p := q; if tol < abs(e) then r := (x-w)*(fx-fv); q := (x-v)*(fx-fw); p := (x-v)*q-(x-w)*r; q := 2.0*(q-r); if 0 < q then p := -p else q := -q end if; if q*(sa-x) < p and p < q*(sb-x) then d := p/q; u := x+d; if u-sa < t2 or sb-u < t2 then d := abs(tol) end if else if m <= x then d := sa-x else d := sb-x end if; d := .381966*d; u := x+d end if; if abs(d) < tol then u := x+abs(tol)*sign(d) end if else if m <= x then d := sa-x else d := sb-x end if; d := .381966*d; u := x+d; if abs(d) < tol then u := x+abs(tol)*sign(d) end if end if; fu := f(u); if fu <= fx then if x <= u then sa := x else sb := x end if; v := w; fv := fw; w := x; fw := fx; x := u; fx := fu else if u < x then sa := u else sb := u end if; if fu <= fw or w = x then v := w; fv := fw; w := u; fw := fu else if fu <= fv or v = x or v = w then v := u; fv := fu end if end if end if end do; return fx end proc

(1)

NULL


Download bard.mw

Good luck

Add this to your worksheet

EQlist := [eq10, eq11, eq12, eq13, eq14, eq15, eq16]:
{seq(i = op(0, i), i in indets(%, function(identical(t))))};
subs(%, EQlist);

The line in the middle creates a replacement set for any set of equations.

Taking x<=y and y<=z as the two inequaltities the region inside the cube looks like this

Here I have only added two equations to Kitonums answer for the cube

plots:-implicitplot3d(max(x - y, -y + z, -x, x - 1, -y, y - 1, -z, z - 1), x = -0.5 .. 1.5, y = -0.5 .. 1.5, z = -0.5 .. 1.5, style = surface, shading = z, axes = normal, grid = [100, 100, 100]);

Update:

I made a sign error in the above plot command. It should be

plots:-implicitplot3d(max(x - y, y - z, -x, x - 1, -y, y - 1, -z, z - 1), x = -0.5 .. 1.5, y = -0.5 .. 1.5, z = -0.5 .. 1.5, style = surface, shading = z, axes = normal, grid = [100, 100, 100])

The ployhedron above only has 4 surfaces. Therefore 4 inequalties are sufficient.

0 <= x and z <= 1 and x <= y and y <= z
plots:-implicitplot3d(max(x - y, y - z, -x, z - 1), x = -0.5 .. 1.5, y = -0.5 .. 1.5, z = -0.5 .. 1.5, style = surface, shading = z, axes = normal, grid = [100, 100, 100]);

The forget command can be used to clear remember tables and therefore free memory.

You could try it within the loop before the next iteration.

Its not fully clear what you want to achieve. Partly because your model does not simulate, and so the result window does not show the structure of your assembly.

However, I can give some recommendations:

  • Make yourself familiar with the flexible beam component with simple cases. It’s a sophisticated component with many parameters that must be set correctly. I have attached double-sided clamped beams which can serve as a first building block to simulate an over-constrained structure.
  • Try to model one rail before adding the second rail.
  • Instead of using the flexible beam frame component use several flexible beam components. I.e. wherever you add a support (a sleeper) or a force, split the flexible beam in two parts. This makes life easier, and a better approximation can be achieved with overall fewer elastic coordinates (see next bullet point).
  • Pay attention to the elastic coordinates. For an over-constrained structure, you need higher numbers. EC=1 won’t work for your problem (and also not for the attached models). Set also elastic coordinates to zero that you do not need to speed up calculation.
  • Make sure that the profile of the rail is correctly oriented to the coordinate frames you use.
  • Each time you increase the complexity of your model save a version.

I hope this helps

 

Double_sided_clamped_beam.msim

Double_sided_clamped_beam_with_prismatic_joint.msim

If your question is about designing a block diagram:

To model something in MapleSim, you need a design or concept. Do you have something like that?

If so, then each (essential) functional element has to be represented by MapleSim components. These components could be referred to as blocks but they are special in the sense that connections between components do not have arrows (the components are acausal).

If you really want a block diagram with arrows like in Simulink you have to use MapleSims Signal Blocks (but then you miss out the simplicity of physical modeling with MapleSim).

If your question is about importing existing block diagrams:

Here is a recent post on MapleSim BlockImporter.

You have to connect the prescibel motion drivers for translation and rotation in series.

See the attached
Spatial_Motion2_fix.msim

1 2 3 4 5 Page 1 of 5