Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I have an expression with number of csgn(arg) in it.

I'd like to scan this expression, telling Maple to assume arg is positive, in order to replace csgn(arg) by 1.

I am trying to do this using subsindets. But I do not know why it is not working. I am doing this in code, without looking at the expression. So I do not know what the arg's are and how many such cases could be.

Here is an example

expr:=(1+csgn(a)*a)/(3*csgn(b)*b);

To get to each csgn(arg), I am using the type 'specfunc( anything, csgn )'. I checked this is correct type by doing

type(csgn(a),'specfunc( anything, csgn )');

           true

Then

subsindets(expr,'specfunc( anything, csgn )', f->simplify(f) assuming positive);

But this does not change anything. 

I also tried

subsindets(expr,'specfunc( anything, csgn )',f->simplify(f) assuming op(1,f)::positive);

No change, But if I do 

simplify(csgn(a)) assuming positive;

it works. And Maple returns 1. Also this works

simplify(expr) assuming a>0,b>0;

But since I am do not before hand what the arguments to csgn() in the expression are, I can't do the above. I do not know even if expression has csgn() in it even. I am trying to simplify a result I obtain inside the program by doing the above.

What is wrong with my use of  subsindets above?

I think the problem is with using assumptions inside subsindents. As this below works

subsindets(expr,'specfunc( anything, csgn )',f->1);

So the call to subsidents was OK, it is just that the assumptions do not seem to be somehow effective inside.  May be name scoping issue?

Maple 2020.2

edit:

For now and as workaround, I am doing this

restart;
expr:=(1+csgn(a)*a)/(3*csgn(b)*b):
fun:=selectfun(expr,'csgn'); #find csgn if any

if numelems(fun)>0 then
    the_args:= op~(1,fun);
    simplify(expr) assuming map(x->x::positive,the_args)[];
fi;

 

The worksheet below mimics some of the construction in the web site https://www.geogebra.org/m/d4k6SjFX.

This seems a crude and limiting way to display a pencil of ellipses tangent in a quadrilateral.

Please provide references (textbooks, articles, etc.) to the mathematics which produces this kind of display.

Pencil_in_quad.mw

Sorry, I was not able to change the displays to inline.

Hi,

How to generate a random list of 4 elements so the sum of the elements is 1 ?

Thanks

LoiProbabilité2.mw

Hi!

I am trying to plot points, which are supposed to be connected by splines. Within a range of say i from 1 to 5 I would like to calculate f(i) and plot the results. It is however possible in my case that the result is discarded before, lets assume because the result is complex. Then no point is saved for that particular i and the program goes on to i+1. It is then possible to have no point and no spline defined. Therefore the function "plot" can complain if the used names for the graphs have not been defined before, because there is nothing to define. Is there a way to define an empty graph, so that I can define the graphs as the empty graph in the beginning, so that the plot command doesn't complain if no usable points are found? I would need something like this:

Graph:= <EmptyGraph>;
Spline:=<EmptyGraph>;
if numelems(<ListWithUsablePoints>) > 0  then
  <define(Graph)>;
  if numelems(<ListWithUsablePoints>) > 1 then
     <define(Spline)>
  fi;
fi;
plot(Graph, Spline,...)

If the condition under which the points are used is never met, then plot should not complain about Graph and Spline not being defined.

Thank you in advance :)

SIR_model.mw
 

How to solve Part(b)? Anyone can give me some ideas? Thank you

Download SIR_model.mw

 

Hello Maple community and others,

It has been proven that every positive
rational number can be represented in 
Egyptian Fraction form

See wikipedia on Egyptian Fractions

We have the fact that the harmonic series diverges
Let Hn = 1 + 1/2 + 1/3 + ... + 1/n.

Then the limit as n goes to infinity of Hn is unbounded.

It seems these two facts go hand in hand.

Is there a procedure in Maple that will give
Egyptian Fraction representation of an arbitrary
rational number?

I made a worksheet with some examples.

egyptian_fractions.mw

egyptian_fractions.pdf

 

Regards,
Matt

Hi, my problem is the next differential equation:

In maple. I used this code to solved it, but throws this error:

dsolve({diff(y(x), x, x) = -P*x/(I*E), eval(y(x), x = L) = 0, eval((D(y))(x), x = L) = 0});
Error, (in dsolve) found differentiated functions with same name but depending on different arguments in the given DE system: {y(L), y(x)}

What is the problem with my code? How can solve my ODE with tis boundary conditions? 

 

Hello to everyone!

I should MINIMIZE a function called α that is a function of the variable h (0 < h < 2.2), therefore I should find the h value that gives the minimum value of α. Here follows the α function:

alpha= ((W1*t/2)+(W2+N)*(t+t/2*h/(h_TOT-h)))/(W1*h/2 + W2*h/2)

 The terms W1 and W2 are constant and assume precise values as a function of h. Simplifying (I will use very simple condition, in reality, the statement is more complicated):

  • if 0<h<1, then W1:=1; W2:=3
    elif 1<h<2.2, then W1:=2, W2:=4
    end if;

How do I collect the IF statements inside the MINIMIZE optimization to obtain a final h value?

I hope I was clear! 

Thanks you all,

Michele

Hi so ive been working on a few codes making Eulers method and RungeKutta and Taylor Series (second order) and I cant figure out why my code is giving me a weird output? I will attach my maple files here, I can post more information if you'd like. Also have no idea how to start for taylor series so any help with code on that would be appreciated!

 


 

euler1 := proc (f, a, b, alpha, h, N) local i, t, w; i := 1; t := a; w := alpha; while i <= N do w := w+h*f(t, w); t := a+i*h; i := i+1 end do; [w] end proc

proc (f, a, b, alpha, h, N) local i, t, w; i := 1; t := a; w := alpha; while i <= N do w := w+h*f(t, w); t := a+i*h; i := i+1 end do; [w] end proc

(1)

euler1(e^(5*3-y), 0, 3, .5, .2, 2)

[.5+.2*e(0, .5)^(15-y(0, .5))+.2*e(.2, .5+.2*e(0, .5)^(15-y(0, .5)))^(15-y(.2, .5+.2*e(0, .5)^(15-y(0, .5))))]

(2)

NULL

NULL

NULL


 

Download p5one.mw
 

RK4 := proc (f, a, b, alpha, h, N) local t, w, i, k1, k2, k3, k4; i := 1; t := a; w := alpha; while i <= N do k1 := h*f(t, w); k2 := h*f(t+(1/2)*h, w+(1/2)*k1); k3 := h*f(t+(1/2)*h, w+(1/2)*k2); k4 := h*f(t+h, w+k3); w := w+(1/6)*k1+(1/3)*k2+(1/3)*k3+(1/6)*k4; t := a+i*h; i := i+1 end do; [w] end proc

proc (f, a, b, alpha, h, N) local t, w, i, k1, k2, k3, k4; i := 1; t := a; w := alpha; while i <= N do k1 := h*f(t, w); k2 := h*f(t+(1/2)*h, w+(1/2)*k1); k3 := h*f(t+(1/2)*h, w+(1/2)*k2); k4 := h*f(t+h, w+k3); w := w+(1/6)*k1+(1/3)*k2+(1/3)*k3+(1/6)*k4; t := a+i*h; i := i+1 end do; [w] end proc

(1)

RK4(exp(5*3-y), 0, 3, .5, .2, 1)

[.5+0.3333333333e-1*(exp(15-y))(0, .5)+0.6666666667e-1*(exp(15-y))(.1000000000, .5+.1000000000*(exp(15-y))(0, .5))+0.6666666667e-1*(exp(15-y))(.1000000000, .5+.1000000000*(exp(15-y))(.1000000000, .5+.1000000000*(exp(15-y))(0, .5)))+0.3333333333e-1*(exp(15-y))(.2, .5+.2*(exp(15-y))(.1000000000, .5+.1000000000*(exp(15-y))(.1000000000, .5+.1000000000*(exp(15-y))(0, .5))))]

(2)

``


 

Download rk4new.mw

 

How to write down the differential equation for this practical question? 

I can use dsolve to solve the system equation. 

Thank you! 

I am still checking output using latest Latex and Maple 2020.2. I noticed a small problem.

Current Latex uses \mathrm{ln} instead of as before, which is just \ln this casues the space before the operator now to be lost, cause hard to read math.

It is better not to use \mathrm on ln

Here is an example

restart;
Latex:-Settings(UseImaginaryUnit=i,
      UseColor = false,
      powersoftrigonometricfunctions= computernotation,
      leavespaceafterfunctionname = true
):
expr:= 4*exp(3*x)+3*ln(x);
Latex(expr)

                       4 {\mathrm e}^{3 x}+3 \mathrm{ln}\left(x \right)

It should be

4 {\mathrm e}^{3 x}+3 \ln\left(x \right)

Without even \, between the letter before \ln as old latex() did:

latex(expr)

           4\,{{\rm e}^{3\,x}}+3\,\ln  \left( x \right)

As the Latex engine itself takes care of the spacing around math operators best.

Here is the difference when the Latex is compiled. The use of mathrm with exponential is not an issue, since it is one letter operator, but not with ln.

\documentclass[12pt]{book}
\usepackage{amsmath}
\usepackage{mleftright} 
\mleftright

\begin{document}
This is how it is now
\[
4 {\mathrm e}^{3 x}+3 \mathrm{ln}\left(x \right)
\]
                      
This is what it is better to be
\[
4 {\mathrm e}^{3 x}+3 \ln\left(x \right)
\]                                         
\end{document}

Compiled with lualatex compiler gives

The above shows the space problem.

Using Maple 2020.2 and Physics   879

 

There might be a setting for this. I do not know.

I  noticed, once I call Latex() first time, if I then later issue Typesetting:-Settings(prime=x,typesetprime=true); and after that, call Latex() again, it has no effect.  The derivative does not change.

But calling Typesetting:-Settings(prime=x,typesetprime=true); before calling Latex() the first time, works.

Since I do not want to do restart() in a running program, and I would like to call Typesetting:-Settings(prime=x,typesetprime=true); may be different times to change the letter and after having called Latex earlier, is there a way to make this work without having to do restart? I do not rememebr now if this was the case in earlier version or not. I looked at Latex:-Settings() and see no setting for this inside Latex itself to use in place of the above global Settings.

Please see worksheet below.


 

interface(version);

`Standard Worksheet Interface, Maple 2020.2, Windows 10, November 11 2020 Build ID 1502365`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 879 and is the same as the version installed in this computer, created 2020, November 19, 20:10 hours Pacific Time.`

restart;
Latex:-Settings(UseImaginaryUnit=i,
      UseColor = false,
      powersoftrigonometricfunctions= computernotation,
      leavespaceafterfunctionname = true
):
ode:=2*diff(y(x),x)*x=(1+x-6*y(x)^2)*y(x):
#This works, since setting is called BEFORE calling Latex first time
Typesetting:-Settings(prime=x,typesetprime=true):
ode;
Latex(ode)

2*(diff(y(x), x))*x = (1+x-6*y(x)^2)*y(x)

2 y^{\prime}\left(x \right) x =
\left(1+x -6 y \left(x \right)^{2}\right) y \left(x \right)

restart;
Latex:-Settings(UseImaginaryUnit=i,
      UseColor = false,
      powersoftrigonometricfunctions= computernotation,
      leavespaceafterfunctionname = true
):
ode:=2*diff(y(x),x)*x=(1+x-6*y(x)^2)*y(x);
Latex(ode);

#This does not work, since setting is called AFTER calling Latex.
#The latex generated remains the same.
 
Typesetting:-Settings(prime=x,typesetprime=true);
ode;
Latex(ode)

2*(diff(y(x), x))*x = (1+x-6*y(x)^2)*y(x)

2 \left(\frac{d}{d x}y \left(x \right)\right) x =
\left(1+x -6 y \left(x \right)^{2}\right) y \left(x \right)

x, false

2*(diff(y(x), x))*x = (1+x-6*y(x)^2)*y(x)

2 \left(\frac{d}{d x}y \left(x \right)\right) x =
\left(1+x -6 y \left(x \right)^{2}\right) y \left(x \right)

 

 

Download how_to_change_setting.mw

 

 

After doing 

A:=tan(3*x);
B:=expand(A)

How to get A back from B? I tried

combine(B);
simplify(B,size);
simplify(B,trig);
simplify(B);

They do not give A back. tried few conversions to exp() and back and forth. Can't get original expression back.  trigsubs() does not help here.

This is all need to be done in code, assuming one can not look at the expression and decide what to do on any A/B pair. But I am mainly now looking at trig expressions.

Any suggestions?

Maple 2020.2

Hi there!

I am trying to tell Maple to print something one time once a condition has been met for a variable that ranges from a to b, let's say from 1 to 9 in this case. Testbestanden is to be printed, if (F[i]+F[i+1]<20) is true for every i, and Durchgefallen is to be printed as soon as one counterexample is found. The following code illustrates what I need, it doesn't work, however. What is the correct syntax? Switching the lines "if (F[i]+F[i+1]<20)" and "for i from 1 to 9" leads to Maple printing "Testbestanden" for every i that fulfils the statement which is not what I need either.

for i from 1 to 10 do
  F[i]:=i
end do;

if (F[i]+F[i+1]<20)
for i from 1 to 9
then print(Testbestanden)

else print(Durchgefallen)
end if
end do

Thank you in advance! :)

Here's a possible bug in ExcelTools.

When importing from an Excel file, Maple drops text which is referenced from a different sheet. That does not apply to numbers.

Workbook_Excel_indirect.zip

First 349 350 351 352 353 354 355 Last Page 351 of 2097