Full Backup
|
@ -1,192 +0,0 @@
|
||||||
/*********************************************************************/
|
|
||||||
/** ACH2023 - Algoritmos e Estruturas de Dados I **/
|
|
||||||
/** EACH-USP - Segundo Semestre de 2021 **/
|
|
||||||
/** Turma 04 - Prof. Luciano Antonio Digiampietri **/
|
|
||||||
/** **/
|
|
||||||
/** EP 1 - Lista Ligada de Produtos **/
|
|
||||||
/** **/
|
|
||||||
/** Guilherme de Abreu Barreto nUSP: 12543033 **/
|
|
||||||
/** **/
|
|
||||||
/*********************************************************************/
|
|
||||||
#include "listadeprodutos.h"
|
|
||||||
|
|
||||||
PLISTA criarLista(){
|
|
||||||
PLISTA res = (PLISTA) malloc(sizeof(LISTADEPRODUTOS));
|
|
||||||
int x;
|
|
||||||
for (x=0;x<NUMTIPOS;x++){
|
|
||||||
res->LISTADELISTAS[x]=(PONT) malloc(sizeof(REGISTRO));
|
|
||||||
res->LISTADELISTAS[x]->id=-1;
|
|
||||||
res->LISTADELISTAS[x]->quantidade=0;
|
|
||||||
res->LISTADELISTAS[x]->valorUnitario=0;
|
|
||||||
res->LISTADELISTAS[x]->proxProd=NULL;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int tamanho(PLISTA l){
|
|
||||||
int tam = 0;
|
|
||||||
int x;
|
|
||||||
PONT atual;
|
|
||||||
for (x=0;x<NUMTIPOS;x++){
|
|
||||||
atual = l->LISTADELISTAS[x]->proxProd;
|
|
||||||
while (atual) {
|
|
||||||
atual = atual->proxProd;
|
|
||||||
tam++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tam;
|
|
||||||
}
|
|
||||||
|
|
||||||
PONT buscarID(PLISTA l, int id){
|
|
||||||
int x;
|
|
||||||
PONT atual;
|
|
||||||
for (x=0;x<NUMTIPOS;x++){
|
|
||||||
atual = l->LISTADELISTAS[x]->proxProd;
|
|
||||||
while (atual) {
|
|
||||||
if (atual->id == id) return atual;
|
|
||||||
atual = atual->proxProd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
PONT buscarIDTipo(PLISTA l, int id, int tipo){
|
|
||||||
if (tipo<0 || tipo>=NUMTIPOS) return NULL;
|
|
||||||
PONT atual = l->LISTADELISTAS[tipo]->proxProd;
|
|
||||||
while (atual) {
|
|
||||||
if (atual->id == id) return atual;
|
|
||||||
atual = atual->proxProd;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void buscarTudoSobre (PLISTA l, int id, int *tipo, PONT *atual, PONT *ant) {
|
|
||||||
for (*tipo = 0; *tipo < NUMTIPOS; *tipo = *tipo + 1){
|
|
||||||
*ant = l->LISTADELISTAS[*tipo];
|
|
||||||
*atual = (*ant)->proxProd;
|
|
||||||
while (*atual && (*atual)->id != id) {
|
|
||||||
*ant = *atual;
|
|
||||||
*atual = (*atual)->proxProd;
|
|
||||||
}
|
|
||||||
if (*atual)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void exibirLog(PLISTA f){
|
|
||||||
int numElementos = tamanho(f);
|
|
||||||
printf("Log lista [elementos: %i]\n", numElementos);
|
|
||||||
int x;
|
|
||||||
PONT atual;
|
|
||||||
for (x=0;x<NUMTIPOS;x++){
|
|
||||||
printf(" #TIPO: %i -> ", x);
|
|
||||||
atual = f->LISTADELISTAS[x]->proxProd;
|
|
||||||
while (atual){
|
|
||||||
printf(" [%i;%i;%i;$%i]", atual->id, atual->quantidade, atual->valorUnitario, atual->quantidade*atual->valorUnitario);
|
|
||||||
atual = atual->proxProd;
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int consultarValorUnitario(PLISTA l, int id){
|
|
||||||
int x;
|
|
||||||
PONT atual;
|
|
||||||
for (x=0;x<NUMTIPOS;x++){
|
|
||||||
atual = l->LISTADELISTAS[x]->proxProd;
|
|
||||||
while (atual) {
|
|
||||||
if (atual->id == id) return atual->valorUnitario;
|
|
||||||
atual = atual->proxProd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Anotações quanto a inserção:
|
|
||||||
|
|
||||||
- Uma lista ligada para cada tipo de produto
|
|
||||||
|
|
||||||
- PLISTA: Variável que armazena um ponteiro para a lista [array] de listas [ligadas].
|
|
||||||
|
|
||||||
- A função necessita proibir a inserção de um novo produto de mesmo identificador que um produto já presente em *qualquer uma* das listas listadas
|
|
||||||
|
|
||||||
- 0 ≤ id ≤ NUMTIPOS -1
|
|
||||||
|
|
||||||
- quantidade, valor ≥ 0
|
|
||||||
|
|
||||||
- Se o valor total for igual, inserir antes.
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool inserirNovoProduto(PLISTA l, int id, int tipo, int quantidade, int valor){
|
|
||||||
PONT p, novo;
|
|
||||||
|
|
||||||
if (id < 0 || tipo < 0 || quantidade < 0 || valor < 0 || buscarID(l, id))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
novo = malloc(sizeof(REGISTRO));
|
|
||||||
novo->id = id;
|
|
||||||
novo->quantidade = quantidade;
|
|
||||||
novo->valorUnitario = valor;
|
|
||||||
p = l->LISTADELISTAS[tipo];
|
|
||||||
|
|
||||||
while (p->proxProd
|
|
||||||
&& p->proxProd->valorUnitario * p->proxProd->quantidade < valor * quantidade)
|
|
||||||
p = p->proxProd;
|
|
||||||
|
|
||||||
novo->proxProd = p->proxProd;
|
|
||||||
p->proxProd = novo;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool removerItensDeUmProduto(PLISTA l, int id, int quantidade){
|
|
||||||
int tipo;
|
|
||||||
PONT atual, ant;
|
|
||||||
REGISTRO novo;
|
|
||||||
|
|
||||||
if (quantidade <= 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
atual = ant = NULL;
|
|
||||||
buscarTudoSobre(l, id, &tipo, &atual, &ant);
|
|
||||||
|
|
||||||
if (!atual || quantidade > atual->quantidade)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
atual->quantidade -= quantidade;
|
|
||||||
|
|
||||||
if (atual->quantidade * atual-> valorUnitario >= ant->quantidade * ant-> valorUnitario)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
novo = *atual;
|
|
||||||
ant->proxProd = atual->proxProd;
|
|
||||||
free(atual);
|
|
||||||
|
|
||||||
if (novo.quantidade == 0)
|
|
||||||
return true;
|
|
||||||
return inserirNovoProduto(l, id, tipo, novo.quantidade, novo.valorUnitario);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool atualizarValorDoProduto(PLISTA l, int id, int valor){
|
|
||||||
int tipo;
|
|
||||||
PONT atual, ant;
|
|
||||||
REGISTRO novo;
|
|
||||||
|
|
||||||
if (valor <= 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
atual = ant = NULL;
|
|
||||||
buscarTudoSobre(l, id, &tipo, &atual, &ant);
|
|
||||||
|
|
||||||
if (!atual)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
atual->valorUnitario = valor;
|
|
||||||
novo = *atual;
|
|
||||||
ant->proxProd = atual->proxProd;
|
|
||||||
free(atual);
|
|
||||||
|
|
||||||
return inserirNovoProduto(l, id, tipo, novo.quantidade, novo.valorUnitario);
|
|
||||||
}
|
|
|
@ -61,19 +61,6 @@ PONT buscarIDTipo(PLISTA l, int id, int tipo){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void buscarTudoSobre (PLISTA l, int id, int *tipo, PONT *atual, PONT *ant) {
|
|
||||||
for (*tipo = 0; *tipo < NUMTIPOS; *tipo = *tipo + 1){
|
|
||||||
*ant = l->LISTADELISTAS[*tipo];
|
|
||||||
*atual = (*ant)->proxProd;
|
|
||||||
while (*atual && (*atual)->id != id) {
|
|
||||||
*ant = *atual;
|
|
||||||
*atual = (*atual)->proxProd;
|
|
||||||
}
|
|
||||||
if (*atual)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void exibirLog(PLISTA f){
|
void exibirLog(PLISTA f){
|
||||||
int numElementos = tamanho(f);
|
int numElementos = tamanho(f);
|
||||||
printf("Log lista [elementos: %i]\n", numElementos);
|
printf("Log lista [elementos: %i]\n", numElementos);
|
||||||
|
@ -119,13 +106,41 @@ int consultarValorUnitario(PLISTA l, int id){
|
||||||
- Se o valor total for igual, inserir antes.
|
- Se o valor total for igual, inserir antes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Funções auxiliares */
|
||||||
|
|
||||||
|
bool buscarTudoSobre (PLISTA l, int id, int *tipo, PONT *atual, PONT *ant) {
|
||||||
|
for (*tipo = 0; *tipo < NUMTIPOS; *tipo = *tipo + 1){
|
||||||
|
*ant = l->LISTADELISTAS[*tipo];
|
||||||
|
*atual = (*ant)->proxProd;
|
||||||
|
while (*atual && (*atual)->id != id) {
|
||||||
|
*ant = *atual;
|
||||||
|
*atual = (*atual)->proxProd;
|
||||||
|
}
|
||||||
|
if (*atual)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void apagarRegistro(PONT atual, PONT ant) {
|
||||||
|
ant->proxProd = atual->proxProd;
|
||||||
|
free(atual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Funções principais */
|
||||||
|
|
||||||
bool inserirNovoProduto(PLISTA l, int id, int tipo, int quantidade, int valor){
|
bool inserirNovoProduto(PLISTA l, int id, int tipo, int quantidade, int valor){
|
||||||
PONT p, novo;
|
PONT p, novo;
|
||||||
|
|
||||||
if (id < 0 || tipo < 0 || quantidade < 0 || valor < 0 || buscarID(l, id))
|
if (id < 1
|
||||||
|
|| tipo < 0
|
||||||
|
|| tipo >= NUMTIPOS
|
||||||
|
|| quantidade < 1
|
||||||
|
|| valor < 1
|
||||||
|
|| buscarID(l, id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
novo = malloc(sizeof(*novo));
|
novo = malloc(sizeof(REGISTRO));
|
||||||
novo->id = id;
|
novo->id = id;
|
||||||
novo->quantidade = quantidade;
|
novo->quantidade = quantidade;
|
||||||
novo->valorUnitario = valor;
|
novo->valorUnitario = valor;
|
||||||
|
@ -141,52 +156,37 @@ bool inserirNovoProduto(PLISTA l, int id, int tipo, int quantidade, int valor){
|
||||||
}
|
}
|
||||||
|
|
||||||
bool removerItensDeUmProduto(PLISTA l, int id, int quantidade){
|
bool removerItensDeUmProduto(PLISTA l, int id, int quantidade){
|
||||||
int tipo;
|
int tipo, valor;
|
||||||
PONT atual, ant;
|
PONT atual, ant;
|
||||||
REGISTRO novo;
|
|
||||||
|
|
||||||
if (quantidade <= 0)
|
if (quantidade <= 0
|
||||||
return false;
|
|| !buscarTudoSobre(l, id, &tipo, &atual, &ant)
|
||||||
|
|| quantidade > atual->quantidade)
|
||||||
atual = ant = NULL;
|
|
||||||
buscarTudoSobre(l, id, &tipo, &atual, &ant);
|
|
||||||
|
|
||||||
if (!atual || quantidade > atual->quantidade)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
atual->quantidade -= quantidade;
|
atual->quantidade -= quantidade;
|
||||||
|
quantidade = atual->quantidade;
|
||||||
|
valor = atual->valorUnitario;
|
||||||
|
|
||||||
if (atual->quantidade * atual-> valorUnitario >= ant->quantidade * ant-> valorUnitario)
|
if (quantidade * valor > ant->quantidade * ant-> valorUnitario)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
novo = *atual;
|
apagarRegistro(atual, ant);
|
||||||
ant->proxProd = atual->proxProd;
|
|
||||||
free(atual);
|
|
||||||
|
|
||||||
if (novo.quantidade == 0)
|
if (quantidade == 0)
|
||||||
return true;
|
return true;
|
||||||
return inserirNovoProduto(l, id, tipo, novo.quantidade, novo.valorUnitario);
|
return inserirNovoProduto(l, id, tipo, quantidade, valor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool atualizarValorDoProduto(PLISTA l, int id, int valor){
|
bool atualizarValorDoProduto(PLISTA l, int id, int valor){
|
||||||
int tipo;
|
int tipo, quantidade;
|
||||||
PONT atual, ant;
|
PONT atual, ant;
|
||||||
REGISTRO novo;
|
|
||||||
|
|
||||||
if (valor <= 0)
|
if (valor <= 0 || !buscarTudoSobre(l, id, &tipo, &atual, &ant))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
atual = ant = NULL;
|
quantidade = atual->quantidade;
|
||||||
buscarTudoSobre(l, id, &tipo, &atual, &ant);
|
apagarRegistro(atual, ant);
|
||||||
|
|
||||||
if (!atual)
|
return inserirNovoProduto(l, id, tipo, quantidade, valor);
|
||||||
return false;
|
|
||||||
|
|
||||||
atual->valorUnitario = valor;
|
|
||||||
novo = *atual;
|
|
||||||
ant->proxProd = atual->proxProd;
|
|
||||||
free(atual);
|
|
||||||
|
|
||||||
return inserirNovoProduto(l, id, tipo, novo.quantidade, novo.valorUnitario);
|
|
||||||
}
|
}
|
||||||
|
|
327
Algoritmos e Estruturas de Dados I/EP 1/output.txt
Normal file
|
@ -0,0 +1,327 @@
|
||||||
|
################# INSERINDO #######################
|
||||||
|
Log lista [elementos: 0]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 ->
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 ->
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Insercao retornou true (1)
|
||||||
|
Log lista [elementos: 1]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [2;22;23;$506]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 ->
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Insercao retornou true (2)
|
||||||
|
Log lista [elementos: 2]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [2;22;23;$506]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;4;4;$16]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Insercao retornou true (3)
|
||||||
|
Log lista [elementos: 3]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;9;$72] [2;22;23;$506]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;4;4;$16]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Insercao retornou true (4)
|
||||||
|
Log lista [elementos: 4]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;9;$72] [3;22;23;$506] [2;22;23;$506]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;4;4;$16]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Insercao retornou false (5)
|
||||||
|
Log lista [elementos: 4]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;9;$72] [3;22;23;$506] [2;22;23;$506]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;4;4;$16]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Insercao retornou false (6)
|
||||||
|
Log lista [elementos: 4]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;9;$72] [3;22;23;$506] [2;22;23;$506]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;4;4;$16]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Insercao retornou false (7)
|
||||||
|
Log lista [elementos: 4]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;9;$72] [3;22;23;$506] [2;22;23;$506]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;4;4;$16]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Insercao retornou false (8)
|
||||||
|
Log lista [elementos: 4]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;9;$72] [3;22;23;$506] [2;22;23;$506]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;4;4;$16]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Insercao retornou false (9)
|
||||||
|
Log lista [elementos: 4]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;9;$72] [3;22;23;$506] [2;22;23;$506]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;4;4;$16]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
################# REMOVENDO #######################
|
||||||
|
Remocao retornou true (1)
|
||||||
|
Log lista [elementos: 4]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;9;$72] [3;22;23;$506] [2;22;23;$506]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;3;4;$12]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Remocao retornou true (2)
|
||||||
|
Log lista [elementos: 4]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;9;$72] [2;21;23;$483] [3;22;23;$506]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;3;4;$12]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Remocao retornou true (3)
|
||||||
|
Log lista [elementos: 3]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;9;$72] [2;21;23;$483]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;3;4;$12]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Remocao retornou false (4)
|
||||||
|
Log lista [elementos: 3]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;9;$72] [2;21;23;$483]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;3;4;$12]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Remocao retornou false (5)
|
||||||
|
Log lista [elementos: 3]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;9;$72] [2;21;23;$483]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;3;4;$12]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Remocao retornou false (6)
|
||||||
|
Log lista [elementos: 3]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;9;$72] [2;21;23;$483]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;3;4;$12]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
################# ATUALIZANDO VALOR #######
|
||||||
|
Atualizacao retornou true (1)
|
||||||
|
Log lista [elementos: 3]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;1;$8] [2;21;23;$483]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;3;4;$12]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Atualizacao retornou true (2)
|
||||||
|
Log lista [elementos: 3]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [2;21;23;$483] [6;8;600;$4800]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;3;4;$12]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Atualizacao retornou true (3)
|
||||||
|
Log lista [elementos: 3]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;20;$160] [2;21;23;$483]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;3;4;$12]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Atualizacao retornou false (4)
|
||||||
|
Log lista [elementos: 3]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;20;$160] [2;21;23;$483]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;3;4;$12]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Atualizacao retornou false (5)
|
||||||
|
Log lista [elementos: 3]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;20;$160] [2;21;23;$483]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;3;4;$12]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Atualizacao retornou false (6)
|
||||||
|
Log lista [elementos: 3]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;20;$160] [2;21;23;$483]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;3;4;$12]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Atualizacao retornou true (7)
|
||||||
|
Log lista [elementos: 3]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;3;$24] [2;21;23;$483]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;3;4;$12]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Atualizacao retornou true (8)
|
||||||
|
Log lista [elementos: 3]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;3;$24] [2;21;23;$483]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;3;200;$600]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
||||||
|
Atualizacao retornou true (9)
|
||||||
|
Log lista [elementos: 3]
|
||||||
|
#TIPO: 0 ->
|
||||||
|
#TIPO: 1 -> [6;8;3;$24] [2;21;20;$420]
|
||||||
|
#TIPO: 2 ->
|
||||||
|
#TIPO: 3 ->
|
||||||
|
#TIPO: 4 -> [4;3;200;$600]
|
||||||
|
#TIPO: 5 ->
|
||||||
|
#TIPO: 6 ->
|
||||||
|
#TIPO: 7 ->
|
||||||
|
#TIPO: 8 ->
|
||||||
|
#TIPO: 9 ->
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
#include "listadeprodutos.c"
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
PLISTA f = criarLista();
|
||||||
|
bool res;
|
||||||
|
|
||||||
|
exibirLog(f);
|
||||||
|
res = inserirNovoProduto(f, 3, 3, 3, 3);
|
||||||
|
if(res) printf("Insercao retornou true (1)\n");
|
||||||
|
else printf("Insercao retornou false (1)\n");
|
||||||
|
exibirLog(f);
|
||||||
|
|
||||||
|
res = inserirNovoProduto(f, 1, 2, 3, 5);
|
||||||
|
if(res) printf("Insercao retornou true (1)\n");
|
||||||
|
else printf("Insercao retornou false (1)\n");
|
||||||
|
exibirLog(f);
|
||||||
|
|
||||||
|
res = inserirNovoProduto(f, 5, 2, 7, 8);
|
||||||
|
if(res) printf("Insercao retornou true (1)\n");
|
||||||
|
else printf("Insercao retornou false (1)\n");
|
||||||
|
exibirLog(f);
|
||||||
|
|
||||||
|
res = inserirNovoProduto(f, 9, 2, 11, 12);
|
||||||
|
if(res) printf("Insercao retornou true (1)\n");
|
||||||
|
else printf("Insercao retornou false (1)\n");
|
||||||
|
exibirLog(f);
|
||||||
|
|
||||||
|
res = removerItensDeUmProduto(f, 1, 3);
|
||||||
|
if(res) printf("Remoção retornou true (1)\n");
|
||||||
|
else printf("Remoção retornou false (1)\n");
|
||||||
|
exibirLog(f);
|
||||||
|
|
||||||
|
res = removerItensDeUmProduto(f, 9, 11);
|
||||||
|
if(res) printf("Remoção retornou true (1)\n");
|
||||||
|
else printf("Remoção retornou false (1)\n");
|
||||||
|
exibirLog(f);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,4 +1,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#define array int*
|
||||||
|
|
||||||
|
/* Bubble Sort */
|
||||||
|
|
||||||
void swap (int *a, int *b) {
|
void swap (int *a, int *b) {
|
||||||
int tmp = *a;
|
int tmp = *a;
|
||||||
|
@ -6,78 +9,124 @@ void swap (int *a, int *b) {
|
||||||
*b = tmp;
|
*b = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int *merge (int *array1, int size1, int *array2, int size2) {
|
void bubbleSort (array A, int size) {
|
||||||
int k, i, j, *array3 = malloc((size1 + size2) * sizeof(*array3));
|
|
||||||
|
|
||||||
for (k = i = j = 0; k < size1 + size2; k++)
|
|
||||||
array3[k] = ((i < size1 && array1[i] <= array2[j]) || j >= size2) ? array1[i++] : array2[j++];
|
|
||||||
return array3;
|
|
||||||
}
|
|
||||||
|
|
||||||
int partition (int *array, int size) {
|
|
||||||
int i = -1, j;
|
|
||||||
|
|
||||||
for (j = 0; j < size - 1; j++)
|
|
||||||
if (array[j] <= array[size - 1])
|
|
||||||
swap(&array[++i], &array[j]);
|
|
||||||
swap(&array[++i], &array[j]);
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
void bubbleSort (int *array, int size) {
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (size <= 1)
|
if (size <= 1)
|
||||||
return;
|
return;
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
if (array[i] > array[i + 1])
|
if (A[i] > A[i + 1])
|
||||||
swap(&array[i], &array[i + 1]);
|
swap(&A[i], &A[i + 1]);
|
||||||
bubbleSort(array, size - 1);
|
bubbleSort(A, size - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void selectionSort (int *array, int size) {
|
/* Selection Sort */
|
||||||
|
|
||||||
|
int * minimalValue (array A, int size) {
|
||||||
int i, pos = 0;
|
int i, pos = 0;
|
||||||
|
|
||||||
if (size <= 1)
|
|
||||||
return;
|
|
||||||
for (i = 1; i < size; i++)
|
for (i = 1; i < size; i++)
|
||||||
if (array[i] < array[pos])
|
if (A[i] < A[pos])
|
||||||
pos = i;
|
pos = i;
|
||||||
swap(array, &array[pos]);
|
return A + pos;
|
||||||
selectionSort(array + 1, size - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void insertionSort (int *array, int size) {
|
void selectionSort (array A, int size) {
|
||||||
|
swap(A, minimalValue(A, size));
|
||||||
|
selectionSort(A + 1, size - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Insertion Sort */
|
||||||
|
|
||||||
|
void insertionSort (array A, int size) {
|
||||||
int i, tmp;
|
int i, tmp;
|
||||||
|
|
||||||
if (size <= 1)
|
if (size <= 1)
|
||||||
return;
|
return;
|
||||||
insertionSort(array, size - 1);
|
insertionSort(A, --size);
|
||||||
tmp = array[size - 1];
|
tmp = A[size--];
|
||||||
for (i = size - 2; i >= 0 && array[i] > tmp; i--)
|
for (i = size; i >= 0 && A[i] > tmp; i--)
|
||||||
array[i + 1] = array[i];
|
A[i + 1] = A[i];
|
||||||
array[i + 1] = tmp;
|
A[i + 1] = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mergeSort(int *array, int size) {
|
/* Merge Sort */
|
||||||
int *tmp, i, m = size / 2;
|
|
||||||
|
|
||||||
if (size > 1) {
|
void merge (array A, int pivot, int size) {
|
||||||
mergeSort(array, m);
|
int i, k, j = pivot;
|
||||||
mergeSort(array + m, size - m);
|
array tmp = malloc(size * sizeof(int));
|
||||||
}
|
|
||||||
tmp = merge(array, m, array + m, size - m);
|
for (i = k = 0; k < size; k++)
|
||||||
for (i = 0; i < size; i++)
|
tmp[k] = ((A[i] <= A[j] && i < pivot) || j == size) ?
|
||||||
array[i] = tmp[i];
|
A[i++] : A[j++];
|
||||||
|
for (k = 0; k < size; k++)
|
||||||
|
A[k] = tmp[k];
|
||||||
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void quickSort (int *array, int size) {
|
void mergeSort (array A, int size) {
|
||||||
int pivot;
|
int pivot;
|
||||||
|
|
||||||
if (size <= 1)
|
if (size <= 1)
|
||||||
return;
|
return;
|
||||||
pivot = partition(array, size);
|
pivot = size / 2;
|
||||||
quickSort(array, pivot);
|
mergeSort(A, pivot);
|
||||||
quickSort(array + (pivot + 1), size - (pivot + 1));
|
mergeSort(A + pivot, size - pivot);
|
||||||
|
merge(A, pivot, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Quick Sort */
|
||||||
|
|
||||||
|
int partition (array A, int size) {
|
||||||
|
int i, j, lastIndex = size - 1;
|
||||||
|
|
||||||
|
for (i = j = 0; i < lastIndex; i++)
|
||||||
|
if (A[i] <= A[lastIndex])
|
||||||
|
swap(&A[i], &A[j++]);
|
||||||
|
swap(&A[i], &A[j]);
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
|
||||||
|
void quickSort (array A, int size) {
|
||||||
|
int pivot;
|
||||||
|
|
||||||
|
if (size <= 1)
|
||||||
|
return;
|
||||||
|
pivot = partition(A, size);
|
||||||
|
quickSort(A, pivot++);
|
||||||
|
quickSort(A + pivot, size - pivot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Heap Sort */
|
||||||
|
|
||||||
|
void heapify (array A, int size, int i) {
|
||||||
|
int max = i, left = 2 * i + 1, right = left + 1;
|
||||||
|
|
||||||
|
if (left < size && A[left] > A[max])
|
||||||
|
max = left;
|
||||||
|
|
||||||
|
if (right < size && A[right] > A[max])
|
||||||
|
max = right;
|
||||||
|
|
||||||
|
if (max == i)
|
||||||
|
return;
|
||||||
|
|
||||||
|
swap(A + i, A + max);
|
||||||
|
heapify(A, size, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
void heapSort (array A, int size) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (size <= 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = (size - 1) / 2; i <= 0; i--)
|
||||||
|
heapify(A, size, i);
|
||||||
|
|
||||||
|
for (i = size - 1; i >= 0; i--) {
|
||||||
|
swap(A, A + i);
|
||||||
|
heapify(A, i, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,6 @@ int main () {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
[^1]: nUSP 12543033
|
[^1]: nUSP 12543033
|
|
@ -0,0 +1,83 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int linhas;
|
||||||
|
int colunas;
|
||||||
|
int** M;
|
||||||
|
}MATRIZ;
|
||||||
|
|
||||||
|
MATRIZ* inicializarMatriz(int linhas, int colunas){
|
||||||
|
if (linhas<=0 || colunas<=0) return NULL;
|
||||||
|
int i;
|
||||||
|
MATRIZ* mat = (MATRIZ*) malloc(sizeof(MATRIZ));
|
||||||
|
mat->M = (int**)malloc(sizeof(int*)*linhas);
|
||||||
|
for (i=0; i<linhas; i++) {
|
||||||
|
mat->M[i] = (int*)malloc(sizeof(int)*colunas);
|
||||||
|
}
|
||||||
|
mat->linhas = linhas;
|
||||||
|
mat->colunas = colunas;
|
||||||
|
return mat;
|
||||||
|
}
|
||||||
|
|
||||||
|
void imprimirMatriz(MATRIZ* mat){
|
||||||
|
int i,j;
|
||||||
|
printf("Matriz %i x %i:\n", mat->linhas, mat->colunas);
|
||||||
|
for (i=0; i<mat->linhas; i++) {
|
||||||
|
for (j=0; j<mat->colunas; j++) printf("%i ", mat->M[i][j]);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
MATRIZ *multiplicarMatrizes(MATRIZ *m1, MATRIZ *m2){
|
||||||
|
int i,j,k;
|
||||||
|
MATRIZ *res;
|
||||||
|
|
||||||
|
if (m1->colunas != m2->linhas)
|
||||||
|
return NULL;
|
||||||
|
res = inicializarMatriz(m1->linhas, m2->colunas);
|
||||||
|
for (i = 0; i < res->linhas; i++) {
|
||||||
|
for (j = 0; j < res->colunas; j++) {
|
||||||
|
res->M[i][j] = 0;
|
||||||
|
for (k = 0; k < m1->colunas; k++)
|
||||||
|
res->M[i][j] += m1->M[i][k] * m2->M[k][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
|
||||||
|
MATRIZ* m1 = inicializarMatriz(3, 2);
|
||||||
|
int i,j;
|
||||||
|
int cont = 1;
|
||||||
|
for (i=0; i<m1->linhas; i++)
|
||||||
|
for (j=0; j<m1->colunas; j++) {
|
||||||
|
m1->M[i][j] = cont;
|
||||||
|
cont++;
|
||||||
|
}
|
||||||
|
|
||||||
|
imprimirMatriz(m1);
|
||||||
|
|
||||||
|
MATRIZ* m2 = inicializarMatriz(2, 3);
|
||||||
|
for (i=0; i<m2->linhas; i++)
|
||||||
|
for (j=0; j<m2->colunas; j++) {
|
||||||
|
m2->M[i][j] = cont;
|
||||||
|
cont++;
|
||||||
|
}
|
||||||
|
|
||||||
|
imprimirMatriz(m2);
|
||||||
|
|
||||||
|
MATRIZ* m3 = multiplicarMatrizes(m1, m2);
|
||||||
|
|
||||||
|
imprimirMatriz(m3);
|
||||||
|
|
||||||
|
|
||||||
|
char c1;
|
||||||
|
printf("Pressione ENTER para terminar.\n");
|
||||||
|
scanf("%c", &c1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
24
Algoritmos e Estruturas de Dados I/Semana 09/Semana 09.md
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# Semana 09: resposta ao [exercício proposto](http://www.each.usp.br/digiampietri/ACH2023/ACH2023_AtividadeSemanal09.pdf)
|
||||||
|
|
||||||
|
> Por Guilherme de Abreu Barreto[^1]
|
||||||
|
|
||||||
|
```c
|
||||||
|
MATRIZ *multiplicarMatrizes(MATRIZ *m1, MATRIZ *m2){
|
||||||
|
int i,j,k;
|
||||||
|
MATRIZ *res;
|
||||||
|
|
||||||
|
if (m1->colunas != m2->linhas)
|
||||||
|
return NULL;
|
||||||
|
res = inicializarMatriz(m1->linhas, m2->colunas);
|
||||||
|
for (i = 0; i < res->linhas; i++) {
|
||||||
|
for (j = 0; j < res->colunas; j++) {
|
||||||
|
res->M[i][j] = 0;
|
||||||
|
for (k = 0; k < m1->colunas; k++)
|
||||||
|
res->M[i][j] += m1->M[i][k] * m2->M[k][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
[^1]: nUSP: 12543033
|
15
Algoritmos e Estruturas de Dados I/Semana 09/saidaMatriz.txt
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
Matriz 3 x 2:
|
||||||
|
1 2
|
||||||
|
3 4
|
||||||
|
5 6
|
||||||
|
|
||||||
|
Matriz 2 x 3:
|
||||||
|
7 8 9
|
||||||
|
10 11 12
|
||||||
|
|
||||||
|
Matriz 3 x 3:
|
||||||
|
27 30 33
|
||||||
|
61 68 75
|
||||||
|
95 106 117
|
||||||
|
|
||||||
|
Pressione ENTER para terminar.
|
55
Algoritmos e Estruturas de Dados I/Semana 10/Semana 10.md
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
# Semana 10: resposta ao [exercício proposto](http://www.each.usp.br/digiampietri/ACH2023/ACH2023_AtividadeSemanal10.pdf)
|
||||||
|
|
||||||
|
> Por Guilherme de Abreu Barreto[^1]
|
||||||
|
|
||||||
|
**Parte 1:** Escreva o que será impresso pela execução do código desta atividade.
|
||||||
|
|
||||||
|
**Resolução:**
|
||||||
|
|
||||||
|
```c
|
||||||
|
FuncaoZZZ (1a execucao): 1
|
||||||
|
FuncaoX (1a execucao): 3
|
||||||
|
Imprimindo (1a execucao): 3 2 1
|
||||||
|
FuncaoZZZ (2a execucao): 3
|
||||||
|
FuncaoX (2a execucao): 6
|
||||||
|
Imprimindo (2a execucao): 3 7 6 5 2 1
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parte 2:** Desenhe a arvore binária resultante da execução deste código.
|
||||||
|
|
||||||
|
**Resolução:**
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
classDiagram
|
||||||
|
Raiz --> esq1
|
||||||
|
Raiz --> dir1
|
||||||
|
dir1 --> esq2
|
||||||
|
dir1 --> dir2
|
||||||
|
esq2 --> dir3
|
||||||
|
class Raiz {
|
||||||
|
(PONT) 0x5555555592a0
|
||||||
|
chave = 1
|
||||||
|
}
|
||||||
|
class esq1 {
|
||||||
|
chave = 3
|
||||||
|
(PONT) 0x5555555592e0
|
||||||
|
}
|
||||||
|
class dir1 {
|
||||||
|
chave = 2
|
||||||
|
(PONT) 0x5555555592c0
|
||||||
|
}
|
||||||
|
class esq2 {
|
||||||
|
chave = 6
|
||||||
|
(PONT) 0x555555559750
|
||||||
|
}
|
||||||
|
class dir2 {
|
||||||
|
chave = 5
|
||||||
|
(PONT) 0x555555559730
|
||||||
|
}
|
||||||
|
class dir3 {
|
||||||
|
chave = 7
|
||||||
|
(PONT) 0x555555559710
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
[^1]: nUSP: 12543033
|
103
Algoritmos e Estruturas de Dados I/Semana 10/arvoresBinaria2.c
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#define true 1
|
||||||
|
#define false 0
|
||||||
|
typedef enum{esquerdo,direito} LADO;
|
||||||
|
typedef int bool;
|
||||||
|
typedef int TIPOCHAVE;
|
||||||
|
|
||||||
|
typedef struct aux{
|
||||||
|
TIPOCHAVE chave;
|
||||||
|
struct aux *esq, *dir;
|
||||||
|
} NO, *PONT;
|
||||||
|
|
||||||
|
PONT buscarChave(TIPOCHAVE ch, PONT raiz){
|
||||||
|
if (raiz == NULL) return NULL;
|
||||||
|
if (raiz->chave == ch) return raiz;
|
||||||
|
PONT aux = buscarChave(ch,raiz->esq);
|
||||||
|
if (aux) return aux;
|
||||||
|
return buscarChave(ch,raiz->dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void apagar(PONT raiz){
|
||||||
|
if (!raiz) return;
|
||||||
|
apagar(raiz->esq);
|
||||||
|
apagar(raiz->dir);
|
||||||
|
free(raiz);
|
||||||
|
}
|
||||||
|
|
||||||
|
PONT criarNovoNo(TIPOCHAVE ch){
|
||||||
|
PONT novoNo = (PONT)malloc(sizeof(NO));
|
||||||
|
novoNo->esq = novoNo->dir = NULL;
|
||||||
|
novoNo->chave = ch;
|
||||||
|
return novoNo;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool inserirFilho(PONT raiz, TIPOCHAVE novaChave, TIPOCHAVE chavePai, LADO lado){
|
||||||
|
PONT pai = buscarChave(chavePai,raiz);
|
||||||
|
if (!pai) return false;
|
||||||
|
PONT novo = criarNovoNo(novaChave);
|
||||||
|
if (lado == esquerdo){
|
||||||
|
apagar(pai->esq);
|
||||||
|
pai->esq = novo;
|
||||||
|
}else{
|
||||||
|
apagar(pai->dir);
|
||||||
|
pai->dir = novo;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void exibirArvoreOrdemW(PONT raiz){
|
||||||
|
if (raiz == NULL) return;
|
||||||
|
exibirArvoreOrdemW(raiz->esq);
|
||||||
|
exibirArvoreOrdemW(raiz->dir);
|
||||||
|
printf("%i ",raiz->chave);
|
||||||
|
}
|
||||||
|
|
||||||
|
int max(int a, int b){
|
||||||
|
if (a>b) return a;
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
int funcaoZZZ(PONT raiz){
|
||||||
|
if (!raiz ) return -1;
|
||||||
|
return 1 + max(funcaoZZZ(raiz->esq), funcaoZZZ(raiz->dir));
|
||||||
|
}
|
||||||
|
|
||||||
|
int funcaoX(PONT raiz){
|
||||||
|
if (!raiz ) return 0;
|
||||||
|
return 1 + funcaoX(raiz->esq) + funcaoX(raiz->dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void inicializar(PONT* raiz){
|
||||||
|
*raiz = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void criarRaiz(PONT* raiz, TIPOCHAVE novaChave){
|
||||||
|
*raiz = criarNovoNo(novaChave);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
PONT raiz;
|
||||||
|
inicializar(&raiz);
|
||||||
|
criarRaiz(&raiz,1);
|
||||||
|
inserirFilho(raiz,2,1,direito);
|
||||||
|
inserirFilho(raiz,3,1,esquerdo);
|
||||||
|
printf("FuncaoZZZ (1a execucao): %i\n",funcaoZZZ(raiz));
|
||||||
|
printf("FuncaoX (1a execucao): %i\n",funcaoX(raiz));
|
||||||
|
printf("Imprimindo (1a execucao): ");
|
||||||
|
exibirArvoreOrdemW(raiz);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
inserirFilho(raiz,4,2,esquerdo);
|
||||||
|
inserirFilho(raiz,5,2,direito);
|
||||||
|
inserirFilho(raiz,6,2,esquerdo);
|
||||||
|
inserirFilho(raiz,7,6,direito);
|
||||||
|
printf("FuncaoZZZ (2a execucao): %i\n",funcaoZZZ(raiz));
|
||||||
|
printf("FuncaoX (2a execucao): %i\n",funcaoX(raiz));
|
||||||
|
printf("Imprimindo (2a execucao): ");
|
||||||
|
exibirArvoreOrdemW(raiz);
|
||||||
|
printf("\n");
|
||||||
|
return 0;
|
||||||
|
}
|
45
Algoritmos e Estruturas de Dados I/Semana 10/binary_tree.c
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
typedef enum {left, right} side;
|
||||||
|
|
||||||
|
typedef struct node{
|
||||||
|
int value;
|
||||||
|
struct node *left, *right;
|
||||||
|
} Node;
|
||||||
|
|
||||||
|
Node * findValue (Node *parent, int value) {
|
||||||
|
Node * tmp;
|
||||||
|
|
||||||
|
if (!parent || parent->value == value)
|
||||||
|
return parent;
|
||||||
|
tmp = findValue(parent->left, value);
|
||||||
|
return (tmp) ? tmp : findValue(parent->right, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Node * newNode (int value) {
|
||||||
|
Node *new = malloc(sizeof(Node));
|
||||||
|
new->value = value;
|
||||||
|
new->left = new->right = NULL;
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
||||||
|
void createRoot (Node **root, int value) {
|
||||||
|
*root = newNode(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool setChild (Node * root, int childValue, int parentValue, side s) {
|
||||||
|
Node *child, *parent = findValue(root, parentValue);
|
||||||
|
if (!parent)
|
||||||
|
return false;
|
||||||
|
child = newNode(childValue);
|
||||||
|
if (s == left) {
|
||||||
|
child->left = parent->left;
|
||||||
|
parent->left = child;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
child->right = parent->right;
|
||||||
|
parent->right = child;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
108
Algoritmos e Estruturas de Dados I/Semana 11/binary_tree.c
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
typedef struct node{
|
||||||
|
int value;
|
||||||
|
|
||||||
|
/* Pointers to nodes which store values that are less or equal (le) and greater than (gt) the current node's. */
|
||||||
|
struct node *parent, *le, *gt;
|
||||||
|
} Node;
|
||||||
|
|
||||||
|
Node * newNode(int value){
|
||||||
|
Node *new = malloc(sizeof(Node));
|
||||||
|
new->parent = new->le = new->gt = NULL;
|
||||||
|
new->value = value;
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool insertNode(Node *root, Node *new) {
|
||||||
|
Node *branch;
|
||||||
|
|
||||||
|
if (!new)
|
||||||
|
return false;
|
||||||
|
if (!root) {
|
||||||
|
root = new;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
branch = (new->value > root->value) ? root->gt : root->le;
|
||||||
|
if (branch)
|
||||||
|
root = branch;
|
||||||
|
} while (branch);
|
||||||
|
|
||||||
|
branch = new;
|
||||||
|
new->parent = root;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Node * findNode(Node *root, int value) {
|
||||||
|
if (!root)
|
||||||
|
return NULL;
|
||||||
|
if (root->value == value)
|
||||||
|
return root;
|
||||||
|
if (root->value > value)
|
||||||
|
return findNode(root->le, value);
|
||||||
|
return findNode(root->gt, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Node * findMaxValue (Node *root) {
|
||||||
|
while (root->gt)
|
||||||
|
root = root->gt;
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rearrangeTree (Node *root, Node *branch) {
|
||||||
|
if (branch->parent != root) {
|
||||||
|
branch->parent->gt = branch->le;
|
||||||
|
branch->le = root->le;
|
||||||
|
}
|
||||||
|
branch->gt = root->gt;
|
||||||
|
}
|
||||||
|
|
||||||
|
Node * selectBranch (Node *root) {
|
||||||
|
Node *branch;
|
||||||
|
|
||||||
|
if (root->le) {
|
||||||
|
if (!root->gt)
|
||||||
|
return root->le;
|
||||||
|
branch = findMaxValue(root->le);
|
||||||
|
rearrangeTree(root, branch);
|
||||||
|
return branch;
|
||||||
|
}
|
||||||
|
return root->gt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void substituteNode (Node *n, Node *branch) {
|
||||||
|
if (n->parent) {
|
||||||
|
if (n->value < n->parent->value)
|
||||||
|
n->parent->le = branch;
|
||||||
|
else
|
||||||
|
n->parent->gt = branch;
|
||||||
|
branch->parent = n->parent;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
branch->parent = NULL;
|
||||||
|
free(n);
|
||||||
|
n = branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
Node * excludeNode(Node *root, int value) {
|
||||||
|
Node *n = findNode(root, value);
|
||||||
|
|
||||||
|
if (!n)
|
||||||
|
return n;
|
||||||
|
substituteNode(n, selectBranch(n));
|
||||||
|
return (n->parent) ? root : n;
|
||||||
|
}
|
||||||
|
|
||||||
|
int treeSize (Node *root) {
|
||||||
|
if (!root)
|
||||||
|
return 0;
|
||||||
|
return treeSize(root->le) + treeSize(root->gt) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main () {
|
||||||
|
Node *new = newNode(23), *r = NULL;
|
||||||
|
insertNode(r,new);
|
||||||
|
return 0;
|
||||||
|
}
|
2
BxComp
|
@ -1 +1 @@
|
||||||
Subproject commit 6a04e7a8fac2a8633a57908becda0e30f216dcc7
|
Subproject commit d4a659215ec8a9097e0bf8d670200112afd92dc3
|
|
@ -1,6 +1,6 @@
|
||||||
# Atividade 5
|
# Atividade 5
|
||||||
|
|
||||||
Resolução dos exercícios obrigatórios, feita por Guilherme de Abreu Barreto[^1].
|
> Resolução dos exercícios obrigatórios, feita por Guilherme de Abreu Barreto[^1].
|
||||||
|
|
||||||
## Capítulo 12.1
|
## Capítulo 12.1
|
||||||
|
|
||||||
|
|
|
@ -55,5 +55,3 @@ O comprimento de um vetor tridimensional $\textbf a = \langle a_1,a_2, a_3 \rang
|
||||||
$$
|
$$
|
||||||
|\textbf a | = \sqrt{a_1^2 + a_2^2 + a_3^2}
|
|\textbf a | = \sqrt{a_1^2 + a_2^2 + a_3^2}
|
||||||
$$
|
$$
|
||||||
|
|
||||||
|
|
||||||
|
|
105
Cálculo II/Atividade 6/Atividade 6.md
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
# Atividade 6
|
||||||
|
|
||||||
|
> Resolução dos exercícios obrigatórios, feita por Guilherme de Abreu Barreto[^1].
|
||||||
|
|
||||||
|
## Capítulo 12.3
|
||||||
|
|
||||||
|
### Exercício 39
|
||||||
|
|
||||||
|
Determine o vetor projeção e a projeção escalar de **b** sobre **a** onde
|
||||||
|
|
||||||
|
$$
|
||||||
|
\textbf a = \lang -5,12 \rang;\, \textbf b = \lang 4,6\rang
|
||||||
|
$$
|
||||||
|
|
||||||
|
### Resolução
|
||||||
|
|
||||||
|
$\text{comp}_\textbf a \textbf b = \dfrac{\textbf a \cdot \textbf b}{|\textbf a|} = \dfrac{-5 \cdot 4 + 12 \cdot 6}{\sqrt{(-5)^2 + 12^2}} = 4$
|
||||||
|
|
||||||
|
$\text{proj}_\textbf a \textbf b = \dfrac{\textbf a}{|\textbf a|}\text{comp}_\textbf a \textbf b = \dfrac 4{13}\lang-5,12\rang = \left\lang\dfrac{-20}{13}, \dfrac{48}{13} \right\rang\ \blacksquare$
|
||||||
|
|
||||||
|
### Exercício 63
|
||||||
|
|
||||||
|
A *Lei do Paralelogramo* afirma que
|
||||||
|
|
||||||
|
$$
|
||||||
|
|\textbf a + \textbf b|^2 + |\textbf a - \textbf b|^2 =
|
||||||
|
2 |\textbf a|^2 + 2|\textbf b|^2
|
||||||
|
$$
|
||||||
|
|
||||||
|
Dê uma interpretação geométrica da Lei do Paralelogramo e a demonstre
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%206/Imagens/8547e17775bc6c2b5c4708c0fc4e8a0575190eb4.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
Considere o paralelogramo acima. É possível aferir o comprimento de suas diagonais à partir do comprimento de seus lados. De fato, podemos aferi-las separadamente usando a *Lei dos Cossenos*:
|
||||||
|
|
||||||
|
$|\overline{BD}|^2 =
|
||||||
|
|\overline{AD}|^2 + |\overline{AB}|^2 - 2 |\overline{AD}||\overline{AB}|\cos \theta
|
||||||
|
$
|
||||||
|
|
||||||
|
e
|
||||||
|
|
||||||
|
$|\overline{AC}|^2 =
|
||||||
|
|\overline{AD}|^2 + |\overline{CD}|^2 - 2 |\overline{AD}||\overline{CD}|\cos(\pi - \theta)
|
||||||
|
= \\ |\overline{AD}|^2 + |\overline{CD}|^2 - 2 |\overline{AD}||\overline{CD}|[\cos \pi \cdot \cos \theta + \cancel{\sin \pi \cdot \sin \theta}] = \\
|
||||||
|
|\overline{AD}|^2 + |\overline{CD}|^2 + 2 |\overline{AD}||\overline{CD}|\cos\theta$
|
||||||
|
|
||||||
|
Substituindo o comprimento dos lados e diagonais por sua representação vetorial ($|\textbf a| = |\overline{AD}| = |\overline{BC}|$, $|\textbf b| = |\overline{AB}| = |\overline{CD}|$, $|\textbf{a + b}| = |\overline{AC}|$, $|\textbf a - \textbf b| = |\overline{BD}|$) e somando-se as equações anteriores, temos demonstrada a *Lei do Paralelogramo*:
|
||||||
|
|
||||||
|
$$
|
||||||
|
+ \begin{cases}
|
||||||
|
|\textbf a - \textbf b|^2 =
|
||||||
|
|\textbf a|^2 + |\textbf b|^2
|
||||||
|
- 2 |\textbf a||\textbf b|\cos \theta \\
|
||||||
|
|\textbf{a + b}|^2 =
|
||||||
|
|\textbf a|^2 + |\textbf b|^2
|
||||||
|
+ 2 |\textbf a||\textbf b|\cos \theta \\
|
||||||
|
\end{cases}\\\ \\ \therefore |\textbf a + \textbf b|^2 + |\textbf a - \textbf b|^2 =
|
||||||
|
2 |\textbf a|^2 + 2|\textbf b|^2\ \blacksquare
|
||||||
|
$$
|
||||||
|
|
||||||
|
## Capítulo 12.4
|
||||||
|
|
||||||
|
### Exercício 37
|
||||||
|
|
||||||
|
Utilize o produto misto para mostrar que os vetores $\textbf u = \textbf i + 5\textbf j - 2 \textbf k$, $\textbf v = 3 \textbf i - \textbf j$ e $\textbf w = 5 \textbf i + 9 \textbf j - 4 \textbf k$ são coplanares.
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
Conforme a definição de produto misto, dados vetores são complanares se o produto misto destes for igual à 0. Avaliemos o presente caso.
|
||||||
|
|
||||||
|
$ \textbf u (\textbf v \times \textbf w) =
|
||||||
|
\left|\begin{matrix}
|
||||||
|
1 & \phantom{-}5 & -2 \\ 3 & -1 & \phantom{-}0 \\ 5 & \phantom{-}9 & -4
|
||||||
|
\end{matrix}\right| =
|
||||||
|
1 \left |\begin{matrix}
|
||||||
|
-1 & \phantom{-}0 \\ \phantom{-}9 & -4
|
||||||
|
\end{matrix}\right | - 5 \left |\begin{matrix}
|
||||||
|
3 & \phantom{-}0 \\ 5 & -4
|
||||||
|
\end{matrix}\right | +
|
||||||
|
(-2) \left |\begin{matrix}
|
||||||
|
3 & -1 \\ 5 & \phantom{-}9
|
||||||
|
\end{matrix}\right | = \\\ \\
|
||||||
|
4 - 5(-12) - 2(27 + 5) = 0\ \blacksquare $
|
||||||
|
|
||||||
|
### Exercício 49
|
||||||
|
|
||||||
|
Demonstre que $(\textbf a - \textbf b) \times (\textbf a + \textbf b) = 2(\textbf a \times \textbf b)$.
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
Lembremos as seguintes propriedades:
|
||||||
|
|
||||||
|
**P1.** $|\textbf a \times \textbf b| = |\textbf a||\textbf b| \sin \theta$ onde $\theta$ é o ângulo entre **a** e **b**, $0 \le \theta \le \pi$;
|
||||||
|
|
||||||
|
**P2.** $\textbf a \times \textbf b = - \textbf b \times \textbf a$;
|
||||||
|
|
||||||
|
**P3.** $\textbf a \times (\textbf b + \textbf c) = \textbf a \times \textbf b + \textbf a \times \textbf c$;
|
||||||
|
|
||||||
|
Logo,
|
||||||
|
|
||||||
|
$(\textbf a - \textbf b) \times (\textbf a + \textbf b) = \underbrace{\textbf a \times (\textbf a + \textbf b) - \textbf b \times (\textbf a + \textbf b)}_{\textbf{P3}} = \\\ \\ \underbrace{\textbf a \times \textbf a}_{\textbf{P1}} + \textbf a \times \textbf b\ \underbrace{- \textbf b \times \textbf a}_{\textbf{P2}} - \underbrace{\textbf b \times \textbf b}_{\textbf{P1}} = \cancel{\textbf a^2\sin 0}\ + 2 (\textbf a \times \textbf b) - \cancel{\textbf b^2\sin 0}\ = 2 (\textbf a \times \textbf b)\ \blacksquare$
|
||||||
|
|
||||||
|
[^1]: nUSP 12543033; Turma 04
|
BIN
Cálculo II/Atividade 6/Imagens/2021-10-17-18-37-42-image.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
Cálculo II/Atividade 6/Imagens/2021-10-18-14-46-40-image.png
Normal file
After Width: | Height: | Size: 8.5 KiB |
BIN
Cálculo II/Atividade 6/Imagens/2021-10-18-16-19-30-image.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
Cálculo II/Atividade 6/Imagens/2021-10-18-16-55-55-image.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
Cálculo II/Atividade 6/Imagens/2021-10-18-16-56-54-image.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
Cálculo II/Atividade 6/Imagens/2021-10-19-12-39-44-image.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
Cálculo II/Atividade 6/Imagens/2021-10-19-18-56-45-image.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
Cálculo II/Atividade 6/Imagens/2021-10-21-11-14-02-image.png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
Cálculo II/Atividade 6/Imagens/2021-10-21-11-25-21-image.png
Normal file
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 5.9 KiB |
134
Cálculo II/Atividade 6/Produto Escalar.md
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
# Produto Escalar
|
||||||
|
|
||||||
|
## Definição
|
||||||
|
|
||||||
|
Se $\textbf a = \langle a_1,\dots, a_n\rangle$ e $\textbf b = \langle b_1, \dots, b_n \rangle$, então o **produto escalar** de $\textbf a$ e $\textbf b$ é o número $\textbf a \cdot \textbf b$ dado por
|
||||||
|
|
||||||
|
$$
|
||||||
|
\textbf a \cdot \textbf b = a_1b_1 + \cdots + a_nb_n
|
||||||
|
$$
|
||||||
|
|
||||||
|
Assim, para achar o produto escalar de a e b, multiplicamos as componentes correspondentes e somamos. O resultado não é um vetor. É um número real, isto é, um escalar, por isso o nome.
|
||||||
|
|
||||||
|
### Exemplos
|
||||||
|
|
||||||
|
1. $\langle 2, 4 \rangle \cdot \langle 3, -1 \rangle = 2 \cdot 3 + 4 \cdot -1 = 2$
|
||||||
|
|
||||||
|
2. $(\textbf i + 2 \textbf j - 3 \textbf k) \cdot (2 \textbf j - \textbf k) = 1 \cdot 0 + 2 \cdot 2 -3 \cdot -1 = 7$
|
||||||
|
|
||||||
|
### Propriedades
|
||||||
|
|
||||||
|
Se $\textbf a$, $\textbf b$ e $\textbf c$ são vetores de $V_3$, $\textbf e$ o vetor nulo, e $c$ um escalar, então:
|
||||||
|
|
||||||
|
1. $\textbf a \cdot \textbf a = |\textbf a |^2$
|
||||||
|
|
||||||
|
2. $\textbf a \cdot \textbf b = \textbf b \cdot \textbf a$
|
||||||
|
|
||||||
|
3. $\textbf a \cdot (\textbf b + \textbf c) = \textbf a \cdot \textbf b + \textbf a \cdot \textbf c$
|
||||||
|
|
||||||
|
4. $(c \textbf a) \cdot \textbf b = c(\textbf a \cdot \textbf b) = \textbf a \cdot (c \textbf b)$
|
||||||
|
|
||||||
|
5. $\textbf e \cdot \textbf a = 0$
|
||||||
|
|
||||||
|
## Teorema
|
||||||
|
|
||||||
|
O produto escalar $\textbf a \cdot \textbf b$ tem uma interpretação geométrica em termos do **ângulo** $\theta$ **entre** $\textbf a$ e $\textbf b$:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\textbf a \cdot \textbf b = |\textbf a| |\textbf b| \cos \theta
|
||||||
|
$$
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%206/Imagens/2021-10-17-18-37-42-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
> Figura 1
|
||||||
|
|
||||||
|
### Demonstração
|
||||||
|
|
||||||
|
Se aplicarmos a Lei dos Cossenos no triânglo $OAB$ da Figura 1, obteremos
|
||||||
|
|
||||||
|
$$
|
||||||
|
|AB|^2 = |OA|^2 + |OB|^2 - 2 |OA||OB| \cos \theta
|
||||||
|
$$
|
||||||
|
|
||||||
|
Onde $|OA| = |\textbf a|$, $|OB| = |\textbf b|$ e $|AB| = |\textbf a - \textbf b|$. Ou seja,
|
||||||
|
|
||||||
|
$|\textbf a - \textbf b|^2 = |\textbf a|^2 + |\textbf b|^2 - 2|\textbf a||\textbf b| \cos \theta = \\
|
||||||
|
|\textbf a|^2 - 2 \textbf a \cdot \textbf b + |\textbf b|^2 = |\textbf a|^2 + |\textbf b|^2 - 2|\textbf a||\textbf b| \cos \theta= \\ - 2 \textbf a \cdot \textbf b = - 2|\textbf a||\textbf b| \cos \theta = \\ \textbf a \cdot \textbf b = |\textbf a||\textbf b| \cos \theta$
|
||||||
|
|
||||||
|
### Exemplo
|
||||||
|
|
||||||
|
Determine o ângulo entre dois vetores $\textbf a = \lang 2, 2, -1\rang$ e $\textbf b \lang 5, -3, 2 \rang$.
|
||||||
|
|
||||||
|
$\textbf a \cdot \textbf b = |\textbf a| |\textbf b| \cos \theta \implies \cos \theta = \dfrac{\textbf a \cdot \textbf b}{|\textbf a| |\textbf b|} = \dfrac{2(5) + 2(-3) + 2(-1)}{\sqrt{2^2 + 2^2 + (-1)^2} \cdot \sqrt{5^2 + (-3)^2 + 2^2}} = \dfrac 2{3\sqrt{38}}$
|
||||||
|
|
||||||
|
### Casos específicos
|
||||||
|
|
||||||
|
Dois vetores $\textbf a$ e $\textbf b$ formam um ângulo
|
||||||
|
|
||||||
|
- ortogonal se $\textbf a \cdot \textbf b = 0 \implies \theta = \frac 12 \pi$;
|
||||||
|
|
||||||
|
- agudo se $\textbf a \cdot \textbf b > 0$;
|
||||||
|
|
||||||
|
- obtuso se $\textbf a \cdot \textbf b < 0$.
|
||||||
|
|
||||||
|
## Ângulos Diretores
|
||||||
|
|
||||||
|
Os ângulos $\alpha$, $\beta$ e $\gamma$ (no intervalo $[0, \pi]$) que $\textbf a$ faz com os eixos coordenados positivos $x$, $y$ e $z$.
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%206/Imagens/2021-10-18-14-46-40-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
Os cossenos desses ângulos diretores são chamados **cossenos diretores** do vetor $\textbf a$.
|
||||||
|
|
||||||
|
$$
|
||||||
|
\cos \alpha = \dfrac{a_1}{|\textbf a|};\,
|
||||||
|
\cos \beta = \dfrac{a_2}{|\textbf a|};\,
|
||||||
|
\cos \gamma = \dfrac{a_3}{|\textbf a|}.
|
||||||
|
$$
|
||||||
|
|
||||||
|
Onde
|
||||||
|
|
||||||
|
$$
|
||||||
|
\cos^2 \alpha + \cos^2 \beta + \cos^2 \gamma = 1
|
||||||
|
$$
|
||||||
|
|
||||||
|
Por isso
|
||||||
|
|
||||||
|
$$
|
||||||
|
\textbf a = \lang a_1, a_2, a_3 \rang =
|
||||||
|
\lang|\textbf a| \cos \alpha,|\textbf a| \cos \beta, |\textbf a| \cos \gamma\rang =
|
||||||
|
|\textbf a|\lang \cos \alpha, \cos \beta, \cos \gamma\rang
|
||||||
|
$$
|
||||||
|
|
||||||
|
Disso implica que
|
||||||
|
|
||||||
|
$$
|
||||||
|
\dfrac 1{|\textbf a|} \textbf a = \lang \cos \alpha, \cos \beta, \cos \gamma\rang
|
||||||
|
$$
|
||||||
|
|
||||||
|
## Projeções
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%206/Imagens/2021-10-18-16-19-30-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
A figura acima mostra as representações $\overrightarrow{PQ}$ e $\overrightarrow{PR}$ de dois vetores $\textbf a$ e $\textbf b$ com a mesma origem $P$. Se $S$ é o pé do perpendicular a partir de $R$ à reta contendo $\overrightarrow{PQ}$ , então o vetor coam representação $\overrightarrow{PS}$ é chamado **vetor projeção** de $\textbf b$ sobre $\textbf a$ e é denotado por $\text{proj}_\textbf a \textbf b$.
|
||||||
|
|
||||||
|
$$
|
||||||
|
\text{proj}_\textbf a \textbf b =
|
||||||
|
\left(\frac{\textbf a \cdot \textbf b}{|\textbf a|}\right) \frac{\textbf a }{|\textbf a|}
|
||||||
|
$$
|
||||||
|
|
||||||
|
> Onde $\frac{\textbf a }{|\textbf a|}$ é o *versor* (vetor unitário) de $\textbf a$.
|
||||||
|
|
||||||
|
A projeção escalar de $\textbf b$ sobre $\textbf a$ (também chamada componente de $\textbf b$ ao longo de $\textbf a$) $\text{comp}_\textbf a \textbf b$ é definida como o módulo com sinal do vetor projeção, cujo valor é dado pelo número $|\textbf b| \cos \theta$, onde $\theta$ é o ângulo entre $\textbf a$ e $\textbf b$.
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%206/Imagens/2021-10-18-16-55-55-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
$$
|
||||||
|
\text{comp}_\textbf a \textbf b = |\textbf b| \cos \theta =
|
||||||
|
\frac{\textbf a \cdot \textbf b}{|\textbf a|}
|
||||||
|
$$
|
||||||
|
|
||||||
|
> Observe que o vetor projeção é a projeção escalar vezes o versor de $\textbf a$:
|
||||||
|
>
|
||||||
|
> $$
|
||||||
|
> \text{proj}_\textbf a \textbf b = \frac{\textbf a }{|\textbf a|}\text{comp}_\textbf a \textbf b
|
||||||
|
> $$
|
105
Cálculo II/Atividade 6/Produto Vetorial.md
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
# O Produto Vetorial
|
||||||
|
|
||||||
|
## Definição
|
||||||
|
|
||||||
|
Se $\textbf a = \lang a_1, a_2, a_3 \rang$ e $\textbf b = \lang b_1, b_2, b_3 \rang$, então **produto vetorial** ou **cruzado** de **a** e **b** é o vetor **c** perpendicular tanto à **a** e **b** descrito por
|
||||||
|
|
||||||
|
$$
|
||||||
|
\textbf c = \textbf a \times \textbf b =
|
||||||
|
\lang a_2b_3 - a_3b_2, a_3b_1 - a_1b_3, a_1b_2 - a_2b_1 \rang
|
||||||
|
$$
|
||||||
|
|
||||||
|
> **Obs:** Definição de produto vetorial para vetores *tridimensionais*.
|
||||||
|
|
||||||
|
Por ser ortogonal tanto à **a** e **b**, tem-se que:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\textbf c \cdot \textbf a = \textbf c \cdot \textbf b = 0
|
||||||
|
= (\textbf a \times \textbf b) \cdot \textbf b
|
||||||
|
= (\textbf a \times \textbf b) \cdot \textbf a
|
||||||
|
$$
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%206/Imagens/2021-10-19-12-39-44-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
> A regra da mão direita fornece a direção de $\textbf a \times \textbf b$, ortogonal ao plano que contêm **a** e **b**.
|
||||||
|
|
||||||
|
### Propriedades
|
||||||
|
|
||||||
|
Se **a**, **b** e **c** são vetores e *c* é um escalar, então
|
||||||
|
|
||||||
|
1. $\textbf a \times \textbf a = 0$
|
||||||
|
|
||||||
|
2. $\textbf a \times \textbf b = - \textbf b \times \textbf a$
|
||||||
|
|
||||||
|
3. $(c \textbf a) \times \textbf b = c(\textbf a \times \textbf b) = \textbf a \times (c\textbf b)$
|
||||||
|
|
||||||
|
4. $\textbf a \times (\textbf b + \textbf c) = \textbf a \times \textbf b + \textbf a \times \textbf c$
|
||||||
|
|
||||||
|
5. $(\textbf a + \textbf b) \times \textbf c = \textbf a \times \textbf c + \textbf b \times \textbf c$
|
||||||
|
|
||||||
|
6. $\textbf a (\textbf b \times \textbf c) = (\textbf a \times \textbf b) \cdot \textbf c$
|
||||||
|
|
||||||
|
7. $\textbf a \times (\textbf b \times \textbf c) =
|
||||||
|
(\textbf a \cdot \textbf c)\textbf b - (\textbf a \cdot \textbf b)\textbf c$
|
||||||
|
|
||||||
|
### Exemplo
|
||||||
|
|
||||||
|
Encontre um vetor perpendicular ao plano que passa pelos pontos
|
||||||
|
|
||||||
|
$$
|
||||||
|
P(1, 4, 6), Q(-2, 5, -1), R(1, -1, 1)
|
||||||
|
$$
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
O vetor $\overrightarrow{PQ} \times \overrightarrow{PR}$ é perpendicular a ambos $\overrightarrow{PQ}$ e $\overrightarrow{PR}$ e, portanto, perpendicular ao plano que passa por $P$, $Q$ e $R$. Tem-se que:
|
||||||
|
|
||||||
|
$\overrightarrow{PQ} = (-2 - 1)\textbf i + (5 - 4)\textbf j + (-1 - 6)\textbf k = - 3\textbf i + \textbf j - 7\textbf k \\ \overrightarrow{PR} = (1 - 1)\textbf i + (-1 -4)\textbf j + (1 - 6)\textbf k = -5 \textbf j - 5 \textbf k \\
|
||||||
|
\overrightarrow{PQ} \times \overrightarrow{PR} = \lang 1(-5) + 7(-5), -7(0) + 3(-5), -3(-5) - 1(0) \rang\\ = \lang-40,-15,15\rang = -5\lang 8,3,-3 \rang$
|
||||||
|
|
||||||
|
Assim, temos que $\lang-40,-15,15\rang$ é perpendicular ao plano e, no mais, todo múltiplo não nulo de $\lang 8,3,-3 \rang$ também o é.
|
||||||
|
|
||||||
|
## Teorema
|
||||||
|
|
||||||
|
Se $\theta$ é o ângulo entre **a** e **b**, $0 \le \theta \le \pi$, então
|
||||||
|
|
||||||
|
$$
|
||||||
|
|\textbf a \times \textbf b| = |\textbf a||\textbf b| \sin \theta = A
|
||||||
|
$$
|
||||||
|
|
||||||
|
Onde $A$ é a área descrita pelo paralelogramo formado entre os vetores. Assim, dois vetores são paralelos entre si se $\theta = k\pi$, $k \in \Z$.
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%206/Imagens/2021-10-19-18-56-45-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
### Caso específico
|
||||||
|
|
||||||
|
A ideia de produto vetorial aparece muito frequentemente em física. Por exemplo, ao apertarmos um parafuso aplicando uma força a uma chave de boca iremos girar o parafuso). O torque $\tau$ (em relação à origem) é definido
|
||||||
|
como sendo o produto cruzado dos vetores posição e força:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\tau = \textbf r \times \textbf F
|
||||||
|
$$
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%206/Imagens/2021-10-21-11-25-21-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
Posto em termos da definição de produto vetorial, isso seria equivalente à
|
||||||
|
|
||||||
|
$$
|
||||||
|
|\tau| = |\textbf r \times \textbf F| = |\textbf r||\textbf F| \sin \theta
|
||||||
|
$$
|
||||||
|
|
||||||
|
## Produtos Triplos
|
||||||
|
|
||||||
|
O produto $\textbf a \cdot (\textbf b \times \textbf c)$ que ocorre na Propriedade 5 da definição de produto vetorial é chamado **produto misto ou produto triplo escalar** dos vetores **a**, **b** e **c**. O significado geométrico do produto misto pode ser visto considerando-se o paralelepípedo determinado pelos vetores **a**, **b** e **c**.
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%206/Imagens/2021-10-21-11-14-02-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
Assim sendo, o volume do paralelepípedo determinado pelos vetores a, b e c é o módulo do produto misto:
|
||||||
|
|
||||||
|
$$
|
||||||
|
V = | \textbf a \cdot (\textbf b \times \textbf c)|
|
||||||
|
$$
|
||||||
|
|
||||||
|
### Caso específico
|
||||||
|
|
||||||
|
Se usarmos a fórmula anterior e descobrirmos que o volume do paralelepípedo determinado por **a**, **b** e **c** é 0, então os três vetores precisam pertencer ao mesmo plano; ou seja eles são **coplanares**.
|
60
Cálculo II/Atividade 7/Atividade 7.md
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
# Atividade 7
|
||||||
|
|
||||||
|
> Resolução dos exercícios obrigatórios, feita por Guilherme de Abreu Barreto[^1].
|
||||||
|
|
||||||
|
## Capítulo 12.5
|
||||||
|
|
||||||
|
### Exercício 41
|
||||||
|
|
||||||
|
Use as intersecções com os eixos coordenados como uma ajuda para esboçar o plano $2x + 5y + z = 10$.
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%207/Imagens/2021-11-02-19-14-54-image.png)
|
||||||
|
|
||||||
|
O plano cruza
|
||||||
|
|
||||||
|
- o eixo x em $2x + 5(0) + (0) = 10 \implies x = 5$
|
||||||
|
|
||||||
|
- o eixo y em $2(0) + 5y + (0) = 10 \implies y = 2$
|
||||||
|
|
||||||
|
- o eixo z em $2(0) + 5(0) + z = 10 \implies z = 10$
|
||||||
|
|
||||||
|
### Exercício 71
|
||||||
|
|
||||||
|
Determine a distância do ponto $(1, -2, 4)$ ao plano $3x + 2y + 6z = 5$.
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
$$
|
||||||
|
D = \frac{|ax + by + cz + d|}{\sqrt{a^2 + b^2 + c^2}}
|
||||||
|
= \frac{|3(1) + 2(-2) + 6(4) - 5|}{\sqrt{9 + 4 + 36}} = \frac{18}7
|
||||||
|
$$
|
||||||
|
|
||||||
|
## Capítulo 14.1
|
||||||
|
|
||||||
|
### Exercício 47
|
||||||
|
|
||||||
|
Faça o mapa de contorno da função mostrando várias curvas de nível para
|
||||||
|
|
||||||
|
$$
|
||||||
|
f (x, y) = ye^x
|
||||||
|
$$
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
Mapa de contorno para valores $10 | k$ tais que $-10^6 \le k \le 10^6$:
|
||||||
|
|
||||||
|
![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%207/Imagens/2021-11-02-21-15-01-image.png)
|
||||||
|
|
||||||
|
### Exercício 71
|
||||||
|
|
||||||
|
Utilize um computador para traçar o gráfico da função $f(x, y) = 3x - x^4 - 4y^2 - 10xy$ usando vários domínios e pontos de vista. Imprima aquela que apre sente melhor os “picos e vales”. Você acha que essa função tem um valor máximo? Você poderia identificar os pontos do gráfico corres- pondentes aos “máximos locais”? E aos “mínimos locais”?
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%207/Imagens/2021-11-02-21-29-18-image.png)
|
||||||
|
|
||||||
|
O gráfico acima corresponde a função descrita. Neste, é possível identificar dois máximos locais, para $z = 15$ e $z = 5$ e um mínimo local em $z = 0$.
|
||||||
|
|
||||||
|
[^1]: nUSP 12543033; Turma 04
|
204
Cálculo II/Atividade 7/Equações de Retas e Planos.md
Normal file
|
@ -0,0 +1,204 @@
|
||||||
|
# Equações de Retas e Planos
|
||||||
|
|
||||||
|
## Equação vetorial no espaço tridimensional
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%207/Imagens/2021-11-02-11-25-13-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
$$
|
||||||
|
\textbf r = \textbf r_0 + t\textbf v
|
||||||
|
$$
|
||||||
|
|
||||||
|
Onde:
|
||||||
|
|
||||||
|
- $\textbf r_0 = \lang x_0, y_0, z_0 \rang$ é o vetor que parte da origem do sistemas de coordenadas $O$ e coincide com a origem do vetor $\textbf a$, $P_0$;
|
||||||
|
|
||||||
|
- $\textbf r = \lang x, y, z \rang$ é o vetor que parte da origem do sistema de coordenadas $O$ e coincide com a extremidade oposta do vetor $\textbf a$, $P$;
|
||||||
|
|
||||||
|
- $\textbf v = \lang a, b, c \rang$ é um vetor paralelo à $\textbf a$ partindo da origem do sistema de coordenadas, denominado **vetor diretor**;
|
||||||
|
|
||||||
|
- $t$ é o escalar que multiplica $\textbf v$ de tal forma que este assume a mesma magnitude e sentido que $\textbf a$.
|
||||||
|
|
||||||
|
> Assim, para diferentes valores de $t$ correspondem distintos pontos $P_0$ em $L$:
|
||||||
|
>
|
||||||
|
> <img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%207/Imagens/2021-11-02-11-36-15-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
Explicitando os componentes na fórmula anterior, tem-se:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\lang x, y, z \rang = \lang x_0, y_0, z_0 \rang + \lang ta, tb, tc \rang
|
||||||
|
= \lang x_0 + ta, y_0 + tb, z_0 + tc \rang
|
||||||
|
$$
|
||||||
|
|
||||||
|
Desta equação derivamos as seguintes **equações paramétricas**:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{cases}x = x_0 + at \\ y = y_0 + bt \\ z = z_0 + ct\end{cases}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Podemos observar que entre estas $t$ é um fator comum. Logo, para qualquer vetor $\textbf a$ na reta $L$ em que $a,b,c \in \R^*$a seguinte igualdade é verdadeira:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\frac{x - x_0}a = \frac{x - y_0}b = \frac{z - z_0}c
|
||||||
|
$$
|
||||||
|
|
||||||
|
Este conjunto de equações são denominadas **equações simétricas** de $L$.
|
||||||
|
|
||||||
|
## Planos
|
||||||
|
|
||||||
|
Um plano no espaço fica determinado se conhecermos um ponto $P_0(x_0, y_0, z_0)$ no plano e um vetor $\textbf n$, denominado **vetor normal**, ortogonal ao plano.
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%207/Imagens/2021-11-02-13-38-20-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
Assim, seja $P(x, y, z)$ um ponto qualquer contido no plano tem-se que o vetor que liga $P_0$ à $P$ é $\textbf r - \textbf r_0$ tal que o produto vetorial $\textbf n \cdot (\textbf r - \textbf r_0) = 0$. Ou seja
|
||||||
|
|
||||||
|
$$
|
||||||
|
\textbf n \cdot \textbf r = \textbf n \cdot \textbf r_0
|
||||||
|
$$
|
||||||
|
|
||||||
|
Escrito de maneira a explicitar os componentes dos vetores $\textbf n = \lang a,b,c \rang$, $\textbf r = \lang x,y,z \rang$ e $\textbf r_0 = \lang x_0,y_0,z_0 \rang$ temos
|
||||||
|
|
||||||
|
$$
|
||||||
|
\lang a,b,c \rang \cdot \lang x - x_0, y - y_0, z - z_0 \rang =
|
||||||
|
a(x - x_0) + b(y - y_0) + c(z - z_0) = 0
|
||||||
|
$$
|
||||||
|
|
||||||
|
a **equação escalar do plano** que passa por $P_0$ com vetor normal $\textbf n$.
|
||||||
|
|
||||||
|
No mais, a equação anterior pode ser simplificada como:
|
||||||
|
|
||||||
|
$$
|
||||||
|
ax + by + cz + d = 0
|
||||||
|
$$
|
||||||
|
|
||||||
|
onde $d = -(ax_0 + by_0 + cz_0)$. Fórmula essa conhecida como **equação linear** em $x$, $y$, $z$. Uma importante aplicação desta equação é o cálculo da distância $D$ de um ponto com relação a um plano. Seja $x, y, z$ as coordenadas deste ponto, tem-se:
|
||||||
|
|
||||||
|
$$
|
||||||
|
D = \frac{|ax + by + cz + d|}{\sqrt{a^2 + b^2 + c^2}}
|
||||||
|
$$
|
||||||
|
|
||||||
|
### Equações simétricas na representação de planos
|
||||||
|
|
||||||
|
Podemos pensar na reta como a intersecção de dois planos:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{matrix} \dfrac{x - x_0}a = \dfrac{x - y_0}b & e &\dfrac{x - y_0}b = \dfrac{z - z_0}c \end{matrix}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Por exemplo, para uma reta $L$ descrita por
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{matrix} \dfrac{x - 1}5
|
||||||
|
= \dfrac y{-2} & e & \dfrac y{-2} = \dfrac z{-3} \end{matrix}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Tem-se o seguinte gráfico:
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%207/Imagens/2021-11-02-18-27-36-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
## Exemplos
|
||||||
|
|
||||||
|
### Exemplo 1
|
||||||
|
|
||||||
|
Mostre que as retas $L_1$ e $L_2$ com equações paramétricas dadas por
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{cases} \begin{matrix}
|
||||||
|
x_1 = 1 + t & y_1 = -2 + 3t & z_1 = 4 - t \\
|
||||||
|
x_2 = 2s & y_2 = 3 + s & z_2 = -3 + 4s
|
||||||
|
\end{matrix} \end{cases}
|
||||||
|
$$
|
||||||
|
|
||||||
|
são retas **reversas**, isto é, são retas que não se interceptam e não são paralelas (não pertencendo, portanto, a um mesmo plano).
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
As retas não são paralelas, pois os componentes de seus vetores diretores $\lang 1, 3, 1 \rang$ e $\lang 2, 1, 4 \rang$ não são proporcionais entre si.
|
||||||
|
|
||||||
|
As retas também não se intersectam pois, se houvesse intersecção, o seguinte sistema haveria uma solução:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{cases}1 + t = 2s \\ -2 + 3t = 3 + s \\ 4- t = -3 + 4s\end{cases}
|
||||||
|
$$
|
||||||
|
|
||||||
|
O que não é o caso para qualquer valor de $t$ e $s$.
|
||||||
|
|
||||||
|
### Exemplo 2
|
||||||
|
|
||||||
|
Encontre uma equação do plano que passa pelos pontos $P(1, 3, 2)$, $Q(3, -1, 6)$ e $R(5, 2, 0)$.
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
Os vetores **a** e **b** correspondentes a $\overrightarrow{PQ}$ e $\overrightarrow{PR}$ são
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{cases}
|
||||||
|
\textbf a = \lang 3 - 1, -1 - 3, 6 - 2 \rang = \lang 2, -4, 4 \rang \\
|
||||||
|
\textbf b = \lang 5 - 1, 2 - 3, 0 - 2 \rang = \lang 5, 2, 0 \rang
|
||||||
|
\end{cases}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Como tanto **a** quanto **b** pertencem ao plano, o produto vetorial $\textbf a \times \textbf b$ é ortogonal ao plano e pode ser tomado como o vetor normal **n**. Assim,
|
||||||
|
|
||||||
|
$$
|
||||||
|
\textbf n = \textbf a \times \textbf b = \left|\begin{matrix}
|
||||||
|
\textbf i & \textbf j & \textbf k \\
|
||||||
|
2 & -4 & 4 \\
|
||||||
|
4 & -1 & -2
|
||||||
|
\end{matrix}\right| = \left|\begin{matrix}
|
||||||
|
-4 & 4 \\
|
||||||
|
-1 & -2
|
||||||
|
\end{matrix}\right| \textbf i - \left|\begin{matrix}
|
||||||
|
2 & 4 \\
|
||||||
|
4 & -2 \end{matrix}\right| \textbf j + \left|\begin{matrix}
|
||||||
|
2 & -4 \\
|
||||||
|
4 & -1
|
||||||
|
\end{matrix}\right| \textbf k =\\
|
||||||
|
(8 + 4) \textbf i - (-4 - 16) \textbf j + (-2 + 16) \textbf k =
|
||||||
|
\lang 12, 20, 14 \rang \equiv \lang 6, 10, 7 \rang
|
||||||
|
$$
|
||||||
|
|
||||||
|
Com o ponto $P(1, 3, 2)$ e o vetor normal **n**, uma equação do plano é
|
||||||
|
|
||||||
|
$$
|
||||||
|
6(x - 1) + 10(y - 3) + 7(z - 2) = 0 \implies 6x + 10y + 7z = 50
|
||||||
|
$$
|
||||||
|
|
||||||
|
### Exemplo 3
|
||||||
|
|
||||||
|
**a.** Determine o ângulo entre os planos $x + y + z = 1$ e $x - 2y + 3z = 1$
|
||||||
|
|
||||||
|
Os vetores normais a esses planos são
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{matrix}
|
||||||
|
\textbf n_1 = \lang 1, 1, 1
|
||||||
|
\rang & \textbf n_2 = \lang 1, -2, 3\rang
|
||||||
|
\end{matrix}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Portanto, se $\theta$ é o ângulo entre os dois planos,
|
||||||
|
|
||||||
|
$$
|
||||||
|
\cos \theta = \frac{\textbf n_1 \cdot \textbf n_2}{|\textbf n_1||\textbf n_2|}
|
||||||
|
= \frac{1(1) + 1(-2) + 1(3)}{\sqrt{1 + 1 + 1} \sqrt{1 + 4 + 9}} =
|
||||||
|
\frac 2{\sqrt{42}}\\\ \\
|
||||||
|
\therefore \theta = \cos^{-1} \left(\frac 2{\sqrt{42}}\right) \approx 72\degree
|
||||||
|
$$
|
||||||
|
|
||||||
|
**b.** Primeiro precisamos encontrar um ponto em $L$. Por exemplo, podemos achar o ponto onde a reta intercepta o plano $xy$ tomando $z = 0$ na equação dos dois planos. Isso fornece as equações $x + y = 1$ e $x - 2y = 1$, cuja solução é $x = 1$, $y = 0$. Portanto, o ponto $(1, 0, 0)$ encontra-se em $L$.
|
||||||
|
|
||||||
|
Observe que, como $L$ pertence a ambos os planos, é perpendicular ao vetor normal de ambos os planos. Então, um vetor **v** paralelo a $L$ é dado pelo produto vetorial
|
||||||
|
|
||||||
|
$$
|
||||||
|
\textbf v = \textbf n_1 \times \textbf n_2 = \left|\begin{matrix}
|
||||||
|
\textbf i & \textbf j & \textbf k \\
|
||||||
|
1 & 1 & 1 \\
|
||||||
|
1 & -2 & 3
|
||||||
|
\end{matrix} \right| = 5 \textbf i - 2 \textbf j - 3 \textbf k
|
||||||
|
$$
|
||||||
|
|
||||||
|
e assim as equações simétricas de $L$ podem ser escritas como
|
||||||
|
|
||||||
|
$$
|
||||||
|
\frac{x - 1}5 = \frac y{-2} = \frac z{-3}
|
||||||
|
$$
|
23
Cálculo II/Atividade 7/Funções de Múltiplas Variáveis.md
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# Funções de Múltiplas Variáveis
|
||||||
|
|
||||||
|
## Funções de Duas Variáveis
|
||||||
|
|
||||||
|
Uma função $f$ de duas variáveis é uma regra que associa a cada par ordenado de números reais $(x, y)$ de um conjunto $D$ um único valor real, denotado por
|
||||||
|
$f (x, y)$. O conjunto $D$ é o domínio de $f$ e sua imagem é o conjunto de valores possíveis de $f$, ou seja, $f= \{(x, y): x, y \in D\}$. Por exemplo, funções da forma $f: \R^2 \to \R$.
|
||||||
|
|
||||||
|
### Gráficos
|
||||||
|
|
||||||
|
Se $f$ é uma função de duas variáveis com domínio $D$, então o gráfico de $f$ é
|
||||||
|
o conjunto de todos os pontos $(x, y, z)$ em $\R^3$ tal que $z = f (x, y)$ e $(x, y)$ pertença a $D$.
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%207/Imagens/2021-11-02-20-08-58-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
#### Curvas de nível
|
||||||
|
|
||||||
|
As curvas de nível de uma função $f$ de duas variáveis são aquelas com equação $f (x, y) = k$, onde $k$ é uma constante (na imagem de $f$).
|
||||||
|
|
||||||
|
![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%207/Imagens/2021-11-02-20-15-15-image.png)
|
||||||
|
|
||||||
|
## Funções de Três ou Mais Variáveis
|
||||||
|
|
||||||
|
Uma função com três variáveis $f$, é uma regra que associa a cada tripla ordenada $(x, y, z)$ em um domínio $D \subset \R^3$ um único número real, denotado por $f(x, y, z)$. Enquanto uma função com $n$ variáveis é uma regra que associa um número $z = f(x_1, x_2, \dots, x_n)$ a uma n-upla $(x_1, x_2, \dots, x_n)$ de números reais. Denotamos por $\R^n$ o conjunto de todas essas n-uplas.
|
BIN
Cálculo II/Atividade 7/Imagens/2021-11-02-11-25-13-image.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
Cálculo II/Atividade 7/Imagens/2021-11-02-11-36-15-image.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
Cálculo II/Atividade 7/Imagens/2021-11-02-13-38-20-image.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
Cálculo II/Atividade 7/Imagens/2021-11-02-18-27-36-image.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
Cálculo II/Atividade 7/Imagens/2021-11-02-19-14-54-image.png
Normal file
After Width: | Height: | Size: 281 KiB |
BIN
Cálculo II/Atividade 7/Imagens/2021-11-02-20-08-58-image.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
Cálculo II/Atividade 7/Imagens/2021-11-02-20-15-15-image.png
Normal file
After Width: | Height: | Size: 203 KiB |
BIN
Cálculo II/Atividade 7/Imagens/2021-11-02-21-15-01-image.png
Normal file
After Width: | Height: | Size: 176 KiB |
BIN
Cálculo II/Atividade 7/Imagens/2021-11-02-21-29-18-image.png
Normal file
After Width: | Height: | Size: 134 KiB |
65
Cálculo II/Atividade 8/Atividade 8.md
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
# Atividade 8
|
||||||
|
|
||||||
|
> Resolução dos exercícios obrigatórios, feita por Guilherme de Abreu Barreto[^1].
|
||||||
|
|
||||||
|
## Capítulo 14.2
|
||||||
|
|
||||||
|
### Exercício 19
|
||||||
|
|
||||||
|
Determine o limite, se existir, ou mostre que o limite não existe:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\lim_{(x,y,z) \to (\pi,\theta,1)} e^{y^2}\tan(xz)
|
||||||
|
$$
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
O limite existe pois a função está definida para $x = \pi$, $y = \theta$ e $z = 1$:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\lim_{(x,y,z) \to (\pi,\theta,1)} e^{y^2}\tan(xz)
|
||||||
|
= e^{\theta^2} \tan (\pi)
|
||||||
|
= e^{\theta^2} \cdot 0 = 0 = e^{y^2}\tan(xz)
|
||||||
|
$$
|
||||||
|
|
||||||
|
### Exercício 31
|
||||||
|
|
||||||
|
Determine o maior conjunto no qual a função é contínua:
|
||||||
|
|
||||||
|
$$
|
||||||
|
F(x, y) = \frac{1 + x^2 + y^2}{1 - x^2 - y^2}
|
||||||
|
$$
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
$$
|
||||||
|
\frac{1 + x^2 + y^2}{1 - x^2 - y^2} = \frac{1 + x^2 + y^2}{1 - (x^2 + y^2)}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Assim, A função $F(x,y)$ está definida para $\{(x,y) : x^2 + y^2 \not = 1\}$, sendo o domínio da função o maior conjunto contínuo de valores para a mesma.
|
||||||
|
|
||||||
|
## Capítulo 14.3
|
||||||
|
|
||||||
|
### Exercício 45
|
||||||
|
|
||||||
|
Use a definição de derivadas parciais como limites 4 para encontrar $f_x(x, y)$ e $f_y(x, y)$ em
|
||||||
|
|
||||||
|
$$
|
||||||
|
f(x,y) = xy^2 - x^3y
|
||||||
|
$$
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
$\displaystyle f_x(x,y) = \lim_{h \to 0} \frac{(x+h)y^2 - (x + h)^3y - xy^2 + x^3y}h\\ = \lim_{h \to 0} \frac{\cancel{xy^2} + hy^2 - \cancel{x^3y} - 3x^2hy - 3xh^2y - h^3y - \cancel{xy^2 + x^3y}}h \\ = \lim_{h \to 0} \frac{\cancel h (y^2 - 3x^2y - 3xhy - h^2y)}{\cancel h} = y^2 - 3x^2y\ \blacksquare$
|
||||||
|
|
||||||
|
$\displaystyle f_y(x,y) = \lim_{h \to 0} \frac{x(y + h)^2 - x^3(y + h) - xy^2 + x^3y}h\\ = \lim_{h \to 0} \frac{\cancel{xy^2} + 2yhx + h^2x - \cancel{x^3y} - x^3h - \cancel{xy^2 + x^3 y}}h \\ = \lim_{h \to 0} \frac{\cancel h (2yx + hx - x^3)}{\cancel h} = - x^2 + 2xy\ \blacksquare$
|
||||||
|
|
||||||
|
### Exercício 65
|
||||||
|
|
||||||
|
Determine a derivada parcial $f_{xyz}$ para $f(x,y,z) = e^{xyz^2}$.
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
$f_x = e^{xyz^2} \cdot yz^2 \implies \\ f_{xy} = e^{xyz^2} \cdot z^2 + e^{xyz^2} \cdot xyz^4 \implies \\ f_{xyz} = (e^{xyz^2} \cdot 2z + e^{xyz^2} \cdot 2xyz \cdot z^2) + (e^{xyz^2} \cdot 4xyz^3 + e^{xyz^2} \cdot 2xyz e^{xyz^2} \cdot xyz^4)\\ = e^{xyz^2}(2z + 6xyz^3 + 2x^2y^2z^5)\ \blacksquare$
|
||||||
|
|
||||||
|
[^1]: nUSP 12543033; Turma 04
|
41
Cálculo II/Atividade 8/Derivadas parciais.md
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
# Derivadas Parciais
|
||||||
|
|
||||||
|
Se $f$ é uma função de duas variáveis ($x$, $y$), suas derivadas parciais são as funções $f_x$ e $f_y$ definidas por
|
||||||
|
|
||||||
|
$$
|
||||||
|
f_x (x, y) = \lim_{h \to 0} \frac{f[(x + h),y] - f(x,y)}h \\\ \\
|
||||||
|
f_y (x, y) = \lim_{h \to 0} \frac{f[x,(y + h)] - f(x,y)}h
|
||||||
|
$$
|
||||||
|
|
||||||
|
Outras notações utilizadas para derivadas parciais:
|
||||||
|
|
||||||
|
$$
|
||||||
|
f_x(x,y) = f_x = \frac{\partial f}{\partial x}
|
||||||
|
= \frac{\partial}{\partial x} f(x,y) = \frac{\partial z}{\partial x} =
|
||||||
|
f_1=D_1f = D_xf
|
||||||
|
$$
|
||||||
|
|
||||||
|
Onde $z = f(x,y)$ e o numerador $1$ é um índice que indica a primeira variável do par ordenado.
|
||||||
|
|
||||||
|
## Regra para determinar Derivadas Parciais de $\mathbf{z = f(x,y)}$
|
||||||
|
|
||||||
|
1. Para determinar $f_x$, trate $y$ como uma constante e derive $f(x,y)$ com relação a $x$.
|
||||||
|
2. Para determinar $f_y$, trate $x$ como uma constante e derive $f(x,y)$ com relação a $y$.
|
||||||
|
|
||||||
|
## Derivadas de Ordem Superior
|
||||||
|
|
||||||
|
Se $f$ é uma função de duas variáveis, suas derivadas parciais $f_x$ e $f_y$ são funções de duas variáveis, de modo que podemos considerar novamente suas derivadas parciais$ (f_x)_x$, $(f_x)_y$, $(f_y)_x$ e $(f_y)_y$, chamadas **derivadas parciais de segunda ordem** de $f$. Se $z = f(x, y)$, usamos a seguinte notação, por exemplo:
|
||||||
|
|
||||||
|
$$
|
||||||
|
(f_x)_x = f_{xx} = f_{11}
|
||||||
|
= \frac \partial{\partial x} \left( \frac {\partial f}{\partial x}\right)
|
||||||
|
= \frac {\partial^2f}{\partial x^2} = \frac {\partial^2z}{\partial x^2}
|
||||||
|
$$
|
||||||
|
|
||||||
|
### Teorema de Clairaut
|
||||||
|
|
||||||
|
Suponha que $f$ seja definida em uma bola aberta $D$ que contenha o ponto $(a, b)$. Se as funções $f_{xy}$ e $f_{yx}$ forem ambas contínuas em D, então
|
||||||
|
|
||||||
|
$$
|
||||||
|
f_{xy}(a,b) = f_{yx}(a,b)
|
||||||
|
$$
|
13
Cálculo II/Atividade 8/Limites e continuidade.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Limites e continuidade
|
||||||
|
|
||||||
|
Seja $f$ uma função de duas variáveis cujo domínio $D$ contém pontos arbitrariamente próximos de $(a,b)$. Dizemos que o limite de $f(x,y)$ quando $(x,y)$ tende a $(a,b)$ é $L$ e escrevemos
|
||||||
|
|
||||||
|
$$
|
||||||
|
\lim_{(x,y) \to (a,b)} f(x,y) = L
|
||||||
|
$$
|
||||||
|
|
||||||
|
se para todo número $\varepsilon > 0$ houver um número correspondente de $\delta > 0$ tal que se $(x,y) \in D$ e $0 < \sqrt{(x - a)^2 + (y - b)^2} < \delta$ então $|f(x,y) - L| < \varepsilon$[^1].
|
||||||
|
|
||||||
|
Se $f (x, y) \to L_1$ quando $(x, y) \to (a, b)$ ao longo do caminho $C_1$ e $f (x, y) \to L_2$ quando $(x, y) \to (a, b)$ ao longo do caminho $C_2$, com $L_1 \not = L_2$, então $\lim_{(x, y) \to (a, b)} f (x, y)$ não existe.
|
||||||
|
|
||||||
|
[^1]: Observe que $|f(x,y) - L |$ corresponde à distância entre os números $f (x, y)$ e $L$, e $\sqrt{(x - a)^2 + (y - b)^2}$ é a distância entre o ponto $(x, y)$ e o ponto $(a, b)$. Noutras palavras, a definição diz que a distância entre $f (x, y)$ e $L$ pode ser feita arbitrariamente pequena se tornarmos a distância de $(x, y)$ a $(a, b)$ suficientemente pequena (mas não nula).
|
123
Cálculo II/Atividade 9/Atividade 9.md
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
# Atividade 9
|
||||||
|
|
||||||
|
> Resolução dos exercícios obrigatórios, feita por Guilherme de Abreu Barreto[^1].
|
||||||
|
|
||||||
|
## Capítulo 14.4
|
||||||
|
|
||||||
|
### Exercício 24
|
||||||
|
|
||||||
|
O índice de sensação térmica $W$ é a temperatura sentida quando a temperatura real é $T$ e a velocidade do vento, $v$. Portanto, podemos escrever $W = f (T, v)$. A tabela de valores a seguir foi extraída da Tabela 1 da Seção 14.1. Use essa tabela para determinara aproximação linear da função de sensação térmica quando $T$ estiver a -15 ºC e $v$ estiver próximo de 50 km/h. Estime, a seguir, a sensação térmica quando a temperatura estiver a -17 ºC
|
||||||
|
e a velocidade do vento for de 55 km/h.
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%209/Imagens/2021-11-16-11-32-12-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
A aproximação linear para $f(T,v)$ é dada por:
|
||||||
|
|
||||||
|
$$
|
||||||
|
f(T,v) \approx f(a,b) + f_T(a,b)(T - a) + f_v(a,b)(v - b)
|
||||||
|
$$
|
||||||
|
|
||||||
|
Para valores $a \approx T$ e $b \approx v$. Assim sendo, para estimarmos $f(-17,55)$ utilizaremos o valor descrito na tabela para $f(a,b) = f(-15,60)$ e aqueles adjacentes a este. Assim, temos que
|
||||||
|
|
||||||
|
$f_T(-15, 60) \approx \displaystyle \lim_{h \to 5} \dfrac{f(-15 + h, 60) - f(-15,60)}{2h}\\\ \\ + \lim_{h \to -5} \dfrac{f(-15 +h, 60) - f(-15,60)}{2h} = \dfrac{\dfrac{-23 + 30}5 + \dfrac{-36 + 30}{-5}}2 = \dfrac{13}{10}$
|
||||||
|
|
||||||
|
e
|
||||||
|
|
||||||
|
$f_v(-15, 60) \approx \displaystyle \lim_{h \to 10} \dfrac{f(-15, 60 + h) - f(-15,60)}{2h}\\ \ + \lim_{h \to -10} \dfrac{f(-15, 60 + h) - f(-15,60)}{2h} = \dfrac{\dfrac{30 - 30}{10} + \dfrac{30 - 29}{-10}}2 = - \dfrac 1{20}$
|
||||||
|
|
||||||
|
Logo,
|
||||||
|
|
||||||
|
$f(-17,55) \approx f(-15, 60) + f_T(-15,60)(-17 + 15) + f_v(-15,60)(55 - 60) \\\ \\ \approx -30 + \dfrac{13}{10}(-2) - \dfrac 1{20}(-5) \approx -32,25\ \blacksquare$
|
||||||
|
|
||||||
|
### Exercício 42
|
||||||
|
|
||||||
|
Suponha que você precise saber uma equação do plano tangente à superfície $S$ no ponto $P(2, 1, 3)$. Você não tem uma equação para $S$, mas sabe que as curvas
|
||||||
|
|
||||||
|
- $\textbf r_1(t) = \lang 2 + 3t, 1 - t^2, 3 - 4t + t^2\rang$
|
||||||
|
|
||||||
|
- $\textbf r_2(u) = \lang 1 + u^2, 2u^3 - 1, 2u + 1 \rang$
|
||||||
|
|
||||||
|
ambas estão em $S$. Encontre uma equação para o plano tangente em $P$.
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
Podemos deduzir onde as retas passam pelo ponto $P$ fazendo a seguinte comparação:
|
||||||
|
|
||||||
|
- Se $\textbf r_1(t) = \lang 2 + 3t, 1 - t^2, 3 - 4t + t^2\rang = \lang 2, 1, 3 \rang$, então
|
||||||
|
$\begin{cases}
|
||||||
|
2 + 3t = 2 \\
|
||||||
|
1 - t^2 = 1 \\
|
||||||
|
3 - 4t + t^2 = 3
|
||||||
|
\end{cases} \therefore t = 0$
|
||||||
|
Portanto, $\textbf r_1(t)$ cruza $P$ em $\textbf r_1(0)$.
|
||||||
|
|
||||||
|
- Se $\textbf r_2(u) = \lang 1 + u^2, 2u^3 - 1, 2u + 1 \rang= \lang 2, 1, 3 \rang$, então
|
||||||
|
$\begin{cases}
|
||||||
|
1 + u^2 = 2 \\
|
||||||
|
2u^3 - 1 = 1 \\
|
||||||
|
2u + 1 = 3
|
||||||
|
\end{cases} \therefore u = 1$
|
||||||
|
Portanto, $\textbf r_2(u)$ cruza $P$ em $\textbf r_2(1)$.
|
||||||
|
|
||||||
|
Derivamos então as equações das curvas para obter a reta tangente destas:
|
||||||
|
|
||||||
|
- $\textbf r_1(t) = \lang 2 + 3t, 1 - t^2, 3 - 4t + t^2\rang \implies \textbf r_1'(t) = \lang 3, - 2t, 2t - 4 \rang$
|
||||||
|
|
||||||
|
- $\textbf r_2(u) = \lang 1 + u^2, 2u^3 - 1, 2u + 1 \rang \implies \textbf r_2'(u) = \lang 2u, 6u, 2 \rang$
|
||||||
|
|
||||||
|
Com as retas tangentes conseguimos obter a reta normal $\textbf n$, perpendicular à ambas, no ponto $P = (2, 1, 3)$:
|
||||||
|
|
||||||
|
$\textbf r_1'(0) \times \textbf r_2'(1) = \lang 3, 0 , -4 \rang \times \lang 2, 6, 2 \rang \\ = \lang 0 \cdot 2 - (-4 \cdot 6), -4 \cdot 2 - 3 \cdot 2, 3 \cdot 6 - 0 \cdot 2 \rang = \lang 24, -14, 18 \rang$
|
||||||
|
|
||||||
|
Por vez, a reta normal nos permite descrever a **equação linear** do plano sobre o ponto $P$:
|
||||||
|
|
||||||
|
$24 x - 14y + 18z - (24 \cdot 2 - 14 \cdot 1 + 18 \cdot 3) = 0\\ \\ \implies 12 x - 7y + 9z - (12 \cdot 2 - 7 \cdot 1 + 9 \cdot 3) = 0\\ \\ \implies 12x - 7y + 9z - 44 = 0\ \blacksquare$
|
||||||
|
|
||||||
|
## Capítulo 14.5
|
||||||
|
|
||||||
|
### Exercício 43
|
||||||
|
|
||||||
|
Um lado de um triângulo está aumentando em uma taxa de $3\ cm/s$ e um segundo lado está decrescendo em uma taxa de $2\ cm/s$. Se a área do triângulo permanece constante, a que taxa varia o ângulo entre os lados quando o primeiro lado tem $20 cm$ de comprimento, o segundo lado tem $30 cm$ de comprimento e
|
||||||
|
o ângulo é $\frac \pi6$?
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
Denominemos por $x$ o primeiro lado, $y$ o segundo e $\theta$ o ângulo entre eles. Pela aplicação da Lei dos senos, podemos aferir a área do triângulo $A$ como sendo $A = \frac{xy\sin\theta}2$ Assim, o valor de $A$ se dá em função de $x$, $y$ e $\theta$ e estes por vez se dão em função do tempo $t$. Sabemos pelo enunciado que a taxa de variação do comprimento de $x$, $\frac{dx}{dt} = 3$, e $y$, $\frac{dy}{dt} = -2$. Também, que para a área $A$ não ocorre variação, $\frac{dA}{dt} = 0$. Buscamos aqui saber a taxa de variação do ângulo $\theta$, $\frac{d\theta}{dt}$. Ora, podemos relacionar estes dados fazendo uso da Regra da Cadeia e inferi-la:
|
||||||
|
|
||||||
|
$\displaystyle \frac{dA}{dt} = \frac{\partial A}{\partial x}\frac{dx}{dt} + \frac{\partial A}{\partial y}\frac{dy}{dt} + \frac{\partial A}{\partial \theta}\frac{d\theta}{dt} \implies 0 = \frac{3y \sin \theta}2 - \frac{2 x \sin \theta}2 + \dfrac{xy \cos \theta}2\frac{d\theta}{dt} \\\ \\ \implies \frac{d\theta}{dt} = \frac{2x\sin \theta - 3y\sin \theta}{xy\cos \theta} = \frac{\sin \theta}{\cos \theta} \cdot \frac{2x - 3y}{xy} = \tan \left(\frac \pi 6\right) \cdot \frac{2 \cdot 2\cancel 0 - 3 \cdot 3\cancel 0}{60\cancel 0}\\\ \\ = \frac{\sqrt 3}3 \cdot - \frac 1{12} = - \frac{\sqrt 3}{36}\ \blacksquare$
|
||||||
|
|
||||||
|
### Exercício 59
|
||||||
|
|
||||||
|
A Equação 6 é uma fórmula para a derivada $dy/dx$ de uma função definida implicitamente por uma equação $F (x, y) = 0$, sendo que $F$ é diferenciável e $F_y \not = 0$. Comprove que se $F$ tem derivadas contínuas de segunda ordem, então uma fórmula para a segunda derivada de $y$ é
|
||||||
|
|
||||||
|
$$
|
||||||
|
\frac{d^2y}{dx^2} = - \frac{F_{xx}F_y^2 - 2F_{xy}F_xF_y + F_yyF_x^2}{F_y^3}
|
||||||
|
$$
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
Dado que a função foi definida implicitamente da maneira descrita pelo enunciado, sabemos que $\frac{dy}{dx} = - \frac{F_x}{F_y}$. Denominemos $G(x,y) = - \frac{F_x}{F_y}$. Ao derivarmos ambos os lados da equação e utilizarmos a Regra da Cadeia, teremos:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\displaystyle \frac{d^2y}{dx^2} = \frac{\partial G}{\partial x} \cdot \cancel{\frac{dx}{dx}}\ 1 + \frac{\partial G}{\partial y} \cdot \frac{dy}{dx}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Sendo que
|
||||||
|
|
||||||
|
- $\dfrac{\partial G}{\partial x} = \dfrac{\partial}{\partial x}\left(- \dfrac{F_x}{F_y}\right) = - \dfrac{F_yF_{xx} - F_xF_{yx}}{F_y^2}$
|
||||||
|
|
||||||
|
- $\dfrac{\partial G}{\partial y} = \dfrac{\partial}{\partial y}\left(- \dfrac{F_x}{F_y}\right) = - \dfrac{F_yF_{xy} - F_xF_{yy}}{F_y^2}$
|
||||||
|
|
||||||
|
Assim,
|
||||||
|
|
||||||
|
$\displaystyle \frac{d2y}{dx2} = - \dfrac{F_yF_{xx} - F_xF_{yx}}{F_y^2} + \left(- \dfrac{F_yF_{xy} - F_xF_{yy}}{F_y^2}\right)\left(- \dfrac{F_x}{F_y}\right) = \\\ \\ - \dfrac{F_{xx}F_y^2 - F_{yx} F_xF_y - F_{xy} F_yF_x + F_{yy}F_x^2}{F_y^3}$
|
||||||
|
|
||||||
|
Consideremos agora que $F$ tem derivadas de segunda ordem contínuas então, pelo Teorema de Clauraut, $F_{xy} = F_{yx}$ e
|
||||||
|
|
||||||
|
$$
|
||||||
|
\frac{d^2y}{dx^2} = - \frac{F_{xx}F_y^2 - 2F_{xy}F_xF_y + F_yyF_x^2}{F_y^3} \ \blacksquare
|
||||||
|
$$
|
||||||
|
|
||||||
|
[^1]: nUSP 12543033; Turma 04
|
BIN
Cálculo II/Atividade 9/Imagens/2021-11-15-18-48-33-image.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
Cálculo II/Atividade 9/Imagens/2021-11-16-10-55-02-image.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
Cálculo II/Atividade 9/Imagens/2021-11-16-11-03-28-image.png
Normal file
After Width: | Height: | Size: 55 KiB |
BIN
Cálculo II/Atividade 9/Imagens/2021-11-16-11-32-12-image.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
Cálculo II/Atividade 9/Imagens/2021-11-18-12-37-12-image.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
Cálculo II/Atividade 9/Imagens/2021-11-18-13-15-49-image.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
|
@ -0,0 +1,141 @@
|
||||||
|
# Planos Tangentes e Aproximações Lineares
|
||||||
|
|
||||||
|
## Planos tangentes
|
||||||
|
|
||||||
|
Suponha que $f$ tenha derivadas parciais contínuas. Uma equação do plano tangente à superfície $z = f(x,y)$ no ponto $P(x_0,y_0, z_0)$ é dada por
|
||||||
|
|
||||||
|
$$
|
||||||
|
z - z_0 = f_x(x_0,y_0)(x - x_0) + f_y(x_0,y_0)(y - y_0)
|
||||||
|
$$
|
||||||
|
|
||||||
|
### Exemplo
|
||||||
|
|
||||||
|
Determine o plano tangente ao paraboloide elíptico $z = 2x^2 + y^2$ no ponto $(1, 1, 3)$.
|
||||||
|
|
||||||
|
#### Resolução
|
||||||
|
|
||||||
|
Seja $f(x,y) = 2x^2 + y^2$. Então
|
||||||
|
|
||||||
|
$f_x(x,y) = 4x \implies f_x(1,1) = 4 \\ f_y(x,y) = 2y \implies f_y(1,1) = 2$
|
||||||
|
|
||||||
|
Portanto, temos a equação do plano tangente em $(1,1,3)$ como
|
||||||
|
|
||||||
|
$$
|
||||||
|
z - 3 = 4(x - 1) + 2(y - 1) \implies z = 4x + 2y - 3\ \blacksquare
|
||||||
|
$$
|
||||||
|
|
||||||
|
## Aproximações lineares
|
||||||
|
|
||||||
|
### Para funções de uma única variável
|
||||||
|
|
||||||
|
Dada uma função $f(x)$ contínua e uma variável real $x$ cujo valor é próximo de uma constante $a$, temos:
|
||||||
|
|
||||||
|
$$
|
||||||
|
f(x) \approx f(a) + f'(a)(x-a)
|
||||||
|
$$
|
||||||
|
|
||||||
|
Tal qual ilustra o seguinte gráfico:
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%209/Imagens/2021-11-15-18-48-33-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
Ou seja para valores próximos de $a$, a curva descrita pela função $f(x)$ se aproxima de uma reta que contém o valor $a$. Desta forma, é possível utilizar uma função afim $L(x)$ de maneira a obter uma aproximação da função geral $f(x)$, tal que $L(x) = f(a) + f'(a)(x-a) \approx f(x)$. Onde $L(x)$ é denominada a **linearização** de $f$ no ponto $a$.
|
||||||
|
|
||||||
|
#### Exemplo
|
||||||
|
|
||||||
|
Calculemos o valor aproximado de $\sqrt[3]{25}$.
|
||||||
|
|
||||||
|
##### Resolução
|
||||||
|
|
||||||
|
1. Seja $f(x) = x^{\frac 13}$, o problema consiste em encontrar o valor de $f(25)$.
|
||||||
|
|
||||||
|
2. Precisamos de um valor próximo de 25, do qual saibamos qual é a raiz cúbica. Sabemos que $f(27) = 3$, então usemos $a = 27$.
|
||||||
|
|
||||||
|
3. Derivando $f(x)$ e encontrando o valor de $f'(a)$:
|
||||||
|
|
||||||
|
$$
|
||||||
|
f'(x) = \frac{x^{- \frac 23}}3 = \frac 1{3 \sqrt[3]{x^2}} \implies
|
||||||
|
f'(27) = \dfrac 1{3\sqrt[3]{27^2}} = \frac 1{27}
|
||||||
|
$$
|
||||||
|
|
||||||
|
4. Usando a aproximação linear:
|
||||||
|
|
||||||
|
$$
|
||||||
|
f(25) \approx f(27) + f'(27)(25 - 27) = 3 - \frac 2{27} \approx 2,926
|
||||||
|
$$
|
||||||
|
|
||||||
|
5. O resultado 2,926 é um valor bem próximo, e portanto uma boa aproximação, do valor real 2,924.
|
||||||
|
|
||||||
|
### Para funções com duas variáveis
|
||||||
|
|
||||||
|
O mesmo procedimento pode ser realizado uma função com duas variáveis $f(x,y)$ fazendo uso de suas derivadas parciais de $x$ e $y$: $f_x$ e $f_y$. Tal que chegamos na seguinte fórmula:
|
||||||
|
|
||||||
|
$$
|
||||||
|
L(x,y) = f(a,b) + f_x(a,b)(x - a) + f_y(a,b)(y - b) \approx f(x,y)
|
||||||
|
$$
|
||||||
|
|
||||||
|
Onde $a$ e $b$ são constantes tais que $x \approx a$ e $y \approx b$.
|
||||||
|
|
||||||
|
### Para funções com três ou mais variáveis
|
||||||
|
|
||||||
|
De forma análoga, temos:
|
||||||
|
|
||||||
|
$L(x,y,z) = f(a,b) + f_x(a,b,c)(x - a) + f_y(a,b,c)(y - b)\\ + f_z(a,b,c)(z - c) \approx f(x,y,z)$
|
||||||
|
|
||||||
|
E assim por diante.
|
||||||
|
|
||||||
|
## Diferenciabilidade
|
||||||
|
|
||||||
|
Se $z = f(x,y)$, então $f$ é **diferenciável** em $(a,b)$ de $\Delta z$ puder ser expresso na forma
|
||||||
|
|
||||||
|
$$
|
||||||
|
\Delta z = f_x(a,b)\Delta x + f_y(a,b)\Delta y + \varepsilon_1\Delta x + \varepsilon_2 \Delta y
|
||||||
|
$$
|
||||||
|
|
||||||
|
onde tanto $\varepsilon_1$ e $\varepsilon_2 \to 0$ quando $(\Delta x,\Delta y) \to (0,0)$
|
||||||
|
|
||||||
|
Ou seja, uma função é diferenciável se, e somente se, sua aproximação linear fornece uma boa aproximação para $f(x,y)$ para valores próximos de $f(a,b)$.
|
||||||
|
|
||||||
|
### Teorema
|
||||||
|
|
||||||
|
Se as derivadas parciais $f_x$ e $f_y$ existirem perto do ponto $(a, b)$ e forem contínuas em $(a, b)$, então $f$ é diferenciável em $(a, b)$.
|
||||||
|
|
||||||
|
## Diferenciais
|
||||||
|
|
||||||
|
### Para funções de uma única variável
|
||||||
|
|
||||||
|
Para uma função de uma única variável, $y = f (x)$, definimos a diferencial $dx$ como uma variável independente; ou seja, $dx$ pode valer qualquer número real. A diferencial de $y$ é definida como
|
||||||
|
|
||||||
|
$$
|
||||||
|
dy = f'(x)\ dx
|
||||||
|
$$
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%209/Imagens/2021-11-16-10-55-02-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
### Para funções de duas variáveis
|
||||||
|
|
||||||
|
Para uma função de duas variáveis, $z = f (x, y)$, definimos as diferenciais $dx$ e $dy$ como variáveis independentes; ou seja, podem ter qualquer valor. Então a diferencial $dz$ também chamada de **diferenciação total**, é definida por
|
||||||
|
|
||||||
|
$$
|
||||||
|
dz = f_x(x,y)\ dx + f_y(x,y)\ dy
|
||||||
|
= \frac{\partial z}{\partial x}\ dx + \frac{\partial z}{\partial y}\ dy
|
||||||
|
$$
|
||||||
|
|
||||||
|
> Algumas vezes a notação utilizada para a diferenciação total é $df$.
|
||||||
|
|
||||||
|
E assim, com a notação diferencial, a aproximação linear pode ser escrita como
|
||||||
|
|
||||||
|
$$
|
||||||
|
f(x,y) \approx f(a,b) + dz
|
||||||
|
$$
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%209/Imagens/2021-11-16-11-03-28-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
### Para funções de três variáveis
|
||||||
|
|
||||||
|
Analogamente,
|
||||||
|
|
||||||
|
$$
|
||||||
|
dw = yz\ dx + xz\ dy + xy\ dz
|
||||||
|
= \frac{\partial w}{\partial x}\ dx + \frac{\partial w}{\partial y}\ dy
|
||||||
|
+ \frac{\partial w}{\partial z}\ dz
|
||||||
|
$$
|
76
Cálculo II/Atividade 9/Regra da Cadeia.md
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
# Regra da Cadeia
|
||||||
|
|
||||||
|
Para as funções de mais de uma variável, a Regra da Cadeia tem muitas versões, cada uma delas fornecendo uma regra de derivação de uma função composta.
|
||||||
|
|
||||||
|
## Caso 1
|
||||||
|
|
||||||
|
Suponha que $z = f (x,y)$ seja uma função diferenciável de $x$ e $y$, onde $x = g(t)$ e $y = h(t)$ são funções diferenciáveis de $t$. Então $z$ é uma função diferenciável de $t$ e
|
||||||
|
|
||||||
|
$$
|
||||||
|
\frac{dz}{dt} = \frac{\partial z}{\partial x} \frac{dx}{dt} +
|
||||||
|
\frac{\partial z}{\partial y} \frac{dy}{dt}
|
||||||
|
$$
|
||||||
|
|
||||||
|
## Caso 2
|
||||||
|
|
||||||
|
Suponha que $z = f(x,y)$ seja uma função diferenciável de $x$ e $y$, onde $x = g(s,t)$ e $y = h(s,t)$ são funções diferenciáveis de $s$ e $t$. Então
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{matrix}
|
||||||
|
\displaystyle \frac{\partial z}{\partial s} =
|
||||||
|
\frac{\partial z}{\partial x} \frac{\partial x}{\partial s} +
|
||||||
|
\frac{\partial z}{\partial y} \frac{\partial y}{\partial s}& &
|
||||||
|
\displaystyle \frac{\partial z}{\partial t} =
|
||||||
|
\frac{\partial z}{\partial x} \frac{\partial x}{\partial t} +
|
||||||
|
\frac{\partial z}{\partial y} \frac{\partial y}{\partial t}
|
||||||
|
\end{matrix}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Denomina-se $s$ e $t$ as variáveis **independentes**, $x$ e $y$ as variáveis **intermediárias**, e $z$ a variável **dependente**. Tal qual ilustra o seguinte **diagrama em árvore**:
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%209/Imagens/2021-11-18-12-37-12-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
## A Regra da Cadeia (Versão Geral)
|
||||||
|
|
||||||
|
Suponha que $u$ seja uma função diferenciável de $n$ variáveis $x_1, \dots , x_n$ onde cada $x$ é uma função diferenciável de $m$ variáveis $t_1, \dots , t_m$. Então $u$ é uma função de $t_1, \dots , t_m$ e
|
||||||
|
|
||||||
|
$$
|
||||||
|
\frac{\partial u}{\partial t_i} =
|
||||||
|
\sum^i_{j = 1} \frac{\partial u}{\partial x_j}
|
||||||
|
\frac{\partial x_j}{\partial t_i}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Por exemplo, a Regra da Cadeia para o caso onde $w = f(x,y,z,t)$ e $x(u,v)$, $y = y(u,v)$, $z = z(u,v)$ e $t = t(u,v)$ é exemplificada pela seguinte diagrama de árvore
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Cálculo%20II/Atividade%209/Imagens/2021-11-18-13-15-49-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
e pode ser descrito em suas parciais por:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\frac{\partial w}{\partial u} =
|
||||||
|
\frac{\partial w}{\partial x}\frac{\partial x}{\partial u} +
|
||||||
|
\frac{\partial w}{\partial y}\frac{\partial y}{\partial u} +
|
||||||
|
\frac{\partial w}{\partial z}\frac{\partial z}{\partial u} +
|
||||||
|
\frac{\partial w}{\partial t}\frac{\partial t}{\partial u} \\\ \\
|
||||||
|
\frac{\partial w}{\partial v} =
|
||||||
|
\frac{\partial w}{\partial x}\frac{\partial x}{\partial v} +
|
||||||
|
\frac{\partial w}{\partial y}\frac{\partial y}{\partial v} +
|
||||||
|
\frac{\partial w}{\partial z}\frac{\partial z}{\partial v} +
|
||||||
|
\frac{\partial w}{\partial t}\frac{\partial t}{\partial v}
|
||||||
|
$$
|
||||||
|
|
||||||
|
## Diferenciação implícita
|
||||||
|
|
||||||
|
Suponha que $z$ seja dado implicitamente como uma função $z = f(x,y)$ por uma equação da forma $F(x,y,z) = 0$. Isso significa que $F(x,y,f(x,y)) = 0$ para todo $(x,y)$ no domínio de $f$. Se $F$ e $f$ forem diferenciáveis,
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{matrix}
|
||||||
|
\dfrac{\partial z}{\partial x} =
|
||||||
|
\dfrac{\dfrac{\partial F}{\partial x}}{\dfrac{\partial F}{\partial z}}
|
||||||
|
& &
|
||||||
|
\dfrac{\partial z}{\partial y} =
|
||||||
|
\dfrac{\dfrac{\partial F}{\partial y}}{\dfrac{\partial F}{\partial z}}
|
||||||
|
\end{matrix}
|
||||||
|
$$
|
||||||
|
|
||||||
|
$$
|
|
@ -1,61 +0,0 @@
|
||||||
# Correção
|
|
||||||
|
|
||||||
- Identificar invariáveis
|
|
||||||
|
|
||||||
- Inicialização
|
|
||||||
|
|
||||||
- Manutenção
|
|
||||||
|
|
||||||
- Término
|
|
||||||
|
|
||||||
## Anotações GDB
|
|
||||||
|
|
||||||
- Compilar um programa com a flag `-g` faz com que este programa armazene seu código fonte, permitindo-o ser debugado em sua execução.
|
|
||||||
|
|
||||||
- Para se debugar um programa, chama-se este com o comando `gdb` no terminal.
|
|
||||||
|
|
||||||
- `run` roda o programa.
|
|
||||||
|
|
||||||
- `layout next` muda a forma de exibição da interface.
|
|
||||||
|
|
||||||
- `refresh` atualiza a interface.
|
|
||||||
|
|
||||||
- `next`, ou `n`, avança o programa em uma linha de comando *no escopo atual*.
|
|
||||||
|
|
||||||
- `print`, ou apenas `p`, pode ser utilizado para realizar calculos aritméticos com o valor de variáveis.
|
|
||||||
|
|
||||||
- `print var` apresenta o valor da variável var.
|
|
||||||
|
|
||||||
- `print vector@x` apresenta os primeiros `x` valores de um vetor `vector`.
|
|
||||||
|
|
||||||
- `print *vector@x` apresenta os valores apontados por um vetor de ponteiros `vector`.
|
|
||||||
|
|
||||||
- `step` avança o programa em uma linha de comando *no escopo global*, entrando em funções, etc.
|
|
||||||
|
|
||||||
- `break x` coloca um ponto de interrupção da execução na linha `x`.
|
|
||||||
|
|
||||||
- `break function` coloca um ponto de interrupção da execução no início de uma função `function`.
|
|
||||||
|
|
||||||
- `info break` lista todos os pontos de interrupção;
|
|
||||||
|
|
||||||
- `del x` apaga o breakpoint de número `x`, tal qual descrito por `info break`.
|
|
||||||
|
|
||||||
- `clear function` retira os pontos de interrupção colocados na função `function`.
|
|
||||||
|
|
||||||
- `display i` para cada comando seguinte, mostrar o valor de `i`. `undisplay n` cessa este comportamento para a variável de índice `n`.
|
|
||||||
|
|
||||||
- `watch [expressão]` (*watchpoint*) interrompe a execução do programa toda vez que o valor de uma expressão se altera.
|
|
||||||
|
|
||||||
- `whatis i`, ou `what i`, mostra o tipo da variável `i`.
|
|
||||||
|
|
||||||
- `backtrace` (`bt`) no caso de um Segmentation Fault, aponta-se a linha em que este ocorreu e os valores das variáveis à este ponto.
|
|
||||||
|
|
||||||
- `finish` executa a função atual e interrompe a execução quando esta termina, indicando onde no código esta retorna e com qual valor.
|
|
||||||
|
|
||||||
- `quit` sai do debugger.
|
|
||||||
|
|
||||||
## Comandos avançados
|
|
||||||
|
|
||||||
- `target record-full` grava a execução e permite voltar para passos anteriores com `reverse-next`, `reverse-step`, `reverse-continue` (`rn`, `rs`).
|
|
||||||
|
|
||||||
- `set var i = x` altera o valor da variável `i` para `x` e permite a continuidade da execução do código.
|
|
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 77 KiB |
After Width: | Height: | Size: 77 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 6.8 KiB |
|
@ -6,24 +6,30 @@
|
||||||
|
|
||||||
```c
|
```c
|
||||||
m ← 0 // c_2
|
m ← 0 // c_2
|
||||||
for i ← 1 até n // c_2 + (n - 1) c_1
|
for i ← 1 até n // c_2 + c_5 + (n - 1) c_1
|
||||||
do for j ← 1 até n // c_2 + (n - 1)² c_1
|
do for j ← 1 até n // c_2 + c_5 + (n - 1)² c_1
|
||||||
do for k ← 1 até n // c_2 + (n - 1)³ c_1
|
do for k ← 1 até n // c_2 + c_5 + (n - 1)³ c_1
|
||||||
if a_i + b_j + c_k = 0 // n³ (2 c_3 + c_5)
|
if a_i + b_j + c_k = 0 // n³ (2 c_3 + c_5)
|
||||||
then m ← m + 1 // 0 c_1 até n³ c_1
|
then m ← m + 1 // 0 (c_2 + c_3) até n³ (c_2 + c_3)
|
||||||
return m // c_4
|
return m // c_4
|
||||||
```
|
```
|
||||||
|
|
||||||
Assim o sendo, temos que este algoritmo, na ausência de valores capazes de satisfazer a condição de iteração da variável $m$ (melhor caso) tem um tempo de execução equivalente à:
|
> **Obs:** Admite-se
|
||||||
|
|
||||||
$$
|
$$
|
||||||
(n^3 - 2n^2 + 2n - 1)c_1 + 4c_2 + 2n^3c_3 + c_4 + n^3c_5
|
c_1 (\text{iteração})= c_3 (\text{soma}) + c_2 (\text{atribuição}) + c_5 (\text{comparação ‒ com o valor }n)
|
||||||
$$
|
$$
|
||||||
|
|
||||||
Enquanto quando este encontra valores compatíveis, este tem um tempo de execução equivalente à:
|
Assim o sendo, temos que este algoritmo, na ausência de valores capazes de satisfazer a condição de acréscimo da variável $m$ (melhor caso) tem um tempo de execução equivalente à:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
[2(n^3 - n^2 + n) - 1]c_1 + 4c_2 + 2n^3c_3 + c_4 + n^3c_5\ \blacksquare
|
(n^3 - 2n^2 + n - 1)c_1 + 4c_2 + 2n^3 c_3 + c_4 + (n^3 + 3)c_5
|
||||||
|
$$
|
||||||
|
|
||||||
|
Enquanto quando este encontra apenas valores compatíveis (pior caso), este tem um tempo de execução equivalente à:
|
||||||
|
|
||||||
|
$$
|
||||||
|
(n^3 - 2n^2 + n - 1)c_1 + (n^3 + 4)c_2 + 3n^3 c_3 + c_4 + (n^3 + 3)c_5\ \blacksquare
|
||||||
$$
|
$$
|
||||||
|
|
||||||
## Exercício 2
|
## Exercício 2
|
||||||
|
@ -40,20 +46,21 @@ $$
|
||||||
0 \le c_1g(n) \le f(n) \le c_2g(n)
|
0 \le c_1g(n) \le f(n) \le c_2g(n)
|
||||||
$$
|
$$
|
||||||
|
|
||||||
Assim sendo, temos que em nosso caso $g(n) = n^3$, enquanto$f(n) = 4n^3 + n^2 + n + 2$ (a função equivalente ao pior caso, igualando as constantes à 1) Para qualquer $n \ge 1$. Assim sendo, tem-se:
|
Assim sendo, temos que em nosso caso $g(n) = n^3$, enquanto a função equivalente ao pior caso, igualando as constantes à 1, e substituindo $c_1$ por $c_2 + c_3 + c_5$ é $f(n) = 8n^3 - 6 n^2 + 3n + 5$, para qualquer $n \ge 1$. Assim sendo, tem-se:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
0 \le c_1n^3 \le 4n^3 + n^2 + n + 2 \le c_2n^3\\\ \\
|
0 \le c_1n^3 \le 8n^3 - 6n^2 + 3n + 5 \le c_2n^3
|
||||||
0 \le c_1 \le 4 + \dfrac 1n + \dfrac 1{n^2} + \dfrac 2{n^3} \le c_2 \implies 0 \le c_1 \le 4\ e\ c_2 \ge 8
|
|
||||||
$$
|
$$
|
||||||
|
|
||||||
|
Utilizando-se de uma calculadora eletrônica, obtemos que $0 \le c_1 ⪅ 2.16$ e $10 \le c_2$.
|
||||||
|
|
||||||
De fato, vemos que este resultado se concretiza para valores de $n \ge 1$:
|
De fato, vemos que este resultado se concretiza para valores de $n \ge 1$:
|
||||||
|
|
||||||
![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Introdução%20à%20Análise%20de%20Algoritmos/Imagens/2021-10-01-22-55-58-image.png)
|
<img title="" src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Introdução%20à%20Análise%20de%20Algoritmos/Imagens/2021-10-18-13-22-07-image.png" alt="" width="485" data-align="center">
|
||||||
|
|
||||||
> Linha verde: $f(n)$; linha cinza: $c_1g(n)$; e linha rosa: $c_2g(n)$
|
> Linha azul: $f(n)$; linha verde: $2.16\,g(n)$; e linha vermelha: $10\,g(n)$
|
||||||
|
|
||||||
Portanto, o tempo de processamento do algorítimo 3Soma é $\Theta(n^3)$ no pior caso. $\blacksquare$
|
Portanto, o tempo de processamento do algoritmo 3Soma é $\Theta(n^3)$ no pior caso. $\blacksquare$
|
||||||
|
|
||||||
## Exercício 3
|
## Exercício 3
|
||||||
|
|
||||||
|
@ -87,8 +94,8 @@ end
|
||||||
m ← 0
|
m ← 0
|
||||||
|
|
||||||
insertionSort (C, sizeof(C))
|
insertionSort (C, sizeof(C))
|
||||||
for i ← 1 to n
|
for i ← 1 to sizeof(A)
|
||||||
do for j ← 1 to n
|
do for j ← 1 to sizeof(B)
|
||||||
do if binarySearch (C, sizeof(C), -(A[i] + B[j]))
|
do if binarySearch (C, sizeof(C), -(A[i] + B[j]))
|
||||||
then m ← m + 1
|
then m ← m + 1
|
||||||
return m
|
return m
|
||||||
|
@ -145,4 +152,4 @@ Ao longo de sua execução, é invariável que $m$ equivale ao número de somas
|
||||||
|
|
||||||
RIBEIRO, M. **Introdução à Análise de Algoritmos**. Disponível em: <https://github.com/marciomr/apostila-iaa/blob/master/apostila-iaa.pdf>. Acesso em: 13 out. 2021.
|
RIBEIRO, M. **Introdução à Análise de Algoritmos**. Disponível em: <https://github.com/marciomr/apostila-iaa/blob/master/apostila-iaa.pdf>. Acesso em: 13 out. 2021.
|
||||||
|
|
||||||
[^1]: nUSP: 12543033
|
[^1]: nUSP: 12543033; Turma 04
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1882642cdcb5ea8bd695dfd315b232302fafcc46
|
Subproject commit 494f6a4e87c166debd17bf71db973158de42ab05
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 28 KiB |
605
Matemática Discreta I/Lista 2/Resolução Lista 2 - MD.md
Normal file
|
@ -0,0 +1,605 @@
|
||||||
|
# Resolução da [Lista 2](https://drive.google.com/file/d/1M3v_yk-E8G9nd8onq83WIpr3zsTuq_iJ/view?usp=drive_web&authuser=0) da disciplina de Matemática Discreta
|
||||||
|
|
||||||
|
> Feita por Guilherme de Abreu Barreto[^1]
|
||||||
|
|
||||||
|
## Funções proposicionais e quantificadores
|
||||||
|
|
||||||
|
### Exercício 1
|
||||||
|
|
||||||
|
**a)** "Existe pelo menos um elemento no conjunto $A$ tal que somado com 3 fica igual à 10". *Falso*, não há tal elemento.
|
||||||
|
|
||||||
|
**b)** "Todo elemento no conjunto $A$ é tal que somado com 3 fica menor que 10". *Verdadeiro*.
|
||||||
|
|
||||||
|
**c)** "Existe pelo menos um elemento no conjunto $A$ tal que somado com 3 fica menor ou igual a 5". *Verdadeiro*, os elementos 1 e 2.
|
||||||
|
|
||||||
|
**d)** "Todo elemento no conjunto $A$ é tal que somado com 3 fica menor que 7". *Falso*.
|
||||||
|
|
||||||
|
### Exercício 2
|
||||||
|
|
||||||
|
**a)** "Existe pelo menos um elemento em $A$ que, para todo elemento em $A$, quando elevado ao quadrado possui valor menor que a soma doutro ou do mesmo elemento com 1". *Verdadeiro*, o elemento 1, no caso.
|
||||||
|
|
||||||
|
**b)** "Para todo elemento em $A$ existe um elemento em $A$ cuja soma dos quadrados destes elementos é menor que 12". *Verdadeiro*.
|
||||||
|
|
||||||
|
**c)** "Para todo par de elementos em $A$ a soma dos quadrados destes é menor que 12". *Falso*.
|
||||||
|
|
||||||
|
### Exercício 3
|
||||||
|
|
||||||
|
**a)** $(\forall x \in \R)(\exists y \in \R)(\neg P(x,y));$
|
||||||
|
|
||||||
|
**b)** $(\exists x \in \R)(\exists y \in \R)(\neg P(x,y));$
|
||||||
|
|
||||||
|
**c)** $(\forall y \in \R) (\forall x \in \R) (\exists z \in \R)(\neg P(x,y)\lor \neg Q(x,z))$
|
||||||
|
|
||||||
|
### Exercício 4
|
||||||
|
|
||||||
|
**a)** Existe pelo menos um estudante de SI da EACH que não é do sexo masculino;
|
||||||
|
|
||||||
|
**b)** Nenhum dos estudantes de GPP da EACH tem 25 anos ou mais;
|
||||||
|
|
||||||
|
**c)** Existe pelo menos um estudante da EACH que não mora na ZL.
|
||||||
|
|
||||||
|
### Exercício 5
|
||||||
|
|
||||||
|
**a)** "Para qualquer número inteiro existe um número inteiro maior que este". *Verdadeiro*. Negação: "Existe um numero inteiro para o qual nenhum número inteiro é maior que este." $(\exist a \in \Z)(\forall b \in \Z)(\neg(a < b))$.
|
||||||
|
|
||||||
|
**b)** "Existe um número inteiro para o qual qualquer número inteiro é menor que ele". *Falso*. Negação: "Para qualquer número inteiro existe pelo menos um número inteiro que não seja menor que ele". $(\forall b \in \Z)(\exists a \in \Z)(\neg(a < b))$.
|
||||||
|
|
||||||
|
### Exercício 6
|
||||||
|
|
||||||
|
**a)** $(\exists x, y, z \in \Z)P(x,y,z)$
|
||||||
|
|
||||||
|
**b)** $(x \in \Z)(n \in \N : n \le 3)P(x_1, \dots, x_n)$
|
||||||
|
|
||||||
|
### Exercício 7[^2]
|
||||||
|
|
||||||
|
$$
|
||||||
|
(\forall \epsilon \in \R^+)(\exists n \in \N)(\forall n > N)(|x_n - x| < \epsilon)
|
||||||
|
$$
|
||||||
|
|
||||||
|
### Exercício 8
|
||||||
|
|
||||||
|
Proposição:
|
||||||
|
|
||||||
|
$$
|
||||||
|
(f, g : \R \to \R) (\forall s \in \R)(\exists r \in \R)(f(r) > 0 \implies g(s) > 0)
|
||||||
|
$$
|
||||||
|
|
||||||
|
Negação:
|
||||||
|
|
||||||
|
$$
|
||||||
|
(f, g: \R \to \R)(\exists s \in \R)(\forall r \in \R)(\neg(f(r) > 0 \implies g(s) > 0))
|
||||||
|
$$
|
||||||
|
|
||||||
|
A proposição implica que a função $g$ contém $f$, pois esta última influencia o valor da primeira, enquanto o contrário não ocorre.
|
||||||
|
|
||||||
|
## Estratégias de demonstração
|
||||||
|
|
||||||
|
### Exercício 1
|
||||||
|
|
||||||
|
**Proposição**
|
||||||
|
|
||||||
|
Sejam $n$ e $k$ dois números naturais onde $n > k$. Se tentarmos distribuir $n$ objetos em $k$ urnas ($P$), então pelo menos uma das urnas conterá mais de um objeto ($Q$). $P\implies Q$.
|
||||||
|
|
||||||
|
**Contrapositiva**
|
||||||
|
|
||||||
|
Sejam $n$ e $k$ dois números naturais onde $n > k$. Pelo menos uma urna restará vazia ($\neg Q$) se tentarmos distribuir $k$ objetos em $n$ urnas ($\neg P$). $\neg Q \implies \neg P$.
|
||||||
|
|
||||||
|
### Exercício 2
|
||||||
|
|
||||||
|
Consideremos $N$ um número de $n$ dígitos $\{a_1, a_2, \dots, a_n\}$ cuja soma $a_1 + a_2 + \dots + a_n = \sum^n_{i = 1} a_i = k$. Sabemos que o critério de divisibilidade de $N$ por 9 é $N | 9 \iff N = 9q$, $\forall N, n, a, k, q \in \N$. Podemos descrever $N$ da seguinte maneira:
|
||||||
|
|
||||||
|
$$
|
||||||
|
N = a_1 \cdot 10^{n - 1} + a_2 \cdot 10^{n - 2} + \dots + a_n \cdot 10^{n - n}
|
||||||
|
= \sum^n_{i = 1}a_i10^{n - i}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Por vez, $10^{n}$ pode ser escrito da seguinte forma:
|
||||||
|
|
||||||
|
$$
|
||||||
|
10^n = 99\dots9 (\text{n - 1 vezes}) + 1 = \underbrace{\sum^{n - 1}_{i = 1}9\cdot 10^i}_{\equiv\ 9q} + 1
|
||||||
|
$$
|
||||||
|
|
||||||
|
Logo, para cada dígito de $N$ teremos:
|
||||||
|
|
||||||
|
$$
|
||||||
|
N = a_1[(10^{n - 1}- 1) + 1] + a_2((10^{n - 2} - 1) + 1] + \dots
|
||||||
|
+ a_n [(10^{n - n} - 1) + 1] =
|
||||||
|
\\ \sum^n_{i = 1}a_i(9q + 1) = k9q + k
|
||||||
|
$$
|
||||||
|
|
||||||
|
Finalmente, $9kq | 9$ e, se $k | 9$ o for, então também é $N | 9$. $\blacksquare$
|
||||||
|
|
||||||
|
### Exercício 3
|
||||||
|
|
||||||
|
**Prova direta**
|
||||||
|
|
||||||
|
Se um número n é par, então $n|2 \implies n = 2k$ para qualquer $k \in \R$.
|
||||||
|
|
||||||
|
$$
|
||||||
|
n^2 = 2k = \pm \sqrt{2k} \cdot \frac{\sqrt 2}{\sqrt 2}
|
||||||
|
= 2 \cdot \underbrace{\left(\pm \frac{\sqrt k}{\sqrt 2}\right)}_{k_2}
|
||||||
|
= 2k_2\ \blacksquare
|
||||||
|
$$
|
||||||
|
|
||||||
|
**Prova por contrapositiva**
|
||||||
|
|
||||||
|
Retomemos o enunciado:
|
||||||
|
|
||||||
|
> Se $n^2$ é par ($P$), então $n$ é par ($Q$, $P \implies Q$).
|
||||||
|
|
||||||
|
A contrapositiva disso seria:
|
||||||
|
|
||||||
|
> Se $n$ é ímpar ($\neg Q$), $n^2$ é ímpar ($\neg P$, $\neg Q \implies \neg P$).
|
||||||
|
|
||||||
|
Se $n$ é ímpar, então $n \nmid 2 \implies n = 2k + 1$ para qualquer $k \in \R$.
|
||||||
|
|
||||||
|
$$
|
||||||
|
n^2 = n \cdot n = (2k + 1)(2k + 1) = 4k^2 + 2k + 2k + 1 =
|
||||||
|
2\underbrace{(2k^2 + 2k)}_{k_2} + 1 = 2k_2 + 1\ \blacksquare
|
||||||
|
$$
|
||||||
|
|
||||||
|
A primeira demonstração é mais objetiva: foram menores os números de passos requeridos. Mas em termos de compreensibilidade a alternativa possui seu valor.
|
||||||
|
|
||||||
|
### Exercício 4
|
||||||
|
|
||||||
|
Um número primo inteiro, $p \in \Z$ é aquele que tem **somente** quatro divisores distintos, $\pm 1$ e $\pm p$. Já um número primo natural, $p \in \N$ tem **unicamente** dois divisores naturais distintos: o número um e ele mesmo. Por estarmos tratando aqui de valores para $p$ tais que $p > 3$, estamos tratando de números primos **naturais**. Seria a fórmula $3k \pm 1$, $k \in \N$, capaz de representá-los?
|
||||||
|
|
||||||
|
- Todo número $p > 2$ é **ímpar**, doutra forma seria divisível por dois e não primo. Se segue que todo número p ímpar maior que 3 **não é divisível** por 3.
|
||||||
|
|
||||||
|
- Múltiplos de três são ora ímpar, ora par:
|
||||||
|
|
||||||
|
- $3(2k) = 2(3k) \equiv 0 (\text{mod }2)$, par;
|
||||||
|
|
||||||
|
- $3 (2k \pm 1) = 6n \pm 3 = 6k \pm 2 \pm 1 = 2(3k \pm 1) \pm 1 \equiv 0(\text{mod }2) \pm 1$, ímpar.
|
||||||
|
|
||||||
|
Assim, proponho que esta fórmula seja capaz de representar todos os números naturais impares $n_i$ não múltiplos de 3 para todo valor $2k$.
|
||||||
|
|
||||||
|
$n_i = 2k \pm 1 \equiv 0 (\text{mod }2) \pm 1\\
|
||||||
|
3(2k) \pm 1 = 2(3k) \pm 1 \equiv 0 (\text{mod }2) \pm 1\\
|
||||||
|
\therefore n_i \equiv 3(2k) \pm 1\ \blacksquare
|
||||||
|
$
|
||||||
|
|
||||||
|
### Exercício 5
|
||||||
|
|
||||||
|
Sempre que qualquer um dos lados de uma inequação sofre uma multiplicação por um valor menor que 0, o sinal de desigualdade assume sua forma dual, de tal sorte que $-2 < 1$ ao ser elevado ao quadrado fica:
|
||||||
|
|
||||||
|
$$
|
||||||
|
(-2)\underbrace{(-2)}_{<\ 0} > 1 \cdot 1 \implies 4 > 1\ \blacksquare
|
||||||
|
$$
|
||||||
|
|
||||||
|
### Exercício 6
|
||||||
|
|
||||||
|
**a.** Conforme exposto anteriormente, qualquer número ímpar pode ser representado pela forma $2k \pm 1 \equiv 0 (\text{mod } 2) \pm 1$, utilizaremo-nos aqui da forma $n = 2k + 1$:
|
||||||
|
|
||||||
|
$n^2 + 4n = (2k + 1)^2 + 4(2k + 1) = 4k^2 + 4k + 1 + 8k + 4 =\\ 2(2k^2 + 2k + 2) + 1 \equiv 0 (\text{mod }2) + 1 \text{; é ímpar.}\ \blacksquare$
|
||||||
|
|
||||||
|
**b.** A contrapositiva dessa afirmação é: se $r$ é racional então $r^2$ é racional. Por definição um número racional é aquele que pode ser representado na forma
|
||||||
|
|
||||||
|
$$
|
||||||
|
\frac n d, n \in \Z, d \in \Z^*
|
||||||
|
$$
|
||||||
|
|
||||||
|
Então,
|
||||||
|
|
||||||
|
$$
|
||||||
|
r = \frac nd \implies r^2 = \frac{n^2}{d^2} = \dfrac{n_2}{d_2}, n_2 \in \Z, d \in \Z^*\ \blacksquare
|
||||||
|
$$
|
||||||
|
|
||||||
|
**c.** Falso. Por exemplo, para $n = 2$ este não é o caso:
|
||||||
|
|
||||||
|
$$
|
||||||
|
2^5 < 5^n \implies 32 < 25 \equiv F
|
||||||
|
$$
|
||||||
|
|
||||||
|
Enquanto para $n = 1$ é:
|
||||||
|
|
||||||
|
$$
|
||||||
|
1^5 < 5^1
|
||||||
|
$$
|
||||||
|
|
||||||
|
Então seria correto dizer que $(\exists n \in \N)(n^5 < 5^n)$. $\blacksquare$
|
||||||
|
|
||||||
|
**d.** Na matemática, considera-se triviais soluções ou exemplos ridiculamente simples e de pouco interesse. Muitas vezes, as soluções ou exemplos triviais que envolvem o número 0 são considerados triviais. Este não é o caso com a desigualdade de Bernoulli, que tem implicações importantes para a análise combinatória necessita ser demonstrada por indução finita. Isto é, admite-se 0 enquanto base de indução, mas então procede-se a demonstrar que tal hipótese vale para qualquer número natural $n$. Tal demonstração se dá da seguinte maneira:
|
||||||
|
|
||||||
|
1. $(1 + r)^n \ge 1 + nr$ é válido para $n = 0$: $(1+r)^0 = 1; 1 \ge 1 + 0r$.
|
||||||
|
|
||||||
|
2. Agora, veremos se isso é válido para $n + 1$:
|
||||||
|
|
||||||
|
$(1 + r)^n \ge 1 + nr \implies (1 + r)(1 + r)^n \ge (1 + r)(1 + nr) \implies \\ (1 + r)^{n + 1} \ge 1 + nr + r + \underbrace{nr^2}_{\ge\ 0}$
|
||||||
|
|
||||||
|
Repare que em $(1 + r)^{n + 1} \ge 1 + nr + r + nr^2$, $nr^2$ é sempre maior ou igual à 0, então
|
||||||
|
|
||||||
|
$(1 + r)^{n + 1} \ge 1 + nr + r \implies (1 + r)^{n + 1} \ge 1 + r(n + 1)\ \blacksquare$
|
||||||
|
|
||||||
|
Fica demonstrado que tal igualdade é válida para qualquer $n \in \N$.
|
||||||
|
|
||||||
|
### Exercício 7
|
||||||
|
|
||||||
|
**a.** Considerando a progressão aritmética $1, \dots, n$, a soma de todos os termos desta progressão ($S_n$)pode ser escrita das seguintes formas:
|
||||||
|
|
||||||
|
$$
|
||||||
|
S_n = 1 + \dots + n \\
|
||||||
|
S_n = n + \dots + 1
|
||||||
|
$$
|
||||||
|
|
||||||
|
Somando estas formulações membro a membro, obtemos:
|
||||||
|
|
||||||
|
$$
|
||||||
|
2 S_n = (1 + n) + (2 + (n - 1)) + \dots + ((n - 1) + 2) + (n + 1)
|
||||||
|
$$
|
||||||
|
|
||||||
|
Nesta formulação, notemos que
|
||||||
|
|
||||||
|
- Todos os pares entre parênteses têm o mesmo valor, por serem simétricos em relação às extremidades da progressão;
|
||||||
|
|
||||||
|
- existem n pares.
|
||||||
|
|
||||||
|
Logo,
|
||||||
|
|
||||||
|
$$
|
||||||
|
2 S_n = n(1 + n) \implies S_n = \frac{n(n + 1)}2
|
||||||
|
$$
|
||||||
|
|
||||||
|
Consideremos agora a soma dos cubos $1^3, \dots , n^3$. O produto notável cubo da soma pode ser descrito da seguinte forma:
|
||||||
|
|
||||||
|
$$
|
||||||
|
(a + b)^3 = a^3 + 3a^2b + 3ab^2 + b^3
|
||||||
|
$$
|
||||||
|
|
||||||
|
Então, enquanto $k^3 = k^3$ para qualquer número $k \in \Z$, temos que
|
||||||
|
|
||||||
|
$$
|
||||||
|
(k + 1)^3 = k^3 + 3k^2 + 3k + 1
|
||||||
|
$$
|
||||||
|
|
||||||
|
Então, $1^3 + \dots + n^3$ equivale à
|
||||||
|
|
||||||
|
$$
|
||||||
|
+ \begin{cases}
|
||||||
|
\textcolor{red}{\cancel{1^3}} = 1^3 \\
|
||||||
|
\textcolor{magenta}{\cancel{2^3}} = 1^3 + 3(1)^2 + 3(1) + \textcolor{red}{\cancel 1} \\
|
||||||
|
\textcolor{blue}{\cancel{3^3}} = \textcolor{magenta}{\cancel{2^3}} + 3(2)^2 + 3(2) + 1 \\
|
||||||
|
\cancel{4^3} = \textcolor{blue}{\cancel{3^3}} + 3(3)^2 + 3(3) + 1 \\
|
||||||
|
\vdots \\
|
||||||
|
\cancel{n^3} = \cancel{(n - 1)^3} + 3(n-1)^2 + 3(n - 1) + 1 \\
|
||||||
|
(n + 1)^3 = \cancel{n^3} + 3n^2 + 3n + 1
|
||||||
|
\end{cases} \\ \implies
|
||||||
|
(n + 1)^3 = 1^3 + 3 S_{n^2} + 3 S_n + (n + 1)
|
||||||
|
$$
|
||||||
|
|
||||||
|
Onde $S_{n^2}$ é o valor da soma dos quadrados de $1, \dots, n$, ou seja, o valor que buscamos. Resolvendo essa equação, temos:
|
||||||
|
|
||||||
|
$(n + 1)^3 = 1 + 3S_{n^2} + 3 \dfrac{n(n + 1)}2 + (n + 1)\\
|
||||||
|
\implies 6 S_{n^2} = 2 (n + 1)^3 - 3n(n+ 1) - 2(n + 1)\\ = (n + 1)[2(n+ 1)^2 - 3n - 2]\\ = (n + 1)[2(n^2 + 2n + 1) - 3n - 2]\\ = (n + 1) (2n^2 + 4n + \cancel 2 - 3n - \cancel 2)\\ = n(n + 1)(2n + 1)\\ \implies S_{n^2} = \dfrac{n(n + 1)(2n + 1)}6\ \blacksquare$
|
||||||
|
|
||||||
|
**b.**
|
||||||
|
|
||||||
|
1. A hipótese se conforma na base de indução: $1^3 = 1^2$.
|
||||||
|
|
||||||
|
2. Se assumirmos que
|
||||||
|
|
||||||
|
$$
|
||||||
|
1^3 + \dots + n^3 = \left[\dfrac{n(n + 1)}2\right]^2
|
||||||
|
$$
|
||||||
|
|
||||||
|
é verdadeiro, então
|
||||||
|
|
||||||
|
$$
|
||||||
|
1^3 + \dots + (n + 1)^3 = \left[\dfrac{(n + 1)(n + 2)}2\right]^2
|
||||||
|
$$
|
||||||
|
|
||||||
|
também o é.
|
||||||
|
|
||||||
|
3. Testemos esta hipótese de indução:
|
||||||
|
|
||||||
|
$1^3 + \dots + n^3 + (n + 1)^3 = \left[\dfrac{n(n + 1)}2\right]^2 + (n + 1)^3 = (n + 1)^2 \left(\dfrac{n^2}4 + n + 1\right)\\ = \dfrac{(n + 1)^2(n^2 + 4n + 4)}4 = \dfrac{(n + 1)^2(n + 2)^2}4 = \left[\dfrac{(n + 1)(n + 2)}2\right]^2\ \blacksquare$
|
||||||
|
|
||||||
|
**c.**
|
||||||
|
|
||||||
|
- Base de indução ($n = 2$):
|
||||||
|
|
||||||
|
$\displaystyle \frac{a_1}{1 + a_1} + \frac{a_2}{(1 + a_1) (1 + a_1 + a_2)} = \frac{a_1(1 + a_1 + a_2) + a_2}{(1 + a_1) (1 + a_1 + a_2)} \\\ \\ = \frac{a_1 + a_1^2 + a_1a_2 + a_2}{(1 + a_1) (1 + a_1 + a_2)} = \frac{a_1\ \cancel{(1 + a_1)} + a_2\ \cancel{(1 + a_1)}}{\cancel{(1 + a_1)}(1 + a_1 + a_2)} = \frac{a_1 + a_2}{1 + a_1 + a_2}$
|
||||||
|
|
||||||
|
- Hipótese de indução: se
|
||||||
|
|
||||||
|
$$
|
||||||
|
\frac{a_1 + \dots + a_n}{1 + a_1 + \dots a_n}
|
||||||
|
= \frac{a_1}{1 + a_1} + \dots +
|
||||||
|
\frac{a_n}{(1 + a_1 + \dots + a_{n - 1})(1 + a_1 + \dots + a_n)}
|
||||||
|
$$
|
||||||
|
|
||||||
|
para todo $n \in \N$, então
|
||||||
|
|
||||||
|
$$
|
||||||
|
\frac{a_1 + \dots + a_{n + 1}}{1 + a_1 + \dots a_{n + 1}}
|
||||||
|
= \frac{a_1}{1 + a_1} + \dots +
|
||||||
|
\frac{a_{n + 1}}{(1 + a_1 + \dots + a_n)(1 + a_1 + \dots + a_{n + 1})}
|
||||||
|
$$
|
||||||
|
|
||||||
|
- Passo de indução:
|
||||||
|
|
||||||
|
$\displaystyle \frac{a_1}{1 + a_1} + \dots +
|
||||||
|
\frac{a_{n + 1}}{(1 + a_1 + \dots + a_n)(1 + a_1 + \dots + a_{n + 1})} =\\\ \\ \underbrace{\frac{a_1 + \dots + a_n}{1 + a_1 + \dots a_n}}_{\text{Por hipótese}} + \frac{a_{n + 1}}{(1 + a_1 + \dots + a_n)(1 + a_1 + \dots + a_{n + 1})}
|
||||||
|
$
|
||||||
|
|
||||||
|
Prosseguimos com a substituição de variáveis $a_1 + \dots + a_n = A$:
|
||||||
|
|
||||||
|
$\displaystyle \frac{A}{1 + A} + \frac{a_{n + 1}}{(1 + A) (1 + A + a_{n + 1})} = \frac{A(1 + A + a_{n + 1}) + a_{n + 1}}{(1 + A) (1 + A + a_{n + 1})} \\\ \\ = \frac{A + A^2 + Aa_{n + 1} + a_{n + 1}}{(1 + A) (1 + A + a_{n + 1})} = \frac{A\ \cancel{(1 + A)} + a_{n + 1}\ \cancel{(1 + A)}}{\cancel{(1 + A)}(1 + A + a_{n + 1})} = \frac{a_1 + \dots + a_{n + 1}}{1 + a_1 + \dots a_{n + 1}}\,\blacksquare$
|
||||||
|
|
||||||
|
### Exercício 8
|
||||||
|
|
||||||
|
**a.** Três é um número ímpar e, portanto, pode ser escrito na forma $(2k + 1)$. Logo,
|
||||||
|
|
||||||
|
$(2k + 1)^n - 1 = (2^nk^n + 2^{n - 1}k^{n - 1} + \dots + 2k + \cancel 1) - \cancel 1\\ = 2(2^{n - 1}k^n + 2^{n - 2}k^{n - 1} + \dots + k) \equiv 0(\text{mod 2})$
|
||||||
|
|
||||||
|
Ou seja, um número par. $\blacksquare$
|
||||||
|
|
||||||
|
**b.** Se $n$ é par, então
|
||||||
|
|
||||||
|
$5^n - 2^n = 5^{2k} - 2^{2k} = (5^k - 2^k) (5^k + 2^k)\\ = (5 - 2)(5^{k - 1} + 5^{k - 2} \cdot 2 + \dots + 5 \cdot 2^{k - 2} + 2^{k - 1})(5^k + 2^k) \\ = 3(5^{k - 1} + 5^{k - 2} \cdot 2 + \dots + 5 \cdot 2^{k - 2} + 2^{k - 1})(5^k + 2^k) \equiv 0 (\text{mod 3})$
|
||||||
|
|
||||||
|
Senão,
|
||||||
|
|
||||||
|
$5^{2k +1} - 2^{2k + 1} = (5 - 2)(5^{2k} + 5^{2k - 1} \cdot 2 + \dots + 5 \cdot 2^{2k - 1} + 2^{2k}) = \\ 3(5^{2k} + 5^{2k - 1} \cdot 2 + \dots + 5 \cdot 2^{2k - 1} + 2^k) \equiv 0 (\text{mod 3})\ \blacksquare$
|
||||||
|
|
||||||
|
**c.** $2^n + 3^n$ é múltiplo de 5 quando $n = 2k + 1$ (ida):
|
||||||
|
|
||||||
|
$2^{2k +1} - 3^{2k + 1} = (2 + 3)(2^{2k} + 2^{2k - 1} \cdot 3 + \dots + 2 \cdot 3^{2k - 1} + 3^k) = \\ 5(2^{2k} + 2^{2k - 1} \cdot 3 + \dots + 2 \cdot 3^{2k - 1} + 3^k) \equiv 0 (\text{mod 5})$
|
||||||
|
|
||||||
|
o número 5, ao ser multiplicado, **não** produz um número da forma $2^n + 3^n$, quando $n = 2k$ (volta):
|
||||||
|
|
||||||
|
- Toda potência de 5 tem como último algarismo 5, pois o resultado da multiplicação de 5 por 5 é 25.
|
||||||
|
|
||||||
|
- Toda potência $2^{2k} = 4^k$, $4 \times 4 = 1\textbf 6; 16 \times 4 = 2\textbf 4; 24 \times 4 = 9\textbf 6$, e assim por diante. Ou seja, ora se produz final 6, ora se produz final 4.
|
||||||
|
|
||||||
|
- Toda potência $3^{2k} = 9^k, 9 \times 9 = 8\textbf 1; 81 \times 9 = 72\textbf 9; 729 \times 9 = 656\textbf 1$, e assim por diante. Ou seja, ora se produz final 1, ora se produz final 9.
|
||||||
|
|
||||||
|
Como 1 + 6 = 7 produz final 7 e 9 + 4 = 13 produz final 3, não é possível que o número resultante desta soma seja múltiplo de 5. $\blacksquare$
|
||||||
|
|
||||||
|
**d.**
|
||||||
|
|
||||||
|
- Base da indução $(k = 1)$:
|
||||||
|
|
||||||
|
$0^3 + 1^3 + 2^3 = 9 \equiv 0(\text{mod 9})$;
|
||||||
|
|
||||||
|
- Hipótese de indução: Se
|
||||||
|
|
||||||
|
$(k - 1)^3 + k^3 + (k + 1)^3 = k^3 - \cancel{3k^2} + 3k - \cancel 1 + k^3 + k^3 + \cancel{3k^2} + 3k - \cancel 1 \\
|
||||||
|
= 3k^3 + 6k \equiv 0(\text{mod 9})$para qualquer $k \in \N$, então também
|
||||||
|
|
||||||
|
$3(k + 1)^3 + 6(k + 1) \equiv 0(\text{mod 9})$
|
||||||
|
|
||||||
|
- Passo de indução:
|
||||||
|
|
||||||
|
$k^3 + (k + 1)^3 + (k + 2)^3 = k^3 + k^3 + 3k^2 + 3k + 1 + k^3 + 6k^2 + 12k + 8\\ = 3k^3 + 9k^2 + 9k + 3 + 6k + 6 = 3(k^3 + 3k^2 + 3k + 1) + 6k + 6\\ = 3(k + 1)^3 + 6(k + 1) \equiv \text{0(mod 9)}\,\blacksquare$
|
||||||
|
|
||||||
|
Logo, conclui-se que a soma de três cubos consecutivos de fato produz um número divisível por 9.
|
||||||
|
|
||||||
|
### Exercício 9
|
||||||
|
|
||||||
|
- Base da indução $(n = 1)$:
|
||||||
|
|
||||||
|
$(\cos \theta + i\sin \theta)^1 = \cos \theta + i\sin \theta$
|
||||||
|
|
||||||
|
- Hipótese de indução: se
|
||||||
|
|
||||||
|
$(\cos \theta + i\sin \theta)^n = \cos (n\theta) + i \sin (n\theta)$
|
||||||
|
|
||||||
|
para todo $n \ge 1$, então também
|
||||||
|
|
||||||
|
$(\cos \theta + i\sin \theta)^{n + 1} = \cos [(n + 1)\theta] + i \sin [(n + 1)\theta]$
|
||||||
|
|
||||||
|
- Passo de indução:
|
||||||
|
|
||||||
|
$(\cos \theta + i\sin \theta)^{n + 1} = (\cos \theta + i\sin \theta)^n(\cos \theta + i\sin \theta)\\ = \underbrace{[\cos (n\theta) + i \sin (n\theta)]}_{\text{Por hipótese}}(\cos \theta + i\sin \theta)\\ = \cos(n\theta)\cos \theta - \sin(n\theta)\sin \theta + i[\cos(n\theta)\sin(\theta) + \sin(n\theta)\cos \theta]\\ = \underbrace{\cos [(n + 1)\theta] + i \sin [(n + 1)\theta]}_{\text{Por identidade trigonométrica}}$
|
||||||
|
|
||||||
|
**Fazendo uso da identidade de Euler**
|
||||||
|
|
||||||
|
- Base da indução $(n = 1)$:
|
||||||
|
|
||||||
|
$e^{1i\theta} = \cos \theta + i\sin \theta$
|
||||||
|
|
||||||
|
- Hipótese de indução: se
|
||||||
|
|
||||||
|
$e^{ni\theta} = \cos (n\theta) + i \sin (n\theta)$
|
||||||
|
|
||||||
|
para todo $n \ge 1$, então também
|
||||||
|
|
||||||
|
$e^{(n + 1)i\theta} = \cos [(n + 1)\theta] + i \sin [(n + 1)\theta]$
|
||||||
|
|
||||||
|
- Passo de indução:
|
||||||
|
|
||||||
|
$e^{(n + 1)i\theta} = e^{ni\theta}e^{1i\theta} = (\cos \theta + i\sin \theta)^n(\cos \theta + i\sin \theta)\\ = \underbrace{[\cos (n\theta) + i \sin (n\theta)]}_{\text{Por hipótese}}(\cos \theta + i\sin \theta)\\ = \cos(n\theta)\cos \theta - \sin(n\theta)\sin \theta + i[\cos(n\theta)\sin(\theta) + \sin(n\theta)\cos \theta]\\ = \underbrace{\cos [(n + 1)\theta] + i \sin [(n + 1)\theta]}_{\text{Por identidade trigonométrica}}\,\blacksquare$
|
||||||
|
|
||||||
|
### Exercício 10
|
||||||
|
|
||||||
|
- Base da indução $(n = 1)$
|
||||||
|
|
||||||
|
$H_1(x) = e^{x^2}\left(- \dfrac d{dx}\right)^1e^{-x^2} = e^{x^2}\cdot 2xe^{-x^2} = 2x$
|
||||||
|
|
||||||
|
- Hipótese de indução: se
|
||||||
|
|
||||||
|
$H_n(x) = e^{x^2}\left(-\dfrac d{dx}\right)^ne^{-x^2}$
|
||||||
|
|
||||||
|
para todo $n \ge 1$, então também
|
||||||
|
|
||||||
|
$H_{n + 1}(x) = e^{x^2}\left(-\dfrac d{dx}\right)^{n + 1}e^{-x^2}$
|
||||||
|
|
||||||
|
- Passo de indução:
|
||||||
|
|
||||||
|
$H_n(x) = e^{x^2}\left(-\dfrac d{dx}\right)^ne^{-x^2} \implies \left(\dfrac d{dx}\right)^ne^{-x^2} = (-1)^nH_n(x)e^{-x^2} \\ \left(\dfrac d{dx}\right)^{n + 1}e^{-x^2} = (-1)^n \underbrace{\left[\left(\dfrac d{dx} H_n (x)\right)e^{-x^2} + H_n(x)(-2x)e^{-x^2}\right]}_{\text{Aplicação da regra da cadeia}}\\ = (-1)^{n + 1}e^{-x^2}\left[\left(2x - \dfrac d{dx}\right)H_n(x)\right] = (-1)^{n + 1}e^{x^2}\left(\dfrac d{dx}\right)^{n + 1}e^{-x^2} = H_{n + 1}(x)\,\blacksquare$
|
||||||
|
|
||||||
|
Quanto a paridade do polinômio de Hermite, vemos que ele possui grau $n$, de tal sorte que, como demonstra o gráfico abaixo
|
||||||
|
|
||||||
|
<img title="" src="file:///home/user/Public/USP/Sistemas de Informação/2º semestre/Matemática Discreta I/Lista 2/Imagens/b4c9396a9eed57a19126a47fc5a401ac316fcd5b.png" alt="" data-align="center" width="305">
|
||||||
|
|
||||||
|
Este produz uma função ímpar quando $n$ é ímpar e uma função par quando não.
|
||||||
|
|
||||||
|
### Exercício 11
|
||||||
|
|
||||||
|
- Base de indução $(n = 1)$:
|
||||||
|
|
||||||
|
$\dfrac{[f(x)]'}{f(x)} = \dfrac{f'(x)}{f(x)}$
|
||||||
|
|
||||||
|
Para demonstrar a propriedade das derivadas subjacente a este cálculo, vale a pena explicitar o passo seguinte também. Considerando que
|
||||||
|
|
||||||
|
$$
|
||||||
|
f(x) = g(x) h(x) \implies f'(x) = g(x) h'(x) + g'(x) h(x)
|
||||||
|
$$
|
||||||
|
|
||||||
|
Então
|
||||||
|
|
||||||
|
$\dfrac{[f_1(x)f_2(x)]'}{f_1(x)f_2(x)} = \dfrac{\cancel{f_1(x)}f'_2(x)}{\cancel{f_1(x)}f_2(x)} + \dfrac{\cancel{f_2(x)}f'_1(x)}{f_1(x)\cancel{f_2(x)}} = \dfrac{f'_1(x)}{f_1(x)} + \dfrac{f'_2(x)}{f_2(x)}$
|
||||||
|
|
||||||
|
- Hipótese de indução: se
|
||||||
|
|
||||||
|
$\dfrac{[f_1(x)\dots f_n(x)]'}{f_1(x)\dots f_n(x)} = \dfrac{f_1'(x)}{f_1(x)} + \dots + \dfrac{f_n'(x)}{f_n(x)}$
|
||||||
|
|
||||||
|
então, para $n \ge 1$, $n \in \N$,
|
||||||
|
|
||||||
|
$\dfrac{[f_1(x)\dots f_{n + 1}(x)]'}{f_1(x)\dots f_{n + 1}(x)} = \dfrac{f_1'(x)}{f_1(x)} + \dots + \dfrac{f_{n + 1}'(x)}{f_{n + 1}(x)}$
|
||||||
|
|
||||||
|
- Passo de indução: considerando $g(x) = f_1(x)\dots f_n$
|
||||||
|
|
||||||
|
$\dfrac{[g(x)f_{n + 1}]'}{g(x)f_{n + 1}} = \dfrac{\cancel{g(x)}f'_{n + 1}(x)}{\cancel{g(x)}f_{n + 1}(x)} + \dfrac{g'(x)\cancel{f_{n + 1}(x)}}{g(x)\cancel{f_{n + 1}(x)}} = \underbrace{\dfrac{f'_1(x)}{f_1(x)} + \dots + \dfrac{f'_n(x)}{f_n(x)}}_{\text{Por hipotése}} + \dfrac{f'_{n + 1}(x)}{f_{n + 1}(x)}\,\blacksquare$
|
||||||
|
|
||||||
|
### Exercício 12
|
||||||
|
|
||||||
|
Prosseguiremos nessa demonstração por absurdo. Assumiremos que $\sqrt 2 \in \mathbb Q$, portanto, $\sqrt 2 = \frac ab$, uma fração irredutível onde $a, b \in \Z$ e $b \not = 0$.
|
||||||
|
|
||||||
|
**Lema:** Todo quadrado de um número inteiro não nulo tem 1 como resto da divisão inteira por três se não for divisível por 3.
|
||||||
|
|
||||||
|
- Todo número inteiro quando dividido por três produz resto 0, 1 ou 2. Considerando que este não produza resto 0, temos:
|
||||||
|
|
||||||
|
$\begin{cases}
|
||||||
|
(3k + 1)^2 = 9k^2 + 6k + 1 = 3\underbrace{(3k^2 + 2k)}_{k_2} + 1 \\
|
||||||
|
(3k + 2)^2 = 9k^2 + 12k + 4 = 3\underbrace{(3k^2 + 4k + 1)}_{k_2} + 1
|
||||||
|
\end{cases}, k \in \Z$
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Temos que $\left(\frac ab\right)^2 = 2$, 2 não é múltiplo de 3 e portanto
|
||||||
|
|
||||||
|
$2 = 3k + 1 \implies 3k = 1 \implies k = \frac 13, k \not \in \Z$
|
||||||
|
|
||||||
|
O que é absurdo. **Teorema:** $\sqrt 2$ e irracional. $\blacksquare$
|
||||||
|
|
||||||
|
### Exercício 13 [^3]
|
||||||
|
|
||||||
|
$(\sqrt 2^{1 + \sqrt 2})^{1 + \sqrt 2} = 2^\frac{(1 + \sqrt 2)^2}2 = \underbrace{2^\frac{3 + 2\sqrt 2}{2}}_{\text{irracional}} \blacksquare$
|
||||||
|
|
||||||
|
### Exercício 14
|
||||||
|
|
||||||
|
**a. Prova por indução finita comum**
|
||||||
|
|
||||||
|
- Base de indução$(n = 2)$: 2 é primo: $2 = 2 \times 1$, então números primos existem.
|
||||||
|
|
||||||
|
- Hipótese de indução: se um número $n > 1$, $n \in \N$ é primo ou múltiplo de primos, $n - 1$ também é.
|
||||||
|
|
||||||
|
- Se $n + 1$ for primo, então não resta nada a provar. Senão, devemos concluir que existem pelo menos dois números inteiros $a$ e $b$, $1 < a \le b \le n$ tais que $ab = n$. Por vez estes também ou são primos ou múltiplos de primos, e assim por diante. Assim, percorremos todos os valores de $n$ à 1 e concluímos que a mesma condição se sustenta. $\blacksquare$
|
||||||
|
|
||||||
|
**b. Prova por indução forte**
|
||||||
|
|
||||||
|
- Base de indução$(n = 2)$: 2 é primo: $2 = 2 \times 1$, então números primos existem.
|
||||||
|
|
||||||
|
- Hipótese de indução: todos os números entre 1 e n ou são primos ou, senão, múltiplos de primos.
|
||||||
|
|
||||||
|
- Passo de indução: Se $n$ for primo, então não resta nada a provar. Senão, devemos concluir que existem pelo menos dois números inteiros $a$ e $b$, $1< a \le b \le n$ tais que $ab = n$. Pela hipótese de indução, $a = p_1p_2\dots p_n$ e $b = q_1q_2\dots q_n$, sendo $p$ e $q$ números primos. Ora, então $n$ também é múltiplo de números primos: $n = p_1p_2\dots p_3q_1q_2\dots q_3$ $\blacksquare$
|
||||||
|
|
||||||
|
### Exercício 15
|
||||||
|
|
||||||
|
<img title="" src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%202/Imagens/3e8adf06f84b682175f5551b93b16d101da89875.png" alt="" data-align="center" width="149">
|
||||||
|
|
||||||
|
> Exemplo de desenho feito seguindo esse método para $n = 3$.
|
||||||
|
|
||||||
|
**Propriedade 1:** Por não ser paralela a qualquer outra reta ou interceptá-las em um ponto comum, uma reta em posição geral intercepta demais retas no plano em n pontos distintos, sendo $n$ o número de demais retas.
|
||||||
|
|
||||||
|
**Propriedade 2:** Por interceptar as $n$ retas, temos $n + 1$ subdivisões do plano em faces opostas, somadas ao número de faces anterior. Ou seja,
|
||||||
|
|
||||||
|
$$
|
||||||
|
F_{n + 1} = F_n + n + 1
|
||||||
|
$$
|
||||||
|
|
||||||
|
1. Base de indução $(n = 0)$:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\dfrac{n^2 + n + 2}2 = 1
|
||||||
|
$$
|
||||||
|
|
||||||
|
De fato, um plano sem subdivisões tem uma única face.
|
||||||
|
|
||||||
|
2. Hipótese de indução: se o número de faces de um plano dividido por retas de maneira a gerar o maior número de subdivisões é dado por
|
||||||
|
|
||||||
|
$$
|
||||||
|
F_n = \dfrac{n^2 + n + 2}2
|
||||||
|
$$
|
||||||
|
|
||||||
|
Para qualquer número de retas $n$, então:
|
||||||
|
|
||||||
|
$$
|
||||||
|
F_{n + 1} = \dfrac{(n + 1)^2 (n + 1) + 2}2
|
||||||
|
$$
|
||||||
|
|
||||||
|
Passo de indução: Retomando a fórmula dada pela propriedade 2:
|
||||||
|
|
||||||
|
$F_{n + 1} = F_n + n + 1 = \dfrac{n^2 + n + 2}2 + n + 1 = \dfrac{n^2 + n + 2 + 2n + 2}2 = \\ = \dfrac{(n² + 2n + 1) + (n + 1) + 2}2 = \dfrac{(n + 1)^2 + (n + 1) + 2}2 \,\blacksquare$
|
||||||
|
|
||||||
|
### Exercício 16
|
||||||
|
|
||||||
|
- Base de indução: $0^p \equiv 0 (\text{mod p})$;
|
||||||
|
|
||||||
|
- Hipótese de indução: se $n^p \equiv n (\text{mod }p)$ para qualquer $n \in \N$ então também $(n + 1)^p \equiv (n + 1)(\text{mod }p)$.
|
||||||
|
|
||||||
|
- Passo de indução: para concluirmos, faremos uso do seguinte lema (o qual será por vez demonstrado ao final desta demonstração):
|
||||||
|
|
||||||
|
$$
|
||||||
|
(a + b)^p \equiv a^p + b^p (\text{mod }p), \forall a,b \in \N, p \in \mathbb P
|
||||||
|
$$
|
||||||
|
|
||||||
|
Ou seja,
|
||||||
|
|
||||||
|
$(n + 1)^p \equiv n^p + 1^p(\text{mod }p) \equiv n^p + 1(\text{mod }p)$
|
||||||
|
|
||||||
|
Pela hipótese de indução $n^p \equiv n (\text{mod }p)$, então
|
||||||
|
|
||||||
|
$$
|
||||||
|
(n + 1)^p \equiv n + 1(\text{mod }p)\,\blacksquare
|
||||||
|
$$
|
||||||
|
|
||||||
|
**Demonstração do lema *Freshman's Dream* (o sonho do calouro):**
|
||||||
|
|
||||||
|
Para $\forall a,b \in \N, p \in \mathbb P$, tem-se:
|
||||||
|
|
||||||
|
$$
|
||||||
|
(a + b)^p = a^p + \binom p1 x^{p - 1}y + \binom p2 x^{p - 2}y^2 + \dots +
|
||||||
|
\binom p{p - 1}xy^{p - 1} + y^p
|
||||||
|
$$
|
||||||
|
|
||||||
|
Isolando-se os coeficientes binomiais, tem-se que cada um deles pode ser escrito na forma:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\binom pi = \frac{p!}{i!(p - i)!} = p \dfrac{(p - 1)!}{i! (p - i)!} \in \N
|
||||||
|
$$
|
||||||
|
|
||||||
|
Como tanto $i < p$ e $(p - i) < p$, e $p$ não é divisível senão por $p$, cada $\binom pi$ é um coeficiente múltiplo de $p$. Assim, o módulo de $(a + b)^p$ por $p$ é tal que:
|
||||||
|
|
||||||
|
$$
|
||||||
|
(a + b)^p \equiv a^p + b^p (\text{mod }p)\,\blacksquare
|
||||||
|
$$
|
||||||
|
|
||||||
|
### Exercício 17
|
||||||
|
|
||||||
|
Para analisar o tempo de processamento deste algoritmo, consideraremos a linha 1 que se repete $(n - 1)$ vezes. A operação executada nessa linha, porém, não é atômica: ela toma tempo proporcional ao tamanho da entrada que varia em cada iteração. Na primeira iteração a comparação na linha 4 é feita $(n - 1)$ vezes, na segunda $(n − 2)$, e assim por diante. Assim, o tempo de processamento em função do tamanho $n$ da entrada, então, é:
|
||||||
|
|
||||||
|
$ \displaystyle \sum^{n - 1}_{i = 1}(n - i)
|
||||||
|
= \sum^{n - 1}_{i = 1} n - \sum^{n - 1}_{i = 1} i
|
||||||
|
= n(n - 1) - \frac{(n - 1)[(n - 1) + 1]}2 \\
|
||||||
|
= (n - 1)\left(n - \frac n2\right) = \frac{n (n - 1)}2
|
||||||
|
= \dfrac{n^2 - n}2 \in \Theta(n^2)\,\blacksquare
|
||||||
|
$
|
||||||
|
|
||||||
|
[^1]: nUSP: 12543033; Turma 04.
|
||||||
|
|
||||||
|
[^2]: Resposta retirada diretamente das notas de aula do dia 03/09/2021
|
||||||
|
|
||||||
|
[^3]: $(\sqrt 2^{\sqrt 2})^{\sqrt 2} = (2^{\frac 12 \cdot 2^{\frac 12}})^{2^{\frac 12}} = 2^{\cancel{\frac 12 \cdot 2^{\frac12} \cdot 2^{\frac 12}}} = 2$
|
After Width: | Height: | Size: 398 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 9.6 KiB |
After Width: | Height: | Size: 9.1 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 6.9 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 9.4 KiB |
After Width: | Height: | Size: 300 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 384 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 36 KiB |
407
Matemática Discreta I/Lista 3/Resolução Lista 3 - MD.md
Normal file
|
@ -0,0 +1,407 @@
|
||||||
|
# Resolução da [Lista 3](https://drive.google.com/file/d/11EVnUCFLDsAWBr3CKzHrrxE9ZWtppUSw/view?usp=drive_web&authuser=0) da disciplina de Matemática Discreta
|
||||||
|
|
||||||
|
> Feita por Guilherme de Abreu Barreto[^1]
|
||||||
|
|
||||||
|
## Teoria dos Conjuntos
|
||||||
|
|
||||||
|
### Exercício 1
|
||||||
|
|
||||||
|
**(a)** O conjunto dos planetas no Sistema Solar;
|
||||||
|
|
||||||
|
**(b)** O conjunto dos Estados Federativos da República do Brasil.
|
||||||
|
|
||||||
|
**(c)** O conjunto dos números naturais pares;
|
||||||
|
|
||||||
|
**(d)** O conjunto de potências de 2 para qualquer expoente ${x \in \N : x \ge 1}$;
|
||||||
|
|
||||||
|
**(e)** O conjunto dos números primos.
|
||||||
|
|
||||||
|
### Exercício 2
|
||||||
|
|
||||||
|
$A \cap B \cap C$: o conjunto das argentinas residentes no Brasil;
|
||||||
|
|
||||||
|
$B \backslash A$: o conjunto dos residentes no Brasil que não são argentinos;
|
||||||
|
|
||||||
|
$C \backslash A$: o conjunto das mulheres no mundo que não são argentinas;
|
||||||
|
|
||||||
|
$C \backslash B$: o conjunto das mulheres no mundo que não residem no Brasil;
|
||||||
|
|
||||||
|
$B \backslash C$: o conjunto de residentes homens no Brasil.
|
||||||
|
|
||||||
|
### Exercício 3
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{matrix}
|
||||||
|
\{\} & \{a\} & \{b\} & \{c\} \\
|
||||||
|
\{d\} & \{a,b\} & \{a,c\} & \{a,d\} \\
|
||||||
|
\{b,c\} & \{b,d\} & \{c,d\} & \{a,b,c\} \\
|
||||||
|
\{a,b,d\} & \{a,c,d\} & \{b,c,d\} & \{a,b,c,d\}
|
||||||
|
\end{matrix}
|
||||||
|
$$
|
||||||
|
|
||||||
|
### Exercício 4
|
||||||
|
|
||||||
|
$$
|
||||||
|
\binom 52 = \frac{5!}{2!(5 - 2)!} = 10
|
||||||
|
$$
|
||||||
|
|
||||||
|
### Exercício 5
|
||||||
|
|
||||||
|
A relação de contingência é transitiva. Então se A está contido em B, e B está contido em C, A está contido em C. Tal qual ilustra a seguinte imagem (em ordem reversa):
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/2021-10-27-18-24-07-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
### Exercício 6
|
||||||
|
|
||||||
|
Se $A$ está contido em $B$, então a união de $A$ com $C$ está contida pela união de $B$ com $C$. De fato, o seguinte diagrama de Venn demonstra esta proposição:
|
||||||
|
|
||||||
|
| A, B, C | B ∪ C | B ∪ C ⊆ A ∪ C |
|
||||||
|
|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
|
| ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/0666956f5b22720e81a8b19e0123d0bbb181e628.png) | ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/5bafa135117158e2f35d20cd8722390c445cb0db.png) | ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/79a22d36358fc370cc73cc65d857f9927d7e6fa8.png) |
|
||||||
|
|
||||||
|
### Exercício 7
|
||||||
|
|
||||||
|
Um dado conjunto A é subconjunto de um conjunto B se A está **contido** em B, isto é, todos os elementos de A também são elementos de B. Os elementos de A e B podendo mesmo coincidir.
|
||||||
|
|
||||||
|
Segue desta definição de subconjunto que o conjunto vazio é contido por todos os conjuntos, pois todos os conjuntos existentes contém os elementos que compõem o conjunto vazio, isto é, nenhum (todos tem nada e mais algo). Ainda, mesmo o conjunto vazio contém todos os elementos que constituem... o conjunto vazio, e portanto também o contém.
|
||||||
|
|
||||||
|
### Exercício 8
|
||||||
|
|
||||||
|
Uma vez que $A\backslash B = A \cap \overline B$, temos:
|
||||||
|
|
||||||
|
$(A \backslash B) \cup (B \backslash A)
|
||||||
|
= (A \cap \overline B) \cup (B \cap \overline A) = \underbrace{[(A \cap \overline B) \cup B] \cap [(A \cap \overline B) \cup \overline A]}_{\text{Distributiva}} \\ = [(A \cup B) \cap (\overline B \cup B)] \cap [(A \cup \overline A) \cap (\overline B \cup \overline A)] = [(A \cup B) \cap \Omega] \cap [\Omega \cap (\overline B \cup \overline A)]\\ = (A \cup B) \cap (\overline B \cup \overline A) = (A \cup B) \cap \underbrace{(\overline{A \cap B})}_{\text{De Morgan}} = (A \cup B) \backslash (A \cap B)\,\blacksquare$
|
||||||
|
|
||||||
|
### Exercício 9
|
||||||
|
|
||||||
|
#### Associatividade na intersecção
|
||||||
|
|
||||||
|
| $B \cap C$ | $A \cap (B \cap C)$ |
|
||||||
|
|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
|
| ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/f6718e43f7bfc4d96bf626cbfeaef9a5a00f1257.png) | ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/5d43aa55b225aa01a83f79681161cddf4d3ee3fe.png) |
|
||||||
|
| $A \cap B$ | $(A \cap B) \cap C$ |
|
||||||
|
| ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/ad71acd12cdaba338848679d7b7f76154e757687.png) | ![](file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/5d43aa55b225aa01a83f79681161cddf4d3ee3fe.png) |
|
||||||
|
|
||||||
|
#### Associatividade na união
|
||||||
|
|
||||||
|
| $B \cup C$ | $A \cup (B \cup C)$ |
|
||||||
|
|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
|
| ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/19640c8af4dfea52049f762f52e639a479e36313.png) | ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/1d66ddcd5609c366f062eff22f73812fb8282708.png) |
|
||||||
|
| $A \cup B$ | $(A \cup B) \cup C$ |
|
||||||
|
| ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/8f848a759ab6843f845632e171fef607836d22b2.png) | ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/1d66ddcd5609c366f062eff22f73812fb8282708.png) |
|
||||||
|
|
||||||
|
### Exercício 10
|
||||||
|
|
||||||
|
#### Distributividade da intersecção na união
|
||||||
|
|
||||||
|
| $B \cup C$ | $A \cap (B \cup C)$ |
|
||||||
|
|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
|
| ![](file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/19640c8af4dfea52049f762f52e639a479e36313.png) | ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/99652ebfc205887cb033d4e3d1cbcaee520c9650.png) |
|
||||||
|
|
||||||
|
| $A \cap B$ | $A \cap C$ | $(A \cap B) \cup (A \cap C)$ |
|
||||||
|
|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
|
| ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/ad71acd12cdaba338848679d7b7f76154e757687.png) | ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/8dc7516caa67a0946b53c8951a9a9c8ac2d47268.png) | ![](file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/99652ebfc205887cb033d4e3d1cbcaee520c9650.png) |
|
||||||
|
|
||||||
|
| $A \cup B$ | $A \cup C$ | $(A \cup B) \cap (A \cup C)$ |
|
||||||
|
|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
|
| ![](file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/8f848a759ab6843f845632e171fef607836d22b2.png) | ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/0eb7d5b2aaea2eeec7c705ecabcdd4b00db40016.png) | ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/38c95bfe63bf5c57d9a87ee53ca75547674b9e99.png) |
|
||||||
|
|
||||||
|
### Exercício 11
|
||||||
|
|
||||||
|
#### Complemento da intersecção
|
||||||
|
|
||||||
|
| $A \cap B$ | $\overline{A \cap B}$ |
|
||||||
|
|:----------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
|
| ![](file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/2021-10-27-23-10-23-image.png) | <img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/6a0ef6868c5af59f3618ee4e6d3999b1f751901a.png" title="" alt="" width="212"> |
|
||||||
|
|
||||||
|
| $\overline A$ | $\overline B$ | $\overline A \cup \overline B$ |
|
||||||
|
|:---------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
|
| ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/2021-10-28-13-05-14-image.png) | ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/57d9f887a8685e25de0394759eccc5808736a5bf.png) | <img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/6a0ef6868c5af59f3618ee4e6d3999b1f751901a.png" title="" alt="" width="208"> |
|
||||||
|
|
||||||
|
#### Complemento da união
|
||||||
|
|
||||||
|
| $A \cup B$ | $\overline{A \cup B}$ |
|
||||||
|
|:----------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
|
| ![](file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/2021-10-27-23-10-06-image.png) | <img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/ddf5127e24e7bac0516564851879785171dbe2a5.png" title="" alt="" width="212"> |
|
||||||
|
|
||||||
|
| $\overline A$ | $\overline B$ | $\overline A \cap \overline B$ |
|
||||||
|
|:----------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
|
| ![](file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/2021-10-28-13-05-14-image.png) | ![](file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/57d9f887a8685e25de0394759eccc5808736a5bf.png) | <img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/ddf5127e24e7bac0516564851879785171dbe2a5.png" title="" alt="" width="206"> |
|
||||||
|
|
||||||
|
### Exercício 12
|
||||||
|
|
||||||
|
**a.** $A\Delta B = \{0,1,2,3,7,8,9\}$;
|
||||||
|
|
||||||
|
**b.** $B \Delta C = \{1, 3, 4, 6, 8\}$;
|
||||||
|
|
||||||
|
**c.** $B \Delta D = \{2,3,4,6,9\}; A \cap (B \Delta D) = \{2,3,4,6\}$
|
||||||
|
|
||||||
|
**d.** $A \cap B = \{4,5,6\}; A \cap D = \{2,3,5\}; (A \cap B) \Delta (A\cap D) = \{2,3,4,6\}$
|
||||||
|
|
||||||
|
### Exercício 13
|
||||||
|
|
||||||
|
| $A \Delta B$ | $C$ | $A \Delta B \Delta C$ |
|
||||||
|
|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
|
| ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/87ff6311a217e1d31b0034614160ba72bc5bbe40.png) | ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/1d5ad7dfaf727a225c5b849048ad08571bdbd011.png) | ![](/home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/18801add5f21f8833e5f651b295331072fde9731.png) |
|
||||||
|
|
||||||
|
### Exercício 14
|
||||||
|
|
||||||
|
**a.** $A \oplus B = (A\backslash B) \cup (B \backslash A) = (B \backslash A) \cup (A\backslash B) = B \oplus A$
|
||||||
|
|
||||||
|
**b.** $A \oplus B = (A\backslash B) \cup (B \backslash A) = (\overline B\backslash \overline A) \cup (\overline A \backslash \overline B) = (\overline A \backslash \overline B) \cup (\overline B\backslash \overline A) = \overline A \oplus \overline B$
|
||||||
|
|
||||||
|
**c.** $A \oplus \varnothing = (A \backslash \varnothing) \cup (\varnothing \backslash A) = A \cup \varnothing = A$
|
||||||
|
|
||||||
|
**d.** $A \oplus A = (A\backslash A) \cup (A\backslash A) = \varnothing \cup \varnothing = \varnothing$
|
||||||
|
|
||||||
|
**e.** $A * A = A \cap A = A$
|
||||||
|
|
||||||
|
**f.** $A \oplus (B \oplus C) = A \oplus B \oplus C = (A \oplus B) \oplus C$
|
||||||
|
|
||||||
|
**g.** $A \oplus B = A \oplus C \implies (A \oplus B) \cap \overline A = (A \oplus C) \cap \overline A \implies (B \backslash A) = (C \backslash A)$
|
||||||
|
|
||||||
|
Pela definição de diferença, tem-se que $B\backslash A = \{x : (x \in B) \land (x \not \in A) \}$, e $C\backslash A = {x : (x \in C) \land (x \not \in A) }$. Ora, se $B\backslash A$ equivale a dizer que um elemento está em $C$ mas não em $A$ ($C\backslash A$), então $B = C$.
|
||||||
|
|
||||||
|
**h.** $A * (B \oplus C) = A \cap (B \oplus C) = \underbrace{(A \cap B) \oplus (A \cap C)}_{\text{Distributividade na intersecção}} = (A * B) \oplus (A * C)$
|
||||||
|
|
||||||
|
Propriedade esta da distributividade demonstrada no exercício 10.
|
||||||
|
|
||||||
|
### Exercício 15
|
||||||
|
|
||||||
|
**a.** Cada subconjunto a integrar o produto fundamental pode assumir 2 formas distintas: $A_i$ ou $\overline A_i$. Assim sendo, conforme a análise combinatória, para $n$ subconjuntos existem $2_1 \times 2_2 \times \dots \times 2_n = 2^n$ possibilidades distintas de produto fundamental.
|
||||||
|
|
||||||
|
**b.** Segue da formulação anterior que, para cada par $J$ e $K$ de produto fundamental existe pelo menos um conjunto $\overline A_i$ ($1 \le i \le n$) em $J$ que é complementar ao conjunto $A_i$ em $K$. Isto é, dado um elemento $x$ qualquer tem-se:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\{x : (x \in A_i)\ \underline \lor\ (x \in \overline A_i)\}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Onde $\underline \lor$ é o "ou exclusivo". Como $J = \{x : x \in (A_1 \cap \dots \cap A_i \cap \dots \cap A_n)\}$, $K = \{x : x \in (A_1 \cap \dots \cap \overline A_i \cap \dots \cap A_n)\}$ e a definição de intersecção para quaisquer conjuntos $A$ e $B$ é $A \cap B = \{x : (x \in A) \land (x \in B)\}$, não à elemento em $J$ que também pertença à $K$. Estes conjuntos são, portanto, **disjuntos** entre si.
|
||||||
|
|
||||||
|
**c.** O conjunto Universo $\Omega$ é aquele que engloba a todos os elementos que pertencem à qualquer conjunto. Consideremos o par de conjuntos $J$ e $K$ anterior. Um elemento $x$ que pertence a $J$ não pertence a $K$ e vice-versa, não obstante este pertence a algum conjunto e portanto pertence também ao conjunto Universo. Pela definição de produto fundamental, podemos extrapolar essa relação para qualquer número $n$ de conjuntos de produto fundamental. Assim, qualquer elemento $x$ é tal que pertence a um produto fundamental, não pertence aos $(n - 1)$ demais, e pertence ao conjunto Universo.
|
||||||
|
|
||||||
|
Como todos os elementos $x$ são assim compreendidos pelo conjunto Universo, pela definição de subconjunto dada no exercício 6, todo produto fundamental é subconjunto do conjunto Universo e, por conseguinte, o conjunto Universo unifica todos os produtos fundamentais.
|
||||||
|
|
||||||
|
## Exercício 16
|
||||||
|
|
||||||
|
Um subconjunto $X$ de $S$ é tal que possui $i$ elementos, $0 \le i \le n$, deste último. Ou seja, para cada elemento de $S$ existem 2 possibilidades: estar ou não em $X$. Assim sendo, conforme a análise combinatória, para $n$ elementos existem $2_1 \times 2_2 \times \dots \times 2_n = 2^n$ possíveis subconjuntos.
|
||||||
|
|
||||||
|
Tal qual fizemos no exercício 4, podemos quantificar o número de subconjuntos a conter $m$ elementos pela seguinte relação binominal:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\binom nm = \frac{n!}{m!(n - m)!}
|
||||||
|
$$
|
||||||
|
|
||||||
|
### Exercício 17
|
||||||
|
|
||||||
|
<img src="file:///home/user/Public/USP/Sistemas%20de%20Informação/2º%20semestre/Matemática%20Discreta%20I/Lista%203/Imagens/2021-10-29-12-49-06-image.png" title="" alt="" data-align="center">
|
||||||
|
|
||||||
|
A relação dada pelo enunciado trata-se do *Princípio de Inclusão e Exclusão*.
|
||||||
|
|
||||||
|
$$
|
||||||
|
|A \cup B| = |A| + |B| - |A \cap B|
|
||||||
|
$$
|
||||||
|
|
||||||
|
De fato, ao contarmos o número de elementos em $|A \cup B|$ pela soma dos elementos em $|A| + |B|$, necessitamos também subtrair o número de elementos em $|A \cap B|$ de forma a evitar que estes sejam contabilizados duas vezes.
|
||||||
|
|
||||||
|
### Exercício 18
|
||||||
|
|
||||||
|
Uma forma mais geral do Princípio de Inclusão Exclusão pode ser expressa como:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\left | \bigcup^n_{i = 1} A_i \right | = \sum^n_{i = 1} |A_i|
|
||||||
|
- \sum^{n - 1}_{i = 1}\sum^n_{j = i + 1} | A_i \cap A_j |
|
||||||
|
+ (-1)^{n - 1} \left | \bigcap^n_{i = 1} A_i \right |
|
||||||
|
$$
|
||||||
|
|
||||||
|
Assim, temos que
|
||||||
|
|
||||||
|
$|A \cup B \cup C| = (|A| + |B| + |C|) - (|A \cap B| + |A \cap C| + |B \cap C|) + |A \cap B \cap C|$
|
||||||
|
|
||||||
|
Enquanto
|
||||||
|
|
||||||
|
$|A \cup B \cup C \cup D| = (|A| + |B| + |C| + |D|) - (|A \cap B| + |A \cap C| + |A \cap D| \\ + |B \cap C| + |B \cap D| + |C \cap D|) - |A \cap B \cap C \cap D|$
|
||||||
|
|
||||||
|
### Exercício 19
|
||||||
|
|
||||||
|
Para qualquer elemento $x$, se $x$ está contido em $A$ este
|
||||||
|
|
||||||
|
- está contido em um subconjunto de $P(A)$
|
||||||
|
|
||||||
|
- não está contido em $B$ ou um subconjunto de $P(B)$
|
||||||
|
|
||||||
|
e vice-versa. Isso pois $A$ e $B$ tratam-se de conjuntos **disjuntos**. Assim sendo,
|
||||||
|
|
||||||
|
- $P(A) \cap P(B) = A \cap B = \varnothing$
|
||||||
|
|
||||||
|
- $P(A) \cup P(B) \subseteq A \cup B$
|
||||||
|
|
||||||
|
### Exercício 20
|
||||||
|
|
||||||
|
Observe o seguinte gráfico:
|
||||||
|
|
||||||
|
```vega-lite
|
||||||
|
{
|
||||||
|
"$schema": "https://vega.github.io/schema/vega/v5.json",
|
||||||
|
"description": "A basic stacked bar chart example.",
|
||||||
|
"width": 500,
|
||||||
|
"height": 200,
|
||||||
|
"padding": 5,
|
||||||
|
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"name": "table",
|
||||||
|
"values": [
|
||||||
|
{"x": "São religiosos", "y": 79, "c": 0}, {"x": "São religiosos", "y": 21, "c": 1},
|
||||||
|
{"x": "Fizeram compras online", "y": 26, "c": 0}, {"x": "Fizeram compras online", "y": 74, "c": 1}
|
||||||
|
],
|
||||||
|
"transform": [
|
||||||
|
{
|
||||||
|
"type": "stack",
|
||||||
|
"groupby": ["x"],
|
||||||
|
"sort": {"field": "c"},
|
||||||
|
"field": "y"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"scales": [
|
||||||
|
{
|
||||||
|
"name": "x",
|
||||||
|
"type": "band",
|
||||||
|
"range": "width",
|
||||||
|
"domain": {"data": "table", "field": "x"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "y",
|
||||||
|
"type": "linear",
|
||||||
|
"range": "height",
|
||||||
|
"nice": true, "zero": true,
|
||||||
|
"domain": {"data": "table", "field": "y1"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "color",
|
||||||
|
"type": "ordinal",
|
||||||
|
"range": "category",
|
||||||
|
"domain": {"data": "table", "field": "c"}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"axes": [
|
||||||
|
{"orient": "bottom", "scale": "x", "zindex": 1},
|
||||||
|
{"orient": "left", "scale": "y", "zindex": 1}
|
||||||
|
],
|
||||||
|
|
||||||
|
"marks": [
|
||||||
|
{
|
||||||
|
"type": "rect",
|
||||||
|
"from": {"data": "table"},
|
||||||
|
"encode": {
|
||||||
|
"enter": {
|
||||||
|
"x": {"scale": "x", "field": "x"},
|
||||||
|
"width": {"scale": "x", "band": 1, "offset": -1},
|
||||||
|
"y": {"scale": "y", "field": "y0"},
|
||||||
|
"y2": {"scale": "y", "field": "y1"},
|
||||||
|
"fill": {"scale": "color", "field": "c"}
|
||||||
|
},
|
||||||
|
"update": {
|
||||||
|
"fillOpacity": {"value": 1}
|
||||||
|
},
|
||||||
|
"hover": {
|
||||||
|
"fillOpacity": {"value": 0.5}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Se admitirmos que o maior número possível de pessoas não religiosas e que nunca fizeram uma compra online, temos que no mínimo o número de pessoas religiosas que nunca fizeram compras é $[100 - (26 + 21)]\% = 53\%$ da população. Por outro lado,
|
||||||
|
|
||||||
|
```vega-lite
|
||||||
|
{
|
||||||
|
"$schema": "https://vega.github.io/schema/vega/v5.json",
|
||||||
|
"description": "A basic stacked bar chart example.",
|
||||||
|
"width": 500,
|
||||||
|
"height": 200,
|
||||||
|
"padding": 5,
|
||||||
|
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"name": "table",
|
||||||
|
"values": [
|
||||||
|
{"x": "São religiosos", "y": 79, "c": 0}, {"x": "São religiosos", "y": 21, "c": 1},
|
||||||
|
{"x": "Não fizeram compras online", "y": 74, "c": 0}, {"x": "Não fizeram compras online", "y":26, "c": 1}
|
||||||
|
],
|
||||||
|
"transform": [
|
||||||
|
{
|
||||||
|
"type": "stack",
|
||||||
|
"groupby": ["x"],
|
||||||
|
"sort": {"field": "c"},
|
||||||
|
"field": "y"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"scales": [
|
||||||
|
{
|
||||||
|
"name": "x",
|
||||||
|
"type": "band",
|
||||||
|
"range": "width",
|
||||||
|
"domain": {"data": "table", "field": "x"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "y",
|
||||||
|
"type": "linear",
|
||||||
|
"range": "height",
|
||||||
|
"nice": true, "zero": true,
|
||||||
|
"domain": {"data": "table", "field": "y1"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "color",
|
||||||
|
"type": "ordinal",
|
||||||
|
"range": "category",
|
||||||
|
"domain": {"data": "table", "field": "c"}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"axes": [
|
||||||
|
{"orient": "bottom", "scale": "x", "zindex": 1},
|
||||||
|
{"orient": "left", "scale": "y", "zindex": 1}
|
||||||
|
],
|
||||||
|
|
||||||
|
"marks": [
|
||||||
|
{
|
||||||
|
"type": "rect",
|
||||||
|
"from": {"data": "table"},
|
||||||
|
"encode": {
|
||||||
|
"enter": {
|
||||||
|
"x": {"scale": "x", "field": "x"},
|
||||||
|
"width": {"scale": "x", "band": 1, "offset": -1},
|
||||||
|
"y": {"scale": "y", "field": "y0"},
|
||||||
|
"y2": {"scale": "y", "field": "y1"},
|
||||||
|
"fill": {"scale": "color", "field": "c"}
|
||||||
|
},
|
||||||
|
"update": {
|
||||||
|
"fillOpacity": {"value": 1}
|
||||||
|
},
|
||||||
|
"hover": {
|
||||||
|
"fillOpacity": {"value": 0.5}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Se admitirmos que a correspondência entre pessoas religiosas e que não fizeram compras online é máxima, teremos que todos que não fizeram compras online, $74\%$ da população, são religiosos.
|
||||||
|
|
||||||
|
Por isso esse índice nunca é igual ou inferior à 50% da população.
|
||||||
|
|
||||||
|
### Exercício 21
|
||||||
|
|
||||||
|
Todos aqueles múltiplos de $2 \times 3 = 6$ e $2 \times 5 = 10$, descontados aqueles múltiplos de $2 \times 3 \times 5 = 30$. Ou seja, o quociente de $100 / 6$ mais o quociente de $100 / 10$ menos o quociente de $100 / 30$, o que resulta em $16 + 10 - 3 = 23$.
|
||||||
|
|
||||||
|
[^1]: nUSP: 12543033; Turma 04
|
After Width: | Height: | Size: 6 KiB |