473,396 Members | 1,990 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,396 software developers and data experts.

Ploting or drawing a mathcurve

Hi i'm new in this group. I need some help with php. I need to draw
any mathematical function i get through a form?

Please help me
Aug 26 '08 #1
7 2128
serave wrote:
Hi i'm new in this group. I need some help with php. I need to draw
any mathematical function i get through a form?
You may be able to do this using either IMagick or GD. These are your
php options. You may find this easier to do client side with either
flash or javascript.

Jeff
Please help me
Aug 26 '08 #2
On Aug 25, 9:18*pm, serave <ramirez.sebast...@gmail.comwrote:
Hi i'm new in this group. I need some help with php. I need to draw
any mathematical function i get through a form?

Do you mean you need to draw a curve from the results of solving an
exact equation or do you mean you need to fit the best curve to a set
of experimental measured points that always have some error. In the
second case, a good bit of statistical calculation often is required.
If you are a glutton for punishment, you can do this with the Math
functions of Javascript or php. You would be much better off using a
language such as c++ or even old Fortran which are better designed for
math and science calculations and curve fitting. There are all sorts
of math programs for curve fitting, plotting, solving equations, etc
and these are what most people now use when working with math. You
will find such programs advertised in many scientific and math
journals. Unfortunately many of these programs are rather expensive
for an individual, but they very soon pay for themselves in time saved
for a company that needs many such math and curve fitting programs and
has to hire many highly trained people with advanced degrees.

I have 2 examples of drawing curves from solution of math equations
at:
http://www.cwdjr.net/math/bessel_function2.html

http://www.cwdjr.net/geometricDraw/curve_write.html

This was done using the math functions of Javascript, but the Math
functions of php could have been used. These pages are very old, and I
likely would use different code if doing them today. Now if you wanted
to input experimental points and curve fit to the data, the
calculations become much more complicated because of the statistical
calculations needed to give the curve that best fits the experimental
data. You would input the experimental data into arrays most likely.

Aug 26 '08 #3
On 26 Aug, 07:53, cwdjrxyz <spamtr...@cwdjr.infowrote:
On Aug 25, 9:18 pm, serave <ramirez.sebast...@gmail.comwrote:
Hi i'm new in this group. I need some help with php. I need to draw
any mathematical function i get through a form?

Do you mean you need to draw a curve from the results of solving an
exact equation or do you mean you need to fit the best curve to a set
of experimental measured points that always have some error. In the
second case, a good bit of statistical calculation often is required.
<snip>

But you might want to look at Google charts or JPgraph for simple
solutions for rendering chart plots (but you'll need to generate
numerical data yourself).

C.
Aug 26 '08 #4
On 26 ago, 01:53, cwdjrxyz <spamtr...@cwdjr.infowrote:
On Aug 25, 9:18*pm, serave <ramirez.sebast...@gmail.comwrote:
Hi i'm new in this group. I need some help with php. I need to draw
any mathematical function i get through a form?

Do you mean you need to draw a curve from the results of solving an
exact equation or do you mean you need to fit the best curve to a set
of experimental measured points that always have some error. In the
second case, a good bit of statistical calculation often is required.
If you are a glutton for punishment, you can do this with the Math
functions of Javascript or php. You would be much better off using a
language such as c++ or even old Fortran which are better designed for
math and science calculations and curve fitting. There are all sorts
of math programs for curve fitting, plotting, solving equations, etc
and these are what most people now use when working with math. You
will find such programs advertised in many scientific and math
journals. Unfortunately many of these programs are rather expensive
for an individual, but they very soon pay for themselves in time saved
for a company that needs many such math and curve fitting programs and
has to hire many highly trained people with advanced degrees.

I have 2 examples of drawing curves from solution of math equations
at:http://www.cwdjr.net/math/bessel_function2.html

http://www.cwdjr.net/geometricDraw/curve_write.html

This was done using the math functions of Javascript, but the Math
functions of php could have been used. These pages are very old, and I
likely would use different code if doing them today. Now if you wanted
to input experimental points and curve fit to the data, the
calculations become much more complicated because of the statistical
calculations needed to give the curve that best fits the experimental
data. You would input the experimental data into arrays most likely.
No i just need to draw the function, no need to draw the best
aproximation. Is just drawing the curve based on a mathematical
equation like y=e^(x-5)+sin(5x^3)-45x^(2/3) or something like that
Aug 26 '08 #5
Message-ID:
<f8**********************************@v26g2000prm. googlegroups.comfrom
serave contained the following:
>No i just need to draw the function, no need to draw the best
aproximation. Is just drawing the curve based on a mathematical
equation like y=e^(x-5)+sin(5x^3)-45x^(2/3) or something like that
Presumably you'd have to specify a range? If so a simple for loop would
be all you'd need to generate the input array for something like
jpgraph.

--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk
Aug 26 '08 #6
On Aug 26, 10:55*am, serave <ramirez.sebast...@gmail.comwrote:
On 26 ago, 01:53, cwdjrxyz <spamtr...@cwdjr.infowrote:
On Aug 25, 9:18*pm, serave <ramirez.sebast...@gmail.comwrote:
Hi i'm new in this group. I need some help with php. I need to draw
any mathematical function i get through a form?
Do you mean you need to draw a curve from the results of solving an
exact equation or do you mean you need to fit the best curve to a set
of experimental measured points that always have some error. In the
second case, a good bit of statistical calculation often is required.
If you are a glutton for punishment, you can do this with the Math
functions of Javascript or php. You would be much better off using a
language such as c++ or even old Fortran which are better designed for
math and science calculations and curve fitting. There are all sorts
of math programs for curve fitting, plotting, solving equations, etc
and these are what most people now use when working with math. You
will find such programs advertised in many scientific and math
journals. Unfortunately many of these programs are rather expensive
for an individual, but they very soon pay for themselves in time saved
for a company that needs many such math and curve fitting programs and
has to hire many highly trained people with advanced degrees.
I have 2 examples of drawing curves from solution of math equations
at:http://www.cwdjr.net/math/bessel_function2.html
http://www.cwdjr.net/geometricDraw/curve_write.html
This was done using the math functions of Javascript, but the Math
functions of php could have been used. These pages are very old, and I
likely would use different code if doing them today. Now if you wanted
to input experimental points and curve fit to the data, the
calculations become much more complicated because of the statistical
calculations needed to give the curve that best fits the experimental
data. You would input the experimental data into arrays most likely.

No i just need to draw the function, no need to draw the best
aproximation. Is just drawing the curve based on a mathematical
equation like y=e^(x-5)+sin(5x^3)-45x^(2/3) or something like that
Then you solve the equation for say y at closely spaced points of x
using the Math functions of Javascript or php at closely spaced points
of the x coordinate and display each point calculated using a
document.write in Javascript. The structure of code is much the same
in php, but the details are rather different.

In the first example I gave you, the Bessel function of the type given
has no exact solution involving simple math functions. It must be
solved in terms of infinite series, and this is quite tricky and
requires a very good understanding of math that usually is taught at
the college level in courses such as advanced calculus.

The second example I gave you with several curves is much more simple,
as the equation can be solved in terms of known simple functions.
Considering the calculation of the 2 circles, the equations are solved
using JavaScript math and points are written using document.write.
That part of the code is:

var c1=.02,c3=.01 // angle
increment
var px1=270 // center x
var py1=180 // center y
var r1=165,r2=175,r3=160,r4=185 // radius
var ns1=325,ns3=650 // number of steps

