Group Abstract Group Abstract

Message Boards Message Boards

11
|
55.4K Views
|
186 Replies
|
92 Total Likes
View groups...
Share
Share this post:

[WSG22] Daily Study Group: A Guide to Programming and Mathematics with WL

186 Replies
POSTED BY: Thomas Rike

We will reach out to you with your certificate.

Thanks for the reply.

POSTED BY: Thomas Rike
POSTED BY: Lori Johnson

Hi Lori, thanks for getting back to me. Anyway, I guess I was really looking for a setting within Mathematica to always show the quotes for an output string.

POSTED BY: Conrad Taylor

Conrad, I suppose you could dig into Global Preferences, but I personally wouldn't bother if your code is behaving as expected.

What exactly are you trying to do?

POSTED BY: Lori Johnson
POSTED BY: Conrad Taylor

Understood! :D

POSTED BY: Lori Johnson
Posted 4 years ago
POSTED BY: Rohit Namjoshi
@Rohit Namjoshi

@Rohit Namjoshi Thanks for the references and I'll definitely take a look at the links.

POSTED BY: Conrad Taylor

How does one always show the double quotes around a string? For example, I'm currently seeing this behavior:

enter image description here

POSTED BY: Conrad Taylor
Posted 4 years ago

POSTED BY: Syd Geraghty
Posted 4 years ago

Clearly Element[, Reals] and _Real treat the symbols differently.

