nmacsai

260 Reputation

9 Badges

4 years, 64 days

MaplePrimes Activity


These are questions asked by nmacsai

I am using GenerateMatrix to construct a matrix out of a set of 6 equations with 6 variables.  The output of Generate Matrix is not sorted correctly.  Where am I going wrong? Is this a bug?

restart

NULL``

with(LinearAlgebra)

NULL

NULL

The command GenerateMatrix is not sorting my set of equations properly.

NULL

NULL

Define a set of 6 equations.

equation_set := [5964.000000-770.0000000*T__1+750.0000000*T__2 = 0, 20*T[1]-770.0000000*T[2]+750.0000000*T[3]+100.0000000 = 0, 20*T[2]-770.0000000*T[3]+750.0000000*T[4]+100.0000000 = 0, 20*T[3]-770.0000000*T[4]+750.0000000*T[5]+100.0000000 = 0, 20*T[4]-770.0000000*T[5]+750.0000000*T[6]+100.0000000 = 0, 5900.787944-770.0000000*T[6]+750.0000000*T[5] = 0]

[5964.000000-770.0000000*T__1+750.0000000*T__2 = 0, 20*T[1]-770.0000000*T[2]+750.0000000*T[3]+100.0000000 = 0, 20*T[2]-770.0000000*T[3]+750.0000000*T[4]+100.0000000 = 0, 20*T[3]-770.0000000*T[4]+750.0000000*T[5]+100.0000000 = 0, 20*T[4]-770.0000000*T[5]+750.0000000*T[6]+100.0000000 = 0, 5900.787944-770.0000000*T[6]+750.0000000*T[5] = 0]

(1)

NULL

NULL

NULL

This is what each one looks like individually.

equation_set[1]

5964.000000-770.0000000*T__1+750.0000000*T__2 = 0

(2)

equation_set[2]

20*T[1]-770.0000000*T[2]+750.0000000*T[3]+100.0000000 = 0

(3)

equation_set[3]

20*T[2]-770.0000000*T[3]+750.0000000*T[4]+100.0000000 = 0

(4)

equation_set[4]

20*T[3]-770.0000000*T[4]+750.0000000*T[5]+100.0000000 = 0

(5)

equation_set[5]

20*T[4]-770.0000000*T[5]+750.0000000*T[6]+100.0000000 = 0

(6)

equation_set[6]

5900.787944-770.0000000*T[6]+750.0000000*T[5] = 0

(7)

NULL

The variables used in the above set of equations.

variables_set := [T[1], T[2], T[3], T[4], T[5], T[6]]

[T[1], T[2], T[3], T[4], T[5], T[6]]

(8)

variables_set[1]

T[1]

(9)

A, b := GenerateMatrix(equation_set, variables_set)

Matrix(%id = 36893490238808803916), Vector[column](%id = 36893490238808803796)

(10)

This output seems wrong because a row of zeros appears in A``.  The first entry of the column vector contains the full equation. Thus, it seems GenerateMatrix didn't sort the set of equation properly.  I tried re-writing the  offending equation  as 5964.000000-770.0000000*T__1+750.0000000*T__2 = 0,but maple just changes it back on evaluation.NULL


 I think the output should look like:


