C++ :: Program That Will Calculate Minimal Polynomial?

Apr 20, 2013

I need to make a program that will calculate minimal polynomial of the nxn matrix.

View 1 Replies


ADVERTISEMENT

C :: Program Doesn't Properly Compute Simple Polynomial

Feb 7, 2014

The program will ask for the user to enter a value for x, then compute the following polynomial: 3x^5 + 2x^4 - 5x^3 - x^2 + 7x - 6.However, when I double check it with my calculator I get a wrong answer for random values of x. To simplify my problem I'm using only integers.

Code:

#include <stdio.h>
int main(void)
{
int x, polynomial;
}

[code]...

View 5 Replies View Related

C++ :: Minimal Integer Value Rolled-up

Feb 3, 2014

Strange (to me) behavior of the following piece of code:

#include <iostream>
using namespace std;
#define MIN_VAL -2147483648
typedef enum E_TEST {
zero_val = 0,

[Code] ....

So, as you can guess, "It's a problem" is printed. I'd like to understand why. According to MSDN, the limits of a signed int are -(2^32)/2 to (2^32)/2-1, e.g. -2147483648 to 2147483647. Enums are also 4-bytes types. So where is the problem? Why the result isn't "Not a problem!" ?

View 6 Replies View Related

C++ :: Divide Set Of Numbers Into Two Subsets Where Difference Between Sums Of Subset Is Minimal

Feb 28, 2013

The problem is that you have a set of numbers and you need to divide that set into two subsets where the difference between the sums of the subset is minimal.

Example: a set of numbers {1,5,9,3,8}, now the solution is two subsets, one subset with elements {9,3} and the other {8,5,1} the sum of the first one is 13 and the sum of the second is 13 so the difference between the sums is 0. The result shows the difference between the sums.

Another example: a set of numbers where the difference between the subsets cannot be zero, {9 51 308 107 27 91 62 176 28 6}, the minimal difference between the two subsets is 2.

I want to know how the function finds the two subsets, it works great because I've tested it for up to 300 inputs which sum adds up to 100,000.

Code:
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
using namespace std;
int BalancedPartition ( int a[] , int n ) {

[Code] ....

View 3 Replies View Related

C :: Value Of A Polynomial In A Point

Jan 3, 2015

I don't know why this doesn't work. It doesn't return any errors, but it does the polynomial equation wrong. I tried using "^" instead of "pow" and it still does it wrong. I'm getting results like "-897123897" instead of "3". This is the code:

Code:
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main()
[code]....

View 4 Replies View Related

C :: How To Get Derivative Of Polynomial

Nov 12, 2014

How to get the derivative of a polynomial.

Code:
#include "p.h"#include <stdio.h>
#include <stdlib.h>

/*----------------------------------------------*/
/* Sets all coefficients to 0 */
/*--------------------------------------------- */
void initialize(Polynomial p)

[Code] .....

View 2 Replies View Related

C++ :: Compute The Value Of A Polynomial

Mar 27, 2014

This program is supposed to find the value of a polynomial

with x being the number of terms

a[x] being the coefficients

b[x] being the exponents in each term

j being the variable

for example if

x=4

a[x]=1,2,1,5

b[x]=3,2,1,0

j=2

then the polynomial is (j*j*j)+2(j*j)+j+5

the value will be 23

however the value computed is wrong in the code below

#include <stdio.h>
#include <math.h>
int main()

[Code].....

View 4 Replies View Related

C++ :: Identify Polynomial With Two Arrays Of Same Length

Oct 15, 2014

I wanna write a class for polynomials, but there are some bugs in my code. I want to identify a polynomial with two arrays of the same length, one that contains the exponents of the nonzero monomials, and the other that contains the coefficients itself.

for example: (shematically)
3x^2 +5x^100 shoud be identified by array1=(2,100) and array2=(3,5)

the size of that polynomial should be Dim=2.

it should be possible to change the size dynamically.

Code:

#ifndef poly
#define poly
#include<cassert>
class poly {

[Code] ....

PROBLEM1 the destructor isnt working:
virtual ~poly() {delete [] start;delete [] koef;} //destruktor
Error: This declaration has no Storage class or typ specifier.
Error: Expected an identifier.

PROBLEM2 the constructor isnt working:
poly::poly(int x=0)
Error: Expected an identifier
Error: Expected a )
Error: Expected a ;.

I dont know what the computer want to tell me??

View 6 Replies View Related

C++ :: Extracting Polynomial Coefficient From String

Nov 30, 2013

I want to extract polynomial coefficient out of a string recieved by input, for example if i enter 4x^3+2x^4+3 , the resulting out put be : 2 , 4 , 0 , 0 , 3

View 10 Replies View Related

C/C++ :: Simple Polynomial Derivative Calculator

Feb 27, 2014

So I'm trying to make a derivative calculator that can do simple polynomial calculations in a very specific way. If you read the cout line you'll understand rather quickly.

#include<iostream>
#include<cstdlib>
#include<string>
#include<cstring>
using namespace std;
struct variable {
char Variable,degree,constant;

[Code] ....

I get an error at line 33 and 37 saying error: request for member '_cstr' in 'constant', which is of non-class type 'char'
and the same line with 'degree' instead of constant.

View 2 Replies View Related

C/C++ :: Define Polynomial Using Linked List

Mar 18, 2014

I'm try to write a program which define a polynomial using a linked list.

1) I fill every node of the list which list is as long as the value of the max power of the polynomial.
2) I print it out the resulting polynomial.
3) I want to re-scan the poly in search for the polynomials with the same index and sum them each other for having only one element with the same index, for instance, if I enter P(x) = 1 + x + x^2 + 3*x^2 + x^3, I want to obtain:
P(x) = 1 + x + (1 + 3)*x^2 + x^3.

