50 years old , haven't sung a note in my life, but

Question: So my friend has been given a few months to live. She is incredibly strong and makes me feel like a coward for not having courage to do things that have interested me, but my fear of failure always held me back. Yet here she is facing her death without a hint of fear.
So we are  putting together a celebration of life for her. People will be singing, bands will be playing, speakers appearing, family members sharing stories. So in an attempt to change my outlook I thought I would use this as an opportunity to  sing a song to her. To show her that she has inspired me to start facing my fears in life. The problem is I've never sung a note in my life.
44 years ago, I weaseled out of a school play that involved singing. I could not deal with attention of any sort. I was physically and sexually abused a few years prior and I couldn't handle any sort of attention. I just wanted to hide and not be noticed by anyone. After all these years I can remember the teacher in charge saying "It's too bad you refuse to take part. You have one of the best voices participating". Those words stuck with me until now.
I feel like I sound terrible and can barely hit a note. Yet I downloaded one of those phone apps that gets you to hit notes and sustain them. I was quite surprised to hit some very high notes for a man of 50 years (A3). It has given me hope that with some help it may be possible to actually sing and not embarrass myself.
My question is or my questions are: Do those apps really work? Where should I go to get real help that won't put me in a situation to feel unworthy or not good enough? Any techniques to improve quickly? Basically anything you can tell me to quietly achieve my goal without putting myself in situations where I will  be laughed at. I struggle dearly with this. I'm on 2 types of anti-depressants/anti-anxiety meds. Just going to get grocery is a task not looked at with anticipation.
I know you're thinking this dude wants to go on stage and perform when he can barely go buy groceries? Yes, and I've never sang a song. I'm fairly certain my voice sounds like a bag of pots and pans clanging together.
The song I have chosen is no campfire song either, it's John Legend's "All of Me". I know right, nothing like starting off easy. I would love to hear something other than "you're nuts".
Like my friends have said. Which is actually giving me a bit more determination, as if that were possible.
Hope to hear from you soon.
Regards, the vocal newb without a clue, Mig
Comment: Regarding singing for your friend: You have no reason not to. That you sing for her at all will be more important than if it's clean, intonated etc; "technically correct". I'm no expert, but emotion is always more important than technique. That is, practice putting emotion into it.
Comment: Thanks Dawg.  It seems everyday I get a little more control of my voice. It's so weird actually. All there years and I've never taken it for a spin sort of speak.Hitting and sustaining notes is one thing, the sound I project is another.  I'm so looking forward to the event and I'm also not looking forward to it as it is a party for a dying friend.Life is so effed up sometimes
Comment: You might want to consider contacting the music department of your local university and asking to work with a graduate voice student. By exploring your own voice, you'll to manage it as well as your confidence. Your song might need to be put into a different key that is more comfortable for your voice. I have a hard time believing you trust the opinion of someone (yourself) with no musical training over others who do. Lastly, I guarantee that people will be focusing on your gesture more than your voice. If they don't, they're heartless, superficial, and missing the point.
Comment: Just on technical points: A3 isn't high (typical bass vocal range per Wikipedia is up to E4), and your range has far more to do with genetics than age.
Answer: First of all: I'm really sorry to hear about your friend. What you're aiming to do is absolutely fantastic, I hope she likes it - and as the first comment above says, the important part is in the doing, not so much how good you are (although no harm in making a nice noise !).
Don't let ANYONE tell you "you're nuts". If you want to do this, I thnk that makes you something of a legend.
I don't know about those apps but if you can get to A3 then you've probably got most pop/rock songs covered.
Regards getting help quickly:

See a vocal coach/tutor. I never have myself (been singing rock for 30 years) but the advice I've read on this site which has come from a singing coach/tutor has helped, so if you want to make quick progress, that's probably a good start.
Sing. A lot. By which I mean .. in the car, in the shower, in a lift, anywhere. just keep at it.
But don't tire yourself out. The vocal chords are operated by a set of muscles like anything else, and they can get strained, pulled etc so if it starts to ache or hurt, give it a rest for a day or so.
Don't practice, just sing. Sing because you like it. I know that sounds really happy-clappy-hippy but if your'e enjoying yourself, it comes across and is often what turns someone just mumbling lines or going through the ropes into a really great performance. Also, it's really the only way of getting better :-)
Re nerves (or fear of ebing laughed at): I was very shy about singing at first, and here's what helped me out:

Think about why you're doing this. Is it to impress everyone? Doesn't sound like it. It seems to me that there's something much deeper, for your friend and for your own confidence, which drives you- so try to put the opinions of nay-sayers in the bucket they need to be: irrelevant cynicism.
No-one wants to hear apologetic singing from someone who'd rather not be there. That does not float the boats, for the audience or the performer. So when you get a chance, sing your tits off and like you mean it, with no apology. It comes out how it comes out, and that's that. If someone doens't like it --------- hot news get ready --------> so what?

I'm not sure I've ever answered a question on stackoverflow with such urgency .. I really hope you go for this & enjoy it !
Answer: I like that, vocal newb without a clue. Might I add that you seem to have a voice. User 2808054 has all the correct answers. Your voice is a muscle, work up gradually. Love what you are doing and it will show when you do it. A vocal coach will show you how to protect your gift, how to breathe properly to conserve energy and to hit the notes with good intonation. Just one other word, prior to singing to your lovely friend, sing to somebody else first, maybe that room mate and you will know where your nervousness will make your singing fail and that knowledge will arm you against doing just that. Your friend will be carried away with your efforts. All the best, and continue to do what you love and love what you do.
E
Answer: You aren't looking for vocal hints, you're looking for confidence.  Maybe your friend's situation will help you find it.  We both know that none of the life factors you mentioned have anything to do with vocal technique, don't we?
This really is a classic case of 'just do it'.   Get the recording of the song you want to perform. I don't know it, but presumably it has some relevance to you and your friend?  Sing along with it.  Don't think vocal technique, just imitate.   You'll be OK.  Give your friend my love.
Answer: I've worked as an accompanist for several decades now and many of the most moving and meaningful experiences in that time have involved singers that were far from professionally trained.  What you're doing is beautiful regardless of anything.  My only suggestion other than the excellent ones above is to try and put yourself in a place of accepting where you are as a singer and performer and not to struggle against it or be unnecessarily apologetic about it.  Try to imagine what you want to convey and let your voice do what it naturally does - there is no need to fix it.
Also, and this might sound naïve but it's often useful to imagine as vividly as you can the situation and what you'd like to happen in the "performance".   Even experienced musicians can find the transition from what things feel like in practice to what things feels like on any sort of stage to be tricky, so its often useful to simulate that to some degree beforehand.  Sing for friends and family before the event.
Answer: Echoing Laurence's excellent answer on confidence, what would really help you (if you have time) is to join a community chorus.  In my experience the vast majority are...

welcoming to inexperienced singers
full of people just like you, who have decided (often later in life) to pursue singing
ensembles that do NOT require you to audition
led by a conductor who will place you where your voice type will be successful

In addition, rehearsals will begin with a lengthy vocal warmup.  Not only will this properly prepare your voice for singing, it should have a positive effect on your breathing, overall technique, range, and tone.
You will also meet some wonderful people and they will be great supporters of you.


Views sort criteria by date does not order properly

Question: I have a drupal 7 site with the most recent updates to core and the views module. I am trying to build a view to show three pieces of content (training events) that should display the three most recent pieces of content, based on the date field set by the user corresponding to the date of a training event (i.e. the input date set by the user, not the date of the content's creation). The date field to set to accept start and end times to show the duration of the event.
The view is based on the content type with the date field and I am trying to implement a sort criteria set on the date field in descending order.  The issue I'm having is that the dates do not order as expected: the ordering that is output is as follows: March 7th, 2019; February 2nd, 2019; and then September 27th, 2016. The ordering is also incorrect for an ascending sort, with September 27th, 2016 followed by September 5th, 2016, and then February 2nd, 2019. The sort order seems to be incorrect regardless of which field I base sort ordering on (start date or end date), so I'm not sure what's going on here. I don't have the option to specify a granularity, so I'm not sure which value the dates are actually being ordered by. The ordering seems to  disregard the ordering of months and individual dates, (e.g. ordering March before February in descending order, then ordering September 16th, 2016 before September 5th, 2016 in ascending order), so I'm not sure which value in the date the view is actually being sorted by. Any advice on how to approach this would be greatly appreciated.
Here is the export of the view:
$view = new view();
$view->name = 'upcoming_training_events';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Upcoming Training Events';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Upcoming Training Events';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
  'title' => 'title',
  'field_date_of_training' => 'field_date_of_training',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
  'title' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'field_date_of_training' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
);
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['text'] = '[title]';
$handler->display->display_options['fields']['title']['alter']['make_link'] = TRUE;
$handler->display->display_options['fields']['title']['alter']['path'] = '[field_link_to_training]';
$handler->display->display_options['fields']['title']['alter']['absolute'] = TRUE;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['title']['link_to_node'] = FALSE;
$handler->display->display_options['fields']['title']['node_in_colorbox_width'] = '600';
$handler->display->display_options['fields']['title']['node_in_colorbox_height'] = '600';
$handler->display->display_options['fields']['title']['node_in_colorbox_rel'] = '';
/* Field: Content: Training Description */
$handler->display->display_options['fields']['field_training_description']['id'] = 'field_training_description';
$handler->display->display_options['fields']['field_training_description']['table'] = 'field_data_field_training_description';
$handler->display->display_options['fields']['field_training_description']['field'] = 'field_training_description';
/* Field: Content: Date of Training */
$handler->display->display_options['fields']['field_date_of_training']['id'] = 'field_date_of_training';
$handler->display->display_options['fields']['field_date_of_training']['table'] = 'field_data_field_date_of_training';
$handler->display->display_options['fields']['field_date_of_training']['field'] = 'field_date_of_training';
$handler->display->display_options['fields']['field_date_of_training']['settings'] = array(
  'format_type' => 'long',
  'fromto' => 'both',
  'multiple_number' => '',
  'multiple_from' => '',
  'multiple_to' => '',
  'show_remaining_days' => 0,
);
/* Field: Content: Link to Training */
$handler->display->display_options['fields']['field_link_to_training']['id'] = 'field_link_to_training';
$handler->display->display_options['fields']['field_link_to_training']['table'] = 'field_data_field_link_to_training';
$handler->display->display_options['fields']['field_link_to_training']['field'] = 'field_link_to_training';
$handler->display->display_options['fields']['field_link_to_training']['label'] = '';
$handler->display->display_options['fields']['field_link_to_training']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_link_to_training']['click_sort_column'] = 'url';
$handler->display->display_options['fields']['field_link_to_training']['delta_offset'] = '0';
$handler->display->display_options['fields']['field_link_to_training']['multi_type'] = 'ul';
/* Sort criterion: Content: Date of Training -  start date (field_date_of_training) */
$handler->display->display_options['sorts']['field_date_of_training_value']['id'] = 'field_date_of_training_value';
$handler->display->display_options['sorts']['field_date_of_training_value']['table'] = 'field_data_field_date_of_training';
$handler->display->display_options['sorts']['field_date_of_training_value']['field'] = 'field_date_of_training_value';
$handler->display->display_options['sorts']['field_date_of_training_value']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'upcoming_training' => 'upcoming_training',
);

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');

