MaplePrimes Questions

int(1/(s^2+1), s = 1-I*infinity .. 1+I*infinity); # as expected
                               0

evalf(Int(1/(s^2+1), s = 1-I*infinity .. 1+I*infinity)); # Pi?
                          3.141592654

So evalf(Int(...)) either doesn't know how to handle complex infinite endpoints or handles them in a way incompatible with how int() does it.

 

Hello every body

I have three vectors `X`, `Y` and `Z`. I need to plot `X` vs `Z` and `Y` vs `Z` in one plot. How can I do this?

Thanks in advance

Hi,

I have some matrix valued functions that that I can only define piecewise. Unfortunately I have some problems to manipulate those functions. Piecewise sees to do the job for  scalar valued functions. There I can easily differentiale and add results. For Matrix valued functions however, those features seem to not be availible.
 

I can work around these limitations by manually applying all operations to the operands of the piecewise function. Like I show here:


 

restart:

# a piecewise function

p1:=piecewise(a(t)^2=0,<cos(a(t))^2+sin(a(t))^2,0>,<1,1/a(t)>)

p1 := piecewise(a(t)^2 = 0, Vector(2, {(1) = cos(a(t))^2+sin(a(t))^2, (2) = 0}), Vector(2, {(1) = 1, (2) = 1/a(t)}))

(1)

# differentiation does not work

diff(p1,t)

diff(piecewise(a(t)^2 = 0, Vector(2, {(1) = cos(a(t))^2+sin(a(t))^2, (2) = 0}), Vector(2, {(1) = 1, (2) = 1/a(t)})), t)

(2)

# selecting individual entries does not work

r:=p1(1)+1

r := (piecewise(a(t)^2 = 0, Vector(2, {(1) = cos(a(t))^2+sin(a(t))^2, (2) = 0}), Vector(2, {(1) = 1, (2) = 1/a(t)})))(1)+1

(3)

# strange simplification behaviour

simplify(p1)

piecewise(t = RootOf(a(_Z)), _z1(RootOf(a(_Z))), Vector(2, {(1) = 1, (2) = 1/a(t)}))

(4)

# current workaround, define new piecewise function by using op

r:=piecewise(op(1,p1),op(2,p1)(1)+1,op(3,p1)(1)+1)

r := piecewise(a(t)^2 = 0, cos(a(t))^2+sin(a(t))^2+1, 2)

(5)

 


 

Download Scratch.mw

 

I think my workaround is very cumbersome and error prone. Is there a better way to tackle this probem? Or should I try to overload all needed operations, and is this even possible?

Thanks for all suggestions!

Honigmelone

is it possible to express rational number into fraction in terms of power of 2

input

2.142857143

output

(2^3+2^2+2+1)/(1+2+2^2)

Hi, there.

I have a program, and I want to make an interface where I can text in the figures and show the results. But I have no idea about this. Anyone can give me some instructions? Thanks!

Hello

I'm importing some data from Excel which comes across as L:

L := Matrix(1, 6, [["TC,DB", "PC,JL", "TD,JK", "IW,CM", "CC,PG", "KJ,DJ"]])

M: = convert( L,'list' );

["TC,DB", "PC,JL", "TD,JK", "IW,CM", "CC,PG", "KJ,DJ"

map(convert, M, 'name') ; # remove inverted commas

[`TC,DB`, `PC,JL`, `TD,JK`, `IW,CM`, `CC,PG`, `KJ,DJ`]

How to I add square brackets to each pair in the output?

What I want is a command to display L or M as:

[[TC,DB], [PC,JL], [TD,JK], [IW,CM], [CC,PG], [KJ,DJ]]

 

1.
tanh(1-x) = sum(p(ii)*x^q(ii), ii=0..infinity) or product(p*x^q(ii), ii=0..infinity) ?
2.
tanh(1-x)*1/(1-x) = sum(p(ii)*x^q(ii), ii=0..infinity) or product(p*x^q(ii), ii=0..infinity) ?
3.
tanh(x) = sum(p(ii)*x^q(ii), ii=0..infinity) or product(p*x^q(ii), ii=0..infinity) ?

Remark: it may not be possible to use diff to find p(ii)

update

series(tanh(1-x), x=0);
with(OrthogonalSeries):
Coefficients(series(1/(1-x), x=0));
coeffs(series(tanh(1-x), x=0));
coeffs(series(tanh(1-x), x=0),x);
Error, invalid arguments to coeffs;
 
and is it possible to find q(ii) only if assume p(ii) all are one?

I am trying to solve a vector calculus problem, find r(t) given:

a(t) = < 4t, sin t, cos(2t) > ,  v(0) = <1,0,0>  , r(0) = <0, 1, 0 >

My approach below seems kind of complicated for such a straightforward problem.  I am trying to do this without copying pasting previous results. Also there might be a recursion issue when i defined v in terms of v(t).

 

 

I am a newbie at generating numeric data sets using the Matrix command.  Linked is the code I used to generate a time profile for various values of k.  The output results in 10 separate matrices for each value of k.  Instead I would like one matrix that has all ten data sets included.   Can anyone provide assistance?

untitled5.mw

 

 

 

   ,Hello friends

  .I want to plot a coupled differential equation numerically  but I dont know whats wrong with the loops


 

 


 

numeric4.mw  .pdfnumeric4.pdf

 

Question on the ditto operator, labels, and unapply, using three examples.

 

Example 1:

The ditto operator produces no output. Why is that? I presumed that the ditto operator is equivalent to copying pasting the last output.

 

Example 2:

Here the label approach seems to work, but in example three, both the ditto and label approach fails.

 

Example 3:

Someone earlier said that I should use unapply.

Why isn't    " v := x->% " equivalent to "v:=unapply(%,x)"

And why does the label approach fail in the vector calculus example.

I am trying to avoid having to copy paste an entire line of output.

The context of the problem , I am given an acceleration vector and want to find the position vector.

a:= <4t, sin t, cos 2t) with v(0) = <1,0,0> and r(0) = <0,1,0>

My problem is with an intermediate step, finding the velocity vector.

There is no output.

Another attempt. This time using a label

This time i do get an output, but v(1) should be (2 + c1) e_x + (-cos(1) + c2) e_y + (1/2 sin(2) + c3)e_z

The only way for it to work is to copy paste manually the output from line (21) as shown here

 

Hello people in mapleprimes,

I have a question about how PDEtools:-declare works.

I declared f__1 as a function of k__1 with the command declare, and

defined f__1 as a function of K__1/L__1, which is k__1,

and, differentiated f__1 with K__1.

But, the form I could get is e_1 and e_2, which contains D(f__1)(k__1).
And, the same thing occurs in e7_2.

How can I have it shown as f__1' or f__1'(k__1), which does not include D of D(f__1).

I hope you will give me a help, and thaks in advance.

18_Sep_2017.mw

Dear Maple users

Let's say I want to plot a line containing a parameter, for example (a+2)*x+6, where a is the parameter. When using the following Explore command:

Explore(plot((a+2)*x+6, x = -5 .. 5, view = -10 .. 10), parameters = [a = -4.0 .. 3], initialvalues = [a = 1])

I will be able to change the value of a by using the slider. The actual value of a is currently displayed as well. Now, However, I want to have the current value of the slope of the line displayed as I move the slider. How is this done? When using a print command inside the Explore command the value of a+2 is not displayed, rather "a+2". Can I use some kind of component?

I hope someone can help. 

NB! I constructed this rather doll example, just to make it simple.

Regards, Erik

 


ode1a := diff(y1(t), t) = round(rhs(odeparm1[1][1]))*y1(t)+round(rhs(odeparm1[1][2]))*y2(t)+round(rhs(odeparm1[1][3]))*y3(t);
ode2a := diff(y2(t), t) = round(rhs(odeparm1[1][4]))*y1(t)+round(rhs(odeparm1[1][5]))*y2(t)+round(rhs(odeparm1[1][6]))*y3(t);
ode3a := diff(y3(t), t) = round(rhs(odeparm1[1][7]))*y1(t)+round(rhs(odeparm1[1][8]))*y2(t)+round(rhs(odeparm1[1][9]))*y3(t);
try
ode1a := diff(y1(t), t) = rhs(odeparm1[1][1])*y1(t)+rhs(odeparm1[1][2])*y2(t)+rhs(odeparm1[1][3])*y3(t);
ode2a := diff(y2(t), t) = rhs(odeparm1[1][4])*y1(t)+rhs(odeparm1[1][5])*y2(t)+rhs(odeparm1[1][6])*y3(t);
ode3a := diff(y3(t), t) = rhs(odeparm1[1][7])*y1(t)+rhs(odeparm1[1][8])*y2(t)+rhs(odeparm1[1][9])*y3(t);
sys := DiffEquation([ode1a, ode2a, ode3a], inputvariable = [y1(t)], outputvariable = [y2(t), y3(t)]);
sysz := ToDiscrete(sys, ts); in_t := Sine(1, 1, 0, 0);
sol := Simulate(sys, [in_t]);
try
p1 := plots[odeplot](sol, [[t, y2(t)]], t = 0 .. t_sim, numpoints = 200, color = red);
print("succeed 1 2", i)
catch:
print("error draw at ", i)
end try;
try
p1 := plots[odeplot](sol, [[t, y3(t)]], t = 0 .. t_sim, numpoints = 200, color = red);
print("succeed 1 3", i)
catch:
print("error draw at ", i)
end try
catch: print("error at ", i);
print(lastexception);
print(ode1a);
print(ode2a);
print(ode3a);
end try;
try
ode1a := diff(y1(t), t) = rhs(odeparm1[1][1])*y1(t)+rhs(odeparm1[1][2])*y2(t)+rhs(odeparm1[1][3])*y3(t);
ode2a := diff(y2(t), t) = rhs(odeparm1[1][4])*y1(t)+rhs(odeparm1[1][5])*y2(t)+rhs(odeparm1[1][6])*y3(t);
ode3a := diff(y3(t), t) = rhs(odeparm1[1][7])*y1(t)+rhs(odeparm1[1][8])*y2(t)+rhs(odeparm1[1][9])*y3(t);
sys := DiffEquation([ode1a, ode2a, ode3a], inputvariable = [y2(t)], outputvariable = [y1(t), y3(t)]);
sysz := ToDiscrete(sys, ts);
in_t := Sine(1, 1, 0, 0);
sol := Simulate(sys, [in_t]);
try
p1 := plots[odeplot](sol, [[t, y1(t)]], t = 0 .. t_sim, numpoints = 200, color = red);
print("succeed 2 1", i)
catch:
print("error draw at ", i)
end try;
try
p1 := plots[odeplot](sol, [[t, y3(t)]], t = 0 .. t_sim, numpoints = 200, color = red);
print("succeed 2 3", i)
catch:
print("error draw at ", i)
end try
catch:
print("error at ", i);
print(lastexception);
print(ode1a);
print(ode2a);
print(ode3a)
end try;
try
ode1a := diff(y1(t), t) = rhs(odeparm1[1][1])*y1(t)+rhs(odeparm1[1][2])*y2(t)+rhs(odeparm1[1][3])*y3(t);
ode2a := diff(y2(t), t) = rhs(odeparm1[1][4])*y1(t)+rhs(odeparm1[1][5])*y2(t)+rhs(odeparm1[1][6])*y3(t);
ode3a := diff(y3(t), t) = rhs(odeparm1[1][7])*y1(t)+rhs(odeparm1[1][8])*y2(t)+rhs(odeparm1[1][9])*y3(t);
sys := DiffEquation([ode1a, ode2a, ode3a], inputvariable = [y3(t)], outputvariable = [y1(t), y2(t)]);
sysz := ToDiscrete(sys, ts);
in_t := Sine(1, 1, 0, 0);
sol := Simulate(sys, [in_t]);
try
p1 := plots[odeplot](sol, [[t, y1(t)]], t = 0 .. t_sim, numpoints = 200, color = red);
print("succeed 3 1", i)
catch:
print("error draw at ", i)
end try;
try
p1 := plots[odeplot](sol, [[t, y2(t)]], t = 0 .. t_sim, numpoints = 200, color = red);
print("succeed 3 2", i)
catch:
print("error draw at ", i)
end try
catch:
print("error at ", i);
print(lastexception);
print(ode1a);
print(ode2a);
print(ode3a)
end try

diff(y1(t), t) = 1.052936200*10^5*y1(t)+70106.19000*y2(t)+35169.00000*y3(t)
diff(y2(t), t) = 70106.19000*y1(t)+71031.61000*y2(t)+35511.00000*y3(t)
diff(y3(t), t) = 35169.00000*y1(t)+35511.00000*y2(t)+36100.00000*y3(t)
"the DEs contain functions with undefined values (probably caused by a discontinuity in the input that was differentiated). As a result, the numerical solution cannot be calculated. The DE system is: %1\"",[(&DifferentialD;)/(&DifferentialD;t) y1(t)=1.052936200 10^5 y1(t)+70106.19000 y2(t)+35169.00000 ({[[0,t<0],[sin(t),otherwise]]),(&DifferentialD;)/(&DifferentialD;t) y2(t)=70106.19000 y1(t)+71031.61000 y2(t)+35511.00000 ({[[0,t<0],[sin(t),otherwise]]),{[[0,t<0],[undefined,t=0],[cos(t),0<t]]=35169.00000 y1(t)+35511.00000 y2(t)+36100.00000 ({[[0,t<0],[sin(t),otherwise]]),y2(0)=0,y1(0)=0]
 
it has error when plot
First 937 938 939 940 941 942 943 Last Page 939 of 2433