MaplePrimes Questions

As my jobs are still crashing with memory leak, I'd like to write results out to files and read them back to add them together.

I see something called 'Export' and something called 'Import'. It didn't work for me. Does the file have to already exist? An example would be nic

I want to plot this function in cylindrical coordinates in a way that it is clear where the function is greater than zero and where it is less that zero. I was wondering what would be the best way to do it. It has two arbritary constants. Usually when I have only one constant, I animate the plot for different values of that constant. But I am not sure what to do for this case.

-2*M^2*sin(theta)^2 - 2*k*r^2

eq1 := diff(f(x), x, x, x)+(1/2)*x*cos(alpha)*(diff(f(x), x, x))+(1/2)*sin(alpha)*f(x)*(diff(f(x), x, x))+G[r]*theta(x)+G[m]*phi(x) = 0;

eq2 := diff(theta(x), x, x)+(1/2)*Pr*cos(alpha)*x*(diff(theta(x), x))+sin(alpha)*f(x)*(diff(theta(x), x))+N[b]*(diff(theta(x), x))*(diff(phi(x), x))+N[t]*(diff(theta(x), x))^2 = 0;

eq3 := diff(phi(x), x, x)+(1/2)*Le*cos(alpha)*x*(diff(phi(x), x))+sin(alpha)*f(x)*(diff(phi(x), x))+N[t]*(diff(theta(x), x, x))/N[b] = 0;

ics := f(0) = 0, (D(f))(0) = gamma*((D@@2)(f))(0), theta(0) = 1+tau*(D(theta))(0), phi(0) = 1;

bcs := (D(f))(infty) = 0, theta(infty) = 0, phi(infty) = 0;

Parameters := G[r] = 5, G[m] = 3, Pr = 7, N[b] = .1, N[t] = .1, Le = 1, gamma = .2, tau = .1, alpha = 30*degree;

Hi Everyone, 

I have a numeric integral which I hope to evaluate (ideally over a infinite domain) that for some reason is giving me difficulty and I cannot seem to find a work around. I want to use method = _d01amc in the integral as a means to speed up the process - I am motivating this by the answer i recieved from @acer in https://www.mapleprimes.com/questions/236772-Any-Ideas-On-How-To-Speed-Upimprove - however I keep recieving an error indicating overflow. 

This seems rather strange to me due to the fact that if I omit a method and just let Maple do its own thing it will eventually spit out an answer albeit slower then I would prefer for the procedure I am going to eventually impliment. 

My integrand and attempts/confusion can be seen in the attached worksheet. 

Any thoughts appreciated. 

OverflowError.mw

The sequence A161786 consists of “primes with at least one digit appearing exactly four times in the decimal expansion”. Below is the Maple program given in that OEIS page:

The code above picks out primes having exactly four identical digits (determined by ) from the first 10,000 prime numbers. However, it's easy to check that this program is rather slow (It takes about 2.6s to execute it!). 
Actually, I would like to select such primes from pn, pn+1, pn+2, …, pn+m-1 (typically, n=1,000,000 and m=1,000,000), where pk denotes the k-th prime number, yet the original program failes to do so in twenty minutes. Part of the reason is that for long sequences, the efficiency can be critical. Therefore I make a slight modification to the original code: 

A161786__0 := proc(m::nonnegint, n::posint := 1, ` $`)::'Vector'(prime):
	#(*
	    kernelopts(opaquemodules = false):
	# *)
	local p := ifelse(n = 1, 1, ithprime(n - 1)), vec := Vector('datatype' = prime);
	to m do
		if ormap(`=`, MultiSet(`convert/base`:-MakeSplit(length((p := nextprime(p))), 1, 10)(p)):-hash, 4) then
			vec ,= p
		fi
	od;
	vec
end:

Nevertheless, this version is still inefficient: 

time[real](A161786__0(10**6, 10**6));
 = 
                            182.414

Another choice is converting each of integers into a string: 

A161786__1 := proc(m::nonnegint, n::posint := 1, ` $`)::'Vector'(prime):
	options no_options:
	local p := ifelse(n = 1, 1, ithprime(n - 1)), vec := DEQueue();
	to m do
		if member(4, rhs~({StringTools['CharacterFrequencies'](nprintf("%d", (p := nextprime(p))), 'digit')})) then
			vec ,= p
		fi
	od;
	Vector([vec[]], 'datatype' = prime)
end:

This time the elapsed time is reduced to nearly two minutes: 

time[real](A161786__1(10**6, 10**6));
 = 
                            118.409

But can this task be accomplished within (a quarter of) a minute in modern Maple? In other words, is there a way to make further improvement on the performance? (Note that the reference time is mesured using a adjusted version (i.e., ) of the Mma code provided in that OEIS page.) 

