#include<stdio.h> #include<conio.h> #include<graphics.h> #include<ctype.h> #include<math.h> #include<stdlib.h> void draw(int x1,int y1,int x2,int y2); void main() { int x1,y1,x2,y2; int gdriver=DETECT,gmode,gerror; initgraph(&gdriver,&gmode,"c:\\tc\\bgi:"); printf("\n Enter the x and y value for starting point:\n"); scanf("%d%d",&x1,&y1); printf("\n Enter the x and y value for ending point:\n"); scanf("%d%d",&x2,&y2); printf("\n The Line is shown below: \n"); draw(x1,y1,x2,y2); getch(); } void draw(int x1,int y1,int x2,int y2) { float x,y,xinc,yinc,dx,dy; int k; int step; dx=x2-x1; dy=y2-y1; if(abs(dx)>abs(dy)) step=abs(dx); else step=abs(dy); xinc=dx/step; yinc=dy/step; x=x1; y=y1; putpixel(x,y,1); for(k=1;k<=step;k++) { x=x+xinc; y=y+yinc; putpixel(x,y,2); } }
# include <graphics.h> # include <math.h> # include <conio.h> # include <iostream.h> void DDALine(int x1,int y1,int x2,int y2,int iColor); void main() { int gDriver=DETECT,gMode; int x1,x2,y1,y2,iColor; initgraph(&gDriver,&gMode,"c:\\tc\\bgi"); cleardevice(); cout<<endl<<"Enter x1 : "; cin>>x1; cout<<"Enter y1 : "; cin>>y1; cout<<endl<<"Enter x2 : "; cin>>x2; cout<<"Enter y2 : "; cin>>y2; cout<<endl<<"Enter COLOR : "; cin>>iColor; cleardevice(); DDALine(320,1,320,480,12); DDALine(1,240,640,240,12); circle(320,240,2); DDALine(320+x1,240-y1,320+x2,240-y2,iColor%16); getch(); } void DDALine(int x1,int y1,int x2,int y2,int iColor) { float dX,dY,iSteps; float xInc,yInc,iCount,x,y; dX = x1 - x2; dY = y1 - y2; if (fabs(dX) > fabs(dY)) { iSteps = fabs(dX); } else { iSteps = fabs(dY); } xInc = dX/iSteps; yInc = dY/iSteps; x = x1; y = y1; circle(x,y,1); for (iCount=1; iCount<=iSteps; iCount++) { putpixel(floor(x),floor(y),iColor); x -= xInc; y -= yInc; } circle(x,y,1); return; }
Here is the C code for DDA line drawing... #include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h> void main() { int gd, gm; float x, y, dx, dy, len; int x1, y1, x2, y2, i; detectgraph(&gd, &gm); initgraph(&gd, &gm,""); printf("\n Enter the coordinates of line : "); scanf("%d %d %d %d", &x1, &y1, &x2, &y2); dx = abs(x2-x1); dy = abs(y2-y1); if (dx >= dy) len = dx; else len = dy; dx = (x2-x1)/len; dy = (y2-y1)/len; x = x1 + 0.5; y = y1 + 0.5; i = 1; while (i <= len) { putpixel(x, y, 6); x = x+dx; y = y+dy; i++; } getch(); } -Suraj.
Let (xc,yc) be the centre of the circle Let r be the radius of the circle Let d be 3-2*r (d for decision) Let x be 0 Let y be r Repeat while x is less than y: Increment x If d is less than zero Let d be d + ( 4 * x ) + 6 Else Decrement y Let d be d + (( x - y ) * 4 ) + 10 End if Plot 8 points: ( xc+x, yc+y ) ( xc-x, yc+y ) ( xc+x, yc-y ) ( xc-x, yc-y ) ( xc+y, yc+x ) ( xc-y, yc+x ) ( xc+y, yc-x ) ( xc-y, yc-x ) End repeat
start: jmp main option1 db 0ah, 0dh, "1. OPTION 1 $" option2 db 0ah, 0dh, "2. OPTION 2 $" exit db 0ah, 0dh, "3. EXIT $" str1 db 0ah, 0dh, "Press Key: $" x db 0ah, 0dh, "You Pressed option 1 $" y db 0ah, 0dh, "You Pressed option 2 $" z db 0ah, 0dh, "End $" nvl db 0ah, 0dh, "Invalid Option $" one db "1" two db "2" tre db "3" main proc mov ah,09h lea dx,option1 int 21h lea dx,option2 int 21h lea dx,exit int 21h again: mov ah,09h lea dx,str1 int 21h mov ah,01 int 21h mov bl,al cmp bl,"1" je disp1 cmp bl,"2" je disp2 cmp bl,"3" je dispexit cmp al,one jne n cmp al,two jne n cmp al,tre jne n n: mov ah,09h lea dx,nvl int 21h jmp again disp1: mov ah,09h lea dx,x int 21h jmp again disp2: mov ah,09h lea dx,y int 21h jmp again dispexit: mov ah,09h lea dx,z int 21h int 20h main endp end start
int(ln(x2)dx)=xln|x2|-2x int(ln2(x)dx)=x[(ln|x|-2)ln|x|+2]
= cos(x)-(cos3(x))/3 * * * * * Right numbers, wrong sign! Int(sin3x)dx = Int(sin2x*sinx)dx = Int[(1-cos2x)*sinx]dx = Int(sinx)dx + Int[-cos2x*sinx]dx Int(sinx)dx = -cosx . . . . . (I) Int[-cos2x*sinx]dx Let u = cosx, the du = -sinxdx so Int(u2)du = u3/3 = 1/3*cos3x . . . . (II) So Int(sin3x)dx = 1/3*cos3x - cosx + C Alternatively, using the multiple angle identities, you can show that sin3x = 1/4*[3sinx - sin3x] which gives Int(sin3x)dx = 1/4*{1/3*cos(3x) - 3cosx} + C
int(- X2 dx) = (- 1/3)X3 + C ================or = - X3/3 + C ===================I like to pull the fraction out front. Add 1 to the exponent and then divide by that number. The power rule.
We have:int int (x * sin(y)) dx dyIntegrate x first:int(x)dx = 1/2 * x2 + CNow integrate sin(y):int(sin(y))dy = -cos(y) + CMultiply:-1/2 * x2 * cos(y) + C
#include<stdio.h> #include<conio.h> #include<graphics.h> #include<ctype.h> #include<math.h> #include<stdlib.h> void draw(int x1,int y1,int x2,int y2); void main() { int x1,y1,x2,y2; int gdriver=DETECT,gmode,gerror; initgraph(&gdriver,&gmode,"c:\\tc\\bgi:"); printf("\n Enter the x and y value for starting point:\n"); scanf("%d%d",&x1,&y1); printf("\n Enter the x and y value for ending point:\n"); scanf("%d%d",&x2,&y2); printf("\n The Line is shown below: \n"); draw(x1,y1,x2,y2); getch(); } void draw(int x1,int y1,int x2,int y2) { float x,y,xinc,yinc,dx,dy; int k; int step; dx=x2-x1; dy=y2-y1; if(abs(dx)>abs(dy)) step=abs(dx); else step=abs(dy); xinc=dx/step; yinc=dy/step; x=x1; y=y1; putpixel(x,y,1); for(k=1;k<=step;k++) { x=x+xinc; y=y+yinc; putpixel(x,y,2); } }
#include<stdio.h> #include<conio.h> #include<graphics.h> #include<ctype.h> #include<math.h> #include<stdlib.h> void draw(int x1,int y1,int x2,int y2); void main() { int x1,y1,x2,y2; int gdriver=DETECT,gmode,gerror; initgraph(&gdriver,&gmode,"c:\\tc\\bgi:"); printf("\n Enter the x and y value for starting point:\n"); scanf("%d%d",&x1,&y1); printf("\n Enter the x and y value for ending point:\n"); scanf("%d%d",&x2,&y2); printf("\n The Line is shown below: \n"); draw(x1,y1,x2,y2); getch(); } void draw(int x1,int y1,int x2,int y2) { float x,y,xinc,yinc,dx,dy; int k; int step; dx=x2-x1; dy=y2-y1; if(abs(dx)>abs(dy)) step=abs(dx); else step=abs(dy); xinc=dx/step; yinc=dy/step; x=x1; y=y1; putpixel(x,y,1); for(k=1;k<=step;k++) { x=x+xinc; y=y+yinc; putpixel(x,y,2); } }
The product rule states: d/dx uv = vdu/dx + udv/dxIt is not quite clear what your denominator is:"over 1 + (x squared)": d/dx (x/1+x2)d/dx(x/1+x2) = d/dx x(1 + x2)-1 = (1 + x2)-1 d/dx x + x d/dx (1 + x2)-1= (1 + x2)-1 + x -2x (1 + x2)-2= (1 + x2)-2 (1 + x2 - 2x2)= (1 - x2) / (1 + x2)2"over (1 + x) [all] squared": d/dx (x/(1+x)2)d/dx(x/(1+x)2) = d/dx x(1 + x)-2 = (1 + x)-2 d/dx x + x d/dx (1 + x)-2= (1 + x)-2 + x -2 (1 + x)-3= (1 + x)-3 (1 + x - 2x)= (1 - x)/(1 + x)3If you prefer, you can use the quotient rule: d/dx (u/v) = (v du/dx - udv/dx) / v2
If you mean: y =(lnx)3 then: dy/dx = [3(lnx)2]/x ddy/dx = [(6lnx / x) - 3(lnx)2] / x2 If you mean: y = ln(x3) Then: dy/dx = 3x2/x3 = 3/x = 3x-1 ddy/dx = -3x-2 = -3/x2
You may integrate this term by term with the power rule as it is additive. int(17X - 1) dx = (17/2)X2 - 1X + C ==============
9
# include <graphics.h> # include <math.h> # include <conio.h> # include <iostream.h> void DDALine(int x1,int y1,int x2,int y2,int iColor); void main() { int gDriver=DETECT,gMode; int x1,x2,y1,y2,iColor; initgraph(&gDriver,&gMode,"c:\\tc\\bgi"); cleardevice(); cout<<endl<<"Enter x1 : "; cin>>x1; cout<<"Enter y1 : "; cin>>y1; cout<<endl<<"Enter x2 : "; cin>>x2; cout<<"Enter y2 : "; cin>>y2; cout<<endl<<"Enter COLOR : "; cin>>iColor; cleardevice(); DDALine(320,1,320,480,12); DDALine(1,240,640,240,12); circle(320,240,2); DDALine(320+x1,240-y1,320+x2,240-y2,iColor%16); getch(); } void DDALine(int x1,int y1,int x2,int y2,int iColor) { float dX,dY,iSteps; float xInc,yInc,iCount,x,y; dX = x1 - x2; dY = y1 - y2; if (fabs(dX) > fabs(dY)) { iSteps = fabs(dX); } else { iSteps = fabs(dY); } xInc = dX/iSteps; yInc = dY/iSteps; x = x1; y = y1; circle(x,y,1); for (iCount=1; iCount<=iSteps; iCount++) { putpixel(floor(x),floor(y),iColor); x -= xInc; y -= yInc; } circle(x,y,1); return; }
Integrate by parts: ∫ uv dx = u ∫ v dx - ∫ (u' ∫ v dx) dx Let u = -2x Let v = cos 3x → u' = d/dx -2x = -2 → ∫ -2x cos 3x dx = -2x ∫ cos 3x dx - ∫ (-2 ∫ cos 3x dx) dx = -2x/3 sin 3x - ∫ -2/3 sin 3x dx = -2x/3 sin 3x - 2/9 cos 3x + c