MaplePrimes Questions

Is it possible to use a vector in the piecewise fuction? I have tried the following and other stuff but the the error below

timestep := <seq(1 .. 100)>;
piecewise(`<`~(30, timestep), 1);
Error, (in PiecewiseTools:-Is) wrong kind of parameters in piecewise
 

I have a time vector and would like to create a u(t), unit step fuction to "turn on" a function at a certain time. e.g.

output(t)=u(t)*f(t)

Where u(t)=1 for t>turn_on_time and 0 otherwise.

TIA for help

  Could you please give maple code for Shooting Method/Kellor box Method or any numerical method except RK Method to this system of Differential Equations.

SMMS.mw

In a recent answer I posted, I had a relation of the form

I*Int(f(x), x) = something - 2*I*Int(f(x), x)

and I wanted to isolate the term Int(f(x), x).
The function isolate failed to do it and I was forced to use some workaround to do the "isolation".

Trying to understand what happened here, it seems that isolate fails when the term to isolate is multiplied by the imaginary unit
Here are a few examples

expr := I*(Int(x^2*ln(-x+sqrt(x^2-1)), x)) = g(x) -(2*I)*(Int(x^2*ln(-x+sqrt(x^2-1)), x))

I*(Int(x^2*ln(-x+(x^2-1)^(1/2)), x)) = g(x)-(2*I)*(Int(x^2*ln(-x+(x^2-1)^(1/2)), x))

(1)

# no isolation

isolate(expr, lhs(expr))

I*(Int(x^2*ln(-x+(x^2-1)^(1/2)), x)) = g(x)-(2*I)*(Int(x^2*ln(-x+(x^2-1)^(1/2)), x))

(2)

# isolation

expr_1 := expand(expr / I)
isolate(expr_1, lhs(expr_1))

Int(x^2*ln(-x+(x^2-1)^(1/2)), x) = -((1/3)*I)*g(x)

(3)

# no isolation neither, so the problem is not related to "Int"

expr := I*diff(h(x), x) = g(x) -2*I*diff(h(x), x):
isolate(expr, lhs(expr))

I*(diff(h(x), x)) = g(x)-(2*I)*(diff(h(x), x))

(4)

# no isolation neither, so the problem comes from "I"

expr := I*A = g(x) -2*I*A:
isolate(expr, lhs(expr))

I*A = g(x)-(2*I)*A

(5)

# isolation (of course)

expr := c*A = g(x) -2*c*A:
isolate(expr, lhs(expr))

c*A = (1/3)*g(x)

(6)

 

Download Isolation.mw

I guess this is a known behavior, but why it is so?
Is there a way to force the "isolation" without using a trick like in result (3)

Thanks in advance

Hello community, I am new in this forum and sorry if the following seems rudimentary:

I am replicating a distribution function using Statistics[Distribution] as defined here:

Vose Software's Beta Subjective

I have tested numerically and the function works for this initial values: Min := 3; Mlikely := 8; Avg := 9; Max := 18;

But failed to complete with these values (which I tested works in another software) Min := 1000; Mlikely := 1400; Avg := 1500; Max := 2100;

What puzzles me is the inconsistency of handling the functions (be aware that the server kernel could be slow at times). I hope I don't have to give up and continue my custom distribution project in another software.

Here is the document: 

NULL

The Beta Subjective Distribution

 

 

restart

 

with(Statistics)

NULL

Min := 3; Mlikely := 8; Avg := 9; Max := 18

18

(1)

NULL

Mid := (Min+Max)*(1/2)

21/2

(2)

alpha := 2*(Avg-Min)*(Mid-Mlikely)/((Avg-Mlikely)*(Max-Min))

2

(3)

beta := alpha*(Max-Avg)/(Avg-Min)

3

(4)

NULLNULLNULLNULL

NULL

f := simplify(piecewise(Min <= x and x <= Max, (x-Min)^(alpha-1)*(Max-x)^(beta-1)/(Beta(alpha, beta)*(Max-Min)^(alpha+beta-1)), 0))

piecewise(x < 3, 0, x <= 18, (4/16875)*(x-3)*(-18+x)^2, 18 < x, 0)

(5)

NULL

NULL

MD := Distribution(PDF = unapply(f, x), Conditions = [`and`(Min < Mlikely and Mlikely < Max and Min < Avg and Avg < Max and Mlikely <> Avg, piecewise(Avg < Mlikely, Mlikely > Mid, Mid > Mlikely))])

_m2352873740384

(6)

NULL

NULL

NULL

NULL

NULL

X := RandomVariable(MD)

_R

(7)

NULL

evalf(Mean(X))NULL

9.

(8)

NULL

NULL

evalf(Mode(X))

{8.}

(9)

evalf(Quantile(X, .25))

HFloat(6.645331256340534)

(10)

NULL

A := Sample(X, 10^5)

Mean(A)

HFloat(8.989513601786443)

(11)

Mode(A)

HFloat(8.399525182283146)

(12)

Variance(A)

HFloat(9.029923294780689)

(13)

Skewness(A)

HFloat(0.29817612117709397)

(14)

Kurtosis(A)

HFloat(2.3706624578773154)

(15)

Quantile(A, .25)

HFloat(6.63427086578336)

(16)

NULL

Download Distribution-Beta-Subjective.mw

I need to create a matrix with 4 dimensions, but I don't know how I can do this. The variable that I need to store could be written in this form:

>S[i,j,k,l];

I don't want to write this with a subscript, but like a matrix. 

Hello there, 

This is another issue, associated with substitution. In the following Maple expressions, I tried to substitutte the denominator of 'eq_K1_m4' in order to make it as 'eq_K1_m4_desired', but did not get any success (yet). 

Therefore, would you have a look at this issue to see if the intended goal can be achieved?

restart;

with(LinearAlgebra):

with(DynamicSystems):

interface(imaginaryunit=j):

eq_K1_m4 := K__1 = E__q0*(R__T*E__B*sin(delta) + X__Td*E__B*cos(delta))/(L__aqs*L__l + L__aqs*X__E + L__aqs*L__ads_p + L__l^2 + 2*L__l*X__E + L__l*L__ads_p + R__E^2 + 2*R__E*R__a + R__a^2 + X__E^2 + X__E*L__ads_p) + (X__q - X__dp)*i__q0*(X__Tq*E__B*sin(delta) - R__T*E__B*cos(delta))/(L__aqs*L__l + L__aqs*X__E + L__aqs*L__ads_p + L__l^2 + 2*L__l*X__E + L__l*L__ads_p + R__E^2 + 2*R__E*R__a + R__a^2 + X__E^2 + X__E*L__ads_p);

K__1 = E__q0*(R__T*E__B*sin(delta)+X__Td*E__B*cos(delta))/(L__aqs*L__l+L__aqs*X__E+L__aqs*L__ads_p+L__l^2+2*L__l*X__E+L__l*L__ads_p+R__E^2+2*R__E*R__a+R__a^2+X__E^2+X__E*L__ads_p)+(X__q-X__dp)*i__q0*(X__Tq*E__B*sin(delta)-R__T*E__B*cos(delta))/(L__aqs*L__l+L__aqs*X__E+L__aqs*L__ads_p+L__l^2+2*L__l*X__E+L__l*L__ads_p+R__E^2+2*R__E*R__a+R__a^2+X__E^2+X__E*L__ads_p)

(1)

eq_K1_m4_desired := K__1 = E__q0*(R__T*E__B*sin(delta) + X__Td*E__B*cos(delta))/Dx + (X__q - X__dp)*i__q0*(X__Tq*E__B*sin(delta) - R__T*E__B*cos(delta))/Dx;

K__1 = E__q0*(R__T*E__B*sin(delta)+X__Td*E__B*cos(delta))/Dx+(X__q-X__dp)*i__q0*(X__Tq*E__B*sin(delta)-R__T*E__B*cos(delta))/Dx

(2)

eq_Dx := Dx = L__aqs*L__l + L__aqs*X__E + L__aqs*L__ads_p + L__l^2 + 2*L__l*X__E + L__l*L__ads_p + R__E^2 + 2*R__E*R__a + R__a^2 + X__E^2 + X__E*L__ads_p;

Dx = L__aqs*L__l+L__aqs*X__E+L__aqs*L__ads_p+L__l^2+2*L__l*X__E+L__l*L__ads_p+R__E^2+2*R__E*R__a+R__a^2+X__E^2+X__E*L__ads_p

(3)

denom(op(1, rhs(eq_K1_m4))) - rhs(eq_Dx); # checking to see if the denominator expression is the same as the expression of Dx

0

(4)

denom(op(2, rhs(eq_K1_m4))) - rhs(eq_Dx); # checking to see if the denominator expression is the same as the expression of Dx

0

(5)

# 1

map2(applyrule, eq_Dx, eq_K1_m4); # did not work.

K__1 = E__q0*(R__T*E__B*sin(delta)+X__Td*E__B*cos(delta))/(L__aqs*L__l+L__aqs*X__E+L__aqs*L__ads_p+L__l^2+2*L__l*X__E+L__l*L__ads_p+R__E^2+2*R__E*R__a+R__a^2+X__E^2+X__E*L__ads_p)+(X__q-X__dp)*i__q0*(X__Tq*E__B*sin(delta)-R__T*E__B*cos(delta))/(L__aqs*L__l+L__aqs*X__E+L__aqs*L__ads_p+L__l^2+2*L__l*X__E+L__l*L__ads_p+R__E^2+2*R__E*R__a+R__a^2+X__E^2+X__E*L__ads_p)

(6)

# 2

subs(eq_Dx, eq_K1_m4); # did not work.

K__1 = E__q0*(R__T*E__B*sin(delta)+X__Td*E__B*cos(delta))/(L__aqs*L__l+L__aqs*X__E+L__aqs*L__ads_p+L__l^2+2*L__l*X__E+L__l*L__ads_p+R__E^2+2*R__E*R__a+R__a^2+X__E^2+X__E*L__ads_p)+(X__q-X__dp)*i__q0*(X__Tq*E__B*sin(delta)-R__T*E__B*cos(delta))/(L__aqs*L__l+L__aqs*X__E+L__aqs*L__ads_p+L__l^2+2*L__l*X__E+L__l*L__ads_p+R__E^2+2*R__E*R__a+R__a^2+X__E^2+X__E*L__ads_p)

(7)

# 3

simplify(eq_K1_m4, {Dx = L__aqs*L__l + L__aqs*X__E + L__aqs*L__ads_p + L__l^2 + 2*L__l*X__E + L__l*L__ads_p + R__E^2 + 2*R__E*R__a + R__a^2 + X__E^2 + X__E*L__ads_p}, [Dx]); # did not work.

K__1 = -E__B*((-R__T*(-X__q+X__dp)*i__q0-E__q0*X__Td)*cos(delta)+sin(delta)*(X__Tq*(-X__q+X__dp)*i__q0-R__T*E__q0))/(L__l^2+(L__aqs+L__ads_p+2*X__E)*L__l+X__E^2+(L__aqs+L__ads_p)*X__E+L__aqs*L__ads_p+(R__E+R__a)^2)

(8)

# 4

algsubs(eq_Dx, eq_K1_m4); # did not work.