I called this function SeekForSameIndex().

But with this example I have 4x^2 + 4x^2 + x^3, losing the firsts members of the expression, I'm behind this problem for days and I do not understand where's the mistake.

Here my code:

#include <stdio.h>
#include <stdlib.h>
struct SPoly {
int coeff;
unsigned int index;

[Code] ....

View 1 Replies View Related

C :: Implementing And Manipulating Polynomial ADT Using Linked List

Sep 23, 2014

Implementing and manipulating a Polynomial ADT using a linked list.

So far I have:

poly_ADT.h
Code: typedef struct nodeT{
int coef;
int powr;
struct nodeT *next;
} node;

[Code]...

I need to create a function that creates the polynomial using input first.

poly *poly_create (num,...) ;return a new polynomial with num terms terms are listed in order of lowest ordered-term to highest. i.e., to initialize poly 15x^6 + -9x^4 + 3x^2 call poly_create(3, 3,2, -9,4, 15,6 );

Once I do that I need to implement various functions that can manipulate the polynomial itself but I'm having trouble just with creating the polynomial itself, how to do that using a linked list and nodes?

View 3 Replies View Related

C++ :: Polynomial Objects - Deep Copy And Operator Overloading

Feb 22, 2015

In main I instantiate two Polynomial objects -- p1 and p2:

int main() {
const int SIZE = 3;
Polynomial *p1 = new Polynomial(SIZE);
Polynomial *p2 = new Polynomial(SIZE);

//Read data into p1
std::cout << "Initialize Polynomial Coefficients (1)" << std::endl;

[Code] .....

The implementation file for Polynomial is as follows:

Polynomial::~Polynomial() {
delete [] this->m_Ptr;
this->m_Ptr = NULL;
} Polynomial::Polynomial(int size) {

[Code] .....

What works: Adding two pointers. The output is correctly produced.

The problem in particular occurs in main when p1 and p2 are attempted to be multiplied. The code attempts to release the memory upon multiplication but I receive a run-time error.

The output for the difference of the two polynomial objects is incorrect. It is displaying addresses.

View 3 Replies View Related

C++ :: Program To Calculate BMI

Oct 7, 2013

I'm trying to successfully run a program that calculates your BMI but, although it runs, it is not giving the the correct math. Instead, it gives me the number i've submitted as my weight as an answer. I'm using Visual Studio 2008 and the formula: weight / (height/100)*2

Here is my code

#include <iostream>
#include <cmath>
using namespace std;
int main() {
int weight;
int height;
double BMI;

[Code] ....

View 2 Replies View Related

C++ :: Polynomial Coefficients Are Memorialized In Field Of Real Double Precision Numbers

Mar 19, 2013

I am starting to learn C++.Designing class CPolynom to work with polynomials. The polynomial coefficients are memorialized in the field of real double precision numbers. Implement the following functions:

-Constructor, which defines the order of the polynomial CPolynom(int order)
-method to add the appropriate grade Coef(int exp, duble coef)
-method of addition, subtraction, multiplication and division two polynomials
-method to add a field coefficient
-method for nala

View 1 Replies View Related

C++ :: Program To Calculate Fractions?

Oct 24, 2013

I need to write a program that can calculate fractions.

View 2 Replies View Related

C++ :: Program That Calculate Discounts

Nov 8, 2013

So my midterm exam for programming is done. My program didn't run. Tried rewriting it once I got home. I am still getting an error that the program could not be run. Also, we weren't allowed to use the internet. So I didn't know how to calculate for the discounted rate.

I am using Microsoft Visual Studio 2010.

Given problem:

ABC Hotel offers 5-10% discounts depending on how much money has the user spent. If item purchase is lesser than 1000php (1USD is 43.19PHP) 5% discount is availed. Greater than 1000php then 10% discount is availed. Total price and discounted price should be displayed.

#include<iostream>
using namespace std;
main() {
float a,b,c,d,e,f,g,h,i,j,total,discounted_price;
cout<<"Please input price of first 1st item: ";

[Code] .....

View 1 Replies View Related

C :: Calculate Offset Of Simple Program

Sep 28, 2013

I would to learn how could i calculate the offset of simple c program?

Lets say that I have that simple program:

Code:
#include <stdio.h>
int main() {
int x=1;
printf("x = %d", x);
return 0;
}

View 9 Replies View Related

C :: How To Write A Program That Will Calculate Stress

Feb 7, 2013

I recently signed up for ES201 class and am confused with how to compile a program in the C language that will convert ACT scores to SAT scores.

View 5 Replies View Related

C :: Program That Will Calculate Strain Of Object

Feb 7, 2013

The equation for strain is:

delta(x)/x_0
delta(x) is the change in length of the rod(final length - initial length) x_0 is the original length of the rod

I'm trying to figure out how to write a program that will calculate the strain of an object, given its initial length and final length.

View 2 Replies View Related

C :: Program To Calculate Difference In Time?

Nov 6, 2014

i writing a code which will calculate the difference between time_in and time out. Can i use a 2 dimensional array for example

int time_in[hours][minutes]
int time_out[hours[minutes]

View 3 Replies View Related

C++ :: Program To Calculate How Many X Or / And Y From Specific Range

Nov 7, 2013

X and Y are numbers

For example: how many 2 or/and 5 are inside range of 0 to 30.
for or: there are 8 (2,5,12,15,22,25)
for and: there is only one (25).

View 1 Replies View Related

C++ :: Program To Calculate Adjacent Triplets?

Apr 10, 2014

I have this program that calculates adjacent pairs. My question is how can I modify it to calculate adjacent triplets?

//Include statements.

#include <cstdlib>
#include <iostream>
#include <math.h>

//Standard namespace.
using namespace std;

void input (int array[20]); //Used when user inputs the numbers.
void calculate(int array[20], int *pairs); //Used to calculate the matches.
void output(int *pairs); //Used to output the number of pairs.

[Code] ....

View 11 Replies View Related

C++ :: Writing A Program To Calculate Grades

Apr 22, 2014

Writing a program to calculate grades... My algorithm is long, so I only posted the part that gives me trouble. When classes== 1,2,4, or 5, the program runs fine. but it terminates when classes == 3.

if (classes==3) {
do {
cout<<"Enter the Letter grade for 1st class. (USE CAPS)"<<endl;
cin>>grade1;

[Code].....

View 3 Replies View Related

C/C++ :: Program To Calculate Inverse Of Matrix

Apr 3, 2014

I write this code for Inverse of matrix in C language . But there is error in determinant function that say "can not convert 'float' to 'float(*)[20]' for argument '1' to 'float determinant(float(*)[20])' " ....

/* a program to calculate inverse of matrix (n*n)*/
//actually one of the way to calculate inverse of matrix is : A^(-1) = 1/|A| * C(t)
that A is matrix and c(t) is taranahade A

#include <stdio.h>;
#include <conio.h>;
#include <string.h>;
#include <stdlib.h>;
const int max=20;
int i , j , n , k , size=0 , row , column ;
float num , det=0 , inverse_matrix[max][max] , matrix[max][max] , new_mat[max][max] , m_minor[max][max] , m_Transpose[max][max];

[Code] .....

View 14 Replies View Related

C++ :: How To Write A Program To Calculate Pi To N Number Of Places

Aug 13, 2014

I assume floating point numbers in C++ have a default maximum of 5 decimal places. You can use setprecision() but is this limitless?

So how would find say write a program to calculate Pi to N number of places?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved