ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 13 Aug 2014 03:06:08 -0500Finding the maximum of a parameterhttp://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/I was trying to use integrals, in order to find the average radius. What I did was I took a function, like $$f'(x,y)$$, and then I replaced f'(rcos(theta),rsin(theta)). Then I replaced r with y, and theta with x.
This was divided into the positives above the x-axis, and the negatives below. Using computer programming I got used it all inorder to find the area under the positive curve.
var('n a b x y s u v A')
n = 5100
a = 0
b =2*pi
h =(b-a)/n
s =0
for i in range(n):
x = a + i*h
s = s +find_root((y*cos(x)+u)^2)/4+((y*sin(x)+v)^2)/9-1,1.9,3.1)
A= float((b-a)/n*s)
Where a is the start of the integral, b is the end of it, h is the intervals for the integral, s is the root to identify the region for integration, the float is the summation,A is the area, and u and v are parameters.. Note: This is an **2-D implicit function**, you can't use a direct integral, but you can use the definition.
I'm trying to use the co-ordinates to find the maximum of u, and v in terms of A, or the area. I would like to find the co-ordinates of the maximum that comes out of this function.
You can think of it as
$$x=u$$
$$y=v$$
$$z=A$$.
I tried this (at the very top of this post) on sage, but it gave...
Error in lines 7-9
Traceback (most recent call last):
File "/projects/180e8f3c-9dc5-424f-abcc-5267257c0d31/.sagemathcloud/sage_server.py", line 736, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 3, in <module>
File "/usr/local/sage/sage-6.3.beta6/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 77, in find_root
return f.find_root(a=a,b=b,xtol=xtol,rtol=rtol,maxiter=maxiter,full_output=full_output)
File "expression.pyx", line 9685, in sage.symbolic.expression.Expression.find_root (build/cythonized/sage/symbolic/expression.cpp:42561)
NotImplementedError: root finding currently only implemented in 1 dimension.
19
Fri, 08 Aug 2014 14:23:25 -0500http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/Comment by vdelecroix for <p>I was trying to use integrals, in order to find the average radius. What I did was I took a function, like $$f'(x,y)$$, and then I replaced f'(rcos(theta),rsin(theta)). Then I replaced r with y, and theta with x.
This was divided into the positives above the x-axis, and the negatives below. Using computer programming I got used it all inorder to find the area under the positive curve.</p>
<pre><code>var('n a b x y s u v A')
n = 5100
a = 0
b =2*pi
h =(b-a)/n
s =0
for i in range(n):
x = a + i*h
s = s +find_root((y*cos(x)+u)^2)/4+((y*sin(x)+v)^2)/9-1,1.9,3.1)
A= float((b-a)/n*s)
</code></pre>
<p>Where a is the start of the integral, b is the end of it, h is the intervals for the integral, s is the root to identify the region for integration, the float is the summation,A is the area, and u and v are parameters.. Note: This is an <strong>2-D implicit function</strong>, you can't use a direct integral, but you can use the definition.
I'm trying to use the co-ordinates to find the maximum of u, and v in terms of A, or the area. I would like to find the co-ordinates of the maximum that comes out of this function.
You can think of it as </p>
<p>$$x=u$$
$$y=v$$
$$z=A$$.</p>
<p>I tried this (at the very top of this post) on sage, but it gave... </p>
<pre><code> Error in lines 7-9
Traceback (most recent call last):
File "/projects/180e8f3c-9dc5-424f-abcc-5267257c0d31/.sagemathcloud/sage_server.py", line 736, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 3, in <module>
File "/usr/local/sage/sage-6.3.beta6/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 77, in find_root
return f.find_root(a=a,b=b,xtol=xtol,rtol=rtol,maxiter=maxiter,full_output=full_output)
File "expression.pyx", line 9685, in sage.symbolic.expression.Expression.find_root (build/cythonized/sage/symbolic/expression.cpp:42561)
NotImplementedError: root finding currently only implemented in 1 dimension.
19
</code></pre>
http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23752#post-id-23752Could you edit your question to describe your problem more precisely?Tue, 12 Aug 2014 09:08:00 -0500http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23752#post-id-23752Comment by Krishnan Arbuja for <p>I was trying to use integrals, in order to find the average radius. What I did was I took a function, like $$f'(x,y)$$, and then I replaced f'(rcos(theta),rsin(theta)). Then I replaced r with y, and theta with x.
This was divided into the positives above the x-axis, and the negatives below. Using computer programming I got used it all inorder to find the area under the positive curve.</p>
<pre><code>var('n a b x y s u v A')
n = 5100
a = 0
b =2*pi
h =(b-a)/n
s =0
for i in range(n):
x = a + i*h
s = s +find_root((y*cos(x)+u)^2)/4+((y*sin(x)+v)^2)/9-1,1.9,3.1)
A= float((b-a)/n*s)
</code></pre>
<p>Where a is the start of the integral, b is the end of it, h is the intervals for the integral, s is the root to identify the region for integration, the float is the summation,A is the area, and u and v are parameters.. Note: This is an <strong>2-D implicit function</strong>, you can't use a direct integral, but you can use the definition.
I'm trying to use the co-ordinates to find the maximum of u, and v in terms of A, or the area. I would like to find the co-ordinates of the maximum that comes out of this function.
You can think of it as </p>
<p>$$x=u$$
$$y=v$$
$$z=A$$.</p>
<p>I tried this (at the very top of this post) on sage, but it gave... </p>
<pre><code> Error in lines 7-9
Traceback (most recent call last):
File "/projects/180e8f3c-9dc5-424f-abcc-5267257c0d31/.sagemathcloud/sage_server.py", line 736, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 3, in <module>
File "/usr/local/sage/sage-6.3.beta6/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 77, in find_root
return f.find_root(a=a,b=b,xtol=xtol,rtol=rtol,maxiter=maxiter,full_output=full_output)
File "expression.pyx", line 9685, in sage.symbolic.expression.Expression.find_root (build/cythonized/sage/symbolic/expression.cpp:42561)
NotImplementedError: root finding currently only implemented in 1 dimension.
19
</code></pre>
http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23731#post-id-23731If there's something that doesn't make sense, please say so.Sat, 09 Aug 2014 17:22:29 -0500http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23731#post-id-23731Comment by vdelecroix for <p>I was trying to use integrals, in order to find the average radius. What I did was I took a function, like $$f'(x,y)$$, and then I replaced f'(rcos(theta),rsin(theta)). Then I replaced r with y, and theta with x.
This was divided into the positives above the x-axis, and the negatives below. Using computer programming I got used it all inorder to find the area under the positive curve.</p>
<pre><code>var('n a b x y s u v A')
n = 5100
a = 0
b =2*pi
h =(b-a)/n
s =0
for i in range(n):
x = a + i*h
s = s +find_root((y*cos(x)+u)^2)/4+((y*sin(x)+v)^2)/9-1,1.9,3.1)
A= float((b-a)/n*s)
</code></pre>
<p>Where a is the start of the integral, b is the end of it, h is the intervals for the integral, s is the root to identify the region for integration, the float is the summation,A is the area, and u and v are parameters.. Note: This is an <strong>2-D implicit function</strong>, you can't use a direct integral, but you can use the definition.
I'm trying to use the co-ordinates to find the maximum of u, and v in terms of A, or the area. I would like to find the co-ordinates of the maximum that comes out of this function.
You can think of it as </p>
<p>$$x=u$$
$$y=v$$
$$z=A$$.</p>
<p>I tried this (at the very top of this post) on sage, but it gave... </p>
<pre><code> Error in lines 7-9
Traceback (most recent call last):
File "/projects/180e8f3c-9dc5-424f-abcc-5267257c0d31/.sagemathcloud/sage_server.py", line 736, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 3, in <module>
File "/usr/local/sage/sage-6.3.beta6/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 77, in find_root
return f.find_root(a=a,b=b,xtol=xtol,rtol=rtol,maxiter=maxiter,full_output=full_output)
File "expression.pyx", line 9685, in sage.symbolic.expression.Expression.find_root (build/cythonized/sage/symbolic/expression.cpp:42561)
NotImplementedError: root finding currently only implemented in 1 dimension.
19
</code></pre>
http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23756#post-id-23756What do you expect from find_root((y*cos(x)+u)^2)/4+((y*sin(x)+v)^2)/9-1,1.9,3.1)?Wed, 13 Aug 2014 03:06:08 -0500http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23756#post-id-23756Comment by Krishnan Arbuja for <p>I was trying to use integrals, in order to find the average radius. What I did was I took a function, like $$f'(x,y)$$, and then I replaced f'(rcos(theta),rsin(theta)). Then I replaced r with y, and theta with x.
This was divided into the positives above the x-axis, and the negatives below. Using computer programming I got used it all inorder to find the area under the positive curve.</p>
<pre><code>var('n a b x y s u v A')
n = 5100
a = 0
b =2*pi
h =(b-a)/n
s =0
for i in range(n):
x = a + i*h
s = s +find_root((y*cos(x)+u)^2)/4+((y*sin(x)+v)^2)/9-1,1.9,3.1)
A= float((b-a)/n*s)
</code></pre>
<p>Where a is the start of the integral, b is the end of it, h is the intervals for the integral, s is the root to identify the region for integration, the float is the summation,A is the area, and u and v are parameters.. Note: This is an <strong>2-D implicit function</strong>, you can't use a direct integral, but you can use the definition.
I'm trying to use the co-ordinates to find the maximum of u, and v in terms of A, or the area. I would like to find the co-ordinates of the maximum that comes out of this function.
You can think of it as </p>
<p>$$x=u$$
$$y=v$$
$$z=A$$.</p>
<p>I tried this (at the very top of this post) on sage, but it gave... </p>
<pre><code> Error in lines 7-9
Traceback (most recent call last):
File "/projects/180e8f3c-9dc5-424f-abcc-5267257c0d31/.sagemathcloud/sage_server.py", line 736, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 3, in <module>
File "/usr/local/sage/sage-6.3.beta6/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 77, in find_root
return f.find_root(a=a,b=b,xtol=xtol,rtol=rtol,maxiter=maxiter,full_output=full_output)
File "expression.pyx", line 9685, in sage.symbolic.expression.Expression.find_root (build/cythonized/sage/symbolic/expression.cpp:42561)
NotImplementedError: root finding currently only implemented in 1 dimension.
19
</code></pre>
http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23750#post-id-23750I want too be able to know to fix the error message and make a function, out of u,v, and A. Then use the program for solving a maximum and minimum of that function.Tue, 12 Aug 2014 08:57:30 -0500http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23750#post-id-23750Comment by vdelecroix for <p>I was trying to use integrals, in order to find the average radius. What I did was I took a function, like $$f'(x,y)$$, and then I replaced f'(rcos(theta),rsin(theta)). Then I replaced r with y, and theta with x.
This was divided into the positives above the x-axis, and the negatives below. Using computer programming I got used it all inorder to find the area under the positive curve.</p>
<pre><code>var('n a b x y s u v A')
n = 5100
a = 0
b =2*pi
h =(b-a)/n
s =0
for i in range(n):
x = a + i*h
s = s +find_root((y*cos(x)+u)^2)/4+((y*sin(x)+v)^2)/9-1,1.9,3.1)
A= float((b-a)/n*s)
</code></pre>
<p>Where a is the start of the integral, b is the end of it, h is the intervals for the integral, s is the root to identify the region for integration, the float is the summation,A is the area, and u and v are parameters.. Note: This is an <strong>2-D implicit function</strong>, you can't use a direct integral, but you can use the definition.
I'm trying to use the co-ordinates to find the maximum of u, and v in terms of A, or the area. I would like to find the co-ordinates of the maximum that comes out of this function.
You can think of it as </p>
<p>$$x=u$$
$$y=v$$
$$z=A$$.</p>
<p>I tried this (at the very top of this post) on sage, but it gave... </p>
<pre><code> Error in lines 7-9
Traceback (most recent call last):
File "/projects/180e8f3c-9dc5-424f-abcc-5267257c0d31/.sagemathcloud/sage_server.py", line 736, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 3, in <module>
File "/usr/local/sage/sage-6.3.beta6/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 77, in find_root
return f.find_root(a=a,b=b,xtol=xtol,rtol=rtol,maxiter=maxiter,full_output=full_output)
File "expression.pyx", line 9685, in sage.symbolic.expression.Expression.find_root (build/cythonized/sage/symbolic/expression.cpp:42561)
NotImplementedError: root finding currently only implemented in 1 dimension.
19
</code></pre>
http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23747#post-id-23747What is your question? You wrote a problem you got with Sage but what do you want? Explanation for the error message? Another strategy to solve your problem?Tue, 12 Aug 2014 04:10:51 -0500http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23747#post-id-23747Comment by Krishnan Arbuja for <p>I was trying to use integrals, in order to find the average radius. What I did was I took a function, like $$f'(x,y)$$, and then I replaced f'(rcos(theta),rsin(theta)). Then I replaced r with y, and theta with x.
This was divided into the positives above the x-axis, and the negatives below. Using computer programming I got used it all inorder to find the area under the positive curve.</p>
<pre><code>var('n a b x y s u v A')
n = 5100
a = 0
b =2*pi
h =(b-a)/n
s =0
for i in range(n):
x = a + i*h
s = s +find_root((y*cos(x)+u)^2)/4+((y*sin(x)+v)^2)/9-1,1.9,3.1)
A= float((b-a)/n*s)
</code></pre>
<p>Where a is the start of the integral, b is the end of it, h is the intervals for the integral, s is the root to identify the region for integration, the float is the summation,A is the area, and u and v are parameters.. Note: This is an <strong>2-D implicit function</strong>, you can't use a direct integral, but you can use the definition.
I'm trying to use the co-ordinates to find the maximum of u, and v in terms of A, or the area. I would like to find the co-ordinates of the maximum that comes out of this function.
You can think of it as </p>
<p>$$x=u$$
$$y=v$$
$$z=A$$.</p>
<p>I tried this (at the very top of this post) on sage, but it gave... </p>
<pre><code> Error in lines 7-9
Traceback (most recent call last):
File "/projects/180e8f3c-9dc5-424f-abcc-5267257c0d31/.sagemathcloud/sage_server.py", line 736, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 3, in <module>
File "/usr/local/sage/sage-6.3.beta6/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 77, in find_root
return f.find_root(a=a,b=b,xtol=xtol,rtol=rtol,maxiter=maxiter,full_output=full_output)
File "expression.pyx", line 9685, in sage.symbolic.expression.Expression.find_root (build/cythonized/sage/symbolic/expression.cpp:42561)
NotImplementedError: root finding currently only implemented in 1 dimension.
19
</code></pre>
http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23740#post-id-23740Is it possible to answer my question now?Mon, 11 Aug 2014 15:30:17 -0500http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23740#post-id-23740Comment by slelievre for <p>I was trying to use integrals, in order to find the average radius. What I did was I took a function, like $$f'(x,y)$$, and then I replaced f'(rcos(theta),rsin(theta)). Then I replaced r with y, and theta with x.
This was divided into the positives above the x-axis, and the negatives below. Using computer programming I got used it all inorder to find the area under the positive curve.</p>
<pre><code>var('n a b x y s u v A')
n = 5100
a = 0
b =2*pi
h =(b-a)/n
s =0
for i in range(n):
x = a + i*h
s = s +find_root((y*cos(x)+u)^2)/4+((y*sin(x)+v)^2)/9-1,1.9,3.1)
A= float((b-a)/n*s)
</code></pre>
<p>Where a is the start of the integral, b is the end of it, h is the intervals for the integral, s is the root to identify the region for integration, the float is the summation,A is the area, and u and v are parameters.. Note: This is an <strong>2-D implicit function</strong>, you can't use a direct integral, but you can use the definition.
I'm trying to use the co-ordinates to find the maximum of u, and v in terms of A, or the area. I would like to find the co-ordinates of the maximum that comes out of this function.
You can think of it as </p>
<p>$$x=u$$
$$y=v$$
$$z=A$$.</p>
<p>I tried this (at the very top of this post) on sage, but it gave... </p>
<pre><code> Error in lines 7-9
Traceback (most recent call last):
File "/projects/180e8f3c-9dc5-424f-abcc-5267257c0d31/.sagemathcloud/sage_server.py", line 736, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 3, in <module>
File "/usr/local/sage/sage-6.3.beta6/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 77, in find_root
return f.find_root(a=a,b=b,xtol=xtol,rtol=rtol,maxiter=maxiter,full_output=full_output)
File "expression.pyx", line 9685, in sage.symbolic.expression.Expression.find_root (build/cythonized/sage/symbolic/expression.cpp:42561)
NotImplementedError: root finding currently only implemented in 1 dimension.
19
</code></pre>
http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23737#post-id-23737@Krishnan Arbuja: To display code properly, indent it by four spaces, and dont use hyphens. Or select lines of code and click the "101 010" button to format these lines as a code block.Sun, 10 Aug 2014 10:06:06 -0500http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23737#post-id-23737Answer by vdelecroix for <p>I was trying to use integrals, in order to find the average radius. What I did was I took a function, like $$f'(x,y)$$, and then I replaced f'(rcos(theta),rsin(theta)). Then I replaced r with y, and theta with x.
This was divided into the positives above the x-axis, and the negatives below. Using computer programming I got used it all inorder to find the area under the positive curve.</p>
<pre><code>var('n a b x y s u v A')
n = 5100
a = 0
b =2*pi
h =(b-a)/n
s =0
for i in range(n):
x = a + i*h
s = s +find_root((y*cos(x)+u)^2)/4+((y*sin(x)+v)^2)/9-1,1.9,3.1)
A= float((b-a)/n*s)
</code></pre>
<p>Where a is the start of the integral, b is the end of it, h is the intervals for the integral, s is the root to identify the region for integration, the float is the summation,A is the area, and u and v are parameters.. Note: This is an <strong>2-D implicit function</strong>, you can't use a direct integral, but you can use the definition.
I'm trying to use the co-ordinates to find the maximum of u, and v in terms of A, or the area. I would like to find the co-ordinates of the maximum that comes out of this function.
You can think of it as </p>
<p>$$x=u$$
$$y=v$$
$$z=A$$.</p>
<p>I tried this (at the very top of this post) on sage, but it gave... </p>
<pre><code> Error in lines 7-9
Traceback (most recent call last):
File "/projects/180e8f3c-9dc5-424f-abcc-5267257c0d31/.sagemathcloud/sage_server.py", line 736, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 3, in <module>
File "/usr/local/sage/sage-6.3.beta6/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 77, in find_root
return f.find_root(a=a,b=b,xtol=xtol,rtol=rtol,maxiter=maxiter,full_output=full_output)
File "expression.pyx", line 9685, in sage.symbolic.expression.Expression.find_root (build/cythonized/sage/symbolic/expression.cpp:42561)
NotImplementedError: root finding currently only implemented in 1 dimension.
19
</code></pre>
http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?answer=23751#post-id-23751First of all, there is a difference between Python variables and symbolic variables. If you write
x = 3
You are initializing a Python variable (whose values is an int). When you do
var('x')
you tell the function **var** to declar a Python variable **x** whose value is an unknown named x (what is called a variable in mathematics). In other words, you should start with
var('y u v')
VincentTue, 12 Aug 2014 09:07:36 -0500http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?answer=23751#post-id-23751Comment by Krishnan Arbuja for <p>First of all, there is a difference between Python variables and symbolic variables. If you write</p>
<pre><code>x = 3
</code></pre>
<p>You are initializing a Python variable (whose values is an int). When you do</p>
<pre><code>var('x')
</code></pre>
<p>you tell the function <strong>var</strong> to declar a Python variable <strong>x</strong> whose value is an unknown named x (what is called a variable in mathematics). In other words, you should start with</p>
<pre><code>var('y u v')
</code></pre>
<p>Vincent</p>
http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23754#post-id-23754Let's say I used the variables u, v, A, from the first code-block in my question, could I take those and make them a 3-d parameter. If there's something wrong with what is on the top how can I get the 3-d parameter I need?Tue, 12 Aug 2014 19:27:21 -0500http://ask.sagemath.org/question/23724/finding-the-maximum-of-a-parameter/?comment=23754#post-id-23754