How would you solve this equation System:

x+|y+1|=1

y+|z+2|=1

z+|x-2|=1

I have no idea what to do, van please someone help me?

Hi,

I am looking for a code to randomly generate 10 equations (powers and radicals) of this type. Any ideas? Thank you.

Note: I would -prefer an answer for Maple 2015, but I can accommodate an answer for a more recent version.

I have a function Gpdf from IR2 to IR+ of class C1 (this comes from the way this function is built).
Although its level curves are continuous, their display show discontinuities for some level values. 

The reason is that  Gpdf contains a term whose denominator vanishes and so, even if the left and right limits of Gpdf are the same at the vanishing point, the resulting plot is dicontinuous.

More details are given in the attached file Discontinuous_contours.mw.

I have tried to adjust the plotting grid, or even to superimpose contours drawn in domains containing no singularities, but I wasn't capable to get continuous drawings (see the attached file).

Do you have any idea to achieve this?

TIA

Hi!

I have M number of linear differential equations. I have solved this system using the 1,2,3,4 stag RK method in the attached file but did not find a significant difference in the accuracy. Kindly see what's wrong there. 

Thank you!

s-stage.mw

When printing a Maple Worksheet  often I go in the PrintPrewiev of the Mac and then select some sides to print.

This is not working anymore since I have updated from Maple 2021 to Maple 2023.

Is this known ?

Any help for his ?

I was trying to assign a Vector to a Vector inside a procedure. However, when the Vector has a size of 5, I was able to do that. But not when the Vector has a size of 7.

I have the following example. I can't assign the Vector over when the Vector has a size of 7 as shown in oneStep_egcd2.  But I can do that when the size is 5 in oneStep_egcd. Copying the contents over using a for loop works as expected. 

 

a:= 17; b:= 5;

17

 

5

(1)

 

# <s, a, t, b, g>
prev := <1, a, 0, b, a>;

Vector(5, {(1) = 1, (2) = 17, (3) = 0, (4) = 5, (5) = 17})

(2)

curr := <0, a, 1, b, b>;

Vector(5, {(1) = 0, (2) = 17, (3) = 1, (4) = 5, (5) = 5})

(3)

oneStep_egcd := proc(prev::Vector, curr::Vector)
    local q, t1, t2, t3;
    if (curr[5] <> 0) then
        q := iquo(prev[5], curr[5]);
        t1, t2, t3 := prev[1] - curr[1] * q, prev[3] - curr[3] * q, prev[5] - curr[5] * q;
        prev = curr;
        curr[1], curr[3], curr[5] := t1, t2, t3;
    end if:
end proc:

oneStep_egcd(prev, curr)

1, -3, 2

(4)

NULL

NULL

# <s, expr_s, a, t, expr_t, b, g>
prev := <1, 1, a, 0, 0, b, a>;

Vector(7, {(1) = 1, (2) = 1, (3) = 17, (4) = 0, (5) = 0, (6) = 5, (7) = 17})

(5)

curr := <0, 0, a, 1, 1, b, b>;

Vector(7, {(1) = 0, (2) = 0, (3) = 17, (4) = 1, (5) = 1, (6) = 5, (7) = 5})

(6)

oneStep_egcd2 := proc(prev::Vector, curr::Vector)
    local q, sb_q, t1, t2, t4, t5, t7;
    if (curr[7] <> 0) then
        q := iquo(prev[7], curr[7]);
        sb_q := (q);
        t1 := prev[1] - curr[1] * q;
        t2 := prev[2] - curr[2] * q;
        t4 := prev[4] - curr[4] * q;
        t5 := prev[5] - curr[5] * q;
        t7 := prev[7] - curr[7] * q;
        prev := curr;
        curr[1], curr[2], curr[4], curr[5], curr[7] := t1, t2, t4, t5, t7;
    end if:
end proc:

oneStep_egcd2(prev, curr)

Error, (in oneStep_egcd2) invalid left hand side in assignment

 

NULL

oneStep_egcd3 := proc(prev::Vector, curr::Vector)
    local q, sb_q, t1, t2, t4, t5, t7, i;
    if (curr[7] <> 0) then
        q := iquo(prev[7], curr[7]);
        sb_q := (q);
        t1 := prev[1] - curr[1] * q;
        t2 := prev[2] - curr[2] * q;
        t4 := prev[4] - curr[4] * q;
        t5 := prev[5] - curr[5] * q;
        t7 := prev[7] - curr[7] * q;
        for i to 7 do
            prev[i] := curr[i];
        end do;
        curr[1], curr[2], curr[4], curr[5], curr[7] := t1, t2, t4, t5, t7;
    end if:
end proc:

oneStep_egcd3(prev, curr)

1, 1, -3, -3, 2

(7)

