MaplePrimes Questions

Dear all 

I approximate the root of a given polynomial using Newton method. 

Whem I change the output option the number of iteration change as displayed, 

Why changind only output from animation to plot, the number of iterations displayed with each figure is not the same.

NewtonQuestion.mw

thank you

How can we determine the highest (or peak) value for every hump and at what value of (x, t) in the plot?

peak.mw

Good day,

I am looking for some guidance with the Syrup toolbox

I have a netlist that was generated with the Altium designer Spice simulator (XSpice based), I was able to import it into LTSpice and verrify the results.

I want to move it into maple to make use of the modellica code generation.

I then began modifying the netlist in order to meet the netlist syntax of Syrup. One of the most prominant change I needed to make was the arbitrary input nodes for my Voltage dependant Voltage sources. 

Therefore, for any line that implies arbitrary sources such as:

E_U8_E1 U8_N208620 LO
+ VALUE { IF(V(U8_N208706, 0) > 0.5, 5, -5) }

was changed to:

V1    16   17 1vdc

E_U8_E1 U8_N208620 LO 16 17
+ VALUE { IF(V(U8_N208706, 0) > 0.5, 5, -5) }

This, of course, is a non ideal workaround which brings me to question 1,

Is there a way to define a arbitrary source with the Spice parser in Syrup?

Once these changes were made, it seems the Solve function in Syrup can parse the netlist without issue, however when it gets to the Solve portion it throws the following error:

Solve("file://C:/Users/msavoy/Documents/Spice_cct/inverter_newfet_nonot.cir", 'tran');
Solve: Analyzing SPICE deck "The Apple" (ignoring this line)
Error, (in Syrup:-Solve) invalid input: rcopy uses a 1st argument, A (of type anything), which is missing

Attached is a copy of the netlist, inverter_newfet_nonot.txtI am honestly at a lost as to what could be throwing the rcopy error

Furthermore, I wanted to test out the Modellica code generation in Syurp, it appears that it does not like having subcircuits, as running the test:

V 1 0 1
L1 1 2 L
C1 2 0 C
L2 2 3 L
C2 3 0 C
L3 3 4 L
C3 4 0 C
Vshort 4 5 0
Rt 5 0 1
.SUBCKT TEST A B C Y
V1 14 15 1
EINT YINT 0 14 15
+ VALUE {IF(V(A) > 0.5 && V(B) > 0.5 && V(C) > 0.5, 1, 0)}
RINT YINT Y 1
CINT Y 0 1n
.ENDS TEST
.end

provides the error of:

test_c := ToModelica("file://C:/Users/msavoy/Documents/Spice_cct/test_cct_RCL.txt", 'probes' = ["Rt.v"], 'parameters' = {C = 2, L = 1});
Error, (in Syrup:-ToModelica) invalid input: nodeToModelica expects its 1st argument, node, to be of type nonnegint, but received Y

Is it possible to define a sub circuit in a netlist that is to be converted to Modellica, or do all subcircuits need to be defined in their own file?

Thank you

Consider the function f:=x->sin(x)/x.

If we plot it we obtain

If we try to solve the equation f(x)=0 we get no result back from Maple.

Now consider the function g(x):=x->|sin(x)/x|

If we plot g we obtain

The weird thing here is that the graph isn't touching the x-axis. Why not?

Dear all

I would like to create a table that contains my ouput : iteration, eigenvalues, eigenvectors, 
My code work well, but unfortunatelly I can't display a table with the wanted output. 

cccc.mw

Thank you 

Dear All,

How to draw 3D plot from given data as follows

x:=[0.1, 0.2, 0.3, 0.4, 0.5, 0.1, 0.2, 0.3, 0.4, 0.5,0.1, 0.2, 0.3, 0.4, 0.5,0.1, 0.2, 0.3, 0.4, 0.5,0.1, 0.2, 0.3, 0.4, 0.5]
y:=[0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.3, 0.3, 0.3, 0.3, 0.3, 0.4, 0.4, 0.4, 0.4, 0.4,0.5,0.5,0.5,0.5,0.5]
z:=[1.971284960, 1.642401616, 1.372353338,1.153620572,0.9762759982,
    1.675502483, 1.411976881, 1.190627373,1.007730234,0.8570007139, 
    1.397140245, 1.184230644, 1.003688984,0.852696223,0.7268039317,
    1.144791107, 0.9725020383,0.8257592921,0.7020549659,0.5979974836,                                                                                 0.9208492326, 0.7816302394, 0.6627749172,0.5620029444,0.4766238930]
 

Like:

Product Name: Maple 17

 

I have to take my equations for velocity, acceleration, and height and evaluate them in 4 second intervals and combine them into one table or columns.

Deal all

I would like to approximate the largest eigenvalue of a given maxtrix and its corresponding eigenvector. 
I have a problem in step 7, how obtain the index where the maximum is located, then How I return at the end of while loop 
a table contains eigenvalues, eigenvectors and err 

