Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I am trying to do a small procedure which converts an input of degrees into the sin function into its corresponding unit-circle value. I can get this to work. 

Sinus:= proc(g::unit)   
return evalf(sin(g*Pi/180));
end proc; 

 

but is there a more elegant way to do it? Using maybe Units package ? Thanks in advance :)

Hello!

How can I make MAPLE to put out the numerical solution of the following system?
(a =0.12, c = 47.04)  Neither solve nor fsolve does the job!

Thank for your help!

>restart:
>S:=t->c*exp(-a*t)+18;

                      S := t -> c*exp(-a*t)+18

> sys:={S(2)=55,S(8)=36};

        sys := {c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55}

> solve(sys);

         {a = -1/2*ln(18/37*RootOf(18*_Z^3-37)^2), c = 37*RootOf(18*_Z^3-37)}

> fsolve(sys);

         fsolve({c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55},{a, c})

 

I have a differential equation involving several functions of the following form:

diff(h,z) = iAf + iBg,

where h, f and g are functions of the Cartesian coordinates x, y and R and the third coordinate corresponds to z = R for some fixed constant value R.  The derivative is then with respect to the coordinate z and A and B are constants, with i the usual imaginary unit.  Is there some way this equation could be solved explicitly with Maple?

I have a system of nonlinear differential equations with initial conditions:


 

restart

de0 := {(1-p)*(diff(f(x), x, x))+p*(beta*[5]*f(x)*(diff(f(x), x))^2+beta[11]*f(x)^7+beta[6]*(diff(f(x), x))^3+beta[7]*f(x)^5+f(x)+diff(f(x), x, x)+beta[3]*f(x)^3+beta[1]*f(x)+beta[2]*(diff(f(x), x))+mu[1]*(diff(f(x), x))+(3/4)*rho*f(x)^3+beta[9]*f(x)^2*(diff(f(x), x))^3+beta[12]*f(x)^4*(diff(f(x), x))^3+beta[13]*f(x)*(diff(f(x), x))^6+beta[10]*f(x)*(diff(f(x), x))^4+beta[8]*f(x)^4*(diff(f(x), x))+beta[4]*f(x)^2*(diff(f(x), x))-(1/4)*rho*(g(x)^3-3*f(x)^2*g(x))*sin(4*Omega*x)-alpha[2]*f(x)^3*cos(2*Omega*x)-(1/4)*rho*(3*f(x)*g(x)^2-f(x)^3)*cos(4*Omega*x)-alpha[1]*g(x)*sin(2*Omega*x)-(1/2)*alpha[2]*(f(x)^3+3*f(x)^2*g(x))*sin(2*Omega*x)+(3/4)*rho*f(x)*g(x)^2-alpha[1]*f(x)*cos(2*Omega*x)-F*Omega^2*cos(Omega*x+theta)), (1-p)*(diff(g(x), x, x))+p*(diff(g(x), x, x)+beta[11]*g(x)^7+beta[7]*g(x)^5+beta[6]*(diff(g(x), x))^3+beta[1]*g(x)+beta[2]*(diff(g(x), x))+beta[3]*g(x)^3+mu[2]*(diff(g(x), x))+(3/4)*rho*g(x)^3+g(x)+beta[9]*g(x)^2*(diff(g(x), x))^3+beta[13]*g(x)*(diff(g(x), x))^6+beta[8]*g(x)^4*(diff(g(x), x))+beta[10]*g(x)*(diff(g(x), x))^4+beta[4]*g(x)^2*(diff(g(x), x))+beta[12]*g(x)^4*(diff(g(x), x))^3+beta[5]*g(x)*(diff(g(x), x))^2-(1/4)*rho*(3*f(x)*g(x)^2-f(x)^3)*sin(4*Omega*x)+(3/4)*rho*g(x)*f(x)^2-F*Omega^2*sin(Omega*x+theta)-(1/2)*alpha[2]*(f(x)^3+3*f(x)*g(x)^2)*sin(2*Omega*x)-alpha[2]*g(x)^3*cos(2*Omega*x)-(1/4)*rho*(3*f(x)^2*g(x)-g(x)^3)*cos(4*Omega*x)-alpha[1]*f(x)*sin(2*Omega*x)+alpha[1]*g(x)*cos(2*Omega*x))}:

ibvc0 := {f(0), g(0), (D(f))(0), (D(g))(0)}:

n := 3:

F := unapply(add(b[k](x)*p^k, k = 0 .. n), x):

de := map(series, eval(de0, {f = F, g = G}), p = 0, n+1):

for k from 0 to n do if k = 0 then ibvc := expand(eval[recurse](ibvc0, {f = F, g = G, p = 0})) else ibvc := {b[k](0)-1, (D(b[k]))(0)-1, (D(c[k]))(0)-1, ((D@@2)(b[k]))(0)-1, ((D@@2)(c[k]))(0)-1, c[k](0) = 1} end if; sys := `union`(simplify(map(coeff, de, p, k)), ibvc); soln := dsolve(sys); b[k] := unapply(eval(b[k](x), soln), x); c[k] := unapply(eval(c[k](x), soln), x) end do; 'F(x)' = F(x); 'G(x)' = G(x)

Error, (in dsolve) invalid input: `PDEtools/NumerDenom` expects its 1st argument, ee, to be of type algebraic, but received [0]

 

F(x) = b[1](x)*p+b[2](x)*p^2+b[3](x)*p^3

 

G(x) = c[1](x)*p+c[2](x)*p^2+c[3](x)*p^3

(1)

``


How would I deal with this error message

Download 6_11_2019_nonlinear_d_e.mw
 

>  

 

 

 

 

 

Basically it spits out the subset of values for which a division by zero error will occur for the function you specify on  range you specify for each of it's arguments, but I get an ambigous error when ever exponentiation features in the function I specify, which of course dramatically reduces the application of the calculator. Division,addition,substraction and multiplication are currently the only available arithmetic operators availble for the function window that I know the error will not occur.

If some one can help it is much appriciated

 

DIVISION_BY_ZERO_CALCULATOR.mw

Dear all

I have an first-order ode

y'(x) =0, for x in [0,1] but x different to 1/2

and we define a function y(x)= 2   if 0<=x<0.5  and y(x)=0 for 0.5<=x <=1

The attached code define these function ( maybe piecewise function is not welle defined) and how can we show that y is solution or not of the differential equation

ode.mw

many thanks

 

I was playing around with some of the maple examples(specifically the knots) and all the plots seem difficult to visualize in 3D... well, more difficult than they should.

In some cases the plots look more like projections and 2D because the graphical representation does seem to project in to the depth of the screen in a natural way.

 

Mainly it happens when rotating when some of the curve's appear to stay in front due to the highlighting and size issues.

 

I'm not sure exactly what the problem is but I imagine it definitely can be improved. It may be simply that there are no other depth cues in the plot to make things more real.

 

1. I'd like anti-aliased edges. The edges of the plot are hard and not correct coloring wise(do not fade like in real life).

2. Some type of depth perspective where the size changes with depth in to the screen in a meaningful way.

3. Proper coloring of this. Maple seems to handle the lighting correctly but it is far too weak to give the impresson of depth

 

I think maple essentially does all this(except probably AA, although there is probably a setting somewhere) but it seems they are not properly tweaked for maximum realism. I played with the lighting and projection and it seems to help a little but not much.

 

Any ideas on how to improve this? Ideally something that doesn't have to be set every plot.

hello everyone,
   INGT.mw
 

L__d := 100:

L__b := 200:

L__c := L__d+(1/2)*L__b;

200

(1)

X := .3;

.3

(2)

Error, (in plot) procedure expected, as range contains no plotting variable

 

`&Delta;E__g` := 1.155*X+.37*X^2;

.3798

(3)

V__0 := .6*`&Delta;E__g`;

.22788

(4)

m__D := 0.67e-1*m[e];

0.67e-1*m[e]

(5)

m__B := (0.67e-1+0.83e-1*X)*m[e];