K__1 = E__q0*(R__T*E__B*sin(delta)+X__Td*E__B*cos(delta))/(L__aqs*L__l+L__aqs*X__E+L__aqs*L__ads_p+L__l^2+2*L__l*X__E+L__l*L__ads_p+R__E^2+2*R__E*R__a+R__a^2+X__E^2+X__E*L__ads_p)+(X__q-X__dp)*i__q0*(X__Tq*E__B*sin(delta)-R__T*E__B*cos(delta))/(L__aqs*L__l+L__aqs*X__E+L__aqs*L__ads_p+L__l^2+2*L__l*X__E+L__l*L__ads_p+R__E^2+2*R__E*R__a+R__a^2+X__E^2+X__E*L__ads_p)

(9)

# 5

applyrule(L__aqs*L__l + L__aqs*X__E + L__aqs*L__ads_p + L__l^2 + 2*L__l*X__E + L__l*L__ads_p + R__E^2 + 2*R__E*R__a + R__a^2 + X__E^2 + X__E*L__ads_p = Dx, eq_K1_m4); # did not work.

K__1 = E__q0*(R__T*E__B*sin(delta)+X__Td*E__B*cos(delta))/(L__aqs*L__l+L__aqs*X__E+L__aqs*L__ads_p+L__l^2+2*L__l*X__E+L__l*L__ads_p+R__E^2+2*R__E*R__a+R__a^2+X__E^2+X__E*L__ads_p)+(X__q-X__dp)*i__q0*(X__Tq*E__B*sin(delta)-R__T*E__B*cos(delta))/(L__aqs*L__l+L__aqs*X__E+L__aqs*L__ads_p+L__l^2+2*L__l*X__E+L__l*L__ads_p+R__E^2+2*R__E*R__a+R__a^2+X__E^2+X__E*L__ads_p)

(10)

 

Download Q20230606.mw

I am surprised Maple could not do this integral. Any ideas how to make it do it?

restart;
integrand:=(ln(-x + sqrt(x^2 - 1))*x + sqrt(x^2 - 1))*x*sqrt(-x^2 + 1)/sqrt(x^2 - 1);
int(integrand,x)

For reference, another software gives

ClearAll[x]
integrand = (Log[-x + Sqrt[x^2 - 1]]*x + Sqrt[x^2 - 1])*x*Sqrt[-x^2 + 1]/Sqrt[x^2 - 1]
Integrate[integrand, x]

Which I verified to be correct.

Any workarounds? I tried assuming x>0 for example. Not sure what else to try now. I am sure with some pre-processing Maple can do it. 

Maple 2023

Please help me to solve this error.   or

Can you give the maple code for Shooting method/ Kellor Box Method for this problem.

mvp-1.mw

I was unsure if this should be a post or a question, or how to word it properly as I feel the attached file is the best way to see my issue. 

 However, when doing a computation involing the D_ specifically D_[mu](F[~mu,~nu]) where is a tensor, Maple is putting in strange "variables" into the output of my expression. I set the spacetime variables myself to tau,x,y,z and in the output there is combinations which appear as x(tau),y(tau) which has completely baffled me. 

Any ideas/help would be greatly appreciated. 

EinsteinPert.mw

EDIT: The problem is resolved when the Physics[Vectors] package is removed and replaced by VectorCalculus for the Lapacian. Still curious as why the Physics[Vectors] package causes this issue. (I of course could just brute force the Laplacian but I thought I would use the power of Maple for this).

How do I label the curves in Maple graph.

Please, I need commands to tweak my maple 18 graph.

Hi,
I want to have the value of the following two integrals numerically for any arbitrary value of kc  and kh. (Physically the answers of the integrals should be real.)
Is it possible to obtain the analytical solution of these integrals with Meple, in terms of parameters kc, kh, deltac, deltah and sigma ?
Thanks

1.mw

I have some ODE system contains unknown variables with  boundary conditions  (see the attachment). How to solve these system and find the vales of unknown variables.

In this problem, the boundary conditions tends to 0, when x tends to infinity.  BVP_with_parameters.mw
 

restart

eq1 := f(x) = x+a[1]*x^2-(1/48)*sqrt(2)*a[1]*x^4-(1/120)*a[1]^2*sqrt(2)*x^5;

