MaplePrimes Questions

Dear community,

I'm a taxation student and trying to figure out maple more or less successfully for a research project... My aim is to find the indifference curve of the two levels S_TEV and S_P. As its probably not easy to find the formula, I'd alternatively like to approach the indifference curve numerically.

These are the basis codes:

E := 'E'
h := 4                     
m := 0.035
g:= h*m            
k := 0.15
a := 0.25;
F_ANR := 4*m;
r:= 0.1;
T := 'T';
ESt := piecewise
(E < 9984, 0,
E < 14926, (1008.7*(E - 9984)/10000 + 1400)*(E - 9984)/10000,
E < 58596, (206.43*(E - 14926)/10000 + 2397)*(E - 14926)/10000 + 938.24,
E < 277826, 0.42*E - 9267.53,
0.45*E - 17602.28);

Er := E + (E - ESt)*r

EStr := piecewise(Er < 9984, 0,
Er < 14926, (1008.7*(Er - 9984)/10000 + 1400)*(Er - 9984)/10000,
Er < 58596, (206.43*(Er - 14926)/10000 + 2397)*(Er - 14926)/10000 + 938.24,
Er < 277826, 0.42*Er - 9267.53,
0.45*Er - 17602.28)

srp := EStr/E

r_p := r*srp

S_P := ESt*(1 + r_p)^T

EStk := piecewise(K < 9984, 0,
K < 14926, (1008.7*(K - 9984)/10000 + 1400)*(K - 9984)/10000,
K < 58596, (206.43*(K - 14926)/10000 + 2397)*(K - 14926)/10000 + 938.24,
K < 277826, 0.42*K - 9267.53,
0.45*K - 17602.28)

r_tev := 0.29*r

K := (0.71*E*(1 + 0.71*r)^T)*0.6

stev := EStk/K
S_TEV := E*(0.29*(1 + r_tev)^T + 0.71*(0.6*stev))

plot3d([S_TEV/E, S_P/E], E = 0 .. 500000, T = 0 .. 15, color = [white, black])

The plot shows the two levels. Id like to derive the indiffernce curve from this plot (intersection of S_TEV and S_PE).
Starting with probably Diff_S := S_TEV - S_P?

Can someone please help me with finding the right codes? I'm lost.... (eg. solve function for S-TEV-S_P=0; finding the right data frame for Diff_S:=0 or almost zero dependent on E and T, i.e. dataframe of E, T and S_TEV and S_P) so that I can plot (3D) all S_TEV = S_P depending on E, T.

Id be incredibly thankful for any help. It would literally safe my thesis!
Thank you so so much in advance!!
Rebekka

When trying to evaluate the following line with values where units are attached Maple chrashes.

(add(eval(F, {x = XY[n, 1], y = XY[n, 2]})^2, n = 1 .. 4), location)

Problem_units.mw

What is the problem here

Dear helpfull community. I stumbled over a problem which I cloud not sort out even after hours of trying to find the error I do. 
A simple IF statement does not work when I attach a unit to a value.

tt := 80*Unit('knot');
if tt < 100*Unit('knot') then
    lprint(got*it);
end if;

Surprisingly Maple can evalue the expression if a use a = instead of the <. File should be attached.

Please can anyone tell me what I did wrong.

NULL`~`[unassign](`<,>`(anames(user)))

with(LinearAlgebra); with(Optimization); Restart

NULLNULL

NULL

Problem 1 ( If Statement with units)

 

The if statement could not evealuated with the logical operator < or > when a unit is attached to the value

 

tt := 80*Unit('knot'); if tt < 100*Unit('knot') then lprint(got*it) end if

Error, cannot determine if this expression is true or false: 100*Units:-Unit(knot) < 80*Units:-Unit(knot)

 

 

 

But it works if the logical operator " = "

 

tt := 80*Unit('knot'); if tt = 80*Unit('knot') then lprint(got*it) end if

got*it

 

 

Anyone an idea why.

``

 

 

NULL

 

 

NULL

NULL

Download Problem_IF.mw

I am still new to Maple and I don't know how to exactly use it. Is it possible to draw a triangle given the length of the three sides?

If so, how do I do it?

Thanks is advance

I have my code in mla. Using try/catch, I am able to capture an error that happend deep in some call chain. But it is hard to know the exact location where this error happened.

