MaplePrimes Questions

I am currently struggling with a piecewise functions. Seeing as this function is defined over a large number of breakpoints, it would seem that Maple is unable to execute a certain integration (over a particular interval). Since the first derivatives match up at all breakpoints and the piecewise function looks perfectly smooth to my eyes, I figured that I might obtain a sensible result approximating the function by means of a polynomial and integrating based on the resulting approximation. When I try to use minimax from numapprox, however, I just receive an error message to the effect that:

Error, (in evalf/int/CreateProc) function does not evaluate to numeric

I'd very much appreciate it if anyone had any pointers on how I might find a reasonably precise (not necessarily polynomial) approximation for a seemingly smooth piecewise function with a large number of breakpoints.

Many thanks.

Edit: Please find attached my worksheet: worksheet.mw. My goal is to approximate the function Z over the interval 5/3 to 5 by something that is not defined in a piecewise manner.

 

 

Dear all

I have a matrix defined using loop 

How, can I print the value of the  matrix

Print_vaue_G.mw

thank you

Dear all

I have a table with entries obtained using maple code, how can I copy this table to powepoint as image 

many thanks

 

How do we replace D^i by diff(y(x),x$i) in did:=D^14+23*D^13+144*D^12
in Maple 13?

Thank you!

mapleatha

 

I have the expression:

This works (Ans. 144):

coeff(144*D^10,D,op(2,op(2,144*D^10)));

This works (Ans. 144):

coeff(op(3,did),D,op(2,op(2,op(3,did))));

Why doesn't this work?

eval(coeff(op(i,did),D,op(2,op(2,op(i,did)))),i=3);

Why doesn't this work?

subs(i=3,coeff(op(i,did),D,op(2,op(2,op(i,did)))));

I need those "generic" substituions for certain loops that I am making.

Thank you!

mapleatha

 

 

sometimes I have a need to do an assignment inside  operator call `if`(......) . but it is not possible it seems to do this in Maple.

This happens when I am using `if`(...) inside cat() to build a long string, and  depending on some condition, different string is build.  

This works fine in general, until I need to assign new value to a variable at the same time as I am building the string.

An example will make it more clear. Instead of the following

str:="A";
x:=10;

str:=cat(str,`if`(x=10," it was 10","it was not 10"));

if x=10 then
   x:=11;
else
   x:=9;
fi;                         

I'd like to do something like this (which does not work in Maple)

str:="A";
x:=10;
str:=cat(str,`if`(x=10,  x:=11;" it was 10" , x:=9; "it was not 10"))

Tried assign() also. Does not work.  I tried different variation on the above, none works. 

In Mathematica, the above is possible. But this is using standard `If`, which can be inlined

Is it possible to do something like this in Maple? 

The reason is that I do not have to do the checking twice: once to build the string, and once after that is done, in order to do the assignment. It is better if both are done in one place. The above is just an example. I could have more than one `if` inside as I am building the long string. 

Btw, how does one look up help on the operator if and not the statement if ? the help page for if does not talk about it or give any examples.

Maple 2020.2

If I set

B:=[1,2^(1/3),2^(2/3),I*sqrt(3),I*sqrt(3)*2^(1/3),I*sqrt(3)*2^(2/3)];

and then let

g:=B[2]+B[4];

I would like to be able to solve for g^2 in terms of the (basis) B, i.e.

solve(expand(g^2)=c[1]*B[1]+c[2]*B[2]+c[3]*B[3]+c[4]*B[4]+c[5]*B[5]+c[6]*B[6],{c[1],c[2],c[3],c[4],c[5],c[6]});

However, Maple does not seem to be able to recognize g^2 as a linear combination of the elements in the set B, in particular that g^2 = -3*B[1] + B[3] + 2*B[5]

A parallel question would be whether one could, for example, do something like this:

coeff(expand(g^2),2^(2/3))

but Maple does not compute coeffiencts except with respect to indeterminates.

Does anyone have an idea how to do such a computation? Thanks.

(The set B is a basis of the field extension of Q given by adjoining 2^(1/3) and sqrt(-3) and I'm trying to find a so-called 'primitive element' for this field extension.)

 

EDİT:
I wrote a procedure in order to add the legends inside plots as follows:

restart:
newlegend:=proc(f::algebraic,g::algebraic,x_left,x_right)
local A,B,location,y_min,y_max,L1,L2,rect,T,F,G:

y_min:=min(minimize(f,x=x_left..x_right),minimize(g,x=x_left..x_right));
y_max:=max(maximize(f,x=x_left..x_right),maximize(g,x=x_left..x_right));
F:=unapply(f,x):
G:=unapply(g,x):
L1, L2:=plottools:-line([x_left,0.9*y_max],[x_left+abs(x_right-x_left)/15,0.9*y_max],color=red), plottools:-line([x_left,0.7*y_max],[x_left+abs(x_right-x_left)/15,0.7*y_max],color=blue):
rect:=plottools:-rectangle([x_left,y_max-abs(y_max-y_min)/3],[x_left+abs(x_left+x_right)/4,y_max],color=cyan);
T:=plots:-textplot([[x_left+abs(x_right-x_left)/9,0.9*y_max,f],[abs(x_left+x_right)/9,0.7*y_max,g]]):
A:=plot(F(x), x=x_left..x_right, style=line, color=red   ):
B:=plot(G(x), x=x_left..x_right, style=line,  color=blue  ):

plots:-display(A, B, L1, L2, T,rect,  scaling=constrained, size=[800,300],axes=boxed);
end proc:
newlegend(sin(x),cos(x),0,2*3.14)

 

Question 1: The lines behind the cyan rectangle seem. How to make the rectangle opaque? 

Question 2:  Could you help me improving the procedure? Because I have bad results for some functions. 

For example;

newlegend(exp(x),x,0,3)

Some Suggestions:

  • If we add an option to change the location of the legends like 'northeast' or 'southwest' etc, it will be a really good procedure.
  • If we add an option to remove the rectangular like "rectangular=off", it will be great.

If you share your valuable ideas and comments, I will be very glad. 

I am trying to rearrange the elements of an equation by the absolute value of their coefficients. eg -3y^2 x+2x z^2+6z^2 to

2x z^2 -3y^2 +6z^2 

 

Download Rearange_test.mwRearange_test.mw

test1_03.mw

The solution I'm getting here for v(y), doesn't satisfy my original two equations. Like for example if I choose u(y)=y, for easy check it can be seen that my de2 equation doesn't satisfy that value.

Can anyone help me out?

Hi
when I use this package, maple makes error like bellow. what is the problem ? thank u

Hi,


I was applying the Grip Map to the procedure LArip. It apparently finished in less than 5 seconds. But when I wanted to display the results as an Array, this step required minutes. How can this time be reduced? Here is a piece of the code:

n := 8;
r := 2^n;
M := Vector(r, randperm(r) + [-seq(1, i = 1 .. r)], datatype = integer[4]);

LArip := proc(k::integer, r::integer, M::Vector(datatype = integer[4]))
local N, j, t, i, A;
N := Vector(r, 0); A := Vector(r, 0);
i := k - 1;
for j from 0 to r - 1 do
for t from 0 to r - 1 do
N[t + 1] := Occurrences(1, Split(Xor(And(t, i), And(M[t + 1], j)))) mod 2;
end do;
A[j + 1] := Occurrences(0, convert(N[], list));
end do;
return convert(A, list);
end proc;

infolevel[Grid:-Map] := 3;
rt := time[real]();
Bb := Grid:-Map(k -> LArip(k, r, M), [$ (1 .. r)]);
GridMapTime := time[real]() - rt;
 

The worksheet is here:

Magma_GridMap.mw

Thank you for your help.

Hey!
I am using the solve function and I get the following form of the result :

rootsq0 := {z = 9.096986124+3.141592654*I}, {z = 1.138376998+3.141592654*I}, {z = .3074241220+3.141592654*I}, {z = .5854971300+3.141592654*I}, {z = -2.519351300+3.141592654*I}, {z = -5.138371980+3.141592654*I}, {z = -1.759344122+3.141592654*I}, {z = -0.9698634104e-1+3.141592654*I}

I want to convert rootsq0 into a list [9.096986124+3.141592654*I, 1.138376998+3.141592654*I, ...]. So, I would like to remove {} and z=. Any suggestions are welcome! :)

Is it possible to write an equation reduction program that uses only LinearAlgebra.?

restart; with(LinearAlgebra); with(Student[LinearAlgebra]); unprotect(D);
f := proc (x, y) options operator, arrow; 5*x^2+4*y*x+8*y^2+16*x-8*y-16 end proc;
A := coeff(f(x, y), x, 2); B := coeff(coeff(f(x, y), x, 1), y, 1); C := coeff(f(x, y), y, 2); D := coeff(coeff(f(x, y), x, 1), y, 0); E := coeff(coeff(f(x, y), y, 1), x, 0);
F := tcoeff(f(x, y));
MQ:=Matrix([[A,B/2], [B/2,C]]):
Delta := A^2-4*A*C;
ML := `<,>`(D, E);
vp := Eigenvalues(MQ);
Omega := evalm(-`&*`((1/2)*ML, 1/MQ));
M1 := MQ-Eigenvalues(MQ)[1]*IdentityMatrix(2);
M2 := MQ-Eigenvalues(MQ)[2]*IdentityMatrix(2);
D := JordanForm(MQ);
with(linalg);
ma := matrix(2, 2, [A, (1/2)*B, (1/2)*B, C]);
jordan(ma, 'P1'); G := map(normalize, GramSchmidt([col(P1, 1 .. 2)])); P := map(simplify, concat(op(G)));

;
evalm(`&*`(`&*`(1/P, MQ), P));
nx := [X, Y];
var := [x, y];
x := matrix([seq([nx[i]], i = 1 .. 2)]); y := evalm(`&*`(P, x));
s := seq(var[k] = y[k, 1]+Omega[k], k = 1 .. 2);
eq := unapply(simplify(expand(subs(s, f(x, y)))), X, Y);
alpha := -eq(0, 0);
a := sqrt(alpha/vp[2]); b := sqrt(alpha/vp[1]); c := sqrt(a^2-b^2); print(X^2/a^2+Y^2/b^2 = 1);

This program works;. It is possible to simplify ? Thank you.

 

First 247 248 249 250 251 252 253 Last Page 249 of 2237