473,563 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Symbolic computation : the derivative of a quotient.

Symbolic computation : the derivative of a quotient.

Hello,

This time I try to simulate the derivative of a quotient.
The same function use the quotient rule if it is a quotient (f/g)
and the reciprocal rule if it is not a quotient. (1/g)

Into a text file,
I have an equation of this type.
I have created these equations
with the previous functions.

Examples:

eq01.txt:

@[ a*cos(2*x+3*x^2 )*cos(2*n+3*a^2 ) : b*cos(2*x+3*a^2 ) ]

eq02.txt: (try this first:Quotient rule )

@[ a*f(x) : b*g(x) ]

eq03.txt: (try this first:Reciproca l rule )

@[ a*f(b) : b*g(x) ]
The functions
=============

is_a_quotient() ;

copy into "eq_n" the numerator.
copy into "eq_d" the denominator.
D_quotient();

Call the previous function,
and do the work.

See below my work.

Have I do some mistakes.
The result seem correct.

Thank.

/* ------------------------------------ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* ------------------------------------ */
#define CHAR_N 1000
#define CHAR_A 2
/* ------------------------------------ */
int is_a_quotient(c har *filename,char *eq_n,char *eq_d,char *x);
void D_quotient( char *filename,char *eq,char *x);
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
char filename[FILENAME_MAX];
char eq [CHAR_N];
char x [CHAR_A];

strcpy(x,"x");
strcpy(filename ,"eq01.txt") ;

D_quotient(file name,eq,x);

printf("\n\n%s" ,eq);

getchar();
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
int is_a_quotient(
char *filename,
char *eq_n,
char *eq_d,
char *x
)
{
/* ------------------------------------ */
FILE *f;
/* ------------------------------------ */
char c[CHAR_A];
/* ------------------------------------ */
int c_int;
int d; /* denominator True:1 Fault:0*/
int y; /* x True:1 Fault:0*/
int q; /* quotient True:1 Fault:0*/
/* ------------------------------------ */
strcpy( c,"");
strcpy(eq_n,"") ;/* numerator */
strcpy(eq_d,"") ;/* denominator */
/* ------------------------------------ */
q = 0;
y = 0;
d = 0;
/* ------------------------------------ */

f = fopen(filename, "r");

if (f==NULL) printf("File doesn't exist\n");
else

while( (c_int=getc(f)) !=EOF )
{
c[0]=c_int;

if( !(strcmp(c,"\n" ))||
!(strcmp(c," " ))||
!(strcmp(c,"@" ))||
!(strcmp(c,"[" ))||
!(strcmp(c,"]" )) )

strcpy(c,"");

else{
if( !(strcmp(c,x )) ) y=1;

if( !(strcmp(c,":") ) )
{
d=1;
if(y)q=1;/* it is a quotient */
}
else /* no : */
if(d==0) strcat(eq_n,c); /* numerator */
else strcat(eq_d,c); /* denominator */
}
}

if(f!=NULL)fclo se(f);

return (q);
}

/* ------------------------------------ */
void D_quotient(
char *filename,
char *eq,
char *x
)
{
/* ------------------------------------ */
char eq_n [CHAR_N];
char eq_d [CHAR_N];
/* ------------------------------------ */

strcpy(eq,"");

if(is_a_quotien t(filename,eq_n ,eq_d,x))
{
strcat(eq," @[");
strcat(eq,eq_n) ;
strcat(eq,"] [");
strcat(eq,eq_d) ;
strcat(eq,"]\n-\n [");
strcat(eq,eq_n) ;
strcat(eq,"] @[");
strcat(eq,eq_d) ;
strcat(eq,"]\n\n:\n\n [");
strcat(eq,eq_d) ;
strcat(eq,"]^2\n");
}
else
{
strcat(eq,"- [");
strcat(eq,eq_n) ;
strcat(eq,"] @[");
strcat(eq,eq_d) ;
strcat(eq,"]\n\n:\n\n [");
strcat(eq,eq_d) ;
strcat(eq,"]^2\n");
}
}

Mar 10 '07 #1
0 1490

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

Similar topics

12
2773
by: daniel.wolff | last post by:
I am looking for a quick C program that takes n+1 pairs of values (integers) (a_i, f(a_i)), i=0,...,n, generates the coefficients \alpha_i, i=0,...,n of the polynomial of degree n that fits these points and then outputs the polynomial with indeterminant in the form \sum_i=0^n\alpha_i X^i, where X is just some indeterminant. Any hints? ...
1
6383
by: solarin | last post by:
Hi, I've developed a program under VS 6.0. I can compile it and run it, but when I try to debbug , all my breakpoints are dissabled and I can see the following messages: Loaded 'D:\prj\simulador HMS\Enviar Datos al sim\CMS\Debug\CMS.exe', no matching symbolic information found. Loaded 'ntdll.dll', no matching symbolic information found....
3
1880
by: xhunga | last post by:
Hello, This time I try to simulate the derivative of a product. Into a text file, I have an equation of this type. I have created these equations with the previous functions. Examples:
0
1563
by: xhunga | last post by:
* Symbolic computation with the language c : The Derivative step by step. (Windows,Linux) You can find some examples into the file a_exampl.txt @ @
1
1225
by: xhunga | last post by:
Hello, I have try symbolic algebra computation with list, in c language. (It is only for fun) This is the result of the example : c13.c /* ---------------------------------------- */ A_n :
4
1670
by: Jon Harrop | last post by:
Can anyone improve this C++ program so that it can compete with the other languages: http://www.codecodex.com/wiki/index.php?title=Derivative -- Dr Jon D Harrop, Flying Frog Consultancy The F#.NET Journal http://www.ffconsultancy.com/products/fsharp_journal/?u6
1
8343
by: amygrant1701 | last post by:
Hi, I've done this before so I don't see what I could doing wrong here. I'm running mysql 5x on freebsd. I'm using the default data directory of "/var/db/mysql" In there I have several dozen mysql datasbases that are functioning perfectly. I am trying to add a database which will be stored on a different drive, therefore the entry in...
1
4621
by: sora | last post by:
Hi, I've developed a MFC program under VS 6.0. My debugger *was* working fine and I've used it often for my project. Then, one day, the errors below appear and they prevent me from using the debugger. I know that I get these warnings because the OS symbols arn't installed (a few of them loaded fine). As far as I can remember, I didn't touch...
1
2837
by: BigBaz | last post by:
If we have a graph G=(N,E), where N is the set of nodes, and E is the set of edges. If we partition N into k parts (partition 1, 2,3...k). And this partition is given by an array, with the node number as the index. For example, C=a means node x is belongs to partition a. We define the "Quotient graph" with respect to the above partition as:...
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6250
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.