h(x) = -0.3535533905e-3*x^5*a[2]*a[1]*a[3]-0.3333333334e-9*x^5*a[3]*a[2]^4+0.4166666668e-7*x^4*a[2]*a[3]^3-0.3333333334e-9*x^5*a[2]^2*a[3]^3-0.5000000000e-9*x^5*a[3]^2*a[2]^3+0.1250000000e-6*x^4*a[3]*a[2]^3-0.8333333336e-10*x^5*a[2]*a[3]^4+0.1250000000e-6*x^4*a[3]^2*a[2]^2-0.8333333336e-10*x^5*a[2]^5+0.4166666668e-7*x^4*a[2]^4+a[3]*x-0.1473139128e-1*x^4*a[1]*a[3]+0.2946278254e-1*x^4*a[1]*a[2]-0.3240906080e-3*x^5*a[1]*a[2]^2+0.2798964342e-5*x^5*a[2]*a[3]^2+0.4714045206e-5*x^5*a[3]*a[2]^2-0.6629126071e-3*x^4*a[3]*a[2]+0.7812499998e-3*x^5*a[3]-0.2946278254e-1*x^3*a[3]-0.5892556508e-3*x^4*a[2]^2+0.1915080866e-5*x^5*a[2]^3+0.5892556509e-1*x^3*a[2]-0.4687500000e-2*x^5*a[2]+0.5000000000e-2*a[2]^2*x^2-0.1666666667e-4*x^3*a[2]^3+0.5000000000e-2*a[2]*x^2*a[3]-0.3333333334e-4*x^3*a[3]*a[2]^2-0.1666666667e-4*x^3*a[2]*a[3]^2+1.

(1)

bcs := f(0) = 0, (D(f))(0) = 1, f(10) = 0, g(0) = 1, g(10) = 0, h(0) = 1, h(10) = 0;

f(0) = 0, (D(f))(0) = 1, f(10) = 0, g(0) = 1, g(10) = 0, h(0) = 1, h(10) = 0

(2)

sol := dsolve([{f(x), g(x), h(x)}, bcs], numeric)

Error, (in dsolve/numeric/process_input) system must be entered as a set/list of expressions/equations

 

``

 

Greetings! I have solved a nonlinear equation by Newton iterative method. Now i want to plot basins of attraction. Being a beginner, I have no clue how to plot it? Its totally different rom other simple plotting commands. Need help in this regard.Thank

When running "C:\Program Files\Maple 2023\bin.X86_64_WINDOWS\cmaple.exe" on my application which makes plots and export them to ps, sometimes I get an exception

              "cannot locate postscript AFM files"

This happens on some plots. Not all. The strange thing, using the same exact run, but from the worksheet, it works fine and I get the .ps generated with no such error. This only happens when running from the command line. It happens here


try
   plotsetup(ps, plotoutput="plot.ps",plotoptions=noborder);
   print(p1);   
   plotsetup(default):
catch:
   print(StringTools:-FormatMessage( lastexception[2..-1] ));
end try;

where p1 above is a plot that was generated earlier OK with no error. I made sure there is no font settings on the plot or any extra options that might cause a problem.

I am not able to make MWE as this problem only shows deep inside my application and only when calling Maple from command line and only shows up on very few plots for some reason I do not understand.  When I made a small .mpl with same code used to make the plot, and run it from command line, the error do not show up. It only shows up when running the whole application from the command line. 

My question is: How does Maple find these postscript AFM files? It looks like the postscript driver used by command like Maple is older than the one used by the frontend/GUI and this is why this error only shows from the command line. Has anyone seen such a Maple error before? 

I have no idea where to find these AFM postscript files it says it can't find and what to do now. I am on windows 10.

Any suggestion what to lookfor and anything else I can do to help me find the cause of this?

If it is any help, here is the MWE I tried to reproduce this with. But this generated no error. Call this foo.mpl