I use StringTools:-FormatMessage( lastexception[2..-1] inside the catch clause to print the exception. But this only prints the message. It does not tell me exactly which line/function/module this happened.

Is there a way to display these information?  Using debugger and stoperror all did not help at all. It does not stop at the line where the error happened. not sure why. I tried it many times. may be I am not using it correctly?

Is it possible to display may be the trace of the calls inside the catch of the try? To know the actual statement that generated the error? Now each time I get an exception, I have to step into the debugger line by line until  I get to the place where the error was which is time consuming. Here is a MWE

 

restart;
A:=module()  
  local B:=module()
     export foo:=proc(n)
         1/n;
     end proc;
  end module;

  export main:=proc()
    try
       B:-foo(0);
    catch:
      print("error happened", StringTools:-FormatMessage( lastexception[2..-1] ));
    end try;
  end proc;

end module;

And now

    A:-main()

                "error happened", "numeric exception: division by zero"

I'd like to get more information than the above as I said. Line number/proc name/module name or stacktrace showing the calls made up to where the exception started (similar to output from where command in debugger).

The above was done in worksheet. My actual code in inside .mla build from lots of .mpl files.

Maple 2021.2 on windows

Does an API involving Maple exist for trading stocks? I am interested in creating a trading bot that uses the Maple engine.

Why GenerateMatrix could not give out the coefficient matrix of the equations in terms of third order vector?

NULL

restart

``

with(LinearAlgebra):

Var[4] := [tau[1](t)^3, tau[2](t)^3, tau[3](t)^3, tau[4](t)^3, tau[5](t)^3, p[1](t)^3]:

EqML := [-0.467902632940817e-5*(-0.398588153114250e-4*tau[1](t)+0.571232697467613e-4*tau[2](t)+0.238866882336809e-4*tau[3](t)+0.333476161338209e-4*tau[4](t)+0.364093457033576e-4*tau[5](t)-p[1](t))^3, 0.670570063557231e-5*(-0.398588153114250e-4*tau[1](t)+0.571232697467613e-4*tau[2](t)+0.238866882336809e-4*tau[3](t)+0.333476161338209e-4*tau[4](t)+0.364093457033576e-4*tau[5](t)-p[1](t))^3, 0.280405833175180e-5*(-0.398588153114250e-4*tau[1](t)+0.571232697467613e-4*tau[2](t)+0.238866882336809e-4*tau[3](t)+0.333476161338209e-4*tau[4](t)+0.364093457033576e-4*tau[5](t)-p[1](t))^3, 0.391467665794924e-5*(-0.398588153114250e-4*tau[1](t)+0.571232697467613e-4*tau[2](t)+0.238866882336809e-4*tau[3](t)+0.333476161338209e-4*tau[4](t)+0.364093457033576e-4*tau[5](t)-p[1](t))^3, 0.427409309211715e-5*(-0.398588153114250e-4*tau[1](t)+0.571232697467613e-4*tau[2](t)+0.238866882336809e-4*tau[3](t)+0.333476161338209e-4*tau[4](t)+0.364093457033576e-4*tau[5](t)-p[1](t))^3, -.11739000000*(-0.398588153114250e-4*tau[1](t)+0.571232697467613e-4*tau[2](t)+0.238866882336809e-4*tau[3](t)+0.333476161338209e-4*tau[4](t)+0.364093457033576e-4*tau[5](t)-p[1](t))^3]:

KKNL := GenerateMatrix(EqML, Var[4])[1]

KKNL := Matrix(6, 6, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0, (3, 4) = 0, (3, 5) = 0, (3, 6) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 0, (4, 5) = 0, (4, 6) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 0, (5, 5) = 0, (5, 6) = 0, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = 0, (6, 6) = 0})

(1)

``

``

``

Download GenMatrix.mw

I don't know how to fix this. What's wrong? Is there an alternative way to include underscores in a cat command?

``

restart; with(LinearAlgebra)

komb := proc (n::integer, m::integer) local L, a, j; L := [seq(cat(a, "__", j, ",", j), j = 1 .. n)]; add(mul(k), `in`(k, combinat:-choose(L, m))); return % end proc

proc (n::integer, m::integer) local L, a, j, k; L := [seq(cat(a, "__", j, ",", j), j = 1 .. n)]; add(mul(k), `in`(k, combinat:-choose(L, m))); return % end proc

