Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Hello,

I have a quite big program designed with packages and subpackages.

I realized that i'm not to well understand the operation of local/ global/ export variables in this case.

Let's detail the issue.

I consider a package like this :

MAIN PACKAGE:=module()

local XM

global YM

export ZM

      SUBPACKAGE1:=module()

      local X1

      global Y1

      export Z1

      end module;

      SUBPACKAGE2:=module()

      local X2

      global Y2

      export Z2

      end module;

end module;

Question:

Can you describe in the simpliest way the rules for accessing to the variables in the case the variables are local/ global/ export and in the case you are writting procedures inside the MAINPACKAGE or the SUBPACKAGEs ?

In others words may you help me to answer to these questions  ?

Is the local variable XM accessible to the procedures used in SUBPACKAGE1? no
Is the local variable X1 accessible to the procedure used in MAINPACKAGE ? no

Is the global variable YM accessible to the procedures used in SUBPACKAGE1? yes
Is the global variable Y1 accessible to the procedure used in MAINPACKAGE ? yes

Is the export variable ZM accessible to the procedures used in SUBPACKAGE1? yes
Is the export variable Z1 accessible to the procedure used in MAINPACKAGE ? yes with the syntax SUBPACKAGE:-Z1

I let my opinion but i need certainty on these points...

I attach a first draft that i would like you help me.

AboutModuleLocalGlobalExport.mw

I thank you in advance for your help.

I could not find a function in StringTools package which removes all substrings (not single characters) from one long string directly. 

For example given a Latex string 

s:=" \\left \\int x \\,dx \\left";

And I want to remove all "\\left"  from it, which results in "  \\int x \\,dx "

In Mathematica, there is a function called StringDelete which removes all occurances of the substring in one call. Like this

s = " \\left \\int x \\,dx \\left";
StringDelete[s, "\\left"]

In Maple, I tried StringTools:-Remove(x->evalb(x="\\left"),s) and this did not work.Also tried

s:=" \\left \\int x \\,dx \\left";
StringTools:-Remove(x->StringTools:-Compare(x,"\\left"),s)

But this returned "leftintxdxleft"

And StringTools:-Delete needs a range, which one then has to first find.

I found this:

s:=" \\left \\int x \\,dx \\left";
idx:=[StringTools:-SearchAll("\\left",s)]; #returns index of first character in the string
StringTools:-Delete(s,idx[1]..idx[1]+4); #this only remove the first one. Need to loop to remove all.

Which returns the first substring. So one has to make a loop and keep removing all substrings found from the call to StringTools:-SearchAll

This is all too much work. But can be done.

The question is: What is the simplist way to remove all substrings from one string? All substrings are the same and the substrings can be more than one character.

Here is another example

s:="1234566X6Y67890A6BC66DEFGH";

And want to remove all "66" substrings, so the result will be

"12345X6Y67890A6BCDEFGH";

I am sure there must be an easier way to do this in Maple than having to call 2 or 3 functions and using a loop, but I could not find it so far. 

What would be the closest function in Maple to Mathematica's StringDelete? 

 

Requesting a code to compute (and graph) the following self referencing sequence:

a(1)=1. If a(n) is a novel term (seen for the first time) then a(n+1)= d(a(n)) where d(k) is the number of divisors of k. 
if a(n) has been seen before then a(n+1) = a(n)+m where m is the least prior term which has not already been used in this way (once m is used it cannot be used again).

Sequence starts:

1,1,2,2,3,2,4,3,5,2,4,6,4,7,2,5,7,11,2...,

note that there are often multiple copies of the least unused term, which might make accounting for them tricky. 

Thanks in advance 

 

 

hello dear maple maple users.

I'm trying to solve this system of equations using fsolve but i'm geting this unrealistic curve.

I don't know exactly how, can help me understand!!!!!.

fsolve.mw

I am working with the JetCalculus package along with the DifferentialGeometry package. Notation: if there are 2 independent variables (x,y), then u[1,2] would now represent the 3rd mixed partial derivative of u, once with respect to x and twice with respect to y. Please check Example 3 here, https://de.maplesoft.com/support/help/Maple/view.aspx?path=DifferentialGeometry/JetCalculus/TotalDiff