0.919e-1*m[e]

(6)

Sol := solve(2*cos(L__d*sqrt(E__x))+(m__D*sqrt((V__0-E__x)/E__x)/m__B-m__B*sqrt(E__x/(V__0-E__x))/m__D)*sin(L__d*sqrt(E__x))-(m__D*sqrt((V__0-E__x)/E__x)/m__B+m__B*sqrt(E__x/(V__0-E__x))/m__D)*sin(L__d*sqrt(E__x))*exp(-sqrt(V__0-E__x)*L__b) = 0, E__x);

0.1110897170e-2, 0.3531161505e-2, -.2585338615+0.9991335677e-27*I

(7)

 

0.1110897170e-2, 0.3531161505e-2, -.2585338615+0.9991335677e-27*I

(8)

E__1 := 0.1110897170e-2:

K__1 := sqrt(E__1);

0.3333012406e-1

(9)

K__2 := sqrt(V__0-E__1);

.4762027959

(10)

C := cosh((1/2)*K__2*L__b);

0.2399908351e21

(11)

beta := m__D*K__2/(m__B*K__1);

10.41631973

(12)

B := -beta*sinh((1/2)*K__2*L__b);

-0.2499821271e22

(13)

A := -B*sin(K__1*L__d)+C*cos(K__1*L__d);

-0.7112056933e21

(14)

h := proc (x) options operator, arrow; piecewise(x <= -L__c, A*exp(K__2*(x+L__c)), -L__c < x and x < -(1/2)*L__b, -B*sin(K__1*(x+(1/2)*L__b))+C*cos(K__1*(x+(1/2)*L__b)), abs(x) <= (1/2)*L__b, (1/2)*exp(K__2*x)+(1/2)*exp(-K__2*x), (1/2)*L__b < x and x < L__c, -B*sin(K__1*(x-(1/2)*L__b))+C*cos(K__1*(x-(1/2)*L__b)), L__c <= x, A*exp(K__2*(x-L__c))) end proc:

'h(x)' = h(x);

h(x) = piecewise(x <= -200, -7.112056933*10^20*exp(95.24055918+.4762027959*x), -200 < x and x < -100, 2.499821271*10^21*sin(3.333012406+0.3333012406e-1*x)+2.399908351*10^20*cos(3.333012406+0.3333012406e-1*x), abs(x) <= 100, (1/2)*exp(.4762027959*x)+(1/2)*exp(-.4762027959*x), 100 < x and x < 200, 2.499821271*10^21*sin(0.3333012406e-1*x-3.333012406)+2.399908351*10^20*cos(0.3333012406e-1*x-3.333012406), 200 <= x, -7.112056933*10^20*exp(-95.24055918+.4762027959*x))

(15)

L__y := 200:

L__z := 200:

P := proc (x, y, z) options operator, arrow; h(x)*cos(Pi*y/L__y)*cos(Pi*z/L__z) end proc:

'Psi(x, y, z)' = P(x, y, z);

Psi(x, y, z) = piecewise(x <= -200, -7.112056933*10^20*exp(95.24055918+.4762027959*x), -200 < x and x < -100, 2.499821271*10^21*sin(3.333012406+0.3333012406e-1*x)+2.399908351*10^20*cos(3.333012406+0.3333012406e-1*x), abs(x) <= 100, (1/2)*exp(.4762027959*x)+(1/2)*exp(-.4762027959*x), 100 < x and x < 200, 2.499821271*10^21*sin(0.3333012406e-1*x-3.333012406)+2.399908351*10^20*cos(0.3333012406e-1*x-3.333012406), 200 <= x, -7.112056933*10^20*exp(-95.24055918+.4762027959*x))*cos((1/200)*Pi*y)*cos((1/200)*Pi*z)

(16)

INGT := proc (x__i) `assuming`([evalf(int(int(int(P(x, y, z)^2*exp(-lambda*sqrt((x-x__i)^2+y^2+z^2)), x = -infinity .. infinity), y = -L__y .. L__y), z = -L__z .. L__z))], [0 < lambda]) end proc

evalf(INGT(2))

``

Warning,  computation interrupted

 

``


 

Download INGT.mw
 

L__d := 100:

L__b := 200:

L__c := L__d+(1/2)*L__b;

200

(1)

X := .3;

.3

(2)

Error, (in plot) procedure expected, as range contains no plotting variable

 

`&Delta;E__g` := 1.155*X+.37*X^2;

.3798

(3)

V__0 := .6*`&Delta;E__g`;

.22788

(4)

m__D := 0.67e-1*m[e];

0.67e-1*m[e]

(5)

m__B := (0.67e-1+0.83e-1*X)*m[e];

0.919e-1*m[e]

(6)

Sol := solve(2*cos(L__d*sqrt(E__x))+(m__D*sqrt((V__0-E__x)/E__x)/m__B-m__B*sqrt(E__x/(V__0-E__x))/m__D)*sin(L__d*sqrt(E__x))-(m__D*sqrt((V__0-E__x)/E__x)/m__B+m__B*sqrt(E__x/(V__0-E__x))/m__D)*sin(L__d*sqrt(E__x))*exp(-sqrt(V__0-E__x)*L__b) = 0, E__x);

0.1110897170e-2, 0.3531161505e-2, -.2585338615+0.9991335677e-27*I

(7)

 

0.1110897170e-2, 0.3531161505e-2, -.2585338615+0.9991335677e-27*I

(8)

E__1 := 0.1110897170e-2:

K__1 := sqrt(E__1);

0.3333012406e-1

(9)

K__2 := sqrt(V__0-E__1);

.4762027959

(10)

C := cosh((1/2)*K__2*L__b);

0.2399908351e21

(11)

beta := m__D*K__2/(m__B*K__1);

10.41631973

(12)

B := -beta*sinh((1/2)*K__2*L__b);

-0.2499821271e22

(13)

A := -B*sin(K__1*L__d)+C*cos(K__1*L__d);

-0.7112056933e21

(14)

h := proc (x) options operator, arrow; piecewise(x <= -L__c, A*exp(K__2*(x+L__c)), -L__c < x and x < -(1/2)*L__b, -B*sin(K__1*(x+(1/2)*L__b))+C*cos(K__1*(x+(1/2)*L__b)), abs(x) <= (1/2)*L__b, (1/2)*exp(K__2*x)+(1/2)*exp(-K__2*x), (1/2)*L__b < x and x < L__c, -B*sin(K__1*(x-(1/2)*L__b))+C*cos(K__1*(x-(1/2)*L__b)), L__c <= x, A*exp(K__2*(x-L__c))) end proc:

'h(x)' = h(x);

h(x) = piecewise(x <= -200, -7.112056933*10^20*exp(95.24055918+.4762027959*x), -200 < x and x < -100, 2.499821271*10^21*sin(3.333012406+0.3333012406e-1*x)+2.399908351*10^20*cos(3.333012406+0.3333012406e-1*x), abs(x) <= 100, (1/2)*exp(.4762027959*x)+(1/2)*exp(-.4762027959*x), 100 < x and x < 200, 2.499821271*10^21*sin(0.3333012406e-1*x-3.333012406)+2.399908351*10^20*cos(0.3333012406e-1*x-3.333012406), 200 <= x, -7.112056933*10^20*exp(-95.24055918+.4762027959*x))

(15)

L__y := 200:

L__z := 200:

P := proc (x, y, z) options operator, arrow; h(x)*cos(Pi*y/L__y)*cos(Pi*z/L__z) end proc:

'Psi(x, y, z)' = P(x, y, z);

Psi(x, y, z) = piecewise(x <= -200, -7.112056933*10^20*exp(95.24055918+.4762027959*x), -200 < x and x < -100, 2.499821271*10^21*sin(3.333012406+0.3333012406e-1*x)+2.399908351*10^20*cos(3.333012406+0.3333012406e-1*x), abs(x) <= 100, (1/2)*exp(.4762027959*x)+(1/2)*exp(-.4762027959*x), 100 < x and x < 200, 2.499821271*10^21*sin(0.3333012406e-1*x-3.333012406)+2.399908351*10^20*cos(0.3333012406e-1*x-3.333012406), 200 <= x, -7.112056933*10^20*exp(-95.24055918+.4762027959*x))*cos((1/200)*Pi*y)*cos((1/200)*Pi*z)

(16)

INGT := proc (x__i) `assuming`([evalf(int(int(int(P(x, y, z)^2*exp(-lambda*sqrt((x-x__i)^2+y^2+z^2)), x = -infinity .. infinity), y = -L__y .. L__y), z = -L__z .. L__z))], [0 < lambda]) end proc

evalf(INGT(2))

``

Warning,  computation interrupted

 

``


 

Download INGT.mw

 

I'm trying to calculate a triple integral complicated by a procedure that changes each time a variable xi, while the program takes a lot of time and it gives me the message "Warning, computation interrupted". If anyone can help me I will be very happy

Is there something I should be doing whenever I use simplify to avoid things like this, or should I stop using the "is" function all together?

 

interface(showassumed = 0):

 

sum(binomial(k+j, k), j = 0 .. n-k) = binomial(n+1, k+1)

(n-k+1)*binomial(n+1, k)/(k+1) = binomial(n+1, k+1)

(1)

#And we have:
is(sum(binomial(k+j, k), j = 0 .. n-k) = binomial(n+1, k+1))

FAIL

(2)

#And since:
is(simplify(convert(sum(binomial(k+j, k), j = 0 .. n-k) = binomial(n+1, k+1), 'factorial')))

true

(3)

is(sum(binomial(k+j, k), j = 0 .. n-k) = binomial(n+1, k+1)) = is(simplify(convert(sum(binomial(k+j, k), j = 0 .. n-k) = binomial(n+1, k+1), 'factorial')))


 

Download main.mw

Can I know how to write code about to solve the second kind of linear Fredholm and also Volterra approximation integral by Simpson's method and Galerkin method, and I need a book about advance math to the integral equation, thanks.

  1. Does it have any detail manual for Matlab programming using Maple symbolic engine? (Except help documentation of Maple Symbolic Toolbox in Matlab).
  2. How to maximize the running speed of the codes programmed by Maple symbolic toolbox? Any Notes?
  3. How to use the function 'GenerateMatrix' of Maple in Matlab? What's the syntax to use this function in Matlab?

Best Regards.

Si

Hello

I wonder how integrate can be applied term by term to the following nonlinear differential equation

(diff(y(t), t))*(diff(y(t), t, t, t))-(diff(y(t), t))*y(t)^2-(diff(y(t), t))*(diff(y(t), t, t))-(diff(y(t), t))*A*y(t)

The expected output will be something like 

(diff(y(t), t))*(diff(y(t), t, t))-(1/3)*y(t)^3-(1/2)*A*y(t)^2-(1/2)*(diff(y(t), t))^2+C+int((diff(y(s), s, s))^2, s = 0 .. t)
map(x-> integrate(x,t),(diff(y(t), t))*(diff(y(t), t, t, t))-(diff(y(t), t))*y(t)^2-(diff(y(t), t))*(diff(y(t), t, t))-(diff(y(t), t))*A*y(t))

solves most of it but not the first part. 

Many thanks

Ed

 

In the applications I am working on, the information are often represented by hierarchical tables (that is tables where some entries can also be tables, and so on).
To help people to understand how this information is organized, I have thought to representent this hierarchical table as a tree graph.
Once this graph built, it becomes very simple to find where a "terminal leaf", that is en entry which is no longer a table, is located in the original table (by location I mean the sequence of indices for which the entry is this "terminal leaf".

The code provided here is pretension free and I do not doubt a single second  that people here will be able to improve it.
I published it for i thought other people could face the same kind of problems that I do.


 

restart

with(GraphTheory):
interface(version);

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

gh := proc(T)
  global s, counter, types:
  local  i:
  if type(T, table) then
    for i in [indices(T, nolist)] do
      if type(T[i], table) then
         s := s, op(map(u -> [i, u], [indices(T[i], nolist)] ));
      else
         counter := counter+1:
         types   := types, _Z_||counter = whattype(T[i]);
         s       := s, [i, _Z_||counter];
      end if:
      thisproc(T[i]):
    end do:
  else
    return s
  end if:
end proc:

t := table([a1=[alpha=1, beta=2], a2=table([a21=2, a22=table([a221=x, a222=table([a2221={1, 2, 3}, a2222=Matrix(2, 2), a2223=u3, a2224=u4])])]), a3=table([a31=u, a32=v])]);

global s, counter, types:
s       := NULL:
counter := 0:
types   := NULL:

ghres := gh(t):
types := [types]:

t := table([a1 = [alpha = 1, beta = 2], a3 = table([a32 = v, a31 = u]), a2 = table([a22 = table([a222 = table([a2222 = (Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0})), a2223 = u3, a2221 = {1, 2, 3}, a2224 = u4]), a221 = x]), a21 = 2])])

(2)


These 3 lines determine the set of edges of the form ['t', v], that are not been captured by procedure h.
They correspond to "first level" indices of table t (v in {a1, a2, a3} in the example above)

L := convert(op~(1, [ghres]), set):     
R := convert(op~(2, [ghres]), set):
FirstLevelEdges := map(u -> ['t', u], L union R minus R):


Complete the set of the edges, build the graph representation TG of table t and draw TG.

edges := convert~({ghres, FirstLevelEdges[]}, set):
TG := Graph(edges):

HighlightVertex(TG, Vertices(TG), white):
p := DrawGraph(TG, style=tree, root='t'):
 


The first line is used to change the the "terminal leaves" of names  _Z_n by their type.

eval(t);

p       := subs(types, p):
enlarge := plottools:-transform((x,y) -> [3*x, y]):

plots:-display(enlarge(p), size=[1000, 400]);

table([a1 = [alpha = 1, beta = 2], a3 = table([a32 = v, a31 = u]), a2 = table([a22 = table([a222 = table([a2222 = (Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0})), a2223 = u3, a2221 = {1, 2, 3}, a2224 = u4]), a221 = x]), a21 = 2])])

 

 


This procedure is used to find the "indices path" to a terminal leaf.
FindLeaf is then applied to all the terminal leaves.

FindLeaf := proc(TG, leaf)
   local here:
   here := GraphTheory:-ShortestPath(TG, 't', leaf)[1..-2]:
   here := cat(convert(here[1], string), convert(here[2..-1], string)):
   here := StringTools:-SubstituteAll(here, ",", "]["):
   here := parse(here);
end proc:

# where is a2221

printf("%a\n", FindLeaf(TG, a2221));

t[a2][a22][a222]

 

 


 

Download Table_Unfolding_2.mw

 

I was attempting to construct  a log question and noticed a problem with the answers that are being resolved by maple.

restart:
with(StringTools):
a := 2:
b := 10:
 c := -4:
d := 5:
rs := 4:
#notice I use the word filler below, in order to randomize later and replace "filler" with various "log[base]" or "ln".
equation1 := convert(filler(a*x+b)-filler(c*x+d) = rs, string):
equationAct := parse(SubstituteAll(equation1, filler, cat(ln))):
answer := [solve(equationAct, x)]:

#it appears maple is applying the log properties and suggesting solutions outside the real domain, for the individual log expressions.  The plot of the equation seems to confirm this.
plotA := plot(lhs(equationAct), x = -10 .. 10):
plotB := plot(rhs(equationAct), x = -10 .. 10):
plots[display](plotA, plotB);

Maple is not able to simplify x^3+a*x+b) -(y^3+a*y+b) )^2/(x-y)^4   into (x^2 + x*y + y^2 + a)^2/(x - y)^2 

wtf

p.s.  how do I get maple to show steps in simplifications

First 495 496 497 498 499 500 501 Last Page 497 of 2097