C_R

1197 Reputation

18 Badges

3 years, 259 days

MaplePrimes Activity


These are answers submitted by C_R

before fsolve you do

W := unapply(W(Y), Y)

With 2023 I get

Maple can formally differentiate W but not evaluate the result at 0

Do you really want to "make functions" with unapply that way?

 

Unfortunately, the 3d workspace is not working well with newer features and functionalities (like the CAD toolbox in your case).

A workaround, that hopefully will not become good practice, is to copy the content of the subsystem and paste it to the main subsystem canvas. The subsystem from the CAD toolbox can be binned or later, after finished assembly, replace the pasted components.

Ein Bild, das Diagramm, Screenshot, Text enthält.

Automatisch generierte Beschreibung

@ Maplesoft developers: Shouldn’t the subsystem ports not be outboard frames (i.e. in white and not in grey)

@Maplesoft management: Please provide resources to update the 3D workspace. In its current state it really makes a bad impression on MapleSim. If it works the way as intended, it is very useful for easy model assembly and inspection.

mine1-5.msim

I do not know if this is programmatically possible (in a reasonable way):

You could use the kernel option cpulimit to terminate an instance of Mapleserver.exe that was started by a batch job. The batch job is processing a batch of mws files (like the attached) each containing a different expression to integrate and a call to kernelopts. keneropts,cpulimit is predictable to what I have seen but kills everything.

That would be a brute Roundup method not taking care “to abort safely” as stated on the timelimit help page.

If this would be possible with a proc statement you could even do the batch processing with Maple.

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.

1 2 3 4 5 6 Page 1 of 6