Items tagged with function function Tagged Items Feed

I currently have a function quadsum(n) that determines the [x,y] solutions of the above equation for an integer n. :

quadsum:= proc(n::nonnegint)
local
k:= 0, mylist:= table(),
x:= isqrt(iquo(n,2)), y:= x, x2:= x^2, y2:= y^2;
if 2*x2 <> n then x:= x+1; x2:= x2+2*x-1; y:= x; y2:= x2; end if;
while x2 <= n do
y:= isqrt(n-x2); y2:= y^2;
if x2+y2 = n then k:= k+1; mylist[k]:= [x,y] end if;
x:= x+1; x2:= x2+2*x-1;
end do;
convert(mylist, list)
end proc:

How would I alter this so that I get [x,y] for n= (5^a).(13^b).(17^c)(29^d) for non-negative integers a,b,c,d?

Dear,

I paste below a simple code illustrating what I want to do: interpolate a function from two lists . I wonder it is a very simple task but I the function and the graph I get don't match with the correct ones in the end (both are plotted below).

> y_data:=[0.5266426348e-1, 0.7090942099e-1, 0.9392192453e-1, .1228458380, .1598545751, .2107200296, .3127241088, .4144428927, .5679723063, .6817484378, .7973388763, .9326799232, 1.393259472, 1.493936979, 1.566845149, 1.624353545, 1.670898228, 1.708874880, 1.739919717, 1.765298377, 1.786042765, 1.803007037, 1.816897481, 1.828294327, 1.837670808, 1.845410531, 1.851823072, 1.857157571, 1.861614283, 1.865354162, 1.868506707, 1.871176289, 1.873447229, 1.875387839, 1.877053637, 1.878489894, 1.879733654, 1.880815343, 1.881760039, 1.882588494, 1.883317935, 1.883962726, 1.884534877, 1.885044474, 1.885500010, 1.885908668, 1.886276537, 1.886608800, 1.886909882, 1.887183573, 1.887433127, 1.887661351, 1.887870669, 1.888063180, 1.888240711, 1.888404854, 1.888557000, 1.888698365, 1.888830022, 1.888952911, 1.889067865];

> x_data:=[10, 53/5, 56/5, 59/5, 62/5, 13, 68/5, 68/5, 13, 62/5, 59/5, 56/5, 56/5, 59/5, 62/5, 13, 68/5, 71/5, 74/5, 77/5, 16, 83/5, 86/5, 89/5, 92/5, 19, 98/5, 101/5, 104/5, 107/5, 22, 113/5, 116/5, 119/5, 122/5, 25, 128/5, 131/5, 134/5, 137/5, 28, 143/5, 146/5, 149/5, 152/5, 31, 158/5, 161/5, 164/5, 167/5, 34, 173/5, 176/5, 179/5, 182/5, 37, 188/5, 191/5, 194/5, 197/5, 40];

inverted_pairs:=[seq([y_[i], x_[i]], i = 1 .. nops(y_))]; 

interp := LeastSquares(y_data, x_data, k_, curve = a*k_^3+b*k_^2+c*k_+d);

 

I've tried different kinds of interpolation methods. In this code I use LeastSquares() function. I'm sure it has a quick solution but I'm really stuck and would appreciate any help/advice.  

Thanks in advance!

 

 

PS: I didn't mention in above, but it is really important for me to get the associated function of the curve (e.g. ak_^3+bk_^2+ck_+d). I can get it using LeastSquares() function but with your code (where you use ArrayInterpolation()) the function is not generated in the end. Could you please indicate some way to do that? Thanks!

Hi,

I am trying to discretize a kernel of the form $K(x,y,t,s)$. I want to evaluate a four dimensional integral of the form

\int\int\int\int K(x,y,t,s)*h_m(x)*h_n(y)*h_p(t)*h_q(s) dsdtdxdy, where limits of integration are from 0 to 1.

$h_m()$ are function of one variable.

please suggest how to evaluate this.

thanks

 

Let a be som expression like
a:=t^2

Now how do I define a function using a.

f:=t->a
doesnt work

I've got the following piecewise function :

(x^2+y^2)^(alpha).arcsin(y/x) if (x,y) are in [-pi/2,pi/2]

0, (x,y)=(0,0)

1. How do I plot this function taking the alpha variable and the piecewise construct into account?

2. How can I check for points of discontinuity, indifferentiability from the plot/function itself?

 

 

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: Mapleprimes_LQ_model_simulation.mw

 

Any ideas?

Thanks,

jon

Hello,

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

f(x)*a*b;
subs(a*b=y,%);

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
od:
od:

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;
2
y + z - x
> solve(f2);
/ 2 \
{ x = y + z, y = y, z = z }
\ /
> f;
2
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.

 

taro

 

 

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