PWM.mw

Thank you 

The procedures "getCP" which uses "cpsub" (not exported) acts differently inside the package as opposed to them outside it.
In the package it returns a column matrix which is incorrect. Should return a 2 row matrix. They dismantle a polynomial into it's powers and coefficients. I know one cant run the package here. Included are the two procedures and the text of the notepad file to make the package.

restart

NULL

with(AlgCalc)

[`⊕`, FundThrm, SignedArea, diag, diftab, faulD, faulS, getCP]

f := sort(2+x^7+5*x^2-7*x^a+k*x^2, [x], ascending)

2-7*x^a+5*x^2+k*x^2+x^7

getCP(f, x)

Matrix(%id = 36893490212391698668)

NULL

g := sort(5*x^8+k*x^2-7*x^3+x+2, [x], ascending)

2+x+k*x^2-7*x^3+5*x^8

CP := getCP(g, x)

Matrix(%id = 36893490212391688180)

NULL

restart

with(AlgCalc)

[`⊕`, FundThrm, SignedArea, diag, diftab, faulD, faulS, getCP]

NULL

f := sort(2+x^7+5*x^2-7*x^a+k*x^2, [x], ascending)

2-7*x^a+5*x^2+k*x^2+x^7

getCP(f, x)

Matrix(%id = 36893490212390043884)

g := sort(5*x^8+k*x^2-7*x^3+x+2, [x], ascending)

2+x+k*x^2-7*x^3+5*x^8

getCP(g, x)

Matrix(%id = 36893490212390032796)

 

restart

 

Dismantlimg a polynomial  uses the following 2 procedures

" cpsub:= proc(t, var:=alpha)  description "used by getCP";       local i,cf,varpwr;                   if   not has(t, var)                  then return < 0,t>:               elif whattype(t)=`^` then return <op(t)[2],1>;                  else varpwr,cf:= selectremove(has,[op(t)],var);                       if op(varpwr)=var then                        return <1, `*`(op(cf))> ;                   end if;                     for i from 1 to nops(varpwr) do                    if numer(varpwr[i])=1  then if op((1)/(varpwr[i]))=alpha then varpwr[i]:=-1 else  varpwr[i] :=-op((1)/(varpwr[i]))[2] end if else  varpwr[i]:=op(varpwr[i])[2]end if                        end do;                   return <`+`(op(varpwr)),`*`(op(cf))>;                   #print(op(t));                                   end if ;            end proc:"

NULL

``

getCP := proc (f, var := alpha) local t; description "Dissmantles a polynomial into powers and coefficients"; if not has(f, var) then return `<,>`(0, f) elif whattype(f) = `^` then return `<,>`(op(f)[2], 1) elif whattype(f) = `*` then return `<|>`(`~`[cpsub]([f], var)[]) else `<|>`(`~`[cpsub]([op(f)], var)[]) end if end proc

NULL

f := sort(2+x^7+5*x^2-7*x^a+k*x^2, [x], ascending)

2-7*x^a+5*x^2+k*x^2+x^7

cp := getCP(f, x)

Matrix(%id = 36893490212391322676)

whattype(cp)

Matrix

NULL

Notepad file to Create AlgCalc.

 

AlgCalc := module ()
export SignedArea,
           `&oplus;`,

             getCP,

             diag,
             diftab,
             faulD,
             faulS,
             FundThrm;
        

 option package;

$include "SignedArea.mm"
$include "`&oplus;`.mm"
$include "cpsub.mm"
$include "getCP.mm"
$include "diag.mm"
$include "diftab.mm"
$include "faulD.mm"
$include "faulS.mm"
$include "FundThrm.mm"

end module;

Download 6-11-22_Procedures_acting_differently_in_Package.mw

There is a document on the Maple website entitled "Writing Packages". It contains the following snippet when talking about libname

Note: Maple automatically adds lib subdirectories of directories in HOMEDIR/maple/toolbox as well as your current directory to the predefined variable libname. Therefore, modifying the .mapleinit or maple.ini file is only necessary if you want to designate a directory as the default location in which the savelib command will save your library files.

Is this snippet accurate?

If we create a directory called test and create a directory inside called lib and in it a repository called myRepo.mla, and in Maple the current working directory is test, will test/lib/myRepo.mla be found by libname?

It doesn't seem to be the case.

in the context of solving an ode, sometimes the constant of integration that will satisfy an initial condition is +infinity or -infinity.

But Maple's solve does not find such solutions to the constant of integration. It only can solve for finite value if it can.

When this happens, I manually try taking the limit as the constant of integration goes to +- infinity, until I get an equation where both sides are the same or fail, and then give up.

I was wondering if there is a way or different command/package which will find solution such as infinity (which is valid solution to constant of integration).

Here are two examples

ode:=diff(y(x),x)=1/(LambertW(-exp(-1+_C1+x))+1);
ic:=[diff(y(x),x)=1,x=0];
eq2:=eval(ode,ic);
solution_for_constant := solve(eq2,_C1,'allsolutions'=true,'tryhard'=true);

Maple can not solve for _C1. It gives

But when trying manually few values, I find that _C1=-infinity satisfies the equation

limit(rhs(eq2),_C1=0);
limit(rhs(eq2),_C1=1);
limit(rhs(eq2),_C1=-1);
limit(rhs(eq2),_C1=infinity);
limit(rhs(eq2),_C1=-infinity);

The above shows that _C1 = -infinity is the constant of integration. Another simpler example

eq:=exp(-1 + _C1) = 0;
solution_for_constant:=solve(eq,_C1) assuming real;
limit(lhs(eq),_C1=-infinity)

The above shows that _C1=-infinity is solution for exp(-1+C_1)=0.  which one can see by just looking at it as exp(-infinity)=0.  Adding assumptions did not help.I also tried symbolic option.

I am not familar with SolveTools package, may there is something there.

So for now, my code just try the limit until it finds solution or gives up.

Any suggestions if Maple itself can find such solutions?

Maple 2022.2

Does the below infinite sum involving primes converge?sum(1/(Prime(n)Prime(n+1)Prime(n+2)*Prime(n+3)),n=1... infinity) Free WolframAlpha app runs out of time while evaluating this sum... The term values which free WolframAlpha app shows for this sum (starting from the term 41 and on) is 0.0059292... If 0.0059292 is indeed the value for this sum, could then more significant digits be produced? Thanks, Best Regards, Alexander R. Povolotsky

Why is a more direct approach of defining a table now working and giving an indexed type, while the indirect approach is giving a table?

atable := table()

table( [ ] )``

(1)

a := table()

table( [ ] )

(2)

atable["a"] := a

a

(3)

atable["b"] := table()

table( [ ] )

(4)

whattype(atable["a"])

table

(5)

whattype(atable["b"])

indexed

(6)

NULL

Download tabledefinition.mw

Hello,

I am trying to create a Homogeneous transformation matrix, where I am given the point 'p' through which a unit rotation axis 'x' passes and the point/vector on which this Homogenous transformation acts is rotated by 'theta'.

I used the Rodrigues formula (the one in the blue-green box) to define the rotation matrix;

unit_axis_cross_mat := unapply(<<0 | -x[3] | x[2]>, <x[3] | 0 | -x[1]>, <-x[2] | x[1] | 0>>, x::Vector);
rot_mat := unapply(LinearAlgebra[IdentityMatrix](3) + unit_axis_cross_mat(<x[1], x[2], x[3]>)*sin(theta) + MatrixPower(unit_axis_cross_mat(<x[1], x[2], x[3]>), 2)*(1 - cos(theta)), x::Vector, theta)

I then tried to concatenate them to generate the matrix function

, where the exponential term represents the rotation matrix (defined above) as such:

trans_mat_ang := unapply(ArrayTools[Concatenate](1, ArrayTools[Concatenate](2, rot_mat(<x[1], x[2], x[3]>, theta), (LinearAlgebra[IdentityMatrix](3) - rot_mat(<x[1], x[2], x[3]>, theta)) . <p[1], p[2], p[3]>), <0 | 0 | 0 | 1>), x::Vector, theta, p::Vector)

But I end up getting the error 

"Error, (in ArrayTools:-Concatenate) number of columns must match"

To diagnose it, I try to evaluate the 1st Concatenation:

trans_mat := unapply(<ArrayTools[Concatenate](2, rot_mat(<x[1], x[2], x[3]>, theta), (LinearAlgebra[IdentityMatrix](3) - rot_mat(<x[1], x[2], x[3]>, theta)) . <p[1], p[2], p[3]>)>, x::Vector, p::Vector, theta);

which runs successfully, but when I try to evaluate it:

trans_mat(<1, 0, 0>, <1, 0, 0>, 0)

, I get a symbolic expression .

Although the expression is correct algabrically, I expected a full evaluation for the numerical inputs.

I am attaching my Homogeneous_Transformation.mw for your ease of diagnosis.

Is this the cause of the error of "Number of Columns must match"?

Any help towards this would be appreciated.

Regards

 

Hello,

I'm attempting to scale the vertical axis of a histogram plot such that each bin reflects the percentage of the total bins (all bins sum to 1). Matlab has an option ('probability') for their histogram command which does this. I've attempted to solve this myself in the attached worksheet but I'm not satisfied with the results (just a hack to replace axis labels). Specifically, I would like for the underlying data in the plot to match the axis scaling. An example can be seen in the image below.

Thank you for your consideration,

Ron

Histogram_percentage.mw

 

 

 

First 144 145 146 147 148 149 150 Last Page 146 of 2308