var z=0,y,x ;
for (i=0;i < ns1;++i) {
x = (px1 + r1*Math.cos(z)); y= (py1 + r1*Math.sin(z));
document.write('<div style=\"position:absolute; left:'+x+'px; top:'+y
+'px; height:4px; width:4px; background-color: #ff0000; z-index:1;
color:#ff0001; font-size:1px\">'+sym+'<\/div>');
z = z + c1;
}

var z2=0,y2,x2 ;
for (i=0;i < ns1;++i) {
x2 = (px1 + r2*Math.cos(z2)); y2= (py1 + r2*Math.sin(z2));
document.write('<div style=\"position:absolute; left:'+x2+'px;
top:'+y2+'px; height:4px; width:4px; background-color: #00ff00; z-
index:1; color:#00ff01; font-size:1px\">'+sym+'<\/div>');
z2 = z2 + c1;
}

It turns out that the equations for the 2 circles are best solved in
terms of polar coordinates, and you loop over many points. You must
keep in mind that the origin of the display is taken at the upper left
corner of the monitor. The positive x direction points to the right as
usual, but the positive y direction points down in contrast to
pointing upward as usually used in math texts. This is just how
JavaScript math functions were set up - don't blame me for that :-).

Thus the key is a fair general knowledge of JavaScript or php, and a
good knowledge of their math functions as well as a knowledge of how
to solve mathematical equations in which you are interested. Every
equation is somewhat different. Thus it is easy to appreciate why
special programs are sold for solving math equations and plotting
results.For calculations that are very time consuming, fewer exact
points often are calculated and some type of extrapolation is used to
calculate points between the exact points.

Aug 26 '08 #7
On Aug 26, 12:46*pm, cwdjrxyz <spamtr...@cwdjr.infowrote:
On Aug 26, 10:55*am, serave <ramirez.sebast...@gmail.comwrote:
On 26 ago, 01:53, cwdjrxyz <spamtr...@cwdjr.infowrote:
On Aug 25, 9:18*pm, serave <ramirez.sebast...@gmail.comwrote:
Hi i'm new in this group. I need some help with php. I need to draw
any mathematical function i get through a form?
Do you mean you need to draw a curve from the results of solving an
exact equation or do you mean you need to fit the best curve to a set
of experimental measured points that always have some error. In the
second case, a good bit of statistical calculation often is required.
If you are a glutton for punishment, you can do this with the Math
functions of Javascript or php. You would be much better off using a
language such as c++ or even old Fortran which are better designed for
math and science calculations and curve fitting. There are all sorts
of math programs for curve fitting, plotting, solving equations, etc
and these are what most people now use when working with math. You
will find such programs advertised in many scientific and math
journals. Unfortunately many of these programs are rather expensive
for an individual, but they very soon pay for themselves in time saved
for a company that needs many such math and curve fitting programs and
has to hire many highly trained people with advanced degrees.
I have 2 examples of drawing curves from solution of math equations
at:http://www.cwdjr.net/math/bessel_function2.html
>http://www.cwdjr.net/geometricDraw/curve_write.html
This was done using the math functions of Javascript, but the Math
functions of php could have been used. These pages are very old, and I
likely would use different code if doing them today. Now if you wanted
to input experimental points and curve fit to the data, the
calculations become much more complicated because of the statistical
calculations needed to give the curve that best fits the experimental
data. You would input the experimental data into arrays most likely.
No i just need to draw the function, no need to draw the best
aproximation. Is just drawing the curve based on a mathematical
equation like y=e^(x-5)+sin(5x^3)-45x^(2/3) or something like that

Then you solve the equation for say y at closely spaced points of x
using the Math functions of Javascript or php at closely spaced points
of the x coordinate and display each point calculated using a
document.write in Javascript. The structure of code is much the same
in php, but the details are rather different.

In the first example I gave you, the Bessel function of the type given
has no exact solution involving simple math functions. It must be
solved in terms of infinite series, and this is quite tricky and
requires a very good understanding of math that usually is taught at
the college level in courses such as advanced calculus.

The second example I gave you with several curves is much more simple,
as the equation can be solved in terms of known simple functions.
Considering the calculation of the 2 circles, the equations are solved
using JavaScript math and points are written using document.write.
That part of the code is:

*var c1=.02,c3=.01 * * * * * * * * * * * * * * * * * * * *// angle
increment
* * * * var px1=270 * * * * * * * * * * ** * * * * * *// *center x
* * * * var py1=180 * * * * * * * * * * ** * * * * * *// *center y
* * * * var r1=165,r2=175,r3=160,r4=185 * * * * * * *// *radius
* * * * var ns1=325,ns3=650 * * * * * * * * * * // number of steps

var z=0,y,x ;
*for *(i=0;i < ns1;++i) {
x = (px1 + r1*Math.cos(z)); y= (py1 + r1*Math.sin(z));
document.write('<div style=\"position:absolute; left:'+x+'px; top:'+y
+'px; height:4px; width:4px; background-color: #ff0000; z-index:1;
color:#ff0001; font-size:1px\">'+sym+'<\/div>');
z = z + c1;
* * * * * }

var z2=0,y2,x2 ;
*for *(i=0;i < ns1;++i) {
x2 = (px1 + r2*Math.cos(z2)); y2= (py1 + r2*Math.sin(z2));
document.write('<div style=\"position:absolute; left:'+x2+'px;
top:'+y2+'px; height:4px; width:4px; background-color: #00ff00; z-
index:1; color:#00ff01; font-size:1px\">'+sym+'<\/div>');
z2 = z2 + c1;
* * * * * }

It turns out that the equations for the 2 circles are best solved in
terms of polar coordinates, and you loop over many points. You must
keep in mind that the origin of the display is taken at the upper left
corner of the monitor. The positive x direction points to the right as
usual, but the positive y direction points down in contrast to
pointing upward as usually used in math texts. This is just how
JavaScript math functions were set up - don't blame me for that :-).

Thus the key is a fair general knowledge of JavaScript or php, and a
good knowledge of their math functions as well as a knowledge of how
to solve mathematical equations in which you are interested. Every
equation is somewhat different. Thus it is easy to appreciate why
special programs are sold for solving math equations and plotting
results.For calculations that are very time consuming, fewer exact
points often are calculated and some type of extrapolation is used to
calculate points between the exact points.
Ther is a free program for plotting data available from the US NIST
(know as the Bureau of Standards in the past). It will not do as much
as the newer commercial programs, but you can't argue with the price.
The name of the prograsm is dataplot. It is available in several
versions including C and a PC version which is likely the one you
would want. Download sometimes is slow in the daytime in the US, so
you may want to try in the evening.

Go to ftp://ftp.nist.gov/pub/dataplot/ . then select "pc". On the pc
screen select ReadMe.Doc and it will tell you where to go from there.
There are a few files to download and it will take some time to learn
how to do everything it can do. I have not used DataPlot in recent
years, but it worked fairly well in the past.
Aug 26 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tomi Holger Engdahl | last post by:
I am looking for a solution to add on-line drawing tool to a phpBB discussion board. The idea would be that the users can draw their own simple drawings with the tool and attach them easily as...
2
by: Champika Nirosh | last post by:
Hi, I want to create drawing board application that can draw Line, rectagle, circle and free hand drawing. Each drawing need to be transparent, moveable (draggable), have bring to front and...
1
by: Hadar | last post by:
Hi, I'm getting "object is currently in use elsewhere" when I use System.Drawing.Graphics.MesureString. This is what I do: My controls use a utility class the helps it to mesure strings. To...
7
by: Marc Pelletier | last post by:
Hello all, I have a class which includes a method to create a chart. I want to be able to call this method from asp.net code as well as windows application code, so I have sketched it out as...
2
by: active | last post by:
I find Bitmap.Save works for WMF files but Bitmap.FromFile does not. If I use FromFile on a WMF file that came with VS I get an exception. If I use it on a WMF file created with Bitmap.Save I...
3
by: Chris Saunders | last post by:
I am fairly new to .Net and C# but am familiar with the Win32 API. I wish to set the pixels of the client area of a window one at a time with a specific color. I have so far discovered that...
5
by: Jerry J | last post by:
I want to use the System.Drawing.Image class. According to the help file, this is an abstract base class. Because it is supposedly abstract, I created another class that inherits from it. However,...
2
by: ThatsIT.net.au | last post by:
I have this code that writes a pie chart in a asp.net page, but I want to use it in a server control. When I try I get a error on the last line "Response.OutputStream" Obviously there is no...
7
by: raylopez99 | last post by:
I have a logical drawing space much bigger than the viewport (the screen) and I'd like to center the viewport (the screen) to be at the center of the logical drawing space. After following the...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.