UPDATE
Per comment request here are the results from drush pml grep|date Seems to be a conflict between date and commerce_cart
PHP Fatal error:  Only variables can be passed by reference in /var/www/html/phisigmarho.org/sites/all/modules/commerce/modules/cart/commerce_cart.module on line 1344
PHP Stack trace:
PHP   1. {main}() /home/nizzok/.composer/vendor/drush/drush/drush.php:0
PHP   2. drush_main() /home/nizzok/.composer/vendor/drush/drush/drush.php:11
PHP   3. Drush\Boot\BaseBoot->bootstrap_and_dispatch() /home/nizzok/.composer/vendor/drush/drush/drush.php:70
PHP   4. drush_bootstrap_to_phase() /home/nizzok/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php:56
PHP   5. drush_bootstrap() /home/nizzok/.composer/vendor/drush/drush/includes/bootstrap.inc:429
PHP   6. Drush\Boot\DrupalBoot7->bootstrap_drupal_full() /home/nizzok/.composer/vendor/drush/drush/includes/bootstrap.inc:313
PHP   7. drupal_bootstrap() /home/nizzok/.composer/vendor/drush/drush/lib/Drush/Boot/DrupalBoot7.php:74
PHP   8. _drupal_bootstrap_full() /var/www/html/phisigmarho.org/includes/bootstrap.inc:2523
PHP   9. module_load_all() /var/www/html/phisigmarho.org/includes/common.inc:5267
PHP  10. drupal_load() /var/www/html/phisigmarho.org/includes/module.inc:24
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Only variables can be passed by reference in
/var/www/html/phisigmarho.org/sites/all/modules/commerce/modules/cart/commerce_cart.module,
line 1344

Comment: Could you post and export of your view?
Comment: update text with the view export.
Comment: Could you show the output of: `drush pml | grep date`
Answer: Could you try this view.
$view = new view();
$view->name = 'upcoming_training_events';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Upcoming Training Events';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Upcoming Training Events';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
  'title' => 'title',
  'field_date_of_training' => 'field_date_of_training',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
  'title' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'field_date_of_training' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
);
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['text'] = '[title]';
$handler->display->display_options['fields']['title']['alter']['make_link'] = TRUE;
$handler->display->display_options['fields']['title']['alter']['path'] = '[field_link_to_training]';
$handler->display->display_options['fields']['title']['alter']['absolute'] = TRUE;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['title']['link_to_node'] = FALSE;
$handler->display->display_options['fields']['title']['node_in_colorbox_width'] = '600';
$handler->display->display_options['fields']['title']['node_in_colorbox_height'] = '600';
$handler->display->display_options['fields']['title']['node_in_colorbox_rel'] = '';
/* Field: Content: Training Description */
$handler->display->display_options['fields']['field_training_description']['id'] = 'field_training_description';
$handler->display->display_options['fields']['field_training_description']['table'] = 'field_data_field_training_description';
$handler->display->display_options['fields']['field_training_description']['field'] = 'field_training_description';
/* Field: Content: Date of Training */
$handler->display->display_options['fields']['field_date_of_training']['id'] = 'field_date_of_training';
$handler->display->display_options['fields']['field_date_of_training']['table'] = 'field_data_field_date_of_training';
$handler->display->display_options['fields']['field_date_of_training']['field'] = 'field_date_of_training';
$handler->display->display_options['fields']['field_date_of_training']['settings'] = array(
  'format_type' => 'long',
  'fromto' => 'both',
  'multiple_number' => '',
  'multiple_from' => '',
  'multiple_to' => '',
  'show_remaining_days' => 0,
);
/* Field: Content: Link to Training */
$handler->display->display_options['fields']['field_link_to_training']['id'] = 'field_link_to_training';
$handler->display->display_options['fields']['field_link_to_training']['table'] = 'field_data_field_link_to_training';
$handler->display->display_options['fields']['field_link_to_training']['field'] = 'field_link_to_training';
$handler->display->display_options['fields']['field_link_to_training']['label'] = '';
$handler->display->display_options['fields']['field_link_to_training']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_link_to_training']['click_sort_column'] = 'url';
$handler->display->display_options['fields']['field_link_to_training']['delta_offset'] = '0';
$handler->display->display_options['fields']['field_link_to_training']['multi_type'] = 'ul';
/* Sort criterion: Content: Date of Training -  start date (field_date_of_training) */
$handler->display->display_options['sorts']['field_date_of_training_value']['id'] = 'field_date_of_training_value';
$handler->display->display_options['sorts']['field_date_of_training_value']['table'] = 'field_data_field_date_of_training';
$handler->display->display_options['sorts']['field_date_of_training_value']['field'] = 'field_date_of_training_value';
$handler->display->display_options['sorts']['field_date_of_training_value']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'upcoming_training' => 'upcoming_training',
);
$handler->display->display_options['filters']['type']['group'] = 1;
/* Filter criterion: Content: Date of training (field_date_of_training) */
$handler->display->display_options['filters']['field_date_of_training_value']['id'] = 'field_date_of_training_value';
$handler->display->display_options['filters']['field_date_of_training_value']['table'] = 'field_data_field_date_of_training';
$handler->display->display_options['filters']['field_date_of_training_value']['field'] = 'field_date_of_training_value';
$handler->display->display_options['filters']['field_date_of_training_value']['operator'] = '>';
$handler->display->display_options['filters']['field_date_of_training_value']['group'] = 1;
$handler->display->display_options['filters']['field_date_of_training_value']['default_date'] = 'now';

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');

Comment: is this possible to configure through the UI? or should I throw together a module for this fix? It does seems to be related to a problem with the drupal_alter function. I haven't had time to look at this in depth yet.
Comment: You can import this code at _http://example.com/admin/structure/views/import_. Please make sure to backup your original view
Comment: Sorry, got reprioritized. I tried the view import and it failed without telling me why. I will have to look at the view in an editor and see if I can figure out what's wrong
Comment: Nothing in your apache/watchdog logs?
Comment: I'm going to poke around now.


Let $G$ be a group of odd order, $k$ be a number of conjugacy classes in $G$. Show that $G\equiv k\pmod{16}$. What is meant by $G\equiv k\pmod{16}$?