Element[#,Reals]&/@{3.1,Pi,\[Pi],E}
{True,True,True,True}
Developer`RealQ/@{3.1,Pi,\[Pi],E}
{True,False,False,False}

My guess is: _Real probably only mean real number. Element will check if the symbol really represent a real number. If you want the behavior of Element, you can use this:

Replace[{3.1,Pi,\[Pi],E},{p_/;Element[p,Reals]->Framed[p]},1]
POSTED BY: Jin Zhang
Posted 4 years ago
Replace[{3.1,Pi,\[Pi],E,10,21},{x_/;Element[x,Reals]->Framed[x]},{1}]

Unfortunately this also selects the Integers 10 and 21 which is the wrong requirement!

POSTED BY: Syd Geraghty
Posted 4 years ago
POSTED BY: Rohit Namjoshi
Posted 4 years ago

Pi is not a Real, but a Symbol

Replace[{3.1, \[Pi], Pi, \[Pi], 10, 3.14159, E}, { 
  x_ /; (MemberQ[{Real, Symbol}, Head[x]]) -> Framed[x]}, {1}]

creates frames for all but the Integer enter image description here

POSTED BY: Peter Lippolt
Posted 4 years ago

Hi, I am a bit confused about quiz 3.4. My code gives exactly the same expected output. But 'Check my solution' gives a red cross. I am wondering if I need to take care of the case '0'->'-1' to be '0'->'9'. Even I did that, I still cannot pass the check. Any idea?

POSTED BY: Jin Zhang

I'm really not understanding what upvalues, downvalues, ownvalues, etc. are. Not how they're used, but what they are. I can find the documentation about them in the documentation center, but I never saw that it defines what they are. Can anyone help?

POSTED BY: Kari Ruggles

Yes, the documentation didn't clearly explain DownValues, UpValues, or OwnValues. However, here's a very good write up for reference:

https://mathematica.stackexchange.com/questions/96/what-is-the-distinction-between-downvalues-upvalues-subvalues-and-ownvalues

I wish that this helps you to better understand their definitions.

POSTED BY: Conrad Taylor
Posted 4 years ago

Quiz 3.3 question:

I am stuck on only one output detail with this question and it appeared as a very straightforward piece of code that just doesn't work! Where am I going wrong, what am I missing?

In[84]:= 
Element[\[Pi], #] & /@ {Complexes, Algebraics, Reals, Rationals, 
  Integers, Primes}

Out[84]= {True, False, True, False, False, False}

So Pi belongs to the domain of Reals!

However any of the input variants for Pi cannot be framed as expected with this Replace code:

Try inputting Pi in different ways ...\ [Pi], [FpormaPi], esc pi esc, ...

In[82]:= Replace[{3.1, \[Pi], Pi, \[Pi], 3.14159, E}, {x_Real -> Framed[x]}, {1}]

Out[82]= {
\!\(\*FrameBox[\!\(3.1`\),
StripOnInput->False]\), \[Pi], \[Pi], \[Pi], 
\!\(\*FrameBox[\!\(3.14159`\),
StripOnInput->False]\), E}

How do I frame the Pi symbol?

Syd

POSTED BY: Updating Name

@Aristarque Monneron yes, each solution to the programming exercises in quiz 3 gets automatically graded and submitted when you click "Check Solution". We see your submissions for quiz 1 and 2 but not for quiz 3. Could you please email wolfram-u@wolfram.com and follow up with your notebook?

Hi Abrita,

I have sent an email with the file to the address indicated.

Posted 4 years ago
POSTED BY: Peter Ransome

@Peter Ransome Yes all your submissions have been received.

Posted 4 years ago

Hi Mitchell

I think Abrita's comment is quite clear on where ToString is not needed

Firstly {"a3bykmn","oka2bcka","bdkba1","4ckxyz"} is already a list of Strings so you do not need ToString for the input.

and where it is needed

You would need to use ToString to convert the digit back to String once you have isolated it and decremented it by 1

The code you posted earlier is close

StringReplace[{"a3bykmn","oka2bcka","bdkba1","4ckxyz"},p:DigitCharacter :>ToExpression[p-1]]

Just need to fix the ToExpression[p-1]]. p is a String, it needs to be converted to an Integer so 1 can be subtracted from it, the result needs to be converted to a String so StringReplace can do the replacement.

POSTED BY: Rohit Namjoshi

Got It. Thanks so much.

Mitch Sandlin

POSTED BY: Mitchell Sandlin
POSTED BY: Mitchell Sandlin

Firstly {"a3bykmn","oka2bcka","bdkba1","4ckxyz"} is already a list of Strings so you do not need ToString for the input. You would need to use ToString to convert the digit back to String once you have isolated it and decremented it by 1.

As the error message says, "StringExpression::invld: Element pDigitCharacter is not a valid string or pattern element in pDigitCharacter:>ToExpression[p-1]."

Remember if you are trying to restrict a pattern to match only expressions with a certain Head that is when you use the Underscore "_". So you can have "p_Integer" or "p_String" etc. When you want to use a pattern object like "DigitCharacter" or "PunctuationCharacter" we want to simply follow up the name with ":" like p:DigitCharacter or p:PunctuationCharacter

StringCases["\"a, b c.\"", p : PunctuationCharacter :> Framed[Style[p, Red]]]

Hi Abrita;

I incorporated the changes that you suggested (see below) and this time, I think the program actually blew up because I never received an answer back as to whether the program actually completed. In any event, I am not getting an option to try again.

However, the comments as to when to use an _ verses a : were very helpful.

StringReplace[{"a3bykmn","oka2bcka","bdkba1","4ckxyz"},p:DigitCharacter :>ToExpression[p-1]]
POSTED BY: Mitchell Sandlin
Posted 4 years ago

The error message is

ToExpression::notstrbox: -1+3 is not a string or a box. ToExpression can only interpret strings or boxes as Wolfram Language input.

p is a String, so ToExpression[p-1] fails. Cannot subtract 1 from a String.

Hint: ToExpression["3"] // Head

POSTED BY: Rohit Namjoshi

Hi Rohit;

The problem stated as hints that ToString[] and ToExpression[] would be needed in the solution of StringReplace[]. Abrita told me in a previous reply that I really didn't need to use ToString since the data was already in string format, so I remove it from my expression.

I need to read the digit characters from the data strings, for example pull the 3 from the first string a3bykmn, then subtract 1 from the value, write it back out as a 2, and then grab the next digit character from the next string oka2bcka which is a 2 subtract 1 giving 1 and so on.

Even after attending every lecture, I don't know how to do that.

Thanks,

Mitch Sandlin

POSTED BY: Mitchell Sandlin

Hi Mitch, Sorry for the confusion. I meant "you do not need ToString for the input", but you will need it when your pattern has found a match. In your code:

StringReplace[{"a3bykmn","oka2bcka","bdkba1","4ckxyz"},p:DigitCharacter :>ToExpression[p-1]]

once p has matched something it is still a string, that is why you cannot subtract 1 from it. You need to convert it into an expression to subtract 1 from it. Once that is done, you want to put it back in the original string, but now again you are stuck with an integer you are trying to insert into a string. This is where ToString comes in handy.

ToExpression can convert string to number i.e. "3" to 3 ToString can convert a number to a string i.e. 3 to "3"

Hope this helps.

Hi Abrita; Referring to 3.3 we are instructed to use Replace[] along with a set of rules to process even, odd and non integers. My solution only wants to process the first element of the string - see below.

Clear[x,y,z]
Replace[#,{x_/;EvenQ[x]->x*2,y_/;OddQ[y]->y*3,z_/;!IntegerQ[z]->Framed[z]}]&  [94,87,[Pi],49,46,"42",28,47,68,57,4,44,100,4.2,{23,1},57]

For example, if you run the function, it will return 188 (294). If you replace the first element of 94 with 87 and run the function, it will return 261 (387). If you replace the first element of 94 with Pi and run the function, it will return Pi with a box around it. Therefore, the logic seems to be working correctly, I just can't get the evaluation to move through the list, and I think I have tried everything that I can find in the documentation as well as the lecture notes. Do you have any suggestions.

Thanks, Mitch Sandlin

POSTED BY: Mitchell Sandlin

On Quiz 3 Problem 3.1, when I click Check My Solution, I getenter image description here the following error within the downloaded notebook:

POSTED BY: Conrad Taylor

@Conrad Taylor Referring to the third template for creating a SparseArray on http://reference.wolfram.com/language/ref/SparseArray.html SparseArray[data,{d1,d2, ...}], we would like you to create your own 'data' with a rule (of the form pattern -> value). The example showing the construction of a tridiagonal matrix using patterns for indices on the documentation page linked above, may be a good starting point to solve this problem.

Hi Abrita;

I followed the example in the link that you sent me for SparceArray to create the data and again it produced exactly the same correct output in the MatrixPlot that the problem indicated it should. However, I am again getting the message that my answer is incorrect and to try again.

Mitch Sandlin

POSTED BY: Mitchell Sandlin

Hi Conrad;

I followed the example that you sent me a link to for SparceArray and again produced exactly the same output as the problem displayed, but still was not accepted as the correct answer. I do not know that to do at this point. Any suggestions.

Mitch Sandlin

POSTED BY: Mitchell Sandlin
Posted 4 years ago

Hi Mitch

Regarding Q1 , there is a grader issue .

I will just recount my approach to doing qustion1 :- I answer the question without looking at the hints . My first approach was to create the data within the SparesArray[] function and got the correct output but the grader did not accept it. After a number of ways of creating the data within the SparesArray[] function and no success., I then looked at the hints

    DATA=................
    SparseArray[DATA ,{n,n}]

So the DATA had to be created outside the SparseArray in a full array :-

    DATA="full array" /"standard matrix " 
    SparseArray[DATA ,{n,n}]

with the correct values for n ,the grader accepted ,

POSTED BY: Doug Beveridge

Hi Doug;

Following your advice, I deleted my data from my SparseArray[] and moved it into a field named dta1= {{1,5}-> 1, etc.}}. Then loaded the data into the functions:

MatrixPlot[SparseArray[dta1,{20,20}]]

The new configuration gave me the exact same data as expected, as I have gotten for the last 5 days, with no error messages. However again, the grader didn't like it, gave me an X and told me to try again.

Thanks,

Mitch Sandlin

POSTED BY: Mitchell Sandlin
Posted 4 years ago

Mitch

As a side note , make sure there are no blank spaces in your code eg

Function[x_   ,  y_ ] 

should be

   Function[x_,y_]

This used to cause major problems with the g4rader

POSTED BY: Doug Beveridge

Hi, I was able to refactor Quiz 3 Problem 3.1 into a solution that appears to have been accepted by the backend. Also, I was definitely in the weeds for this problem. Anyway, could someone confirm that I have submitted all 3 quizzes for the study group?

POSTED BY: Conrad Taylor

Hello;;

I cannot figure out why my If statements are not working, Please see below. I believe my If statements are pretty straight forward.

I am first checking if my retrieved value is an integer and if false, I put a box around it. If true, I run another If statement to see if it is even, if true, I simply multiply it by 2, if false, I multiply it by 3.

Additionally, I am not even sure it function is reading the data, but I thought I would work on getting the If statements working first.

ReplaceAll[x,x:>{If[IntegerQ[x],If[EvenQ[x],x*2,x*3],Framed[x]]}]{94,87,\[Pi]}

{FrameBox["x", StripOnInput -> False]} {94,87,[Pi]}

Thanks,

Mitch Sandlin

POSTED BY: Mitchell Sandlin
Posted 4 years ago

ReplaceAll[x will only match a literal x e.g.

ReplaceAll[x :> y][{a, x, x^2}]
(* {a, y, y^2} *)

For this quiz question use Replace with a level specification (which is what the quiz asks for). Rather than nested If, consider using Which.

POSTED BY: Rohit Namjoshi

Hi;

Based on the definition and hints given by the problem, I think that everything is included in my solution, however I am not getting the desired output - see below. I am sure that it is something that I am doing incorrectly, but based on my knowledge at this point in time, I do not have a clue.

StringReplace[ToString[{"a3bykmn","oka2bcka","bdkba1","4ckxyz"}],p_DigitCharacter :>ToExpression[p-1]]
POSTED BY: Mitchell Sandlin

Hi Rohit;

Thanks for the reply directing me to use Which[] as opposed to using a nested If[]. However, I still do not understand why the nested If[] failed. I actually believe the Which[] is a much cleaner solution but unfortunately it doesn't seem to work either - see below. I actually tried both formats using RelpaceAll[] and // with no success.

As an aside, I even tried using x--EvenQ[x], x*2, with no success.

ReplaceAll[x,x:>Which[EvenQ[x],x*2,OddQ[x],x*3,!IntegerQ[x],Framed[x]]]{94,87,\[Pi]}

{94,87,\[Pi]}//.x_:>Which[EvenQ[x],x*2,OddQ[x],x*3,!IntegerQ[x],Framed[x]]
POSTED BY: Mitchell Sandlin
POSTED BY: Mitchell Sandlin
Posted 4 years ago
POSTED BY: Dave Middleton
Posted 4 years ago

POSTED BY: Dave Middleton

Hi Dave,

This is so good that I had to save a copy. Thanks for your hard work!

L

POSTED BY: Lori Johnson
Posted 4 years ago

You're welcome Lori.

Even though the exercise to create a short tutorial made me wiser, I will still refer to it whenever I need entities :)

POSTED BY: Dave Middleton

It seems absolutely necessary because of the myriad of ways to do things in WL and have files with favorite snippets based on certain functions that I use for the same purpose in clearer language! You know, like IBM mainframe manuals!

POSTED BY: Lori Johnson

I'm working on Quiz 3 Problem 3.3. I have created a function, transform, that fulfills cases 1 - 3 and returns the correct value depending on the input. Now, I'm trying to integrate the function, transform, as a rule to the Replace function. Is there something that I'm missing within the current implementation?

enter image description here

POSTED BY: Conrad Taylor
Posted 4 years ago

Hi Conrad,

/; (Condition) requires a predicate function to perform the test. From the documentation

{6, -7, 3, 2, -1, -2} /. x_ /; x < 0 -> w

Try something like

Replace[numbers, value_ :> transform[value]]

and don't forget the hint in the question.

POSTED BY: Rohit Namjoshi

@Rohit Namjoshi I was able to refactor into a better solution. Thanks for your assistance.

POSTED BY: Conrad Taylor
Posted 4 years ago
POSTED BY: Updating Name

Yes Quiz 3 has only 5 questions.

Posted 4 years ago

Is there a way to get a list of all Developer' functions ?

eg Developer`RealQ

and

Developer`MachineRealQ

POSTED BY: Doug Beveridge
Posted 4 years ago

Hi Doug,

Names ["Developer`*"] // 
  Partition[#, UpTo@3] & // 
  Grid[#, Alignment -> Left, Frame -> All] &
POSTED BY: Rohit Namjoshi

Hi, I just completed Quiz 1 and clicked the click Get Results. However, it's not clear how to determine that the quiz was submitted successfully. Can someone confirm that Quiz 1 has been submitted?

POSTED BY: Conrad Taylor
Posted 4 years ago
POSTED BY: Doug Beveridge

@Conrad Taylor received your submissions

POSTED BY: Mitchell Sandlin
Posted 4 years ago

Hi Mitchell,

DigitCharacter does not take any arguments, it matches a digit character in a StringExpression. It is not a predicate function. From the documentation

StringMatchQ[#, DigitCharacter] & /@ {"1", "a", "2", "b", ".", " "}

So the pattern given to StringReplace must contain DigitCharacter to match the digits in the input string. It can be bound to a symbol e.g. d : DigitCharacter, then d can be used in the replacement Rule.

POSTED BY: Rohit Namjoshi

Hi;

What am I doing wrong here on the 1st problem - see below? I have included everything the problem indicates, but I am getting a syntax error regarding the position of my rule.

MatrixPlot[ SparseArray[data,{n,n} /;n>0]]

Thanks,

Mitch Sandlin

POSTED BY: Mitchell Sandlin
Posted 4 years ago

Hi Mitch,

The wording of the question is a bit odd IMO. Look at the expected output and generate data using Rule and Condition so that you can reproduce the plot

data = (* some expression using Rule and Condition *)
MatrixPlot[SparseArray[data, {n, n}] (* This reproduces the expected output *)
POSTED BY: Rohit Namjoshi

Sorry if the question is not clear. Referring to the third template for creating a SparseArray on http://reference.wolfram.com/language/ref/SparseArray.html SparseArray[data,{d1,d2, ...}], we woul dlike you to create your own 'data' with a rule (of the form pattern -> value). The example showing the construction of a tridiagonal matrix using patterns for indices on the documentation page linked above, may be a good starting point to solve this problem.

Hi Abrita;

Please ignore my previous request for assistance on 3.3, I figured it out myself and can produce exactly the same required output, however the grader still marked them incorrect. The same can be said for 3.1, producing the correct output but the grader still marked it incorrect. So these 2 quiz questions will need to be hand graded. Questions 3.2 and 3.4 did not produce any problems since the grader correctly graded them as correct. Question 3.5, I could not produce the required output, so most likely it is incorrect - wasn't sure what was being asking to solve.

Quiz 1 and 2, I submitted sometime ago with passing grades on both.

Please let me know if you need anything else from me concerning these quizzes.

Thanks,

Mitch Sandlin

POSTED BY: Mitchell Sandlin

If by any chance any of your quiz notebooks on the cloud get corrupted you can follow these instructions to delete the notebooks from your cloud account and start afresh: https://www.wolframcloud.com/obj/online-courses/Published/UpdatingWolframUCourseQuizzesAndExercises.nb

Just a reminder that we start early tomorrow at 1:30 AM CT for a series review. If you were unable to put in your request for a review topic, feel free to reply to this post and add it here.

POSTED BY: Joseph Sauvageau

You are very welcome.

When you click the "Check My Solution" button for each problem in Quiz 3, your graded submission (Correct or Incorrect) automatically gets recorded at our end. We are able to pull your total score for the quiz from those submissions.

If one downloads a copy of Quiz 3 notebook and clicks the Check My Solution, will the score get recorded in the backend? Thanks in advance for your feedback.

POSTED BY: Conrad Taylor

Yes it should.

Posted 4 years ago

Hi Abrita,

Concerning quiz 3, I'm experiencing similar issues I encountered in previous DSGs in that I get some answers marked as wrong (3.4 and 3.5 in this case) despite I can reproduce the expected output by using the required functions as stated in the questions. Should I send a local copy of the notebook via email?

Thanks in advance!

__

FA

POSTED BY: Fabio Alcaro
Posted 4 years ago

I missed the Survey at the end of today's session. My request for tomorrow's Review session is to look a bit into string replacements using patterns. Do we have to use Regular Expressions at times, or can we do the same with patterns?

Cheers,

Dave

POSTED BY: Dave Middleton

You can do a lot even without Regular Expressions. You will have to use dedicated functions to work with string patterns like StringReplace, StringMatchQ, StringContainsQ etc. You will find them listed here and you can use this tutorial to get started.

Posted 4 years ago

Hi. If I define an uppervalue x by: x /: _[x] = 0, How can I clear it?

POSTED BY: Jin Zhang

I suppose you want to clear ONLY a specific upvalue otherwise Unset or Clear would have been fine. You can use TagUnset.

In[1]:= sq /: area[sq] = s^2;
sq /: circ[sq] = 4 s;

In[2]:= sq /: circ[sq] =.

In[3]:= {area[sq], circ[sq]}

Out[3]= {s^2, circ[sq]}

I found another user try to do something similar here: https://community.wolfram.com/groups/-/m/t/1072731

Posted 4 years ago
POSTED BY: Jin Zhang
Posted 4 years ago

Hi Abrita, Thank you for this comprehensive explanation. Really helpful!

POSTED BY: Jin Zhang
Posted 4 years ago

In today's study group's "Exercises for Image Processing", Exercise 1. the code provided does not work on my Windows 10 21H2 machine with Mathematica version 13.0.1.0 i.e. the 2D slider t2 doesn't do anything.

img = Binarize[
   Graphics[{Disk[{0, 0}, 8], White, Disk[{0, 0}], Disk[{2, 2}]}, 
    ImageSize -> 200]];
Manipulate[
 ImageResize[ImageTrim[img, {t1, t2}], 
  400], {t1, {1, 1}, {177, 177}, {1, 1}, 
  Appearance -> "Labeled"}, {{t2, {400, 400}}, {271, 271}, {400, 
   400}, {1, 1}, Appearance -> "Labeled"}, ControlPlacement -> Left]

Is this an issue on my end or is this a bug? If the latter, is there a work-around?

Cheers,

Dave

POSTED BY: Dave Middleton
Posted 4 years ago
POSTED BY: Doug Beveridge
Posted 4 years ago

Thanks Doug. The "Dynamic Updating Enabled" is on, or else the t1 2D slider wouldn't work either. Maybe my installation is corrupted somehow.

POSTED BY: Dave Middleton

Hi Dave, Does a simple 2DSlider work for you?

Slider2D[{.7, .3}]
Posted 4 years ago
POSTED BY: Updating Name
Posted 4 years ago
POSTED BY: Updating Name

Quiz 2, Problem 4, answer option A says "Displays a dialog box with the message 'Click OK', where evaluations can still be done without dismissing the dialog box", i.e. you can continue to evaluate further code in the notebook, without dismissing the dialog box.

Posted 4 years ago
POSTED BY: Updating Name
Posted 4 years ago

What is the most efficient way to do XOR matrix multiplication?

Attachments:
POSTED BY: Doug Beveridge
Posted 4 years ago

I am not entirely clear about this behavior of Interval[ ]:

POSTED BY: lara wag
Posted 4 years ago

Thank you very much, Abrita and Dave!

I would never have thought of that...

POSTED BY: lara wag
POSTED BY: Zbigniew Kabala
POSTED BY: Zbigniew Kabala
Posted 4 years ago
POSTED BY: lara wag
Posted 4 years ago
POSTED BY: Updating Name
Posted 4 years ago

Hi Zbigniew,

I think all of your questions are related to the fact that by default the frontend only shows 6 digits for MachinePrecision values, irrespective of what precision values is passed to N.

sol // InputForm
(* {-3.035090330572526, 1.0350903305725259} *)

This can be changed, e.g.

(* For the current frontend session *)
SetOptions[$FrontEndSession, PrintPrecision-> 16]

(* For the current and future frontend sessions *)
SetOptions[$FrontEnd, PrintPrecision-> 16]

(* For the current notebook *)
SetOptions[InputNotebook[], PrintPrecision-> 16]

Or you can use NumberForm.

NumberForm[sol[[1]], 16]
(* -3.035090330572526 *)
POSTED BY: Rohit Namjoshi

@Zbigniew Kabala, Here is Dave's response to your questions:

Posted 4 years ago

Thank you for the thourough explanation.

POSTED BY: Updating Name
POSTED BY: Zbigniew Kabala
Posted 4 years ago
Posted 4 years ago
Attachments:
POSTED BY: Gerald Dorfman
Posted 4 years ago

If you create DockedCells

eg enter image description here

How do you remove it ?

POSTED BY: Doug Beveridge
Posted 4 years ago

Doug,

To remove all docked cells

SetOptions[EvaluationNotebook[], DockedCells -> {}]
POSTED BY: Rohit Namjoshi

Try evaluating x by itself and I think you'll see where the Irishman comes from :). Run ClearAll[x] after that and NRoots will do its job as expected.

POSTED BY: Arben Kalziqi

Thank you!

Posted 4 years ago
Attachments:
POSTED BY: George Schils
Posted 4 years ago

I feel like I am doing something exceedingly stupid, but am having trouble getting the volume of a sphere as given below.

enter image description here

This calculation gives 7.06858347057703478654094869079, which is off by a factor of 4.

POSTED BY: George Schils

Try Ball instead of Sphere—despite colloquial usage, a sphere is a 2D object that embeds into 3D space.

POSTED BY: Arben Kalziqi
Posted 4 years ago

Arben, thank you for your kind response. Indeed, the use of Ball in place of Sphere makes everything work wonderfully. I went on to play around with some cool and fun examples, and I am including the updated notebook. Here is a highlighted example from the attached notebook, where it finds a closed form solution. enter image description here

POSTED BY: George Schils
POSTED BY: Arben Kalziqi
Posted 4 years ago
POSTED BY: George Schils
Posted 4 years ago
POSTED BY: George Schils
Posted 4 years ago
Attachments:
POSTED BY: George Schils
Posted 4 years ago
Posted 4 years ago
POSTED BY: George Schils
Posted 4 years ago

Expanding on your comments, Arben, we see indeed that integrating using Sphere vs. Ball clearly gives different answers.

In[6]:= Integrate[1, {x, y, z} \[Element] Sphere[]]

Out[6]= 4 \[Pi]

In[7]:= Integrate[1, {x, y, z} \[Element] Ball[]]

Out[7]= (4 \[Pi])/3

Using RegionMeasure allows the dimension of the integration to be specified.

In[8]:= RegionMeasure[Sphere[]]

Out[8]= 4 \[Pi]

Agreeing with your comment, Arben, Sphere[] is 2-dimsional, and its 3-D measure gives zero. WOW - that's a gocha.

In[10]:= RegionMeasure[Sphere[], 3]

Out[10]= 0

Note the correct answers using Ball[] below.

In[9]:= RegionMeasure[Ball[]]

Out[9]= (4 \[Pi])/3

In[11]:= RegionMeasure[Ball[], 3]

Out[11]= (4 \[Pi])/3

As a final note, we see and understand the next result.

In[12]:= RegionMeasure[Ball[], 4]

Out[12]= 0
POSTED BY: George Schils
Posted 4 years ago
POSTED BY: George Schils
Posted 4 years ago
POSTED BY: Peter Lippolt
Posted 4 years ago
Attachments:
POSTED BY: Gerald Dorfman
Posted 4 years ago
POSTED BY: Updating Name

Notebook 19SolvingEquations.nb has now been added.

Is there a way to prevent Mathematica from inserting spaces into a URL I put in a notebook?

If I copy a URL into Mathematica, then copy it from there, it comes out like this:

https : // www . wolframalpha . com/input?i = Table %5 BExpand %5 B %28 Power %5 BGoldenRatio %2 Cn %5 D + -+Power \ %5 B %281 + -+GoldenRatio %29 %2 Cn %5 D %29 %2 FSqrt %5 B5 %5 D %5 D \ %2 C + %7 Bn %2 C + 0 %2 C + 18 %7 D %5 D

POSTED BY: Lori Johnson
Posted 4 years ago

My congratulations to Abrita Chakravarty with splendid and so useful work during all this daily group! Great efforts, thank you.

Could you (or someone else) give a clue concerning quizes? As far as I remember, we should have two of them at this week. What is a way to get the quizes? Or, perhaps, it is too early to ask (my apologies then).

POSTED BY: Olga Pavlova

Hi Abrita! Thank you, Abrita, and everyone working to put them together!

POSTED BY: Lori Johnson
Posted 4 years ago
POSTED BY: Gerald Dorfman
Posted 4 years ago
POSTED BY: Rohit Namjoshi

@Thomas Ray Worley please feel free to email wolfram-u@wolfram.com if you are facing issues with the notebooks. We will be happy to help you troubleshoot further. You should be able to open all the notebooks in the same way.

Thanks Richard.

It appears that f[x_] := f[x] =. .. is more efficient. Is there ever a case in which it should not be used?

Posted 4 years ago

You would probably not want to use this if the function was unlikely to be frequently called with the same argument. You would DEFINITELY NOT want to use it if you need the function to return different results when called with the same argument (e.g. if the result depended on some extermal value such as the current time or any of the Random* functions).

POSTED BY: Richard Hewens

When defining functions, when is it better to use f[x_] := f[x] =. ..instead of just f[x_] := ...? Why?

Posted 4 years ago
POSTED BY: Richard Hewens
Posted 4 years ago
POSTED BY: Richard Hewens
POSTED BY: Arben Kalziqi
POSTED BY: Sanjit Das
Posted 4 years ago

This is really helpful - thank you!

POSTED BY: D Groves
Posted 4 years ago
POSTED BY: D Groves
Posted 4 years ago
POSTED BY: Peter Lippolt

Responding to multiple-choice Qs does not contribute to certification. It's for self-testing. Watching the lectures and passing the quizzes do.

I need to regroup for a trip that starts Monday. For that time I will switch to a cloud account and need to arrange file directories. (1) How to (up)load their files for the class? (2) How to order them based on the sessions' order number? . The ordering turned out to be especially ticky. Thank you

Posted 4 years ago

Hi, I can watch the lectures as a recorded video. Is there an another way to get certificate of progtam completion rather than solving multiple choices problems on live sessions?

POSTED BY: Hasan SANSAR
Posted 4 years ago
POSTED BY: D Groves

Posted exercises for days 1, 2 and 3 in the series download folder.

Hello, Abrita, and thank you. M

Is it possible to access the NB files and quizzes for this class in the cloud?

Hello Michael,

While the notebooks are only available in the downloadable form right now, they will soon be available as part of the new interactive course on the Wolfram U site (as cloud notebooks). We just do not have a confirmed release date for that course yet.

The quizzes (with multiple choice questions) to be completed for Certificate of Program Completion will definitely be available on the cloud - same a other Daily Study Groups so far.

If you are referring to the programming exercises we added to the download folder, I think we can try to share cloud published versions of the exercises by the end of the week.

The following code should explain what parts of the expression Range[10] are matching p, q and r:

Range[10] /. {p___, q_, 
r_} -> {{"This is p: ", p}, {"This is q: ", q}, {"This is r: ", r}}

This is the output you get:

 {{"This is p: ", 1, 2, 3, 4, 5, 6, 7, 8}, {"This is q: ", 9}, {"This is r: ", 10}}

So what is essentially happening with the {#^2 & /@ p, q r} part of the expression is {#^2 & /@ 1, 2, 3, 4, 5, 6, 7, 8, q r} i.e. #^2 is mapped over the single element 1 and therefore gives the result {1, 2, 3, 4, 5, 6, 7, 8, 90}

This would give the expected result:

Range[10] /. {p___, q_, r_} :> Join[#^2 & /@ {p}, {q r}]

Awesome! Thank you very much, Abrita. Best. M

Range[10] /. {p___, q_, r_} :> {Hold[ 2 p], q r}

shows what's happening with 2 p. It is computing 2X2X3X4X5X6X7X8

p (from the RHS of the rule) is really a fragment of an expression. It needs to be explicitly turned into a list to get the output you are looking for. Maybe something like:

Range[10] /. {p___, q_, r_} :> Append[2 {p}, q r]

Dear Arbita and Dave. Your responses are very valuable, especially by teaching how to "huck" it (look under the hood). There is a lot to digest. Thank you. M

POSTED BY: Arben Kalziqi

Thank you, Arben, At first sight, it indeed seems so .... insignificant :(. I am sure that it is а misleading impression. This happens with everything really basic.

POSTED BY: Lori Johnson

Caesar Cipher example and Day 1 exercises have been added to the download folder.

Posted 4 years ago

Where is the link to the download folder?

POSTED BY: Syd Geraghty

Hi Joel, You can join the Wolfram Community and participate in any discussion thread. This particular thread is dedicated to the Daily Study Group: A Guide to Programming and Mathematics with the Wolfram Language. You can click on "Follow this Post" to receive notifications of any activity on this thread. enter image description here

Thank you. The auto-grader is an interesting creature on its own. Is it one of Wolfram's projects? If it is, please post a link. What are the grading criteria (in addition to the final result), the ideas behind it, how does it learn...? Are there wider applications, e.g., for a justice system, or for use by a Supernal being judging the Humans? Thanks again. Michael.

Posted 4 years ago

Do we have to post a reply to join the group?

POSTED BY: Joel Healy
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard