leafgreen

45 Reputation

5 Badges

8 years, 226 days

MaplePrimes Activity


These are questions asked by leafgreen

I am trying to use a do loop with if/else statements to create a 5x5 unit matrix. I made an empty array. Converted it to a matrix. Then made a do loop where I was trying to get the matrix elements where i=j to be 1 and all else to be 0. It didn't spit out a matrix.

Any advice? I assume I must have missed a small detail in syntax.


 

with(LinearAlgebra):

````

U := array(1 .. 5, 1 .. 5);

array( 1 .. 5, 1 .. 5, [ ] )

(1)

NULL

for i to 5 do for j to 5 do if i = j then U[i, j] := 1 else U[i, j] := 0 end if end do end do

U;

U

(2)

``


 

Download fail_unit_matrix_loop.mw

By the way, I am open to completely different methods, also! I was just trying to use loops to do it rather than inbuilt commands.

I can't for the life of me figure out how to do something which seems so simple.

I want to plot eigenvalues 2ℏ2 and 6ℏ2 with probabilities of 1/2 each on a histogram. That is, have the bottom of the histogram read the two discrete eigenvalues and the vertical axis read the probability.

How would I code this? I tried several times and got errors about the Histogram command expecting different data or being unable to interpret the input.

Thanks for helping with this seemingly simple request.

I am trying to perform the following integral:

Which spits the integral back out at me.

I've also tried

Which, again, spits the integral back out at me.

My last attempt was this

Which... Still spit back out the integral.

Is there something special I should be doing for functions I'm integrating with a natural log? I need to get an exact value for this, not an approximation (because I am trying to check the accuracy of an approximation with this!).

Thanks!

My professor insists for a homework problem that we write down a number answer to this one problem which boils down to...

I'm aware that's incredibly small. So much so that when trying to get a value to display using the command

at its max, it's still 0.00000000000000..0 as an answer.

I might just give up and write down the exponential form. But I was just curious if there is a way to get a number in scientific notation.

Basically what I'm trying to do is use Newton's method to find the root of f(x)=sqrt(x)+ln(0.1x) starting at x0=5 within a tolerance of 0.001.

 

f := proc (x) options operator, arrow; sqrt(x)+ln(.1*x) end proc

> xk := 1.0;
print(`output redirected...`); # input placeholder
                              1.0
> for k to 6 do xk1 := xk-f(xk)/(D(f))(xk); xk := xk1 end do;
 

 

When I do that, Maple barfs out pages of nonsense when I'm looking for it to give numerical values. It seemed to work fine with a different function, so maybe that's part of the problem? But I need to do it with the function I asked about.

1 2 3 4 5 Page 3 of 5