Question: I am struggling with this exercise:
Let $G$ be a group of odd order, let $k$ be a number of conjugacy classes in $G$. Show that $G \equiv k\pmod{16}$.
What is meant by $G \equiv k \pmod{16}$? Isn't it supposed be cardinality of the group or something like that? Not just $G$?
To be honest, I am completely lost with that.
Comment: If you are struggling with the question itself, not just with the wording, there is a thread about exactly that: https://math.stackexchange.com/questions/38694/surprising-but-simple-group-theory-result-on-conjugacy-classes
Comment: It means that $16$ divides $|G|-k$.
Comment: Use `\pmod{16}` to get the modular parenthetical symbol, and use `\equiv` for the equivalence symbol.
Comment: @lulu: Are you saying that "$G\equiv k\pmod{16}$" is a typo and should be "$|G|\equiv k \pmod{16}$", or that it is meaningful notation as written?
Comment: @Troposphere   i don't know if it is a typo because I don't have the original text.  But the classical result in this context is that $16\,|\,(|G|-k)$ so I assume that is what  the OP meant.
Comment: @lulu It was like I wrote in the original text, so probably a typo. It is from my university lectures, so not any official material.
Comment: Ok.  So, they meant to write $|G|$ when they wrote $G$.  Or whatever notation they use for the order of the group.
Comment: So now the meaning of the question has been explained to you, you need to provide some context.  You have asked three questions in rapid succession with very little context.
Comment: After you ask a question here, if you get an acceptable answer, you should "accept" the answer by clicking the check mark $\checkmark$ next to it. This scores points for you and for the person who answered your question. You can find out more about accepting answers here: [How do I accept an answer?](http://meta.math.stackexchange.com/questions/3286/), [Why should we accept answers?](http://meta.math.stackexchange.com/questions/3399/), [What should I do if someone answers my question?](https://math.stackexchange.com/help/someone-answers).
Comment: hi all, what is special about mod 16 here? why not just mod 8 or mod 4?
Answer: I believe it is a typo.
What it should read is this:
$$\lvert G\rvert\equiv k\pmod{16},$$
which means $16\mid \lvert G\rvert-k$. Here $\lvert G\rvert$ is the order of $G$.

As for the question itself, see here.
Comment: See [here](https://math.stackexchange.com/q/38694/104041), @МаринаMarinaS.
Comment: can you explain what is special about mod 16 here? (why not just mod 8 or mod 4?)


Maximizing a positive semidefinite quadratic form over the standard simplex

Question: I am attempting to maximize a positive semidefinite quadratic form over the standard simplex.
Given a symmetric positive semidefinite (Hessian) matrix $A \in \Bbb R^{d \times d}$ and a matrix $W \in \Bbb R^{d \times n}$,
$$\begin{array}{ll} \underset{z \in \Bbb R^n}{\text{maximize}} & z^\top W^\top A W z\\ \text{subject to} & \Bbb 1_n^\top z = 1\\ & z \geq \Bbb 0_n\end{array}$$
where $z_i \in [0,1]$ is a probability value used to proportionally weight each column of $W$.
I tried to solve this problem by utilizing the fact that given a constraint $z^\top z = 1$, the $z$ that maximizes $z^\top W^\top A W z$ is the first eigenvector of the matrix $A$. But I'm not sure whether this is the right way.
Thank you.
Comment: You wish to solve the problem explicitly or you're asking for numerical methods for this problem?
Comment: @TSF Sorry for the late reply, either explicit(analytical from my understanding) or numerical solution is fine. I want to get a sense of how to solve it.
Comment: Related: https://math.stackexchange.com/q/253233
Comment: It is a convex functional, so the maximum is attained at one of the vertices, i.e., it equals the largest diagonal entry of $W^TAW$.
Answer: In general your problem is a non-convex QP with potentially many local maxima (consider for instance that even in the simplest case $W^TAW = I$, every nontrivial corner of the simplex is a local maximum).
If $n$ is sufficiently small, testing all $2^n$ active sets will definitely work. I don't know an analytic solution for your specific constraints; branch-and-bound techniques might be able to solve it numerically in practice.
Comment: Thank you for the answer. Seems that my problem is tricky. Unfortunately n is not sufficiently small.
Comment: If A is a positive definite matrix instead of PSD, would my problem be solved more easily?
Comment: @JJumSSu No, that wouldn't help. To make the problem convex you'd need the matrix to be negative (semi)-definite.
Comment: I see. Thank you for the novel answer and the comment.
Comment: The suggested approach obviously won't work: consider $A=Id+J$ where $J$ is the matrix of all $1$'s, so the first eigenvector is unique and equals $(1,\dots,1)$. Do you really believe that $(1/n,\dots,1/n)$ is a maximizer? If so, compute the value and compare with that at $(1,0,\dots,0)$.
Comment: @fedja I assume that the OP intends the *largest*-eigenvalue eigenvector when they say "first", as that's what makes sense.
Comment: @user7530 Yes, that is what I mean too and it gives you a wrong answer in the example I pointed out.
Comment: @fedja I see; you're right.
Comment: What are the $2^n$ points of the active set to be tested? Must not the max occur at one of the $n$ corners of the simplex?
Comment: @Hasse1987 You are right; in general there are $2^n$ active sets, but in this problem you can skip checking all but the $n$ corresponding to simplex corners.


Can we fail jenkins build if build.xml fails which is being called through a bat script

Question: I am calling a batch file from Jenkinsfile. Through that batch file I am calling ant build.xml.
Currently though the ant build.xml is failing pipeline is executing next stage.
Is there any way to avoid this scenario?
Comment: Question is not clear, can you make it clear in description.
Answer: For the case that you are using Jenkins declarative pipeline you could add thw following to let Jenkins skip the stages after one becomes unstable:
options
 {
  skipStagesAfterUnstable()
 }


Two kinds of blues scales?

Question: I sometimes read about the major and minor blues scales.
Now, this makes me a bit confused. Are there really two kinds of blues scales?
I was told that in a 12 bar blues you play the I chord for 4 bars. Now, a piano teacher told me that in some blues the IV chord could be played in the second bar. What kind of blues would that be?
Comment: There are many questions here and they are a bit unclear
Answer: What you probably mean by minor and major blues scales are the two following scales (with root C):
C Eb F Gb G Bb (minor blues)
C D Eb E G A (major blues)
These are just the minor and major pentatonic scales with one note added. The minor pentatonic scale gets a b5 (Gb), and the major pentatonic scale gets a b3 (Eb), both to make those pentatonic scales sound bluesier. Note that both scales are modes of each other, i.e. the C minor blues scale and the Eb major blue scale have the same notes.
A standard blues uses dominant seventh chords on the I, IV, and V. For such a blues both scales can be used. The minor pentatonic scale with the added b5 (which I and many other people refer to as the blues scale) works well over all 3 chords. What some people call the major blues scale works well over the I chord, but not all of its notes work so well over the other two chords, so you have to be a bit more careful with that scale. [Note that I refer to the use of one scale with the root of the I chord over all three chords. If you change the root of the scale with every chord change (e.g., C major blues over C7, F major blues over F7, and G major blues over G7), then there are no notes that must be avoided.]
A totally different thing is a minor blues, which can be recognized by the fact that at least the I and the IV chord are minor seventh chords. In this case you obviously can't use the major pentatonic (or blues) scale, but only the (minor) blues scale.
The IV chord in the second bar, which your teacher referred to, is just a variation of the standard 12-bar blues (with dominant seventh chords), and it does not really influence the choice of scales, other than that you get a chance to sound horrible already in the second bar if you're not careful with the major blues scale.
As a final note, there are many scales that can be played over a standard 12-bar blues (if you're not afraid of sounding a bit unconventional). Guitar player Oz Noy gave a nice (albeit slightly artificial) example at a clinic: read about it and have a listen!
Comment: Interesting that the C major blues notes are the same as A minor blues notes. Rather like C maj pent. and A min pent. notes. And C full major and A natural minor notes.
Comment: @Tim: Yes, they are modes of each other. Because major and minor pent. scales are modes of each other, and the added note is chosen such that this property remains unchanged.
Comment: A couple of extra tips: The standard approach for using the major blues scale on a 12 bar (dominant) Blues progression is to use it whenever the I7 chord appears in the first 8 Bars of the progression, and use the Minor Blues scale for the rest. Both the blues scale and the major blues scale should be used on the root of the whole song, if you want to switch scales every chord use pentatonics or arpeggios. So unless there is a key change, you use only one blues scale and possibly one major blues scale along with it.
Comment: @JaySkyler: You can't use the major blues scale with the root of the I chord over the IV chord, at least not all of its notes (e.g., in C, you can't use the note E of the major blues scale over the F7 chord, which contains an Eb). This is different from the standard (minor) blues scale, which can be used over all 3 chords.
Comment: @JaySkyler: Yes, but you wrote "*both* the blues scale and the *major blues scale* should be used on the root of the whole song", which is not the case for the major blues scale. And by the way, you *can* use D blues and E blues over the respective chords, if you know how to. See [this example](http://www.mathiaslang.com/2013/11/scales-over-12-bar-blues-great-example.html).
Comment: @Matt L. I know. Read my comment again. "use it whenever the I7 chord appears in the first 8 Bars of the progression, and use the Minor Blues scale for the rest".
Comment: @JaySkyler: OK, but what about "Both the blues scale and the major blues scale should be used on the root of the whole song"? This was what caused the misunderstanding, at least for me.
Comment: @ Matt L. Ok, here's an example: If it is a 12 Bar Dominant Blues Progression in A using A7, D7, and E7 we can use A Minor blues over all 12 bars. We can also use A major Blues whenever the A7 appears in the first 8 bars. We cannot play D Blues or E Blues or D Major Blues  or E Major Blues, regardless of where we are in the progression.
Comment: @Matt L. It may have be clearer if I said "both the blues scale and the major blues scale should be constructed on the root of the whole song".  "And by the way, you can use D blues and E blues over the respective chords, if you know how to." Actually, that's not really true. You can get away with it if you put the b5 on a weak beat and enforce it with unholy rhythmic mastery, but you only use one minor blues scale unless there is a key change. You can superimpose pentatonics but  the blues scale demands to be improvised with horizontally. Even Jazz players respect this when using it.
Comment: @JaySkyler: Looks like you haven't checked out the link in my previous post. Especially the blues scale of the V chord *is* used a lot (over the V chord), and not by jazz players but by guys like Stevie Ray Vaughan, who is not really known for his unconventional note choices.
Comment: I didn't listen to it because I'm using my phone right now, but I didn't see it listed. Do you have an SRV song example? I'd be very interested to see the context he uses it in.
Comment: @JaySkyler: Listen to [Mary had a little lamb](https://www.youtube.com/watch?v=5aP2RzLNlbw): at around 1:42 he uses the blues scale (including the blue note) of the V chord, just *before* the V chord comes. It's pretty common to anticipate a chord by playing its chord scale just before the chord actually comes.
Answer: "Now, a piano teacher told me that in some blues the IV chord could be played in the second bar. What kind of blues would that be?"
I'm not sure whether it's local terminology but among the jam sessions I frequent, this is called  a fast-change blues. You play the IV chord in the second bar then return to I, then go to Iv again after a total of 4 bars as you would in the usual blues progression.
Essentially you're just putting a IV chord in for the second bar, just for that bar, just for a bit of effect. An example would be "Drink that bottle down" by the Stray Cats
Comment: @Hank re making right hand more interesting and still keeping the hook :  You could look at transitional chords - eg Hoagy Carmichael's "the old music master" is in C (it's not a blues progression) but has a part whcih goes C - F#7 -  D7 - Dm - C while the melody is fundamentally in a C scale. those chords look like they ought not to work at all but they fit very well.
Comment: Let's say I find a nice blues melody  "hook" in the A minor pentatonic scale.
Comment: Let's say I find a nice blues melody  "hook" in the A minor pentatonic scale. It would be easy to leave it like that. Now, if I'm writing a blues song for only piano it would be kind of boring if I just had: a melody and A-E and A-F# (that classical shuffle) in the left hand.  Questions: 1. How can I make the right hand more interesting and still keep the "hook" that I came up with? 2. If I have a song with a minor pentatonic scale will that become a major or minor blues (is the terms major and minor really blues terms?)? 3. Can I use other scales as well, eg the blues scale, for this song?
Comment: @Hank I was confused about major/minor blues scale too - but I play by ear so i'm not so famiiar with all the terminology.
Comment: @Hank Re other scales: You can use any scale you want. There aren't any rules in music or art, just established things that sound familiar/nice. But for example: you could take it from Am to Cmajor and keep the same melody (or scale)  for an uplifting chirpy chorus. A few songs do this like Paul Simon's "The Boy In The Bubble" or Genesis' "That's all". If you want to find your way, I'd suggest experimentation at the keyboard rather than paying too much heed to theory as a defining way of achieving a mood. The mood is in the playing :-D  (but then I would say that, as I play by ear haha)
Comment: It can also be called a quick change or fast four depending on local preference.
Answer: Blues scales don't exist, they are licks.
Ex chord I7 (ex in C) : can compose any blueslick with  combinations of ...
Descending: Notes triad mixed with descending (doubled) appoggiaturas :
     C Bes A G // G Fis F E // E Es D C Sadness - Downwards ( rem. Bes here  is not a chord note!)
Ascending: Notes triad mixed with +ascending appoggiaturas:
     C D Dis E // E F Fis G // G A C  Hope  - Pentatonic
Same principle for other degrees(Chordnote=>appoggiaturas=horizontal motion=>chordnote) Appoggiaturas create also the possibility tu use in the chord nested harmonic functionalities."
Comment: Albert - it's very difficult to understand what you are trying to say here. Matt describes the normal meaning of blues scales, so I think your first sentence doesn't work - and the rest is unreadable (to me)

Two kinds of blues scales?


create matrices from directed dyadic data

Question: I have a directed dyadic data frame that looks like this.
       ccode.a ccode.b year  mindist int.a2b
167603     220     570 1976 8.985324       0
624316     781     770 1976 7.914206       0
593896     740     620 1976 9.128673       0
669443     900     660 1976 9.235735       1
323404     434      20 1976 8.764419       0
353101     451     432 1976 5.390160       0
37109       53     700 1976 9.373724       0
624853     790       2 1976 8.949047       0
242472     355      53 1976 9.030233       0
35129       53     350 1976 9.006963       0
481129     600     140 1976 8.377329       0
621802     781     310 1976 8.885368       0
236655     350     600 1976 7.587584       0
192503     290     950 1976 9.636472       1
464722     580      94 1976 9.551535       0
550661     694      42 1976 9.377167       0
585022     712     625 1976 8.586424       0
637007     812       2 1976 8.902645       0
539818     678     572 1976 8.402542       0
690214     950     900 1976 7.859377       1
135804     160     135 1976 6.314121       0
554291     694     811 1976 8.603649       0
496453     620     680 1976 7.565657       0
68160       90     220 1976 9.003781       0
605932     770     482 1976 8.355514       0
509185     640     660 1976 4.873909       0
24928       42     830 1976 9.774045       0
454705     570     666 1976 8.740049       0
92800      100      51 1976 6.631003       1
492025     616     651 1976 7.140152       0
598335     750     663 1976 7.997375       0
485329     615     130 1976 8.951390       0
330093     435     520 1976 8.560956       0
74135       91     570 1976 9.453192       0
465351     580     235 1976 8.989404       1
227129     345     165 1976 9.296795       0
488046     615     696 1976 8.298939       0
381548     483     375 1976 8.325534       0
237750     350     840 1976 9.103709       0
402138     510     265 1976 8.688151       0
372394     475     950 1976 9.798338       0
216445     338     570 1976 8.890926       1
598308     750     660 1976 8.082419       0
613237     775     235 1976 9.100852       0
310790     420      42 1976 8.617836       0
611272     771     696 1976 8.065013       0
183450     235     551 1976 8.739090       0
659939     840     590 1976 8.879307       0
506308     640      70 1976 9.232063       0
188756     290      91 1976 9.120557       1

I want to create a matrix of all of the pairs of ccode.a and ccode.b,
d.sender <- matrix(0, nrow = 192, ncol = 192, dimnames = list(unique(dyad$ccode.a), unique(dyad$ccode.a)))

And then assign the value of int.a2b (I'll have to do this for a bunch of variables) to the appropriate cell in the matrix. This will be done separately for each year in the data set. Since the data frame is directed dyadic I'll also have a receiver matrix of the same dimension that that mirrors the sender matrix I'm trying to create now.
Answer: If I am correct in understanding what you want, here is one way:
 x <- data.frame(a=(1:3),b=(4:6),val=c(8,3,7))
 library(reshape2)

 acast(x, a~b, value.var="val")
#   4  5  6
#1  8 NA NA
#2 NA  3 NA
#3 NA NA  7

Comment: to be honest there are lots of options: e.g. `xtabs(val~a+b, data=x)` and `igraph` also has a `get.adjacency`
Comment: ah yes I didn't even think about using reshape. That works, thanks!


Looking for a function that preserves concavity

Question: Consider the function
$$
f(x,y) = g(x) y
$$
where $g$ is some other function. We can restrict ourselves to $y\geq 0$ and $0\leq x\leq 1$. I would like to find a function $g$ with the following properties:

$f$ is concave
$g(x)\geq 0 $ for $x\in [0,1]$
$g$ looks like a rough inverted U, i.e. there exists an $0<x^*<1$ such that $g$ is increasing before $x^*$ and decreasing after it.

Does such a function $g$ exist? If so it would be great to have an example. Many thanks!
Comment: $f$ can't be concave in $y$ since $\frac{\partial^2}{\partial y^2}f=0$. Do you mean $f$ is concave in $x$: $\frac{\partial^2}{\partial x^2}f<0$? If so, then I beleive an up and right shifted, down facing parabola would work (something like f(x)= -(x-.5)^2+1).
Comment: It doesn't have to be strictly concave. Weak concavity is enough.
Comment: That parabola does not work. $f$ is not concave in that case.
Answer: The Hessian of $f$ is:
$$\begin{pmatrix}g''(x)y & g'(x) \\ g'(x) & 0\end{pmatrix}$$
The eigenvalues need to be nonpositive. Since the trace is the sum of the eigenvalues and the determinant is the product of the eigenvalues, you need
$g''(x)y \leq 0$ and $-(g'(x))^2 \geq 0$.
The last condition implies that $g$ is constant.


Using passing notes in SATB writing

Question: When writing for SATB, which is the best voice in which you can use passing notes & auxiliary notes?  Also, in a music exam where the Soprano part is given to you (and you have to harmonise the given music), can you insert passing notes in the given Soprano part?
Is it alright to use passing notes in the Bass part?
The above questions are in context to a music theory exam.
Comment: My gut feeling is that you should never add notes to any given part/line in an exam. Add notes to other parts or lines. If you add notes to the exam-given line in order to avoid parallel fifths or octaves, I don't think they'll take it well.
Comment: Your textbooks, teachers, and classmates are the best resources for preparing for exams. We don't know what content is covered in what ways in the exams you're going to take.
Comment: It's certainly a good skill to have, to be able to insert passing notes like that, but to add to the idea of asking the direct sources, I'd advise you not to do it unless you're confident it's okay.
Comment: Alright. If it weren't for an exam, then you have the freedom to do whatever you want to?
Comment: That's good advice @Dekkadeci, I felt the same too.
Answer: At least in the two methods I have done (ABRSM & UNISA) you NEVER and I do mean NEVER get to change the given. As for where you can use the chromatic notes, really wherever they fit. Usually you tell the newbies to stick it in the outer voices. Usually is such hard work teaching the basics of voice leading that you just want them to learn to walk before you teach them tactics for olympic marathon running.
Just as a general guide to harmony just stick to one piece of chromaticism per harmony. This means dont go overboard with too many non-harmony notes as this can easily confuse the harmony.
Answer: Imagine SATB as a string quartet. You can there use passing notes in each voice as well.
The human ear/brain recognizes the highest and the lowest pitch the most. So if you change either of those, it will be probably the most recognizable, but that doesn't mean, that you can't do it in the other voices as well. In string quartets, the Violin II and Viola can also have passing notes and when used correctly, it sounds just as good as with the highest/lowest voice.
Comment: It always depends on the context, the exam and the teacher I would say...
If it's me, I would just ask the teacher before the exam. Ask him if it's welcome or allowed to use passing notes, or if this isn't the focus of that exam. If he tells you that you shouldn't use them, because the main focus of the exam is just how you voice the different parts for example, then of course don't do it ;)
Comment: But it wouldn't be advisable to use passing notes for a voice given in a music theory exam question, isn't it?

Using passing notes in SATB writing


Como remover imagens selecionadas dinamicamente antes do submit

Question: Gostaria de saber como posso remover imagens selecionadas do input file antes de envia-las, sou novo em JavaScript, vi diversos exemplos, porém sem a implementação com o botão "submit" e não sei como pegar esses valores, seria algo como isto:

Algo baseado num post que vi aqui na comunidade
Comment: Podes mostrar o código que estás a usar e referir eventuais bibliotecas que uses (jQuery, Boostrap, MooTools, etc...)
Answer: Olá, veja este exemplo, talvez lhe ajude:

$(document).on("click", "[data-remove-file]", function (e) {

  e.preventDefault();

  $(e.target).closest("[data-row]").remove();

});

$(document).on("submit", "form", function (e) {

  //e.preventDefault();

  $(e.target).find("[data-mark-remove-file]").each(function (i, chk) {

    if ($(chk).is(":checked"))
      $(chk).closest("[data-row]").remove();
  });

});

<form>

    <input type="file">
    <input type="checkbox" data-mark-remove-file>remove before submit
    remove now

    <input type="file">
    <input type="checkbox" data-mark-remove-file>remove before submit
    remove now

    <input type="file">
    <input type="checkbox" data-mark-remove-file>remove before submit
    remove now

<button>submit</button>

</form>
Comment: interessante sua forma de responder a questão, mas ele quer utilizar um input do multiple, e remover apenas um arquivo desse input, e não vários inputs single... Estou com o mesmo problema que ele.


Change properties of an object in an observable array with a Colorpicker

Question: I have to use data bind on the two colours of a header (one for background, one for text), but I don't want to create two separate observables, just an array with a single object with two properties: MainColor and SecondaryColor initialized with a hex value. (A colorpicker for each property changes the  colours)
I tried this way, but it doesn't work:
(js file)
function mainViewModel() {
var self = this;

    self.model = new function () {
        var model = this;
        model.myColor = ko.observable([{
            MainColor: '#0080C0',
            SecondaryColor: '#001111'
        }]);
    }

/* applyBindings is written in another method */

    self.domUtils = new function () {
        var domUtils = this;

        domUtils.initColorPicker = function (selector) {
            $('#' + selector + ' button').colpick({
                colorScheme: 'light',
                layout: 'rgbhex',
                submit: 0,
                color: function () {
                    if (selector == 'MainColor')
                        self.model.myColor()[0].MainColor;
                    else
                        self.model.myColor()[0].SecondaryColor;
                },
                onChange: function (hsb, hex, rgb, el) {
                    if (selector == 'MainColor')
                        self.model.myColor()[0].MainColor = '#' + hex;
                    else
                        self.model.myColor()[0].SecondaryColor = '#' + hex;
                 },

                onShow: function (elem) {
                    var top = parseFloat($(elem).css('top').replace('px', ''));
                    var availableHeight = $(window).height();
                    if (top + $(elem).height() > availableHeight) {
                        $(elem).css('top', (availableHeight - $(elem).height() - 20) + 'px');
                    }
                }
            });
        };

        domUtils.initColorPickers = function () {
            domUtils.initColorPicker('MainColor');
            domUtils.initColorPicker('SecondaryColor');
        };
}

(cshtml file)

#Next Class

I already verified that all this code works using single observable variables like:
model.MainColor = ko.observable('#0080C0');

But that's not the way I should follow, any thoughts on what may stop the colours from changing?
Answer: The problem might be because MainColor and SecondaryColor themselves are not observables.Knockout's 'observability' does not trickle down automatically.
Also, since you are using an array, you might be better off using a observableArray instead of a simple observable.

Your declaration will then become something like :
model.myColor = ko.observableArray([{
            MainColor: ko.observable('#0080C0'),
            SecondaryColor: ko.observable('#001111')
        }]);

Note: Rest of your code will have to be changed accordingly in light of this.
Answer: The color option only defines the initial value. Try this:
<!DOCTYPE html>

    <link rel="stylesheet" href="colpick/css/colpick.css" type="text/css"/>

#Next Class

    <button id="MainColorButton" data-bind="value: model.myColor.MainColor">Main Color</button>
    <button id="SecondaryColorButton" data-bind="model.myColor.SecondaryColor">Secondary Color</button>


How to put a php variable into an HTML form

Question: I have code that queries an SQL database and displays all of the users in a table, that all works fine, from there you are able to click any user and it displays another table that contains all of their information, that also works fine.
The problem I am running into here is on the page that displays the table of the selected users information. On that page I have a button that allows the user information to be edited and update the DB.
Here is the code for the button:
 print "<form method='post' action='adminedituser.php'>
<input type='hidden' name='id' value='$id' />
<input type='submit' value='Click here to edit this user' />
</form>";

When I click this it takes me to a page with an input box that needs to display the current username and allow the user to put in a new value and submit.
I'm trying to call a php variable inside of the HTML form I have:
<?php

$id = filter_input(INPUT_POST, "id");
//Make db connection
$conn=mysql_connect("localhost","root","")or die(mysql_error());

//Step 2: select your db to use
mysql_select_db("final",$conn);

//Step 3: Write the sql that we want to run against the database
$result = mysql_query("select id, firstname, lastname, email, phone, username, password, favchar, bio from user where id=$id");

$username = $result["username"];

?>

<form method='post' id='myForm' name='input' action='adduser.php'>
Username: <input type='text' value="<?php echo ($username); ?>" id='uName' name='uName'>
<input type='submit'>
</form>

The problem is that the variable $username is not being displayed as the text box value.
What am I doing wrong?
Comment: Add the following to the end of your mysql_query: or die(mysql_error()). Tell us what is returned, if anything.
Answer: Firstly, if I don't say it someone else is: Use mysqli instead of mysql. You can still use the procedural style, if you want (although I can say firsthand it is VERY easy to learn the object style), you just need to do a quick brush up on mysqli. Mysql is deprecated, so it is sort of useless to use. You'll have to learn it eventually, so when you're building a new program, it might be easiest.
Moving on to what you are doing wrong, is that you have not actually fetched anything. MySQL will give you an object, and then you need to sort the rows.
So, what you need to do is pull mysql_fetch_array.
You can do so like this:
while($row = mysql_fetch_array($result)) {
    $username = $row["username"];
}

Comment: Technically, no. `mysql_fetch_array` returns both numeric and associative keys at the same time. But, for the sake of clean code, I prefer `mysql_fetch_assoc`, which only returns the associative array
Comment: In order to use "username" as the index, don't you need to fetch as an associative array as in `mysqli_fetch_array($result, MYSQLI_ASSOC)`?
Comment: I also think mysql_fetch_row is very convenient when you're pulling only one result. Or mysql_fetch_object if you like the object style. The possibilities are endless!
Comment: Then I get this `Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\final\adminedituser.php on line 18`
Comment: You probably have an error in your SQL syntax. Give us the feedback of what happens when you put or die(mysql_error()) after your query() function, before the semicolon.
Answer: The form code shuld be changed to:
<input type='hidden' name='id' value='<?= $id ?>' />

You forgot to "print" the $id value.
and the code of adminedituser.php:
$id = filter_input(INPUT_POST, "id");

Get the "id" field from POST request of your form.
Comment: No dice, I can't get any value to display in the myForm, form.
Comment: It's not pulling the hidden value $id from the previous page


Question of linear transformation

Question: Given the matrices
$$M= \begin{bmatrix}
  5 & -\sqrt{3} \\
  -\sqrt{3} & 7 \\
  \end{bmatrix},$$
and
 $$N= \begin{bmatrix}
  6 & -2 \\
  -2 & 6 \\
  \end{bmatrix},$$
prove that there is a linear transformation $T ∈ L(R^2)$ and two orthonormal bases
$B=\{b_1,b_2\}$ and $V=\{v_1,v_2\}$, such that
$[T]^{B}=N$ and $[T]^{V}=M$.
I have to draw the bases and the eigenvectors of $T$.
Could someone help me with this question?
Answer: It suffices to show that $M$ and $N$ are similar via an orthonormal matrix. This follows immediately, as they are symmetric and both have characteristic polynomial $x^2 - 12x + 32$.

Question of linear transformation


Why is this function expression undefined?

Question: Can someone explain me why this function become undefined when i store it in a variable ?
model.where({'artisan.id':id}).count(function(err, doc) {
  console.log(err, doc); // this work
})

var fn = model.where({'artisan.id':id}).count;

console.log(typeof fn); // ==> 'function'

fn(function(err, doc) { // undefined is not a function
      console.log(err, doc);
})

Thanks.
Comment: @AlfonsoGarnett, if that were true then their console.log of typeof fn would show it as undefined, and their first line wouldn't work either. Abel, Are you sure that is the actual line that the error refers to?
Comment: When i call fn with a 10 seconds timeout, it's still undefined. It seems that it's the callback function that is undefined. But it doesn't make any sens...
Comment: `count` probably expects the value of `this` to refer to  a specific object, not the global object. In general `var foo = obj.foo; foo();` is not equal to `obj.foo()`.
Answer: I think the error is not thrown from the line you said, but internally from the fn function because you are executing it using wrong context.
When you say model.where(...).count(...) the count function is executed using the value returned from where() as its context, but when you fn(...) that is not happening instead the function will be executed using the window context(undefined in strict mode) where it may not be finding some required internal properties resulting in the error
var where  = model.where({
    'artisan.id': id
});

var fn = where.count;

console.log(typeof fn); // ==> 'function'

fn.call(where, function (err, doc) { // undefined is not a function
    console.log(err, doc);
})
//or
where.count(function (err, doc) {
    console.log(err, doc); // this work
})

Answer: The error is likely because you aren't actually calling count() as a method.
Assigning .count to fn only keeps a reference to the function itself. It becomes detached from the model.where({'artisan.id':id}) query object and is later invoked with the default this value -- global or undefined, depending on the use of strict mode.
At some point, it likely tries to reference another method, which won't be available through the default this, such as:
function count(callback) {
    this.method(...);      // TypeError: undefined is not a function
    // global.method(...);
}

One way to resolve this is to .bind() the method, so its this value is fixated:
var query = model.where({'artisan.id':id});
var fn = query.count.bind(query);

fn(function (...) { ... });


Is it possible to solve $\int_{0}^{1} t^4 \sqrt{1+t^2}\,dt$

Question: How should I solve the below integral?$$\int_{0}^{1} t^4 \sqrt{1+t^2}\,dt$$
Comment: Define $u = \sqrt{1+t^2}$.
Comment: @RicardoCervantes That gives I guess $\frac{1}{2} \int (u^2-1)^{3/2} u^2 du$; is that so much better than what you started with?
Comment: Integration by parts and possibly trigonometric substitution.
Comment: Try to substitute $t = i\sin(u)$, where $i$ is the imaginary unit.
Comment: The most obvious trig approach is $u=\tan(\theta)$, which gives $\sqrt{1+t^2}=\sec(\theta)$ and $dt=\sec(\theta)^2 d \theta$. The resulting trig integral is doable but difficult.
Comment: @Ricardo: Doesn't that just change the way the integrand looks? You'll still have a square root term from the $du$ part, I believe
Comment: @ it is true. iT is no bueno, I solved the exercise and I had a mistake
Comment: The change of variable $t=\sinh x$ yields $t^4=\sinh^4x$, $\sqrt{1+t^2}=\cosh x$ and $dt=\cosh x\,dx$ hence one is left with some tedious but easy integral to evaluate.
Comment: another approach sqrt(1+t^2)+t=u  https://www.wolframalpha.com/input/?i=int_0%5E1+%7Bt%5E4sqrt(1%2Bt%5E2)%7Ddt
Answer: By setting $t=\sinh u$ we get:
$$ I=\int_{0}^{\log(1+\sqrt{2})}\sinh^4(u)\cosh^2(u)\,du=\\\frac{1}{64}\int_{0}^{\log(1+\sqrt{2})}\left(4+e^{-6 u}-2 e^{-4 u}-e^{-2 u}-e^{2 u}-2 e^{4 u}+e^{6 u}\right)\,du $$
that is not a difficult integral to compute, just a tedious one. It boils down to:

$$ I = \color{red}{\frac{7}{48}\sqrt{2}+\frac{1}{16}\log(1+\sqrt{2})}.$$
Comment: Quite a bit more elegant than the trig integral that results from the substitution $u = \tan(\theta)$. +1 of course.
Comment: Another approach could be to write the integral in the form $0.5t^3*2t\sqrt{1+t^2}$ and perform integration by parts. What happens is that behind the integral sign you now get a quadratic $t$ with a squareroot. If you perform a trig or hyperbolic sub on that integral, things work out quicker because the polynomial term upfront is only a quadratic The method of Jack becomes quite easy then...
Comment: It might be less tedious to derive the recursion $$I_n={\sqrt2\over n+1}-{2n-1\over2n+2}I_{n-1}$$ where $I_n=\int_0^1t^{2n}\sqrt{1+t^2}dt$, which lets you get to $$\int_0^1t^4\sqrt{1+t^2}dt={\sqrt2\over12}+{1\over8}\int_0^1\sqrt{1+t^2}dt$$ in two steps.
Comment: I disagree that the evaluation need be so tedious! Since $\sqrt2+1$ and $1/(\sqrt2+1)=\sqrt2-1$ are algebraic conjugates, one can just store the former constant in memory and punch out exponentials as powers of the constant, knowing that the answer will be $N\times\sqrt2/D$, where $D$ is a common denominator, so $\text{answer}\times D\div\sqrt2$ will be an integer.
Answer: Starting with the integral
$$I =\int_0^1 t^4\sqrt{1+t^2}\,\text{d}t,$$
use the substitution $t = \tan(\theta)$, $\text{d}t = \sec^2(\theta)\,\text{d}\theta$; when $t = 0$, $\theta = 0$, when $t=1$, $\theta =\pi/4$. This yields the integral
$$I = \int_0^{\pi/4} \tan^4(\theta)\sqrt{1+\tan^2(\theta)}\sec^2(\theta)\,\text{d}\theta = \int_0^{\pi/4} \tan^4(\theta)\sec^3(\theta)\,\text{d}\theta$$
Now integrate by parts, using $\text{d}v = \tan^4(\theta)\sec^2(\theta)\,\text{d}\theta$, $u=\sec(\theta)$.
\begin{align}
I &= \left.\frac{1}{5}\tan^5(\theta)\sec(\theta)\right|_0^{\pi/4} - \frac{1}{5}\int_0^{\pi/4} \tan^5(\theta)\sec(\theta)\tan(\theta)\,\text{d}\theta\\
&= \left.\frac{1}{5}\tan^5(\theta)\sec(\theta)\right|_0^{\pi/4} - \frac{1}{5}\int_0^{\pi/4} \tan^6(\theta)\sec(\theta)\,\text{d}\theta\\
&=  \left.\frac{1}{5}\tan^5(\theta)\sec(\theta)\right|_0^{\pi/4} - \frac{1}{5}I + \frac{1}{5}\int_0^{\pi/4} \tan^4(\theta)\sec(\theta)\,\text{d}\theta\\
&=\frac{1}{5}\sqrt{2} - \frac{1}{5}I + \frac{1}{5}I_2
\end{align}
Now compute $I_2 = \int_0^{\pi/4} \tan^4(\theta)\sec(\theta)\,\text{d}\theta$.
\begin{align}
I_2 &= \int_0^{\pi/4} \tan^4(\theta)\sec(\theta)\,\text{d}\theta \\
&= \int_0^{\pi/4} \left(\sec^4(\theta) - 2\sec^2(\theta)+1\right)\sec(\theta)\,\text{d}\theta\\
&= \int_0^{\pi/4}\sec^5(\theta) \,\text{d}\theta - 2\int_0^{\pi/4}\sec^3(\theta)\,\text{d}\theta + \int_0^{\pi/4}\sec(\theta)\,\text{d}\theta\\
&= \int_0^{\pi/4}\sec^5(\theta)\,\text{d}\theta - \left.\left(\sec(\theta)\tan(\theta) + \ln|\sec(\theta)+\tan(\theta)|\right)\right|_0^{\pi/4} + \left.\ln|\sec(\theta)+\tan(\theta)|\right|_0^{\pi/4}\\
&= \int_0^{\pi/4} \sec^5(\theta)\,\text{d}\theta -\sqrt{2}\\
&= I_3 - \sqrt{2}
\end{align}
Now, compute $I_3 = \int_0^{\pi/4}\sec^5(\theta)\,\text{d}\theta$.
Use integration by parts, with $\text{d}v = \sec^2(\theta)\,\text{d}\theta$, $u = \sec^3(\theta)$ to get:
\begin{align}
I_3 = \int_0^{\pi/4}\sec^5(\theta)\,\text{d}\theta &= \left.\sec^3(\theta)\tan(\theta)\right|_0^{\pi/4} - \int_0^{\pi/4} 3\tan^2(\theta)\sec^3(\theta)\,\text{d}\theta\\
&=2\sqrt{2} - \int_0^{\pi/4} 3(\sec^2(\theta)-1)\sec^3(\theta)\,\text{d}\theta\\
&= 2\sqrt{2}-3I_3 + 3\int_0^{\pi/4}\sec^3(\theta)\,\text{d}\theta\\
&= 2\sqrt{2}-3I_3 + \frac{3}{2}\left(\sqrt{2}+\ln(\sqrt{2}+1)\right)
\end{align}
We conclude that
$$I_3 = \frac{7}{8}\sqrt{2} + \frac{3}{8}\ln(\sqrt{2}+1)$$
Hence \begin{align}I_2 &= -\sqrt{2}+ I_3 \\
&= -\sqrt{2}+\frac{7}{8}\sqrt{2} + \frac{3}{8}\ln(\sqrt{2}+1)\\
&= -\frac{1}{8}\sqrt{2} + \frac{3}{8}\ln(\sqrt{2}+1)
\end{align}
Concluding, we have
\begin{align}
\frac{6}{5}I &= \frac{1}{5}\sqrt{2} + \frac{1}{5}I_2\\
&= \frac{1}{5}\sqrt{2}-\frac{1}{40}\sqrt{2} +\frac{3}{40}\ln(\sqrt{2}+1)\\
&= \frac{7}{40}\sqrt{2} + \frac{3}{40}\ln(\sqrt{2}+1)
\end{align}
And hence
$$I = \frac{7}{48}\sqrt{2} + \frac{1}{16}\ln(\sqrt{2}+1)$$

I feel I should emphasize that this is not the easiest way to do this, nor is it even the most straightforward using trig substitution. However, it was what came out when I worked it out the first time from scratch, and sometimes seeing it in such a raw form can be instructive.
(Jack's method is much more elegant, but again, I am posting this to show what sometimes comes of "first attempts" that work out.)
Comment: +1 it is nice to see that sometimes trying a few different methods is needed.
Answer: Hint let $t=tan(x)$ so $dt=sec^2(x)dx$ so integral becomes $tan^4(x)sec^3(x)dx$ Now use $tan^2(x)=sec^2(x)-1$ so we get $sec^7(x)-2sec^5(x)+sec^3(x)$ now coorectly use  $\sec^2(x)dx=tan(x),d(sec^{n-2}(x))/dx=(n-2)sec^{n-3}(x)sec(x)tan(x)$


Proof for cosine formula for the dot product

Question: I'm trying to understand how the geometric and algebraic formulas for the dot product are in equal. In doing so, I first am going through the proof that $V \cdot W = ||V||||W|| \cos{\theta}$
Here's the proof and I don't follow $||V-W||^2 = (V-W) \cdot (V-W)$. It site's the rule used is "dot product of a vector with itself" but this doesn't make sense since V and W aren't the same vectors. Where am I getting confused?
LaTeX isn't working for me, I tried on FireFox and IE. Is it working for other people? It doesn't display properly.
Comment: The vector they're taking is $U=V-W$.
Answer: As mentioned in the comments the vector the book is referring to is $V-W$ which is generally not the same vector as $V$ or $W$. However its easy to prove the statement just by breaking the problem into components which is how most statements involving vectors are proven.
$$ (V-W) \cdot (V-W) $$ $$= [ (V_x-W_x) \vec{i} + (V_y-W_y)\vec{j} +(V_z-W_z)\vec{k}] \cdot [ (V_x-W_x) \vec{i} + (V_y-W_y)\vec{j} +(V_z-W_z)\vec{k}] $$ $$=  (V_x-W_x)^2 + (V_y-W_y)^2 +(V_z-W_z)^2 $$ $$= \left(\sqrt{(V_x-W_x)^2 + (V_y-W_y)^2 +(V_z-W_z)^2}\right)^2= || V-W||^2$$


Number of triangles in a graph based on number of edges

Question: Given a graph $G(V,E)$, what is the maximum number of triangles that this graph can have in terms of $|E|$?
I know that there is a triangle listing algorithm that lists all the triangles in $O(|E|^{3/2})$, but I need to prove that the number of triangles is actually $O(|E|^{3/2})$. Can anyone help me? Any tighter bound is also appreciated, but I need it to be based on $E$.
Comment: @M.Vinay Maybe, but if $|E|$ is fixed, take as few vertices as possible to force lots of triangles and the graph will be nearly complete. Also, the complete graph has ${|V| \choose 3}$ triangles, which is $O(|E|^{3/2})$, no?
Comment: @M.Vinay I did mean number of vertices, but you're right, that comment doesn't make sense.
Comment: When you say maximum, do you mean over all possible graphs on a fixed number of vertices? (In which case the complete graphs clearly achieves the maximum).
Comment: @Casteels Then $|E| = ^{|V|}C_2$. The question asks for a bound in terms of $|E|$, so clearly $|E|$ has to be fixed. Did you mean fixed number of edges with any possible number of vertices?
Comment: The question is : given that you graph has $|E|$ edges, how many triangles are there in the worst case, with respect to $|E|$ only.  It's harder than it sounds, really.  Yes a complete graph has $O(|E|^{3/2})$ triangles, but is that the worst case ?  Is there a worse setup such that you get, say, $\Theta(|E|^{3/2 + 0.1})$ triangles ?  The difficulty is that $|V|$ is irrelevant here.
Comment: @Casteels Yes, so you meant fixed number of edges, not fixed number of vertices.
Answer: So far, I came up with a proof myself, but others may help verify this proof:
Lemma. Given a graph $G(V,E)$, the number of its triangles is $O(|E|^{1.5})$.
Proof. For each node $v$, let us denote by $A(v)$ the set $\{u \in N(v), d(u) \geq d(v)\}$; this set contains only neighbors of  $v$ whose degree is no less than degree of $v$ itself.
Without loss of generality, let's consider each triangle $\Delta_{uvw}$ such that $d(u) \leq d(v) \leq d(w)$, where $d(v)$ is the degree of node $v$ in $G$. One may then discover $\Delta_{uvw}$ by checking that $w$ is in $A(u) \cap A(v)$.
Thus, we can claim that the set of triangles is $T=\{\Delta_{uvw} | (u,v) \in E, w \in A(u) \cap A(v)\}$. Therefore, we only need to prove that for every edge $(u,v) \in E$, the $|A(u)|$ and $|A(v)|$ are both $O(\sqrt{|E|})$.
Suppose $u$ has $\omega(\sqrt{|E|})$ such neighbors in $A(u)$. Since the degree of all of them is at least equal to the degree of $u$, the total number of edges become $\omega(|E|)$ which is a contradiction.
So we can claim that $|T| \in O(|E|^{1.5})$.
Comment: That's a nice way !  I think that makes sense, though to be fully convinced you'd need to show formally that $T$ misses no triangle.  The last statement would also require some more detail IMO.  For instance, say $u$ has $|E|^{0.51}$ neighbors in $A(u)$.  Then you could say that each $v \in A(u)$ has $|E|^{0.51} - 1$ edges not incident to $u$, and that we get a total of $|E|^{0.51}(|E|^{0.51} - 1)$ edges (note that we double-count edges within $A(u)$).  This is smaller than $|E|$ if $|E| = 10$ for instance.  So I think you need to show there is a certain $|E|$ from which it starts working.
Comment: Nice proof! my 2 cents: the reference to $\omega(\sqrt{|E|})$ is a bit vague to me. You could simply say that $|A(u)| = k$ implies that there are at least $k (k-1) /2 + k$ edges (first term bounds the edges incident to elements of $A(u)$ but not to $u$, taking care not to count such an edge twice; the second term counts the edges connecting $A(u)$ to $u$). From this it follows that $k \leq \sqrt{2|E|}$.
Comment: @manuellafond I need to prove that $T$ doesn't miss any triangle; About the reasoning, if we approach this prove that way: For $u$ we have $|E|^{0.5}$ neighbors in $A(u)$, and for every $v \in A(u)$ we have $(|E|^{0.5}-1)$ candidates to form the triangles. Thus it should be $|V|.(|E| - |E|^{0.5})$. But we know that $|E|^{3/2}$ is a tighter bound than $|V|.|E|$.
Answer: I'm pretty sure your proof can work out, but here's an alternative.
Let $t(e)$ be the maximum number of triangles in a graph with $e$ edges.
We want $t(e) \in O(e^{1.5})$.
As you may know, if $e = {k \choose 2}$ for some $k$, the graph with the most triangles is the complete graph on $k$ vertices, which has $O(e^{1.5})$ triangles.  So we can say there is a $c$ such that $t(e) \leq ce^{1.5}$ whenever $e = {k \choose 2}$ for some $k$.
The problematic values of $e$ are those in-between binomial values, i.e. ${ k - 1 \choose 2} < e < {k \choose 2}$.  I want to show these values of $e$ still "fit in" $O(e^{1.5})$.  Let $\delta$ be such that $e + \delta = {k \choose 2}$.
We can assume $\delta \leq e$.  That's because $e + e > 2{k-1 \choose 2} > {k \choose 2}$ whenever $k > 4$, so a $\delta > e$ will never be required to reach the next binomial (for large enough $e$).
One last thing to note : $t$ is non-decreasing.  That is, $t(e) \leq t(e + 1)$, because the maximum number of triangles we can make cannot decrease by adding an edge.
So here's what happens :
$$t(e) \leq t(e + \delta) \leq c(e + \delta)^{1.5} \leq c(2e)^{1.5} = 2^{1.5}ce^{1.5}$$
The first inequality because $t$ is non-decreasing, the second because $e + \delta = {k \choose 2}$, and the third because $\delta \leq e$ and "non-decreasingness".
So $t(e) \leq de^{1.5}$ with the constant $d = 2^{1.5}c$, and thus $t(e) \in O(e^{1.5})$.


How to detect input field change in angularjs

Question: I have group of input fields( I am not using form),I need to detect if any one of them is changed by user, before user leave the page, I need to show a popup, How can I make it happen? I need a function like checkchanges, if changes, will return false/true. something like this.
I try to use$scope.$watch and angular.forEach to loop all input ng-model, but seems like doesn't work out.
Comment: `ng-model` should apply `ng-dirty` css class to changed fields. So you can just simply look for existence of elements with this class.
Answer: As per the documentation, any inputs that where changed are given the ng-dirty class by AngularJS.
Look for any input fields with this class.
Comment: if we are editing an input field and clearing it using the backspace button the "ng-dirty" will be true. so we cant use it for showing pop up here


Polymer2.0- Trying to download DIV content of custom element

Question: I am trying to download div content of custom element using document.getElementById of the div and trying to implement download option from the JS FIddle - http://jsfiddle.net/evx9stLb/
From console, I am getting below error
pen.js:6 Uncaught TypeError: Cannot read property 'innerHTML' of null
    at download (pen.js:6)
    at HTMLButtonElement.onclick (index.html:15)
HTML:

  <base href="https://polygit.org/polymer+v2.0.0/shadycss+webcomponents+1.0.0/components/">
  <link rel="import" href="polymer/polymer.html">
  <link rel="import" href="iron-collapse/iron-collapse.html">

  <x-foo></x-foo>

<button onClick="download()">Download</button>
  <dom-module id="x-foo">
    <template>

      <button on-click="toggle">toggle collapse</button>

<iron-collapse id="collapse">

Content goes here...

</iron-collapse>

    </template>
  </dom-module>

JS:
function download(){
    var a = document.body.appendChild(
        document.createElement("a")
    );
    a.download = "export.html";
    a.href = "data:text/html," + document.getElementById("content").innerHTML;
    a.click();
}

    class XFoo extends Polymer.Element {
      static get is() { return 'x-foo'; }

      static get properties() {
        return {};

      }
         toggle() {
    this.$.collapse.toggle();
  }

    }
    customElements.define(XFoo.is, XFoo);

Code which I am below - https://codepen.io/nagasai/pen/ZyRKxj
Answer: Make some updates, and help this would help,
HTML

  <base href="https://polygit.org/polymer+v2.0.0/shadycss+webcomponents+1.0.0/components/">
  <link rel="import" href="polymer/polymer.html">
  <link rel="import" href="iron-collapse/iron-collapse.html">

  <x-foo></x-foo>

  <dom-module id="x-foo">
    <template>
<button on-click="download">Download</button>

      <button on-click="toggle">toggle collapse</button>

<iron-collapse id="collapse">

Content goes here...

</iron-collapse>

    </template>
  </dom-module>

JS
    class XFoo extends Polymer.Element {
      static get is() { return 'x-foo'; }

      static get properties() {
        return {};

      }
         toggle() {
    this.$.collapse.toggle();
  }
download(){
    var a = document.body.appendChild(
        document.createElement("a")
    );
    a.download = "export.html";
    a.href = "data:text/html," + this.$.content.innerHTML;
    a.click();
  console.log(this.$.content.innerHTML);
}

    }
    customElements.define(XFoo.is, XFoo);

https://codepen.io/renfeng/pen/BZOQro
Answer: a document query (on light dom) won't pierce the shadowDom. To do that you have to specifically select the element and query it's shadowRoot.
it would look something like this
a.href = "data:text/html," + document.getElementsByTagName('x-foo')[0].shadowRoot.querySelector('#content').innerHTML;

BUT only do this if you can't modify the element itself. It's not nice to stir around in someone else's shadowRoot.
As shown by Frank R. its far better to modify the element itself and provide a download functionality.
You can trigger this easily from an external element with something like
document.getElementsByTagName('x-foo')[0].download();

Answer: DOM under the shadow Root, or the shadow DOM, can not be accessed via innerHTML. It is not supposed to be. Just the way it is.
So, No, you simply can not get the shadow DOM contents via  innerHTML.
There used to be access now deprecated to shadowDOM via vanilla javascript earlier
and also discussed here
However, with shadow DOM V1 beig the norm now, you may have to just wait and watch if you can pierce the shadowDOM
An alternative would be, to move your entire DOM in the custom element, outside of it, Using Slots.
Slots distribute content, so, the page that uses your element, can access it via innerHTML.
You could possibly try hacky ways like the one mentioned here


Formatar datas incluindo o offset

Question: Não estou conseguindo formatar nesse padrão: 2020-10-01T11:34:00.270-03:00.
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
System.out.println(inputFormat.format(new Date()));

Answer: Esse valor -03:00 é o offset (a diferença com relação a UTC - então neste caso seriam "3 horas a menos que UTC"), e segundo a documentação, basta usar o pattern X para exibi-lo. No caso, para ter horas e minutos separados por dois-pontos, basta usar 3 letras X:
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
System.out.println(inputFormat.format(new Date())); // 2020-10-06T17:02:42.755-03:00

Lembrando que o valor do offset depende do timezone default que está configurado na JVM. No meu caso, o default (que pode ser consultado com TimeZone.getDefault()) é America/Sao_Paulo, que corresponde ao Horário de Brasília.
Mas se o timezone default for outro, será usado o offset correspondente. Ex:
// setando o timezone default para usar o fuso horário da Alemanha
TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin"));
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
System.out.println(inputFormat.format(new Date())); // 2020-10-06T22:04:44.057+02:00

Mudando o timezone default para o fuso da Alemanha, SimpleDateFormat usa o offset deste fuso. No caso, é +02:00 (pois atualmente a Europa está em horário de verão, geralmente a Alemanha usa +01:00).
Se quiser que o SimpleDateFormat sempre use um timezone específico, independente do que estiver configurado na JVM, basta setar nele:
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
// usar o Horário de Brasília, independente do timezone default da JVM
inputFormat.setTimeZone(TimeZone.getTimeZone("America/Sao_Paulo"));
System.out.println(inputFormat.format(new Date())); // 2020-10-06T17:07:06.891-03:00

Pode não parecer, mas isso é um detalhe importante, pois o timezone default é algo que pode não estar no seu controle (por exemplo, os responsáveis pelo servidor podem mudar esta configuração - sem querer ou de propósito - sem te avisar, ou outra aplicação na mesma JVM pode chamar TimeZone.setDefault(), etc). Se você depender do default, de repente o sistema pode começar a mostrar datas erradas "do nada", mas se você setar o timezone no SimpleDateFormat, essas mudanças de configuração não afetarão o seu código.
Esses nomes de timezones no formato Continente/Regiao (como America/Sao_Paulo e Europe/Berlin) são definidos pela IANA, e é possível consultar todos os disponíveis usando TimeZone.getAvailableIDs().

API java.time
Se estiver usando Java >= 8, outra opção é usar a API java.time (mais moderna e que resolve vários problemas e falhas de design de Date e SimpleDateFormat).
No caso, uma opção é usar OffsetDateTime, que é uma classe que possui a data, hora e offset (ou seja, todos os campos que você precisa):
OffsetDateTime now = OffsetDateTime.now();
System.out.println(now.toString());

Por padrão, o método toString() já retorna a data no formato que você precisa (este formato é conhecido como ISO 8601).
Vale lembrar que o método now usa o offset baseado no timezone default da JVM (ou seja, se o timezone default for o da Alemanha, ele usaria +02:00, como no exemplo anterior). Se quiser que ele use um timezone específico, independente do que está configurado na JVM, basta passar um ZoneId:
// usa o offset do Horário de Brasília, independente do timezone default configurado na JVM
OffsetDateTime now = OffsetDateTime.now(ZoneId.of("America/Sao_Paulo"));
System.out.println(now.toString());

Para consultar todos os timezones disponíveis, use ZoneId.getAvailableZoneIds().

Um detalhe é que toString pode omitir alguns campos, caso eles sejam zero:
OffsetDateTime now = OffsetDateTime.of(2020, 10, 1, 9, 0, 0, 0, ZoneOffset.ofHours(-3));
System.out.println(now.toString()); // 2020-10-01T09:00-03:00

Repare que os segundos e frações de segundo não aparecem, pois toString omite esses campos quando o valor destes é zero. Se quiser sempre mostrar esses campos, o jeito é usar um DateTimeFormatter:
OffsetDateTime now = OffsetDateTime.of(2020, 10, 1, 9, 0, 0, 0, ZoneOffset.ofHours(-3));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss.SSSXXX");
System.out.println(now.format(formatter)); // 2020-10-01T09:00:00.000-03:00

Java < 8
Se estiver usando o JDK 6 ou 7 e quiser uma alternativa melhor que Date e SimpleDateFormat, pode usar o ThreeTen Backport, um excelente backport do java.time. O código fica idêntico ao exemplo acima (as mesmas classes e métodos), a única diferença é que as classes ficam no pacote org.threeten.bp em vez de java.time (isso inclusive facilita uma futura migração para o Java 8, pois bastaria trocar os import's - além de alguns outros detalhes, explicados no final desta resposta).

E para JDK 5, uma alternativa é o Joda-Time. No caso do formato ISO 8601, já existe inclusive um método pronto:
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;

// data/hora atual em um timezone específico (para não depender do timezone default da JVM)
DateTime now = DateTime.now(DateTimeZone.forID("America/Sao_Paulo"));
DateTimeFormatter formatter = ISODateTimeFormat.dateTime();
System.out.println(formatter.print(now)); // 2020-10-07T09:31:52.822-03:00

Vale lembrar que o Joda-Time é um projeto antigo e encerrado, então sugiro que leia as considerações desta pergunta antes de decidir usá-lo.

Formatar datas incluindo o offset


Refer to proof of "every $\sigma$-finite measure is semifinite"

Question: Let $(X,\mathcal{M})$ be a measurable space. A measure $\mu: \mathcal{M} \to [0,\infty]$ is $\sigma$-finite if $X=\cup_i X_i$ where $X_i\in \mathcal{M}$ and $\mu(X_i)<\infty$ for each $i\ge 1$. A measure $\mu$ is said to be semi-finite if for any set $E\in \mathcal{M}$ with $\mu(E)=\infty$, one can find $F\subset E, F\in \mathcal{M}$ such that $0<\mu(F)<\infty$.
I read one result that and its proof

every $\sigma$-finite measure is semifinite.

The proof just takes $E=\cup_i (X_i\cap E)$ and takes $F:=X_i\cap E$, which satisfies our condition.
I am working on a similar question that if $\mu$ is $\sigma$-finite with $\mu(X)=\infty$, then for any $\epsilon>0$, there is a set $F\in \mathcal{M}$ so that $\epsilon<\mu(F)<\infty$.
I try to use a similar idea of above proof: Fix $\epsilon>0$. Let $E\in \mathcal{M}$ with $\mu(E)=\epsilon$. Consider the cover $E=\cup_i(E\cap X_i)$ and $X_i$ is as in definition of $\sigma$-finite. Let $E_j:=E\cap X_j$. Then $\mu(E_j)\le \mu(X_j)<\infty$.
However, we will get $0<\mu(E_j)<\epsilon$ for some $j$ with $E_j\in \mathcal{M}$...
Comment: As it stands, your statement : If $\mu$
is σ-finite, then for any $ϵ>0$, there is a set $F∈M$ so that $ϵ<\mu (F)<∞$ is false. Take $X=\{1,2\}, \mu({1})=\mu({2})=1, \mu(X)=2$ and $ϵ>1$.
Comment: @geetha290krm Oh, sorry, I miss one conditions $\mu(X)=\infty$.
Answer: A useful trick is to let $Y_n = \bigcup_{i=1}^n X_i$, so that $Y_n \in \mathcal{M}$, $\mu(Y_n) < \infty$, $X = \bigcup_{n=1}^\infty Y_n$, and $Y_1 \subseteq Y_2 \subseteq \dots$.  (Or to put it another way, in the definition of $\sigma$-finite, you can always assume without loss of generality that the $X_i$ are increasing.)
Now, using continuity from below, what can you say about $\mu(Y_n)$?
Comment: @Hermi: That question assumes only that the measure is semifinite.  Your question assumes $\sigma$-finite which makes things much easier.
Comment: So do you mean that from continuity from below, $\lim_{n\to \infty} \mu(Y_n)=\mu(\lim_{n\to\infty} Y_n)=\mu(X)=\infty$. So for any $\epsilon>0$, there is a $N>0$ so that for any $n>N$, $\mu(Y_n)>\epsilon$?
Comment: @Hermi: Yes, exactly.
Comment: Thank you! But I just read this question:https://math.stackexchange.com/questions/234930/if-a-measure-is-semifinite-then-there-are-sets-of-arbitrarily-large-but-finite. Why do they use more complicated way? Say define $\mathcal{F}:=\{F\subset E: E \mbox{ is measurable and } 0<\mu(F)<\infty \}$ and $C:=\sup \mu(F)$. They show that $C=\infty$...