Ask Your Question
0

Finding the maximum of a parameter

asked 2014-08-08 14:23:25 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

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
edit retag flag offensive close merge delete

Comments

If there's something that doesn't make sense, please say so.

Krishnan Arbuja gravatar imageKrishnan Arbuja ( 2014-08-09 17:22:29 -0600 )edit

@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.

slelievre gravatar imageslelievre ( 2014-08-10 10:06:06 -0600 )edit

Is it possible to answer my question now?

Krishnan Arbuja gravatar imageKrishnan Arbuja ( 2014-08-11 15:30:17 -0600 )edit

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?

vdelecroix gravatar imagevdelecroix ( 2014-08-12 04:10:51 -0600 )edit

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.

Krishnan Arbuja gravatar imageKrishnan Arbuja ( 2014-08-12 08:57:30 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-08-12 09:07:36 -0600

First 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')

Vincent

edit flag offensive delete link more

Comments

Let'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?

Krishnan Arbuja gravatar imageKrishnan Arbuja ( 2014-08-12 19:27:21 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-08-08 14:23:25 -0600

Seen: 241 times

Last updated: Aug 12 '14