If I have an expression like u[1,0]+f(u[0,0])*u[0,1]+u[1,1]*u[0,3], then I am looking for a procedure which gives me the Lead derivative term. In the example above, it is u[1,1]*u[0,3], and then I can find the lead coefficient, i.e u[1,1].
Please note that the Lead derivative is not unique and can have several terms. For example, orders are the same for u[1,1] and u[0,2].

Idea: If I can find a way to extract the subscripts and do operations on them, then it would be very helpful. 
Any help/guidance is much appreciated. Thanks.
EDIT 1: LeadingDerivative command is not the solution for me.

Dear maple users,

A fine day wishes to all.

How to replace a value in already computed data value.

In my problem, I have evaluated a set of values (with help of #ma1 := evalf(seq((A4(t)), t = 0.0..1, 0.1));)  

ma1 := 0., .1941703021, .3203871063, .4089371834, .4712881303, .5145114133, .5435036431, .5617715009, .5718586242, .5756277760, .5744585726

I need to change 0 value as a 1.

I have used subs(ma[1]=1,ma1), but its coming wrong.

 

diff(w(r, theta), r)/r + diff(w(r, theta), r, r) + diff(w(r, theta), theta, theta)/r^2 = r^3*cos(3*theta)

 

Can it be solved without boundary conditions?

Hi there.

Following by https://www.mapleprimes.com/questions/232199-Bug-In-EllipticCPi

there is some strange behavior of EllipticPi - this function return complex answer when nu>1

WolframAlpha and some another online calculators return real values - just real part of Maple's value.

Why Maple's EllipticPi return complex answer?

help.mw

How to solve Linear first-order PDE by the Lagrange method?

dx/(x) =dy/0=dt/0=du/3=dv/v=dw/w, where x,y,t are independent variables and u,v,w are dependent variables.

hello guys,

I want to plot the phase plane between F and m when:

F := 736*R^4/sqrt((-1380*Pi*R*m(r)^3 + 368*R^4 - 1587*m(r)^2*R^2 + 1280*m(r)^2*a)^2);
R := X^(1/3)/(-l^2 + 4*a) - 3*l^2*m(r)^2/X^(1/3);
X := m(r)*l^2*(sqrt((27*l^2*m(r)^4 - 16*a^2*l^2 + 64*a^3)/(-l^2 + 4*a)) + 4*a)*(-l^2 + 4*a)^2;
 

and

m := (l^2*r^2 + r^4 + a*l^2)/(2*l^2*r)

for positive constant a and l

please guide me,

thanks

Hello everyone. I took part in a project in which we had to solve problems with Maple 2015. The managers gave us a permanent license. However recently I had trouble on my computer and now Maple doesn't work anymore because it somehow lost the license. The project ended last year, so I can't really ask them anymore. Is there any way to get the license working again? I checked on the site but didn't found anything useful and I'd really need it for the final exam of the last year of high school...

Thanks in advance!

Sorry file was not attached
 

ASME B31.3-2002 - Flexibility Analysis

This document considers the requirements for flexibility analysis of pipe work in accordance with standard ASME B31.3 2002 Edition.

 

 

Temperature Reduction for Swagelok fittings and tube.

 

Based on 316L Stainless steel fittings and tube, from Data Sheet MS-01-107 rev S and shown below a linear interpolation is used to determine the factor for operation at 100 and 130 centigrade.

with(Interpolation)

with(plots)

Temperature values from table. temp := [93, 204, 315, 426, 537]

Factor values from fable. fact := [1, .96, .85, .79, .76]

Graph of data points. pointplot(temp, fact)

 

facto := LinearInterpolation(temp, fact)

_m2344257169824

(1.1)

Factor for operation at 100 centigrade.facto(100) = HFloat(0.9974774774774775)NULL

Factor for operation at 130 centigrade. facto(130) = HFloat(0.9866666666666667)NULL

Swagelok compatability

 

From the B31.3 standard, Table 326.1 Component Standards, Swagelok fittings are not listed directly but it is considered that they are covered under the entry for Unified inch screw threads (UN and UNR thread form) with designation ASME B1.1. Stainless steel pipe is covered directly with designation ASME B36.19M.

Therefore the use of these parts is acceptable under the standard.

Specific Tube Sizes.

 

The initial specification suggests a DN15 tube size. This equates to 5/8", however the range of fittings in this size is limited. A preferred size would be to either go down to 1/2" or up to 3/4" tube. These will give an actual bore of ~10mm and ~15mm respectivly. In terms of the pressure and temperature specification the following information is provided from Swagelok data sheet MS-01-181.

1/2" x 0.049" wall pressure rating at 37C. TP05__37 := 3700*Unit('psi') = 3700*Units:-Unit(` psi `)NULL

3/4" x 0.065" wall pressure rating at 37C. TP75__37 := 3300*Unit('psi') = 3300*Units:-Unit(` psi `)NULL

Hence pressure ratings, converted to bar at 130C are:

TP05__130 := convert(TP05__37*facto(130), units, bar) = HFloat(251.70460624926636)*Units:-Unit(bar)NULL

TP75__130 := convert(TP75__37*facto(130), units, bar) = HFloat(224.49329746556185)*Units:-Unit(bar)NULL

Hence the tubing used in the design is acceptable.

Weld Fitting Specifications

 

There are several types of welded fittings as "Tee" "Reduceing Tee" and "Reducing Unions" and they have various pressure ratings.

A 3/4" tube butt weld "Tee" Tee75__37 := 2400*Unit('psi') = 2400*Units:-Unit(` psi `)NULL

The weld fittings have pressure rating at 130C of. Tee75__130 := convert(Tee75__37*facto(130), units, bar) = HFloat(163.2678527022268)*Units:-Unit(bar)NULL

Hence the weld fittings used in the design are acceptable.

``

Tube wall calculation

 

with(Units[Standard])

Determine the minimum wall thickness based on the design code.

Design pressure. P__D := 150*Unit('bar') = 150*Units:-Unit(bar)NULL

Outside diameter of nominal 3/4" tube. D__75 := 19.05*Unit('mm') = 19.05*Units:-Unit(mm)NULL

Quality factor. E := 1 = 1 for seamless stainless steel tube.

Allowable stress for 316L tube at 166C (300F). From B31.1 Table A1. S__allow := 115.14*Unit('MPa') = 115.14*Units:-Unit(MPa)NULL

Y__coeff := .4 = .4NULL

Miniumum wall thickness. t__min := P__D*D__75/(2*(E*S__allow+P__D*Y__coeff)) = 0.1179420505e-2*Units:-Unit(m)NULL

Actual wall thickness. W__75 := 1.65*Unit('mm') = 1.65*Units:-Unit(mm)NULL

if W__75 >= t__min then print(PASS) else print(FAIL) end if = PASSNULL``

NULLNULL

Conversions

 

From Appendix A

allowable stress for TP316L at 100C (212F).convert(16.7, units, ksi, MPa) = 115.1424468NULL

allowable stress for TP316L at room temperature.convert(25.0, units, ksi, MPa) = 172.3689323NULL

convert(18, units, m^3/h, L/minute) = 300NULL

convert(3300.0, units, psi, bar) = 227.5269907NULL

.58*% = 131.9656546NULL

convert(70.0, units, degF, degC) = 38.88888889NULL

convert(300.0, units, degF, degC) = 166.6666667NULL

convert(.117, units, Unit('dm'^3), Unit('L')) = .117NULL

with(ThermophysicalData:-Chemicals)

with(ThermophysicalData)

Property(MolarMass, He, useunits)

4.0026020*Units:-Unit(g/mol)

(3.1)

Property(density, Helium, temperature = 300*Unit(kelvin), pressure = 101325*Unit(Pa), source = CoolProp)

.1625153176*Units:-Unit(kg/m^3)

(3.2)

Helium flow rate. flow[he] := 300*Unit('L')/Unit('min')``

Determine molar flow rate. molflow[he] := .1625153176*flow[he]*Units[Unit](kg/m^3)/(4.0026020*Units[Unit](g/mol)) = .2030120876*Units:-Unit(mol/s)NULL

Determine mass flow rate. massflow[he] := 4.0026020*molflow[he]*Units[Unit](g/mol) = 0.8125765879e-3*Units:-Unit(kg/s)NULL

Property(MolarMass, CO2, useunits)

44.0095000*Units:-Unit(g/mol)

(3.3)

Property(density, CO2, temperature = 300*Unit(kelvin), pressure = 101325*Unit(Pa), source = CoolProp)

1.796636097*Units:-Unit(kg/m^3)

(3.4)

Property(MolarMass, Air, useunits)

28.9651159*Units:-Unit(g/mol)

(3.5)

Property(density, Air, temperature = 300*Unit(kelvin), pressure = 101325*Unit(Pa), source = CoolProp)

1.176995588*Units:-Unit(kg/m^3)

(3.6)

Determine the boiling point of water at 6 bar, the maxiumum pressure delivered by the cd90e unit.

boiling := Property(temperature, water, pressure = 6*Unit(bar), Q = 0)

431.9764773*Units:-Unit(K)

(3.7)

convert(boiling, temperature, Celsius)

158.8264773*Units:-Unit(`°C`)

(3.8)

evalf(convert(30, units, Unit('ft'^3/'min'), liters/s))

14.15842330

(3.9)

NULL

Input Parameters

 

Allowable stress for calculations. S[A] := evalf(f*(1.25*S[c]+.25*S[h]))`` = 219.82275*Units:-Unit(MPa)NULL

Allowable stress at minimum temperature. S[c] := 172.37*Unit('MPa')

Allowable stress at maximum temperature. S[h] := 115.14*Unit('MPa')

Stress reduction factor for N=7000 to 14000 cycles. f := .9

From Table C6 of standard, modulus of elasticity for stainless steel at room temperature.convert(28.3*10^6, units, psi, MPa) = 195121.6314NULL

Named as E[A] := 195121*Unit('MPa') = 195121*Units:-Unit(MPa)NULL

alpha[stst] := 16*10^(-6)*(Unit('m')*(1/(Unit('m')*Unit('K')))) = (1/62500)*Units:-Unit(1/K)NULL

Flexibility Stress

 

with(Units[Standard])

text##

S[E] := sqrt(S[b]^2+4*S[t]^2) =  = (S[b]^2+4*S[t]^2)^(1/2)NULL

Allowable stress factor for analysis requirement. K[allow] := 208000*S[A]/E[A] = 234.3321939NULL

Pipe diameter for 1/2" tube. D__A := 12.7*Unit('mm') = 12.7*Units:-Unit(mm)NULL

Pipe diameter for 3/4" tube. D__B := 19.05*Unit('mm') = 19.05*Units:-Unit(mm)NULL

Change in temperature. Delta[T] := 130*Unit('K') = 130*Units:-Unit(K)NULL

Section A1

Combined length of section A1.L[A1] := 110*Unit('mm')+119*Unit('mm') = 229*Units:-Unit(mm)NULL

Length increase due to thermal expansion. y[A1] := evalf(alpha[stst]*Delta[T]*L[A1]) = .4763200000*Units:-Unit(mm)NULL

U__A1 := 163*Unit('mm') = 163*Units:-Unit(mm)NULL

K[A1] := D__A*y[A1]/(L[A1]-U__A1)^2 = 0.1388719927e-2NULL

if K__A1 <= K__allow then print(PASS) else print(FAIL) end ifError, cannot determine if this expression is true or false: K__A1 <= K__allowNULL

Section A2

Combined length of section A2.L[A2] := 610*Unit('mm')+119*Unit('mm') = 729*Units:-Unit(mm)NULL

Length increase due to thermal expansion. y[A2] := evalf(alpha[stst]*Delta[T]*L[A2]) = 1.516320000*Units:-Unit(mm)NULL

U__A2 := 622*Unit('mm') = 622*Units:-Unit(mm)NULL

K[A2] := D__A*y[A2]/(L[A2]-U__A2)^2 = 0.1682004018e-2NULL

if K__A2 <= K__allow then print(PASS) else print(FAIL) end ifError, cannot determine if this expression is true or false: K__A2 <= K__allowNULL

Section A3

Combined length of section A3.L[A3] := 723*Unit('mm')+288*Unit('mm') = 1011*Units:-Unit(mm)NULL

Length increase due to thermal expansion. y[A3] := evalf(alpha[stst]*Delta[T]*L[A3]) = 2.102880000*Units:-Unit(mm)NULL

U__A3 := 778*Unit('mm') = 778*Units:-Unit(mm)NULL

K[A3] := D__A*y[A3]/(L[A3]-U__A3)^2 = 0.4919334672e-3NULL

if K__A3 <= K__allow then print(PASS) else print(FAIL) end ifError, cannot determine if this expression is true or false: K__A3 <= K__allowNULL

 

unwith(Units[Standard])

Length of section B. L[B] := 526*Unit('mm')`` = 526*Units:-Unit(mm) 

Length of section C. L[C] := 1331*Unit('mm') = 1331*Units:-Unit(mm) 

Length of section D. L[D] := 416*Unit('mm') = 416*Units:-Unit(mm) 

Length of section E. L[E] := 526*Unit('mm') = 526*Units:-Unit(mm) 

Length of section F. L[F] := 762*Unit('mm') = 762*Units:-Unit(mm) 

Length of section G. L[G] := 287*Unit('mm') = 287*Units:-Unit(mm) 

Length of section H. L[H] := 440*Unit('mm') = 440*Units:-Unit(mm) 

Length of section I. L[I] := 400*Unit('mm') = 400*Units:-Unit(mm)NULL

 

Length increase due to thermal expansion. y[B] := evalf(alpha[stst]*Delta[T]*L[B]) = 1.094080000*Units:-Unit(mm)NULL

Length increase due to thermal expansion. y[C] := evalf(alpha[stst]*Delta[T]*L[C]) = 2.768480000*Units:-Unit(mm)NULL

Length increase due to thermal expansion. y[D] := evalf(alpha[stst]*Delta[T]*L[D]) = .8652800000*Units:-Unit(mm)NULL

Length increase due to thermal expansion. y[E] := evalf(alpha[stst]*Delta[T]*L[E]) = 1.094080000*Units:-Unit(mm)NULL

Length increase due to thermal expansion. y[F] := evalf(alpha[stst]*Delta[T]*L[F]) = 1.584960000*Units:-Unit(mm)NULL

Length increase due to thermal expansion. y[G] := evalf(alpha[stst]*Delta[T]*L[G]) = .5969600000*Units:-Unit(mm)NULL

Length increase due to thermal expansion. y[H] := evalf(alpha[stst]*Delta[T]*L[H]) = .9152000000*Units:-Unit(mm)NULL

Length increase due to thermal expansion. y[I] := evalf(alpha[stst]*Delta[T]*L[I]) = .8320000000*Units:-Unit(mm)NULL

``

K[B] := D[B]*y[B]/(L[B]-u[B])^2Error, (in Units:-Standard:-+) the units `mm` and `1` have incompatible dimensionsNULL

K[C] := D[C]*y[C]/(L[C]-u[C])^2Error, (in Units:-Standard:-+) the units `mm` and `1` have incompatible dimensionsNULL

K[D] := D[D]*y[D]/(L[D]-u[D])^2Error, (in Units:-Standard:-+) the units `mm` and `1` have incompatible dimensionsNULL

K[E] := D[E]*y[E]/(L[E]-u[E])^2Error, (in Units:-Standard:-+) the units `mm` and `1` have incompatible dimensionsNULL

K[F] := D[F]*y[F]/(L[F]-u[F])^2Error, (in Units:-Standard:-+) the units `mm` and `1` have incompatible dimensionsNULL

K[G] := D[G]*y[G]/(L[G]-u[G])^2Error, (in Units:-Standard:-+) the units `mm` and `1` have incompatible dimensionsNULL

K[H] := D[H]*y[H]/(L[H]-u[H])^2Error, (in Units:-Standard:-+) the units `mm` and `1` have incompatible dimensionsNULL

K[I] := D[I]*y[I]/(L[I]-u[I])^2Error, (in Units:-Standard:-+) the units `mm` and `1` have incompatible dimensionsNULL

unwith(Units[Standard])

Error, (in unwith) no package called `Units:-Standard' is currently bound

 

NULL

NULL

NULL

NULL


 

Download CALC-0191-Upload.mw

When I have an operation to perform with Maple, my first reflex is to use the "native" Maple procedure(s) because it seems logical to think that they have been written in order to reduce the memory used and/or the execution time.
Unfortunately, this feeling is not confirmed by reading some of the answers provided on this site.

The attached file shows 4 ways (among probably several others) to center and reduce (by columns) a random matrix.
Amid them is the Statistics:-Scale procedure which appears not to be the most efficient (even a double loop outperforms in term of time).
This is just an example among many others (for instance Statistics:-Select can be easily outperformed)

So my question: why deceive the user with magic functions which sometimes have a very relative efficiency?

Scaling_efficiency.mw

Hello

I have used Maple almost daily for the last four years, but a few days ago two students approached me with an issue I had never encountered before. However, it had happened to both of them within a few weeks.

They described the issue as follows: When they opened a random Maple document and they tried to type in simple operators (like +, - or *), Maple would instead write an odd symbol, which none of them recognised as a mathematical symbol.

As they could not find a way to solve the problem within Maple, they tried restarting their computers. When they afterwards reopened Maple, the problem was gone and the operators worked as expected again. Neither of the students has experienced the issue since.

During the last few days, I have been trying to replicate the issue myself without success. Therefore, I also don't have any screenshots to share, so hopefully my simple explanation is enough.

My questions are: Has anyone heard about this issue before? Does anyone know what might have caused it? Is there a way to replicate it and/or prevent it from happening again in the future?

I hope someone is able to clarify it a bit for me! :)

Regards,

Frederik

How to find the location of the poles of a normal chord in an ellipse ?
Here is my code :

restart; with(geometry); with(plots); `local`(O);
_EnvHorizontalName := x; _EnvVerticalName := y;
corde := a*x/cos(theta)-b*y/sin(theta) = a^2-b^2;
isolate(corde, a/cos(theta));
Error, (in isolate) a*x/cos(theta)-b*y/sin(theta) = a^2-b^2 does not contain a/cos(theta)
eq1 := (a^2-b^2)*X/a^2 = a/cos(theta);
c := solve(eq1, cos(theta));
eq2 := (a^2-b^2)*Y/b^2 = -b/sin(theta);
s := solve(eq2, sin(theta));
lieu := simplify(expand((a^2-b^2)^2*X^2*Y^2*(c^2+s^2 = 1)));
allvalues(eliminate({eq1, eq2}, theta))[1][2];
ell := x^2/a^2+y^2/b^2 = 1;
P := [a*cos(theta), b*sin(theta)];
tgP := x*P[1]/a^2+y*P[2]/b^2 = 1;

sol := solve({corde, ell}, {x, y});
tgP1 := simplify(x*rhs(sol[2][1])/a^2+y*rhs(sol[2][2])/b^2 = 1);

Drawing in a case
a := 5; b := 3; theta := (1/6)*Pi;

line(l1, corde); conic(co, ell);
Pole(P1, l1, co); coordinates(P1);
a := 5; b := 3; theta := (1/6)*Pi;
Ell := implicitplot(ell, x = -a .. a, y = -b .. b, color = red);
Cor := implicitplot(corde, x = -a-1 .. a, y = -b-1 .. b, color = blue);
TgP := implicitplot(tgP, x = 0 .. 10, y = -5 .. 10, color = magenta);
TgP1 := implicitplot(tgP1, x = -5 .. 10, y = -5 .. 10, color = magenta);
lieu := subs(X = x, Y = y, lieu);
subs(x = 125*sqrt(3)*(1/24), y = -27/8, lieu);
Lieu := implicitplot(lieu, x = -a .. a, y = -b .. b, color = green);
dr := draw(P1);
display([Ell, Cor, Lieu, TgP, TgP1, dr], axes = normal, view = [-10 .. 10, -10 .. 10], scaling = constrained);

Why the drawin of the location (lieu) does not appear ? Thank you.

First 402 403 404 405 406 407 408 Last Page 404 of 2216