A, b := Matrix(6, 6, {(1, 1) = -770.0000000, (1, 2) = 750.0000000, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (2, 1) = 20, (2, 2) = -770.0000000, (2, 3) = 750.0000000, (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (3, 1) = 0, (3, 2) = 20, (3, 3) = -770.0000000, (3, 4) = 750.0000000, (3, 5) = 0, (3, 6) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 20, (4, 4) = -770.0000000, (4, 5) = 750.0000000, (4, 6) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 20, (5, 5) = -770.0000000, (5, 6) = 750.0000000, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = 750.0000000, (6, 6) = -770.0000000}), Vector(6, {(1) = -5964.000000, (2) = -100.0000000, (3) = -100.0000000, (4) = -100.0000000, (5) = -100.0000000, (6) = -5900.787944})

NULL

I rename the matrix and column vector and use LinearSolve to find a solution for T.

AA := Matrix(6, 6, {(1, 1) = -770.0000000, (1, 2) = 750.0000000, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (2, 1) = 20, (2, 2) = -770.0000000, (2, 3) = 750.0000000, (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (3, 1) = 0, (3, 2) = 20, (3, 3) = -770.0000000, (3, 4) = 750.0000000, (3, 5) = 0, (3, 6) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 20, (4, 4) = -770.0000000, (4, 5) = 750.0000000, (4, 6) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 20, (5, 5) = -770.0000000, (5, 6) = 750.0000000, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = 750.0000000, (6, 6) = -770.0000000})

Matrix(%id = 36893490238866723772)

(11)

``

bb := Vector(6, {(1) = -5964.000000, (2) = -100.0000000, (3) = -100.0000000, (4) = -100.0000000, (5) = -100.0000000, (6) = -5900.787944})

Vector[column](%id = 36893490238885708252)

(12)

NULL

NULL

T := LinearSolve(AA, bb)

Vector[column](%id = 36893490238857651132)

(13)

NULL

Download GenerateMatrix_Improper_Sorting.mw

How do I use ErrorPlots to put error bars on my scatter plot of data, AT THE LOCATION OF THE SCATTER PLOT DATA POINT? Below I write an example demonstrating how I plot the data and error bars using ErrorPlots.  When I use display to combine plots you clearly see that the errorbars are not on the scatter plot data points.  How do I give ErrorPlots, the x-y locations of the data points, so it knows to print the error bars on the location of the data points?  Is there a better approach to putting horizontal and vertical error bars onto scatter plot data?

restart

NULL

Is there a direct way to have the int command return the anti-derivative plus an arbitrary constant of integration? I am imagining the process to look like:
int(f(x), x) = F(x)+c1

NULL

Consider the integral of f(x)=x.f := x

x

(1)

Int(f, x); int(f, x)

(1/2)*x^2

(2)

Notice that the output has no intregration constant or the constant has been assigned the value of zero and is not displayed in the output.

Maple 2021 Help states, "Indefinite integration  is performed if the second argument x is a name. Note that no constant of integration appears in the result. Definite integration is performed if the second argument is of the form x=a..b where a and b are the endpoints of the interval of integration."

I'd like Maple to output the anti-derivative plus an arbitrary constant in the same way dsolve outputs a general solution of an ode with arbitrary constants. My first work around was to just use dsolve.  

There is a sense in which performing an integration is equivalent to solving an ode:
diff(h(x), x) = g(x); int(diff(h(x), x), x) = int(g(x), x); h(x) = int(g(x), x)+c1; h(x) = G(x)+c2
    

Is there a way to force int to output arbitrary constants of integration or should I stick to just using dsolve if I want that effect?

Download constants_of_integration_int_output.mw

How do I make a new dataframe based on the criteria that a particular row is included when a particular element in that row is equal to a specific string, say, "Ontario"?

I downloaded the publicly availble covid dataset from the Gov. of Canada website.  I want to look at data pertaining to Ontario only. Each data entry corresponds to a row of data where the second column represents the province or territory.  My goal is to create a new dataframe of rows where the second column entry is equal to the string "Ontario".

I have attached my maplesheet.  I can't upload the data but it can be downloaded here: https://open.canada.ca/data/en/dataset/261c32ab-4cfd-4f81-9dea-7b64065690dc.

In the image below, see how the second column is a mix of different strings.  I want a new dataframe where the second column reads only "Ontario".  I have included my naive attempt to select data with 'prname'="Ontario".

sort_data_and_make_new_df_Covid_Analysis_Sheet_1.mw

restart;
with(Physics);
with(Physics[Vectors]);
with(geom3d);
with(LinearAlgebra);
with(ColorTools);
with(plots);

When I define a vector with Physics[Vectors] as:

a1 := a/2*(0*_i + _j + _k)

Maple returns:

a1:= a/2*(_j + _k)

Which is fine but if you try to take the cross product it won't work because the command expects a vector in R3 but interprets a1 as a vector in R2.

How do I ensure Physics[Vectors] understands a1 is a vector in R3

zero_component_problem.mw

5 6 7 8 Page 7 of 8