# MaplePrimes Questions

Search Questions:

## Latest Questions Latest Questions Feed

### Problem with "if value in RealRange"...

November 17 2015
2 7

Hi, I'm trying to create a procedure like this;

f:=proc(a);
if a in RealRange(0,1) then a else no;
end if;
end proc;

But when I try with f(0.5); for instance, I get the error:

Error, (in f) cannot determine if this expression is true or false: .5 in RealRange(0, 1)

What am I doing wrong here, why can Maple not determine this?

Thank you!

### Use of Large Operators...

November 17 2015
1 2

HI,

wondered if anyone knows how to make proper use of the large operators pallete on the list of pallettes on the left. For example when using the contour integration symbol on the left how do you enter the delimiters.

I always get the error: "Error, unable to match delimiters". The help on this is not useful for this case.

Thanks.

### How do I solve a differential equation in Maple?...

November 17 2015
0 2

Hi everyone, I'm a new one to Maple. I've just learnt some basic tools :)

This is my task. I tried to record in Maple but I had errors. I don't know why I had problems but I hope you will help me and I will do it.

tkanks

### How to put 'if' into dsolve?...

November 17 2015
0 4

This is the code example_hw2.mw which derives from hw2_I1.mw.

hw2_I1.mw works but example_hw2.mw doesn't work and the differences between two codes are two new function I added to the dsolve which are η(t) and I2(t). The I2(t) is the second part of I1(t) at the interval t>t* which subject to Phi(t*)=0.

So how to make the sentence 'if |(H(t))/(omega)|>1 then eta(t)=0 else eta(t)=arccos(-(H(t))/(omega))' and 'I2(t) = (int(p(t), x = -eta(t) .. eta(t)))/Pi' work?

### How to plot a 2D contour plot embed in the botton ...

November 17 2015
1 4

I would like to plot a 2D contour plot in the botton of a 3D plot of a spacial curve. I don't know how to do that in maple, but I found something similar done in Matlab for a 2Dcontour plot in the botton of a 3D surface.

Can someone help me?

Thanks,

Fernando

### Answers in MW and kW...

November 17 2015
2 1

Hi everyone,

One of my teachers got stuck in the last century and will not approve my turned in papers when i use "replace unit"
Can i make a global setting that makes all my watt results come up as MegaWatt ?

### How to solve a PDE?...

November 17 2015
0 4

Hi,

i meet  a partial differential equation seems not complicated

with(PDEtools):

PDE := (diff(f(x__1, x__2, p__1, p__2), x__1))*p__1/m-(diff(f(x__1, x__2, p__1, p__2), p__1))*(2*k*x__1-k*x__2)+(diff(f(x__1, x__2, p__1, p__2), x__2))*p__2/m-(diff(f(x__1, x__2, p__1, p__2), p__2))*(-k*x__1+2*k*x__2);

when i use

pdsolve(PDE);

i get nothing,but i sure

f=c*(p__1^2/m+p__2^2/m+4*p__1*p__2/m+6*k*x__1*x__2)

is the one solution of the differential equation .

how i can get solutions about of the above equation.

thanks .

### Problem with integral in dsolve...

November 17 2015
0 6

This is the code  hw2_final.mw

Let me explain it.

I am sure that the mistakes must be about the expresstion of the I1(t) and I2(t). Actually if you delete I1(t) and I2(t) , the whole code works and get the picture at the bottom.

What I want is to put the expresstion of the I1(t) and I2(t) into 'sol:=dsolve...' and 'plots...' to get the picture of I1(t) and I2(t) with respect to t. Before the t* which subject to Phi(t*)=0 (The blue line in the picture at the bottom is Phi) I want I1(t) and after t* I want I2(t).

I1(t) = (int(sqrt(2*(H(t)+omega*cos(q(t)))), q(t) = q(t)-2*Pi .. q(t), numeric))/Pi.    what I want of this experesstion is to get  'int(sqrt(2*(H(t)+omega*cos(q(t)))' from  'q(t)-2*Pi' to 'q(t)' by numeric method.This q(t) is the solution of the ODE sys.

For example(the number I used is not true,just for example) , at the point t=20, q(t)=30-2*Pi.

so I1(t)= (int(sqrt(2*(H(t)+omega*cos(x))), x = 30-2*Pi .. 30, numeric))/Pi.The I2(t) I want is similar to I1(t).

How can I solve it?

### Fit routine to find parameters...

November 17 2015
0 5

Hello,

I am pretty new to Maple and Im trying to find the parameters of an equation using some kind of fit routine but I can only find such a routine to fit an expression to data and not vice versa.

my equation is as follows

epsilon(E):= a0 + a1*ln(E) + a2*ln(E)^2 + a3*ln(E)^3

I do have data for E which I imagine I need.

E:= {121, 244, 344, 411, 444, 778, 867, 964, 1085, 1112, 1212, 1299, 1408} all in keV :)

Any suggestions/help would be much appreciated, although I am new to the program so go easy on me :)

Cheers

### Testing for control characters ...

November 17 2015
1 5

Hi, I'm searching through a text file looking at individual letters, characters etc.  As part of this I want to detect if the character is the control character for a new paragraph - carriage return, line feed. I believe the ASCII numbers for these are 13, 10 respectively. I'd like to know the code to do this, please.  It's something along the lines: CR:=???:  if c=CR then

