473,387 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

slope field solution for my class

3
does anyone know how to create the code for making a slope field? so if i insert a function using gui or something it'll graph the slopes for the function on the graphic screen. here's wat i have so far:

import math
from livewires import *
begin_graphics()
x1=random_between(1,639)
y1=random_between(1,479)
plot(x1,y1)
a=5
while a==5 :
corner= float(random_between(1,3))
if corner == 1:
x2=320
y2=480
elif corner == 2:
x2=0
y2=0
else:
x2=640
y2=0
x1=(x1+x2)/2
y1=(y1+y2)/2
plot(x1,y1)

i know im missing the yend. and probably some other stuff too, but if anyone can help me out finding the missing codes and errors, i'll appreciate it a lot.
Jun 16 '07 #1
4 3089
ttja
3
does anyone know how to create the code for making a slope field? so if i insert a function using gui or something it'll graph the slopes for the function on the graphic screen. here's wat i have so far:
Expand|Select|Wrap|Line Numbers
  1. from livewires import*
  2. import math
  3. begin_graphics()
  4. def slope(x,y):
  5.     return float(x*y)
  6. def xend (x,r,m):
  7.     return [r-r/math.sqrt(1+m**2),x+r/math.sqrt(1+m**2)]
  8. def yend (x,r1,m1,r,m)
  9.         return [r-r/math
  10. r=0.25
  11. y=4
  12. while y>=-4:
  13.     x=-4
  14.     while x<=4:
  15.         m=slope(x,y)
  16.         xnd=xend(x,r,m)
  17.         ynd=yend(x,y,xnd[0],xnd[1],m)
  18.         line(50*xnd[0]+200,50*ynd[0]+200,50*xnd[1]+200,50*ynd[1]+200)
  19.         x=x+1
  20. y=y-1
  21.  
i know im missing the yend. and probably some other stuff too, but if anyone can help me out finding the missing codes and errors, i'll appreciate it a lot.
Jun 16 '07 #2
ttja
3
how would you go about making a slope field using python?
Jun 16 '07 #3
bartonc
6,596 Expert 4TB
For those interested:
Given a system of differential equations,
Expand|Select|Wrap|Line Numbers
  1.     {du}/{dt}=f(t,u,...y,z)
  2.  
  3.          ...
  4.  
  5.     {dy}/{dt}=j(t,u,...y,z)
  6.     {dz}/{dt}=k(t,u,...y,z)
  7.  
the slope field is an array of slope marks in the phase space (the preceding equations imply seven dimensions, but can be any number depending on the number of relevant variables; for example, two in the case of a first-order linear ODE, as seen to the right). Each slope mark is centered at a point (t,u,...y,z) and is parallel to the vector
Expand|Select|Wrap|Line Numbers
  1.     ( 1 \\ f(t,u,...y,z) \\ ... \\ j(t,u,...y,z) \\ k(t,u,...y,z). 
Much prettier here.
Jun 17 '07 #4
bartonc
6,596 Expert 4TB
how would you go about making a slope field using python?
For solving Differential Equations, you'll probably want to check out the scipy extensions.
Also, this IEEE Computer Society article looks interesting.
Jun 17 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: kux | last post by:
Hello everyone, I hope someone is out here who can help me with a simple calculation... I have a sales data base in access with monthly sales history by product. to make future predictions I...
5
by: kux | last post by:
Hello everyone, I hope someone is out here who can help me with a simple calculation... I have a sales data base in access with monthly sales history by product. to make future predictions I...
4
by: kux | last post by:
Hello everyone, I hope someone is out here who can help me with a simple calculation... I have a sales data base in access with monthly sales history by product. to make future predictions I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.