foo:=proc()
local p1,ode,y,x;
   ode:=3*y(x)+x*diff(y(x),x) = 2*x^5;
   p1 := DEtools:-phaseportrait(ode,y(x),x=-1..5,[y(2)=1],y=-1000..1000):
   try
      plotsetup(ps, plotoutput=cat("C:/tmp/plot.ps"),plotoptions=noborder);
      print(p1);   # also tried without "display"
      plotsetup(default):
   catch:
      print(StringTools:-FormatMessage( lastexception[2..-1] ));
      print("Exception");
   end try;
end proc;

foo();

Then run 

 

C:\tmp>"C:\Program Files\Maple 2023\bin.X86_64_WINDOWS\cmaple.exe"  foo.mpl

No error. The error only shows in my large application.

                             "cannot locate postscript AFM files"

Will keep trying to make a MWE, but for 3 hrs now, no luck yet.

Update

I've added 

if lasterrorlocus<>'lasterrorlocus' then
                     print(lasterrorlocus);
                     showsource();
end if; 

Inside the catch, which print the exact location of the exception generated. It is at print(p1) as you see

again, same code runs with no problem from the worksheet. This only shows when running from command line. Will keep trying to make MWE...

When translating Maple expression with special math functions, Maple does not use the same familar name shown in worksheet, but replaces these special functions with one letter. 

This makes it very hard when looking at the equations in latex and the pdf to know what these special functions are. 

Is there an option to keep the same name used in Maple but use the \operatorname{name} in the latex generated? This will go a long way to improve the output and make one understand what they are looking at.

Here are examples below. Notice as side note, that Maple does not translate pochhammer at all. Is this a bug? It only gave its arguments in the latex. 

I think everyone will agree that reading BesselJ in the equation is more clear than reading J and reading hypergeom is more clear than and reading  MeijerG is more clear than and so on as one does not have to guess what these letters mean when looking at the final output in pdf.  
 

1384004

restart;

1384004

expr:=BesselJ(1,x);
latex(expr)

BesselJ(1, x)

J_{1}\! \left(x \right)

expr:=hypergeom( [],[],z );
latex(expr)

hypergeom([], [], z)

{}_{0}^{}{\moversetsp{}{\mundersetsp{}{F_{0}^{}}}}\! \left(;;z \right)

expr:=pochhammer(3/10, n);
latex(expr)

pochhammer(3/10, n)

\left(\frac{3}{10}\right)_{n}

expr:=MeijerG([[1, 1, 1, 1], []],[[], [4, 3, 2, 2]],Pi);
latex(expr)

MeijerG([[1, 1, 1, 1], []], [[], [4, 3, 2, 2]], Pi)

G_{4,4}^{0,4}\! \left(\pi \bigg| {\mstack{1,1,1,1}{4,3,2,2}}\right)

 


It should not be hard to provide an option for latex() in Maple (say Keep_special_function_math_names:=true) and keep default as is now.

Then all what Maple needs to do is simply generate \operatorname{BesselJ} instead of and \operatorname{hypergeom} instead of and \operatorname{pochhammer} and so on for any special function that does not have any standard Latex known notation. Even if one can argue that somewhere somehow someone should know that F is hypergeom and one should know that J means BesselJ and so on for dozens of other single letters used, I think it is much more clear to the reader to see the full name of the function as it shows in Maple worksheet.

The rest of the arguments remain the same exactly as shown by Maple on the screen and no need to make any changes there. It is only the name of the function which is the problem.

This only applies for all the special math function names ofcourse.

Any chance of making such changes to Maple's latex()? I tried to make the changes by post-processing the latex as string using patterns and string replace, but this was breaking things as it is not possible to just simply change letter J to BesselJ for example, as the letter J can be anything else in the latex. I think the best solution is to do this at the source, when the latex is generated by Maple.

Version 2023 on windows.

Download latex_math_functions.mw

ps. removed the list to make the question shorter as requested.

 

First 73 74 75 76 77 78 79 Last Page 75 of 2308