(1)

komb(5, 5)

`a__1,1`*`a__2,2`*`a__3,3`*`a__4,4`*`a__5,5`

(2)

whattype(`a__1,1`)

symbol

(3)

A := Matrix(5, 5, shape = diagonal, symbol = a)

Matrix(%id = 36893489895174306860)

(4)

abs(A)

a[1, 1]*a[2, 2]*a[3, 3]*a[4, 4]*a[5, 5]

(5)

whattype(a[1, 1])

indexed

(6)

simplify(komb(5, 5)-abs(A))

`a__1,1`*`a__2,2`*`a__3,3`*`a__4,4`*`a__5,5`-a[1, 1]*a[2, 2]*a[3, 3]*a[4, 4]*a[5, 5]

(7)

``

Download indexed.mw

Could please help me to write codes for solving the following problem:  The plane (p) includes the line (d): (x-1)/-1=y/1=(z-3)/2, and distance from it to the point M(1,0,3) equal 3. (I solved it with Maple, but the result was "no solution". Thanks so much.

Could you help me to get the general solution in this way?

ODE2 := diff(T[1](t), t, t)+2*(diff(T[1](t), t))/t+(Omega^2/(a[i]^2*t^(4/3))-20/(9*t^2))*T[1](t)

diff(diff(T[1](t), t), t)+2*(diff(T[1](t), t))/t+(Omega^2/(a[i]^2*t^(4/3))-(20/9)/t^2)*T[1](t)

(1)

generalsol := dsolve(ODE2, T[1](t))

T[1](t) = _C1*BesselJ((1/2)*89^(1/2), 3*Omega*t^(1/3)/a[i])/t^(1/2)+_C2*BesselY((1/2)*89^(1/2), 3*Omega*t^(1/3)/a[i])/t^(1/2)

(2)

``

NULL

Download general_solve.mw

Thanks

Here is short description of the problem with code MWE below.

Short version of the question

I want to change

parent:=module()
  local foo:=proc()
     NULL;
  end proc;

  local child:=module()    
     export boo:=proc()
        foo(); #call works as is
     end proc;
  end module;

end module;

To

parent:=module()
  local foo:=proc()
     NULL;
  end proc;

  local child:=module()    
     export boo:=proc()

         #now call no longer works. Maple wants foo exported
         #I want to add parent:- to the call to remind me where foo((
         #lives but do not want to make foo() in parent exported

         parent:-foo();

     end proc;
  end module;
end module;

Longer version of the question

I have a parent module with one child local module inside it. In the child module, there is a proc which wants to call parent's local proc named foo().

As is, the child module can just call the parent's local proc foo() by typing foo() without the need to do parent:-foo() this is because child module has access to parent local proc's and maple knows which foo() by searching the scope from bottom up.

The problem comes when I added a proc also called foo() (by mistake) in the child module without noticing there is one with same name in the parent's.

Now the call foo() will end up calling the child's module foo() and not the parent's foo() becuase that is the "closest" one with this name in the scope. All of this makes sense so far.

The problem comes when the child module wants to really call the parent's foo().

One solution is to change the call to parent:-foo() to explicitly says which foo() to call.

This however now fail, since the parent foo() is local ! And Maple when it sees call to parent:-foo() it now insist it be exported proc (even though the call is being made from inside, i.e. from the child).

I do not want to make the parent's foo() exported just so the child can call it.  I want to keep parent's foo() local, as it is meant to be used only inside the parent and by its children.

You might ask, why not then change the name of the child's foo() to some other name so it does not clash with the parent's local proc name. Yes, I can do this. But for large modules in different files with many procs(), there is a always a chance  a local proc can be added by mistake with happend to be the same name as one in the parent and having to manually keep checking names does not look like the right solution.

My question is: How can a child module call parent's local proc() explicitly, but without making the parent proc exported?  Is there is different syntax to use?

Here is a MWE

 

restart;
parent:=module()

  export main:=proc()
     child:-boo();
  end proc;

  local foo:=proc()
     print("in parent:-foo() proc");
  end proc;

  local child:=module()     
     export boo:=proc()
        print("in child:-boo() proc");
        foo(); #this works. It called parent's local foo()
     end proc;
  end module;

end module;

Now doing parent:-main() works as expected. Notice parent's foo is local to parent module.

Now I changed the child module and did this

parent:=module()

  export main:=proc()
     child:-boo();
  end proc;

  local foo:=proc()
     print("in parent:-foo() proc");
  end proc;

  local child:=module()
     local foo:=proc() #added this using same name by mistake
        print("in child:-boo()");
     end proc;

     export boo:=proc()
        print("in child:-boo() proc");
        foo(); #now this calls the child's foo() ofcourse. But it was meant to call the parents's
     end proc;
  end module;

end module;

The fix is to change the call from the child to becomes    parent:-foo() but now Maple will give an error saying parent does not export foo().

Since the child have access to parent's local proc's, is there a different way to tell Maple I want to call parent's foo() and not my own foo() without making parent's foo() exported? 

For example , in Python one call call parent's method expliclity using super().foo() 

Maple 2021.2

Hello community,

how can I import only selected columns from a csv file?
My current code is the following:

IK := Import("Indifferenzkurve.csv", output = datadir)

However, I'd like to only import the three columns "E","T", and "S_P and S_TEV", not column " " and "Diff".
On this basis, I'd like to plot "S_P and S_TEV":

plot3d([IK], E = 0.1 .. 1000000, T = 1 .. 45)

Thanks so much in advance!
Rebekka

Hello,

I noted that add and 'add' can give different result, can somebody help me understand it?  Consider the code below:

>phi1 := GAMMA(-(1/2)*vst-8.333500000-(1/2)*r)*GAMMA((1/2)*vst+21/2+(1/2)*r); phi2 := GAMMA(16.66700000+r-2*vst)*GAMMA(2.166500000+vst); xi1 := -vst; xi2 := 16.66700000+r-2*vst; z := 37.52950222; K := 9.846618489*10^(-38)*33.330^(.5000000000*r+10.)

### Then I have the following sums (they were supposed to give the same results):

>f := unapply(K*add(phi1*(-1)^vst*z^(-xi1)/factorial(vst)+phi2*(-1)^vst*z^(-xi2)/(.5*factorial(vst)), vst = 0 .. 10000), r):

>g := unapply(K*'add'(phi1*(-1)^vst*z^(-xi1)/factorial(vst)+phi2*(-1)^vst*z^(-xi2)/(.5*factorial(vst)), vst = 0 .. upto), [r, upto]);


# I am interested in the following quantities:

>evalf(f(1)/f(0));

-6.265883733

>evalf(g(1,10000)/g(0,10000))

25.80438437

That seems very strange to me, why maple gives different results?

How we can locate legend inside the plot like the one in the picture

equ1 := BesselJ(sqrt(17)/2, 10*sqrt(t)*sqrt(2))/t^(1/4) + BesselY(sqrt(17)/2, 10*sqrt(t)*sqrt(2))/t^(1/4)
equ2 := BesselJ(sqrt(17)/2, 10*sqrt(t)*sqrt(2))/t^(1/4) + 5*BesselY(sqrt(17)/2, 10*sqrt(t)*sqrt(2))/t^(1/4)
equ3 := BesselJ(sqrt(17)/2, 10*sqrt(t))/t^(1/4) + 5*BesselY(sqrt(17)/2, 10*sqrt(t))/t^(1/4)
plot([equ1, equ2, equ3], t = 0 .. 30, labels = [t, T[2](t)], tickmarks = [0, 0], labelfont = [TIMES, ITALIC, 12], axes = boxed, color = ["Red", "Violet", "Blue"])
C[3] = 1, C[4] = 1, Omega^2 = 50
C[3] = 1, C[4] = 5, Omega^2 = 50
C[3] = 1, C[4] = 5, Omega^2 = 25

 

Thank you!

I want to calculate the arithmetic average of a class of 5 students for 3 different exams. I want to calculate a different average for each exam. I want to use i and j variables. exam grades will be random like 20*i. How can i do this program? Any can do this? Thank you 

I try this program but i get error

total:=0;

numb:=0;

for i from 1 to 3 do

for j from 1 to 5 do

N[i,j]:=20*i;

total:=total+N[i,j];

numb:=numb+i

end do;

end do;

evalf(total/numb);

 

First 78 79 80 81 82 83 84 Last Page 80 of 2173