where c is a character read from the text file.   ....but what goes in place of ???

Thanks, David

### How to create an animation function?...

November 17 2015
1 4

Hello everyone, I'm a new one to Maple, I've just learnt some basic tools.

I want to creat a command that can animate the graph of line y=ax+b by the parameter a, and b will be subscribe later. For example, I can plot y=x+b by:

F:=b->plot(x+b,x=-1..1):

display(F(1));

It did work.

However, applying this with animation didn't seem to work.

F:=b->animate(plot,[a*x+b,x=-1..1],a=0..10,frames=5):

display(F(1));

It did not create an animation, instead 5 frames of this graph for a=0, 2.5, 5, 7.5, 10

Please show me a solution for this problem, thank you

### Can 'if' be coded in Components?...

November 17 2015
1 2

I am wondering if Selection Statement 'if' can be coded in Embedded Components such as Text Area.

I have typed codes in the Text Area(%text_beta_degress) as follows:

if %text_beta_degress=1.2 then Do(%text_ps=28);Do(%text_l4=5.439);
elif %text_beta_degress=8.77 then Do(%text_ps=15);Do(%text_l4=2.785);
elif %text_beta_degress=10 then Do(%text_ps=12.83);Do(%text_l4=2.348);
elif %text_beta_degress=14.4 then Do(%text_ps=5);Do(%text_l4=0.758);
end if

When I typed 1.2 or 8.77 into the Text Area(%text_beta_degress) and tapped 'Enter', %text_ps and %text_l4 didn't response.

Is there any solution?

### Mean Value Theorem...

November 17 2015
0 4

Hi

f := x->x^2:

AB(f, 0, 5);

But my proc is not true for below example:

f := x -> x^3-2*x;
AB(f, -1, 4);
I think c has two value and it is not true.

How can I add a condition to my proc that c be between a and b (a<c<b)?

### Problem with solving system...

November 16 2015
0 1

How can I solve the following system in Maple for $S_1$ and $S_{i+1}$? I have the code written, but it is giving me nothing as output.

eq1 := Q-A*S[1]*C/X+B*D*(sum(S[j], j = 2 .. i+1))/Y-r[1]*S[1] = 0;
eq2 := A*S[i-1]*C/X-A*S[i]*C/X-B*S[i]*D/Y-r[1]*S[i] = 0;
eq3 := A*S[i]*C/X-B*S[i+1]*D/(Y+S[i+1])-r[2]*S[i+1] = 0;
solve({eq1, eq2, eq3}, {S[1], S[i+1]});

The only non-constants in the system are the $S_j$'s for $j = 1, \ldots, i+1$.

Here is the system in math mode:
$$Q-\frac{AC}{X}S_1-r_1 S_1 +\frac{BD}{Y}\sum\limits_{j=2}^{i+1}S_j = 0 \\ \frac{AC}{X}S_{i-1} - \frac{AC}{X}S_i - \frac{BD}{Y}S_i - r_1 S_i = 0\\ \frac{AC}{X}S_i - \frac{BD S_{i+1}}{Y+S_{i+1}} - r_2 S_{i+1} = 0$$

I have a head start on it by hand, but it's too cumbersome to complete.

Basically, my strategy is to solve for $S_{i+1}$ as a function of $S_1$ and some constants. Then to plug in $S_2, \ldots, S_{i+1}$ in the summation and solve for $S_1$ as a function of constants. Then I would obtain $S_{i+1}$ as a function of constants itself.

Thanks for any help.

### Probability density normalization...

November 16 2015
2 2

Probability_density_normalization.mw

In this code I'm trying to separately normalize two independent probability densities and then combine them to get the joint probability density that's normalized and then use it to calculate the probability that the two variables are equal. fD(x) is a Gaussian divided by x^2 and fA(x) is a Gaussian. The first problem occurs when I'm checking the normalization of the joint probability density by doing the double integral over all space for fD(x)*fA(y)dxdy, I get weird vanishing number when the parameter "hartree" takes a certain value, namely 27.211. If I change hartree to 27 or 1 or 2 it all worked, but 27.211 is not good. Also later when I do a single integral over all space for fD(x)*fA(x)dx to get the probability that these two are equal, I find the result is dependent on hartree. This hartree thing is a unit conversion in my physical problem and in principle should not interfere with either the normalization or the probability result at all. I suspect this is a coding bug but I can't find what it is. I'd appreciate any input.

Thank you very much!

Edit: I found out that the problem with the double integral normalization may have something to do with the discretization for numerical evaluation of the integral, since if I change the lower bound to 1/hartree and upper to 10/hartree then it's fine, however if I use lower bound at 1/hartree and upper at 5/hartree it doesn't work, although the distribution has no value between 5/hartree and 10/hartree. However after this is fixed I still have the problem with the single integral over all space for fD(x)*fA(x)dx changing with hartree. Well as a probability I would expect the integral to be bound between 0 and 1, but since it almost linearly depends on hartree, at hartree around 27 I would get the integral value to be about 25, which doesn't make sense. In fact, I now suspect it is not Maple, but my calculation of the probability of the two random variables taking the same value is wrong, I'd appreciate it very much if someone can confirm this.

 5 6 7 8 9 10 11 Last Page 7 of 1234
﻿