Items tagged with function function Tagged Items Feed

Dear mapleprimes users,

I have a problem concerning this function:

Naief := proc(A::integer,B::integer, p::posint)
local x, a:= A mod p, b:= B mod p;

 for x from 1 to p-1 do
    if a^x mod p = b then return x end if
end do;
print(¨No solution.¨)

end proc

It works fine for what it should do, finding x for a^x = b mod p by inserting x from 1 to p-1 until it finds an
apprioperate x.

My problem is concerning its computation time, which I like to calculate with:

Codetools:- Usage(Naief(a,b,p), output = [cputime], quiet, iterations= 2^12)

The problem is that keeps repeating

alot even when a,b and p are immensely huge. I don`t know how to fix it, because I need real CPUtimes which increase
a,b and p increase. I get the idea that the values of the CPUtime are not realistic.


Thanks for the help!




Hi there,

I am trying to simulate the behaviour of an equation in the continuous domain for two different populations given a set of parameters.

The equations reads:

S(t) = exp(-alpha·D(t)-beta·G·D^2(t))

where alpha and beta are known (and are different for two populations of cells), and G may be:

Case 1: G=1

Case 2: G = (D1^2+D2^2+2*D1*D2*exp(-lambda*T))/D^2 (where D1=D/3; D2=2·D/3; and lambda is also known)


For the Case 1, I need to simulate for different values of D. Even if for the purposes of this case, D(t) = D0 (a constant); I would like to know how I would do it for a time-dependent D, for example,  D(t) = D0·t, with a varying D0, for example in the range [1..8].

For the Case 2, I need to simulate under different values of T (for example in the range [1..8]), letting D be a constant, known value. In this case, D(t) is a piecewise function:

D(t) =
= D/3 if t=0

= 2·D/3 if t=T
= 0 for any other t

I really don't know how to write the expression for S(t) in this case.


I guess I need an array to store as many instances of S as numbers of parameters I have (8 values for D0 int he first case, and another eight for T).

And besides, it needs to be a function of t (even if in the first case, it is not; I'd like to simulate as if it were).


So I am at a loss when it comes to writing the expressions of S(t), and having it evaluated (and its values plot in the same graph using a palette for differente parameter values) for say, t=0..100.


Attached is my attempt:


Any ideas?




I have a question: why does the following not work and how can I make it work:


The result is f(x) a b but I want f(x) y. What can I do? I also tried eval.

Thanks and best regards.

is it possible to generalize a function to a combinatorial level for approximate axioms

for example, first 100 or 1000 data points satisfy axioms

or 100% satisfy a axioms which means satisfy to infinity

because i find data always not exactly satisfy the axioms,
i guess it only satisfy to some limit, this may explain why data has decimal number

or conversely is it possible to generalize some axioms which approximate the original exact axioms
then data can exactly satisfy the approximate axioms

can generalize a nested forloop to achieve this goal?

how can it be done in algebra point of view?


For example:

x*y = for loop -> for loop -> i*j

it can change for loop expression into algebra

for i from 1 to 10 do
for j from 1 to 10 do
print i*j

I am having issues when defining functions in a loop. First, I define the first two functions as follows (here, r(x) is a function already assigned).


f_0 := x -> r(x):

f_1 := x -> r(x)*f_0(r(x)):


Then, I define successive functions in a for loop as follows.


for i from 2 to 10 do

   f_i := x -> r(x)*f_[i - 1](r(x));

end do


The loop defines the function f_2 but compiles erroneously for f_3 which, and I do admit, relies on f_2. Does someone have an idea of how to fix this issue? Any help will be greatly appreciated. Thanks.

Hi all!

I have this function:


Problem is it doesn`t have any output, really anoying! Could you please help. Thanks guys!

I need to find only the x for which a^x = b mod p is a solution of.

f := x^2+y-z=0

f2:= y^2 +z-x = 0

after shift , solution shift too, can it be said it is invariant in parameter shift?

if not, any example to show a function which is invariant in parameter shift?

> solve(f);
/ 2 \
{ x = x, y = -x + z, z = z }
\ /
> f2 := y^2+z-x;
y + z - x
> solve(f2);
/ 2 \
{ x = y + z, y = y, z = z }
\ /
> f;
x + y - z = 0

Hi all,

I am trying to solve the following differential equation numerically using dsolve,


y * abs (y''') = -1

y(0) =1, y'(0) = 0, y''(0)=0


it works fine when tthe absolute function is not there, i.e. yy''' = -1. 

Do you have any suggestion?

When you label a function of curve, this label is put just next to it. Is there a way to move this label to another position of the same curve?

Dear people in mapleprimes,


>define(INT, linear, conditional(INT(a::algebraic, X::name) = a*X, _type(a, freeof(X))), INT(X::name, X::name) = (1/2)*X^2);

>INT(2*x+4, x);

x^2 + 4*x

>INT(z+x, z);

(1/2)* z ^2+ x*z

is written in the help page of maple.

This code is to make a function INT.

What it means is that if INT(a::algebraic, x::name) then this is transformed into a*X, where a is independent from x.

And, INT(X::name,X::name) is transformed into (1/2)*X^2.


The first of what I want to ask you is the way of use of "_type", which is not in the help page, and as for names with "_" ahead, 

it is written that "_" means internal command for Maple, so not to use it. Is it right to use a name with "_" ahead of it here?

The second of what I want to know is the way to use "conditional."

Please teach me the meaning of this.

Thanks in advance.


I hope you will teach me the above questions.


Best wishes.





I have been having problems with using the BodePlot function with units:


R1 := 18.2*10^3*Unit('Omega');

R2 := 10^3*Unit('Omega');

C1 := 470*10^(-12)*Unit('F');

C2 := 4.7*10^(-9)*Unit('F');

# wo is in hertz

wo := 1/sqrt(R1*R2*C1*C2);

# Q is unitless

Q := wo*R1*R2*C2/(R1+R2)



sys := TransferFunction(wo^2/(s^2+wo*s/Q+wo^2));


This is the error message I got:

Error, (in Units:-Standard:-+) the units `1` and `Hz` have incompatible dimensions


I think the problem is that the BodePlot function doesn't expect 'wo' to have units.  

So I tried to work around the issue by using the loglogplot but it doesn't seem to like 

complex function even when I used abs to find the magnitude (with or without units).


 Any workaround is appreciated.


Maple 15 allows the following syntax

omega := sqrt(w0^2*(1+((z-zf)/z0)^2))

But it does not allow this one 

omega^2 := sqrt(w0^2*(1+((z-zf)/z0)^2))

Why is this so for functions and variables? Is there any way around this, I am really bugged by this issue. The Maple Math told me that the syntax was invalid so I had type the commands directly.



I'm trying make Maple write the actual result, when i differenting an expression: x[s] := x(t)+sin(theta(t))*a.
when i differentiate with respect to t, i get:

> diff(x[s], t);
print(`output redirected...`); # input placeholder
/ d \ / d \
|--- ()(t)| + cos(theta(t)) |--- theta(t)| a
\ dt / \ dt /

Maple, writes the expression as a table, but i need to see the normal function? Why does it do that? And how can i make it show the expression as a normal function?

When i derive the two parts serperately i get the normal result, but as soon as i add them together, i get the table rasult again?

Is there an easy trick for this one?




Consider the function



The above definition may result in four cases depening on r and x.

Can Maple calculate automatically all possible cases and the corresponding Maxima, Minima and Values at intervals limits?


Hi all

Assume that we have a function, say f(t) and we want to substitute t in it where t is:


by subs or other better command, how can we do it?

best wishes

Mahmood   Dadkhah

Ph.D Candidate

Applied Mathematics Department

1 2 3 4 5 6 7 Last Page 3 of 25