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
If there's something that doesn't make sense, please say so.
@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.
Is it possible to answer my question now?
What 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?
I 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.