NULL

Download ErrorExample.mw

Hello

I want to write a program to get unknown coefficients of multiple polynomials. I have a problem with this program. The code sometimes doesn't work. Can anyone help me? It's very important to me.

restart

with(student)

``

EQ[0] := tanh(d)*b[1]*(b[1]+1)

tanh(d)*b[1]*(b[1]+1)

(1)

EQ[1] := -(-1+(a[1]-b[1]-1)*tanh(d)^2+(a[0]+1)*tanh(d))*b[1]

-(-1+(a[1]-b[1]-1)*tanh(d)^2+(a[0]+1)*tanh(d))*b[1]

(2)

EQ[2] := tanh(d)*((a[1]-b[1])*(a[0]+1)*tanh(d)-b[1]^2-a[1])

tanh(d)*((a[1]-b[1])*(a[0]+1)*tanh(d)-b[1]^2-a[1])

(3)

EQ[3] := (-a[1]^2+(2*b[1]-1)*a[1]-b[1]^2-b[1])*tanh(d)^2+(a[1]+b[1])*(a[0]+1)*tanh(d)-a[1]-b[1]

(-a[1]^2+(2*b[1]-1)*a[1]-b[1]^2-b[1])*tanh(d)^2+(a[1]+b[1])*(a[0]+1)*tanh(d)-a[1]-b[1]

(4)

EQ[4] := -tanh(d)*((a[1]-b[1])*(a[0]+1)*tanh(d)+a[1]^2+b[1])

-tanh(d)*((a[1]-b[1])*(a[0]+1)*tanh(d)+a[1]^2+b[1])

(5)

EQ[5] := -a[1]*(-1+(-a[1]+b[1]-1)*tanh(d)^2+(a[0]+1)*tanh(d))

-a[1]*(-1+(-a[1]+b[1]-1)*tanh(d)^2+(a[0]+1)*tanh(d))

(6)

EQ[6] := (a[1]+1)*a[1]*tanh(d)

(a[1]+1)*a[1]*tanh(d)

(7)

Eqs := {seq(EQ[i], i = 0 .. 6)}

Sol := solve(Eqs, {a[0], a[1], b[1]})NULL

{a[0] = a[0], a[1] = 0, b[1] = 0}, {a[0] = (tanh(d)^2-tanh(d)+1)/tanh(d), a[1] = -1, b[1] = -1}, {a[0] = -(tanh(d)-1)/tanh(d), a[1] = -1, b[1] = 0}, {a[0] = -(tanh(d)-1)/tanh(d), a[1] = 0, b[1] = -1}

(8)

for i from 2 to 4 do Case[i] := allvalues(Sol[i]) end do

{a[0] = -(tanh(d)-1)/tanh(d), a[1] = 0, b[1] = -1}

(9)

``

T1.mw

T2.mw

My Maple-Program is creating svg-files (or PNG) in a squared format.
There are a lot of these files in a local folder.
I would like to add a white surrounding frame (10% of the Imagesize) to it and afterwards store it as a TIFF file.

Studying ImageTools I have not found a way to solve this with ImageTools.

Until now I am using a graphic software to add a frame and store as TIFF in a desired resolution.

Now I plan to do this process automatically with maple.

Thanks for support :)

I found this option mentioned in help(MapleSim,Multibody,Dynamic_Exports).

For the example of the help page I tried

SliderCrank:-GetDynEQs(AugType = Reaction);
SliderCrank:-GetDynEQs(AugType = Lagrange);

but the output is the same (which I would expect since GetDynEQs is not defined with parameters).

In the help system I only find deprecated commands that use this option

How can this option be set in newer versions of MapleSim without using deprecated commands?

For the following Equation:

Equation := int(diff(u(x), x)*v(x), x) = int(u(x)^(1/2)*v(x), x)^(-2/3);
Maplesoft finds the following solution:

Solution1:=3/4*u(x)^(4/3) + 2/3*u(x)^(5/6)*Intat(1/(sqrt(u(x))*Int(v(_b), _b))^(5/3), _b = x) + _C1 = 0

or , which I believe as an alternative, can be written as

Solution2:=3/4*u(x)^(4/3) + 2/3*u(x)^(5/6)*Int(1/(sqrt(u(x))*Int(v(x),x))^(5/3) +_C1=0

My question is how did Maple arrive at 'Solution1' from 'Equation'? In other words, can someone fill

in the steps between 'Equation'  and 'Solution1'? Or even, prove that Solution 1 is a valid solution to Equation.

Plugging the Solution1 into Equation, did not clearly demonstate the validity of the solution (to me at least)

Unfortunately, I am still unable to post the corresponding Maplesoft worksheet onto this post.

First 43 44 45 46 47 48 49 Last Page 45 of 2308