vs140580

490 Reputation

8 Badges

5 years, 16 days

MaplePrimes Activity


These are questions asked by vs140580

If I have a Polynomial of the form say 

c1x^{a1} y^{b1} +c2x^{a2} y^{b2} +... +cnx^{an} y^{bn}

Now I want to form a list say of the form

 

L=[[[a1, b1], c1], [[a2, b2], c2],.... [[an, bn], cn]] 

 

Kind help with a peice of code 

 

How to do multivariate polynomial regression using Maple?

Kind help with the needful

Any sample code with 4 independent vatiables and one dependent variable with less data may be useful.

Kind help. 

#include<iostream>
#include<vector>
#include<cmath>
#define NODE 8

using namespace std;
int graph[NODE][NODE] = {
   {0,1,1,0,0,0,0,0},
   {1,0,1,1,1,0,0,0},
   {1,1,0,1,0,1,0,0},
   {0,1,1,0,0,0,0,0},
   {0,1,0,0,0,1,1,1},
   {0,0,1,0,1,0,1,1},
   {0,0,0,0,1,1,0,0},
   {0,0,0,0,1,1,0,0}
};
int tempGraph[NODE][NODE];
int findStartVert() {
   for(int i = 0; i<NODE; i++) {
      int deg = 0;
      for(int j = 0; j<NODE; j++) {
         if(tempGraph[i][j])
            deg++; //increase degree, when connected edge found
      }
      if(deg % 2 != 0) //when degree of vertices are odd
      return i; //i is node with odd degree
   }
   return 0; //when all vertices have even degree, start from 0
}
int dfs(int prev, int start, bool visited[]){
   int count = 1;
   visited[start] = true;
   for(int u = 0; u<NODE; u++){
      if(prev != u){
         if(!visited[u]){
            if(tempGraph[start][u]){
               count += dfs(start, u, visited);
            }
         }
      }
   }
   return count;
}
bool isBridge(int u, int v) {
   int deg = 0;
   for(int i = 0; i<NODE; i++)
      if(tempGraph[v][i])
   deg++;
   if(deg>1) {
      return false; //the edge is not forming bridge
   }
   return true; //edge forming a bridge
}
int edgeCount() {
   int count = 0;
   for(int i = 0; i<NODE; i++)
      for(int j = i; j<NODE; j++)
         if(tempGraph[i][j])
   count++;
   return count;
}
void fleuryAlgorithm(int start) {
   static int edge = edgeCount();
   static int v_count = NODE;
   for(int v = 0; v<NODE; v++) {
      if(tempGraph[start][v]) {
         bool visited[NODE] = {false};
         if(isBridge(start, v)){
            v_count--;
         }
         int cnt = dfs(start, v, visited);
         if(abs(v_count-cnt) <= 2){
            cout << start << "--" << v << " ";
            if(isBridge(v, start)){
               v_count--;
            }
            tempGraph[start][v] = tempGraph[v][start] = 0; //remove edge from graph
            edge--;
            fleuryAlgorithm(v);
         }
      }
   }
}
int main() {
   for(int i = 0; i<NODE; i++) //copy main graph to tempGraph
   for(int j = 0; j<NODE; j++)
      tempGraph[i][j] = graph[i][j];
   cout << "Euler Path Or Circuit: ";
   fleuryAlgorithm(findStartVert());
}

Kind help 

 

 

Below is python code found in the internet kind help to convert to maple but only thing instead on the input to be string I want it to be a set of integers or array of integers

Kind help

# Python program to print all permutations with repetition

# of characters

  

def toString(List):

    return ''.join(List)

  

# The main function that recursively prints all repeated

# permutations of the given string. It uses data[] to store

# all permutations one by one

def allLexicographicRecur (string, data, last, index):

    length = len(string)

  

    # One by one fix all characters at the given index and

    # recur for the subsequent indexes

    for i in xrange(length):

  

        # Fix the ith character at index and if this is not

        # the last index then recursively call for higher

        # indexes

        data[index] = string[i]

  

        # If this is the last index then print the string

        # stored in data[]

        if index==last:

            print toString(data)

        else:

            allLexicographicRecur(string, data, last, index+1)

  

# This function sorts input string, allocate memory for data

# (needed for allLexicographicRecur()) and calls

# allLexicographicRecur() for printing all permutations

def allLexicographic(string):

    length = len(string)

  

    # Create a temp array that will be used by

    # allLexicographicRecur()

    data = [""] * (length+1)

  

    # Sort the input string so that we get all output strings in

    # lexicographically sorted order

    string = sorted(string)

  

    # Now print all permutaions

    allLexicographicRecur(string, data, length-1, 0)

  

# Driver program to test the above functions

string = "ABC"

print "All permutations with repetition of " + string + " are:"

allLexicographic(string)

restart;
with(GraphTheory);
with(SpecialGraphs);
with(StringTools);
GT := GraphTheory;
G := GT:-SpecialGraphs:-GridGraph(3, 3);
G := Graph(AdjacencyMatrix(G));
H := GT:-SpecialGraphs:-GridGraph(3, 2);
H := Graph(AdjacencyMatrix(H));
GH := CartesianProduct(G, H);
V := Vertices(GH);
P := [];
flag := 0
f := proc(K::string) local L; global P; L := Split(K, ":"); P := [op(P), cat("(", L[1], ",", L[2], ")")]; end proc
if flag = 0 then
    for i to NumberOfVertices(GH) do f(V[i]); end do;
end if
GH := RelabelVertices(GH, P)
DrawGraph(GH, stylesheet = "legacy")
 
I need the graph with those exact relabed vertices type i have done

Now the problem i want my graph a little better in output  i want my vertices a better visible the edges as they more not a issue atleast want the verices a little more visbile and distictive  kind help i apologize for the distubance kind help

the below is output i get i want it more better

First 20 21 22 23 24 Page 22 of 24