Ask Your Question

ds22's profile - activity

2020-05-28 10:08:40 +0200 received badge  Notable Question (source)
2020-05-28 10:08:40 +0200 received badge  Famous Question (source)
2019-01-02 17:41:30 +0200 received badge  Popular Question (source)
2018-04-26 02:51:16 +0200 commented answer Generating a random vector with elements in specified range

@Emmanuel Charpentier: I really need it to be a closed interval though. This is the beginning of a function for a Monte Carlo simulation. I need to know when the input (which is a probability) is less than one.

2018-04-25 20:53:28 +0200 asked a question Generating a random vector with elements in specified range

I would like to generate a random vector in which its elements are between 0 and 1 (including 0 and 1). As far as I know, v = random_matrix(ZZ, 1, 10) is a way to generate a random matrix. How would I restrict the elements to the range I want?

I am trying to build a function with a probability input, and then compare the probability to each of the elements separately in the random vector.

2018-02-01 19:28:09 +0200 commented question What does r signify in this output?

@dan_fulea Yeah, I realize lam has nothing to do with the system. I am just trying to emulate an example from a textbook which includes the variable lam. However, I am unable to figure out what lam is supposed to do or what it is supposed to equal.

2018-02-01 19:02:18 +0200 asked a question What does r signify in this output?

It appears after lam ==

solve([diff(P,x) == 0, diff(P,y) == 0], x, y, lam)

 [[x == 816.8214285714286, y == 506.0324074074074, lam == r5], [x == -816.2645502645503, y == -514.5402298850574, lam == r6], [x == (13.33265402759081 + 1414.015105182754*I), y == (3.906674551362281 - 883.7900965450355*I), lam == r7], [x == (13.33265402759081 - 1414.015105182754*I), y == (3.906674551362281 + 883.7900965450355*I), lam == r8]]
2018-02-01 03:32:07 +0200 commented question Help with defining constraints in Lagrangian

@dan_fulea, No we do not. I wasn't sure.

2018-01-31 23:26:36 +0200 asked a question Help with defining constraints in Lagrangian

I am trying to maximize the function P, with constraints of x >= 75,000 and y >= 200,000. However, I do not think I am defining them correctly. I attempt to define them as arguments of the solve() function.

var('x','y', 'lam')

P = (0.05*x*(1-(x/150000) - 0.0000008*x*y)) + (0.08*y*(1-(y/200000) - 0.0000008*x*y))

diff(P, x)
-(4.00000000000000e-8)*x*y - (6.40000000000000e-8)*y^2 - (3.33333333333333e-7)*x*(0.120000000000000*y + 1) - (3.33333333333333e-7)*x + 0.0500000000000000

diff(P, y)
-(4.00000000000000e-8)*x^2 - (6.40000000000000e-8)*x*y - (4.00000000000000e-7)*(0.160000000000000*x + 1)*y - (4.00000000000000e-7)*y + 0.0800000000000000

solve([diff(P,x) == 0, diff(P,y) == 0, x >= 75000, y >= 200000], x, y, lam)
[[75000 < x, 200000 < y, -(4e-08)*x*y - (6.4e-08)*y^2 - (3.33333333333333e-07)*x*(0.12*y + 1) - (3.33333333333333e-07)*x + 0.05 == 0, -(4e-08)*x^2 - (6.4e-08)*x*y - ((6.4e-08)*x + 4e-07)*y - (4e-07)*y + 0.08 == 0], [x == 75000, 200000 < y, -(6.4e-08)*y^2 - 0.006*y == 0, -0.0096008*y - 224.92 == 0], [x == 75000, y == 200000, -3760.0 == 0, -2145.08 == 0], [y == 200000, 75000 < x, -0.01600066666666667*x - 2559.949999999999 == 0, -(4e-08)*x^2 - 0.0256*x - 0.08 == 0]]
2018-01-31 23:14:22 +0200 received badge  Scholar (source)
2018-01-31 23:14:15 +0200 received badge  Supporter (source)
2018-01-31 22:34:47 +0200 received badge  Editor (source)
2018-01-31 20:38:51 +0200 received badge  Student (source)
2018-01-31 20:38:14 +0200 asked a question In what way am I using the "&" sign incorrectly?

Ex 4.3 Dichotomy function

var('a','b','N')
(a, b, N)
def Dichotomy(a,b,N):
    if f(a)*f(b) >= 0:
        print "Don't bother me or my wrath shall fall upon you"
    lb = a
    ub= b
    for i in range(1, N):
        mp = (lb+ub)/2
        if f(mp) == 0:
            lb = mp
            up = mp
        if(((f(mp)<0) & (f(lb)<0)) | ((f(mp)>0) & (f(lb)>0))):
            lp = mp
        else: up = mp
    return [lb,ub,ub-lb]

Dichotomy(1,2,10)
Don't bother me or my wrath shall fall upon you

Error in lines 1-1
Traceback (most recent call last):
  File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1013, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "", line 1, in 
  File "", line 11, in Dichotomy
TypeError: unsupported operand type(s) for &: 'sage.symbolic.expression.Expression' and 
'sage.symbolic.expression.Expression'