Skip to content
Snippets Groups Projects
Commit 22d2a825 authored by Robert Lanzafame's avatar Robert Lanzafame
Browse files

GA 1.5 feedback and solution ready

parent bc106abb
No related branches found
No related tags found
No related merge requests found
Pipeline #250745 passed
# README for Group Assignment 1.5
*[CEGM1000 MUDE](http://mude.citg.tudelft.nl/): Week 1.5, Friday, Oct 4, 2024.*
Most groups did well, although there are a few minor points listed below. Most notably, _many_ groups did not implement the CD method correctly. Compare your analysis to the solution carefully; you may have also already realized this as part of PA 1.6, which used an assert statement to check that the values of the CD were calculated correctly. Finally, an explanation is provided at the end of this document.
## Feedback on individual questions
Q1: It does not make sense to compute for the entire year because there is no ice in summer! Therefore, the gradient cannot be calculated over multiple years. Seasonality also would mean the physical process changes, but the point is the absence of ice. Always make sure you think about the meaning of your calculations, rather than proceeding with a numerical scheme blindly.
Q2: Equidistance is **often** misunderstood for CD approach. Many groups have the wrong number of intervals and/or data points.
Q3: Some groups placed the evaluation point “in the middle”, however the points are not equidistant between the neighboring points (most likely cause was that you found the average of _three_ points, not two).
Some groups place it at the days where the measurements are (not equidistant, here the resulting calculation is much further away from the value we intended).
Do not forget that CD is second order! This is illustrated below in the example.
Q4: Make sure you know your trigonometry!
Q5: Mostly very good!
Q6: Some forgot to evaluate at $x_0+5$
Q7: Make sure you know your trigonometry! Do not forget to evaluate your derivatives at $x_0= \pi$ and $y_0= \pi$
Q8: Some groups made mistakes in the code, some in the calculation, many various mistakes. Feel free to ask if your graph does not match the solution. See also the explanation below, and PA 1.6.
## Feedback on Central Difference method
In this assignment we were faced with a situation where we wanted to calculate the numerical derivatives for a series of points. These "data" were irregularly spaced, making the application of our typical differentiation schemes a little different than normal, in particular, the _central difference_ method. Note that all three approaches (forward, backward and central) differences assume that every increment of the discretized domain (in this case, time) is equal. In other words, $\Delta t$ is always the same. This is apparent if you follow the derivations in the book (an exercise left for you to practice on your own!).
Actually, since since forward and backward differences use only one time step, there is not problem with the non-uniform increments, as long as you use the $\Delta t$ associated with each data point. However, since CD uses _two_ increments, this approach returns incorrect results.
There are two approaches possible:
1. Re-derive the CD method to take into accound unequal time steps (e.g, $\Delta t_1$ and $\Delta t_2$)
2. Apply the original method at the midpoint between the points. Assume that the numerical derivative is representative of the _midpoint_ between the two points.
We opted for the second approach, as it is very easy to implement. Note also that the computed value of CD with this approach will be exactly the same as the FD and BD for the left and right points, respectively. Yet it is still 2nd order accurate. Magic?! No! See illustration below to see why.
Although the approach of using _three_ points is ok, there are a few problems here:
1. You reduce the number of difference calculations by 1
2. You are averaging over larger time increments, and the function varies a lot (we can't adopt the "normal" approach of making the increments small enough for this not to matter, because we only have a small number of points)
3. Many of those who did this incorrectly applied the computed derivative at the _center_ point, rather than the _midpoint_ of the two outer points, which incorrectly assumes uniform time increments, as described above.
**Why are the values of FS, BD, CD exactly the same, but CD is still 2nd order accurate?** We illustrate this here with a plot that fits a polynomial function to the ice data, then also presents the numerical derivatives calculated for that function (with smaller time steps). Take a look and note the following:
1. The same points used in GA 1.5 are illustrated; FD, BD, CD have same values, again.
2. CD always falls very close to the "true" derivative (the pink line)...because it is more accurate!
3. the difference between the "true" value and the FD and BD approximations increases as the derivative changes more (i.e., as the second derivative increases; this is not plotted). In other words: all methods are accurate for the first increment because the green line is nearly linear (constant value for the true derivative). The opposite is true near the middle and right side of the plot where the derivative is changing rapidly.
![illustration of CD accuracy](./central_diff_illustration.svg)
**End of file.**
<span style="font-size: 75%">
&copy; Copyright 2024 <a rel="MUDE" href="http://mude.citg.tudelft.nl/">MUDE</a>, TU Delft. This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">CC BY 4.0 License</a>.
\ No newline at end of file
Source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
<!DOCTYPE html>
<html>
<head>
<title>Feedback.md</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<style>
/* https://github.com/microsoft/vscode/blob/master/extensions/markdown-language-features/media/markdown.css */
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
body {
font-family: var(--vscode-markdown-font-family, -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", "Ubuntu", "Droid Sans", sans-serif);
font-size: var(--vscode-markdown-font-size, 14px);
padding: 0 26px;
line-height: var(--vscode-markdown-line-height, 22px);
word-wrap: break-word;
}
#code-csp-warning {
position: fixed;
top: 0;
right: 0;
color: white;
margin: 16px;
text-align: center;
font-size: 12px;
font-family: sans-serif;
background-color:#444444;
cursor: pointer;
padding: 6px;
box-shadow: 1px 1px 1px rgba(0,0,0,.25);
}
#code-csp-warning:hover {
text-decoration: none;
background-color:#007acc;
box-shadow: 2px 2px 2px rgba(0,0,0,.25);
}
body.scrollBeyondLastLine {
margin-bottom: calc(100vh - 22px);
}
body.showEditorSelection .code-line {
position: relative;
}
body.showEditorSelection .code-active-line:before,
body.showEditorSelection .code-line:hover:before {
content: "";
display: block;
position: absolute;
top: 0;
left: -12px;
height: 100%;
}
body.showEditorSelection li.code-active-line:before,
body.showEditorSelection li.code-line:hover:before {
left: -30px;
}
.vscode-light.showEditorSelection .code-active-line:before {
border-left: 3px solid rgba(0, 0, 0, 0.15);
}
.vscode-light.showEditorSelection .code-line:hover:before {
border-left: 3px solid rgba(0, 0, 0, 0.40);
}
.vscode-light.showEditorSelection .code-line .code-line:hover:before {
border-left: none;
}
.vscode-dark.showEditorSelection .code-active-line:before {
border-left: 3px solid rgba(255, 255, 255, 0.4);
}
.vscode-dark.showEditorSelection .code-line:hover:before {
border-left: 3px solid rgba(255, 255, 255, 0.60);
}
.vscode-dark.showEditorSelection .code-line .code-line:hover:before {
border-left: none;
}
.vscode-high-contrast.showEditorSelection .code-active-line:before {
border-left: 3px solid rgba(255, 160, 0, 0.7);
}
.vscode-high-contrast.showEditorSelection .code-line:hover:before {
border-left: 3px solid rgba(255, 160, 0, 1);
}
.vscode-high-contrast.showEditorSelection .code-line .code-line:hover:before {
border-left: none;
}
img {
max-width: 100%;
max-height: 100%;
}
a {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:focus,
input:focus,
select:focus,
textarea:focus {
outline: 1px solid -webkit-focus-ring-color;
outline-offset: -1px;
}
hr {
border: 0;
height: 2px;
border-bottom: 2px solid;
}
h1 {
padding-bottom: 0.3em;
line-height: 1.2;
border-bottom-width: 1px;
border-bottom-style: solid;
}
h1, h2, h3 {
font-weight: normal;
}
table {
border-collapse: collapse;
}
table > thead > tr > th {
text-align: left;
border-bottom: 1px solid;
}
table > thead > tr > th,
table > thead > tr > td,
table > tbody > tr > th,
table > tbody > tr > td {
padding: 5px 10px;
}
table > tbody > tr + tr > td {
border-top: 1px solid;
}
blockquote {
margin: 0 7px 0 5px;
padding: 0 16px 0 10px;
border-left-width: 5px;
border-left-style: solid;
}
code {
font-family: Menlo, Monaco, Consolas, "Droid Sans Mono", "Courier New", monospace, "Droid Sans Fallback";
font-size: 1em;
line-height: 1.357em;
}
body.wordWrap pre {
white-space: pre-wrap;
}
pre:not(.hljs),
pre.hljs code > div {
padding: 16px;
border-radius: 3px;
overflow: auto;
}
pre code {
color: var(--vscode-editor-foreground);
tab-size: 4;
}
/** Theming */
.vscode-light pre {
background-color: rgba(220, 220, 220, 0.4);
}
.vscode-dark pre {
background-color: rgba(10, 10, 10, 0.4);
}
.vscode-high-contrast pre {
background-color: rgb(0, 0, 0);
}
.vscode-high-contrast h1 {
border-color: rgb(0, 0, 0);
}
.vscode-light table > thead > tr > th {
border-color: rgba(0, 0, 0, 0.69);
}
.vscode-dark table > thead > tr > th {
border-color: rgba(255, 255, 255, 0.69);
}
.vscode-light h1,
.vscode-light hr,
.vscode-light table > tbody > tr + tr > td {
border-color: rgba(0, 0, 0, 0.18);
}
.vscode-dark h1,
.vscode-dark hr,
.vscode-dark table > tbody > tr + tr > td {
border-color: rgba(255, 255, 255, 0.18);
}
</style>
<style>
/* Tomorrow Theme */
/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
/* Tomorrow Comment */
.hljs-comment,
.hljs-quote {
color: #8e908c;
}
/* Tomorrow Red */
.hljs-variable,
.hljs-template-variable,
.hljs-tag,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class,
.hljs-regexp,
.hljs-deletion {
color: #c82829;
}
/* Tomorrow Orange */
.hljs-number,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params,
.hljs-meta,
.hljs-link {
color: #f5871f;
}
/* Tomorrow Yellow */
.hljs-attribute {
color: #eab700;
}
/* Tomorrow Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet,
.hljs-addition {
color: #718c00;
}
/* Tomorrow Blue */
.hljs-title,
.hljs-section {
color: #4271ae;
}
/* Tomorrow Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #8959a8;
}
.hljs {
display: block;
overflow-x: auto;
color: #4d4d4c;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}
</style>
<style>
/*
* Markdown PDF CSS
*/
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", "Ubuntu", "Droid Sans", sans-serif, "Meiryo";
padding: 0 12px;
}
pre {
background-color: #f8f8f8;
border: 1px solid #cccccc;
border-radius: 3px;
overflow-x: auto;
white-space: pre-wrap;
overflow-wrap: break-word;
}
pre:not(.hljs) {
padding: 23px;
line-height: 19px;
}
blockquote {
background: rgba(127, 127, 127, 0.1);
border-color: rgba(0, 122, 204, 0.5);
}
.emoji {
height: 1.4em;
}
code {
font-size: 14px;
line-height: 19px;
}
/* for inline code */
:not(pre):not(.hljs) > code {
color: #C9AE75; /* Change the old color so it seems less like an error */
font-size: inherit;
}
/* Page Break : use <div class="page"/> to insert page break
-------------------------------------------------------- */
.page {
page-break-after: always;
}
</style>
<script src="https://unpkg.com/mermaid/dist/mermaid.min.js"></script>
</head>
<body>
<script>
mermaid.initialize({
startOnLoad: true,
theme: document.body.classList.contains('vscode-dark') || document.body.classList.contains('vscode-high-contrast')
? 'dark'
: 'default'
});
</script>
<h1 id="readme-for-group-assignment-15">README for Group Assignment 1.5</h1>
<p><em><a href="http://mude.citg.tudelft.nl/">CEGM1000 MUDE</a>: Week 1.5, Friday, Oct 4, 2024.</em></p>
<p>Most groups did well, although there are a few minor points listed below. Most notably, <em>many</em> groups did not implement the CD method correctly. Compare your analysis to the solution carefully; you may have also already realized this as part of PA 1.6, which used an assert statement to check that the values of the CD were calculated correctly. Finally, an explanation is provided at the end of this document.</p>
<h2 id="feedback-on-individual-questions">Feedback on individual questions</h2>
<p>Q1: It does not make sense to compute for the entire year because there is no ice in summer! Therefore, the gradient cannot be calculated over multiple years. Seasonality also would mean the physical process changes, but the point is the absence of ice. Always make sure you think about the meaning of your calculations, rather than proceeding with a numerical scheme blindly.</p>
<p>Q2: Equidistance is <strong>often</strong> misunderstood for CD approach. Many groups have the wrong number of intervals and/or data points.</p>
<p>Q3: Some groups placed the evaluation point “in the middle”, however the points are not equidistant between the neighboring points (most likely cause was that you found the average of <em>three</em> points, not two).</p>
<p>Some groups place it at the days where the measurements are (not equidistant, here the resulting calculation is much further away from the value we intended).</p>
<p>Do not forget that CD is second order! This is illustrated below in the example.</p>
<p>Q4: Make sure you know your trigonometry!
Q5: Mostly very good!
Q6: Some forgot to evaluate at $x_0+5$</p>
<p>Q7: Make sure you know your trigonometry! Do not forget to evaluate your derivatives at $x_0= \pi$ and $y_0= \pi$</p>
<p>Q8: Some groups made mistakes in the code, some in the calculation, many various mistakes. Feel free to ask if your graph does not match the solution. See also the explanation below, and PA 1.6.</p>
<h2 id="feedback-on-central-difference-method">Feedback on Central Difference method</h2>
<p>In this assignment we were faced with a situation where we wanted to calculate the numerical derivatives for a series of points. These &quot;data&quot; were irregularly spaced, making the application of our typical differentiation schemes a little different than normal, in particular, the <em>central difference</em> method. Note that all three approaches (forward, backward and central) differences assume that every increment of the discretized domain (in this case, time) is equal. In other words, $\Delta t$ is always the same. This is apparent if you follow the derivations in the book (an exercise left for you to practice on your own!).</p>
<p>Actually, since since forward and backward differences use only one time step, there is not problem with the non-uniform increments, as long as you use the $\Delta t$ associated with each data point. However, since CD uses <em>two</em> increments, this approach returns incorrect results.</p>
<p>There are two approaches possible:</p>
<ol>
<li>Re-derive the CD method to take into accound unequal time steps (e.g, $\Delta t_1$ and $\Delta t_2$)</li>
<li>Apply the original method at the midpoint between the points. Assume that the numerical derivative is representative of the <em>midpoint</em> between the two points.</li>
</ol>
<p>We opted for the second approach, as it is very easy to implement. Note also that the computed value of CD with this approach will be exactly the same as the FD and BD for the left and right points, respectively. Yet it is still 2nd order accurate. Magic?! No! See illustration below to see why.</p>
<p>Although the approach of using <em>three</em> points is ok, there are a few problems here:</p>
<ol>
<li>You reduce the number of difference calculations by 1</li>
<li>You are averaging over larger time increments, and the function varies a lot (we can't adopt the &quot;normal&quot; approach of making the increments small enough for this not to matter, because we only have a small number of points)</li>
<li>Many of those who did this incorrectly applied the computed derivative at the <em>center</em> point, rather than the <em>midpoint</em> of the two outer points, which incorrectly assumes uniform time increments, as described above.</li>
</ol>
<p><strong>Why are the values of FS, BD, CD exactly the same, but CD is still 2nd order accurate?</strong> We illustrate this here with a plot that fits a polynomial function to the ice data, then also presents the numerical derivatives calculated for that function (with smaller time steps). Take a look and note the following:</p>
<ol>
<li>The same points used in GA 1.5 are illustrated; FD, BD, CD have same values, again.</li>
<li>CD always falls very close to the &quot;true&quot; derivative (the pink line)...because it is more accurate!</li>
<li>the difference between the &quot;true&quot; value and the FD and BD approximations increases as the derivative changes more (i.e., as the second derivative increases; this is not plotted). In other words: all methods are accurate for the first increment because the green line is nearly linear (constant value for the true derivative). The opposite is true near the middle and right side of the plot where the derivative is changing rapidly.</li>
</ol>
<p><img src="./central_diff_illustration.svg" alt="illustration of CD accuracy"></p>
<p><strong>End of file.</strong></p>
<span style="font-size: 75%">
&copy; Copyright 2024 <a rel="MUDE" href="http://mude.citg.tudelft.nl/">MUDE</a>, TU Delft. This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">CC BY 4.0 License</a>.
</body>
</html>
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment