SlideShare a Scribd company logo
Strassen’s
Algorithm
PR ES EN TATIO N BY,
ABDOURAZAK H. GUEDI I M S C ( I T)
1
content
 Introduction
 Procedure
 Formulas
Pseudo code
Conclusion
2
Introduction
The Strassen algorithm, also known as Strassen's matrix multiplication
algorithm.
Strassen in 1969 which gives an overview that how we can find the
multiplication of two matrix 2*2 dimension by the brute-force
algorithm.
But by using divide and conquer technique the overall complexity
for multiplication of two matrices is reduced.
This happens by decreasing the total number of multiplication
performed at the expenses of a slight increase in the number of
addition.
3
For multiplying the two 2*2 dimension matrices Strassen's used
some formulas in which there are eight multiplication and eighteen
addition, subtraction, but in brute force algorithm, there is seven
multiplication and four addition.
The utility of Strassen's formula is shown by its asymptotic superiority
when order n of matrix reaches infinity.
Let us consider two matrices A and B, n*n dimension, where n is a
power of two. It can be observed that we can contain four n/2*n/2
submatrices from A, B and their product C. C is the resultant matrix of
A and B.
Introduction
4
Procedure for Strassen matrix
multiplication
There are some procedures:
1.Divide a matrix of order of 2*2 recursively till we get the matrix of 2*2.
2.Use the previous set of formulas to carry out 2*2 matrix multiplication.
3.In this seven multiplication and four additions, subtraction are performed.
4.Combine the result of two matrixes to find the final product or final matrix.
5
Formulas for Strassen matrix
multiplication
In Strassen's matrix multiplication there are seven multiplication and four addition, subtraction in
total.
D1 = (a11 + a22).(b11 + b22)
D2 = (a21 + a22).b11
D3 = (b12 – b22).a11
D4 = (b21 – b11).a22
D5 = (a11 + a12).b22
D6 = (a21 – a11).(b11 + b12)
D7 = (a12 – a22).(b21 + b22)
C11 = d1 + d4 – d5 + d7
C12 = d3 + d5
C21 = d2 + d4
C22 = d1 - d2 + d3 + d6
6
Pseudo code
Algorithm Strassen(n, a, b, d)
1. If n = threshold
2. C = a * b
Else
3. Partition a into four sub matrices a11,a12,a21,a22.
4. Partition b into four sub matrices b11,b12,b21,b22.
5. Strassen ( n/2, a11 + a22, b11 + b22, d1)
7
6. Strassen ( n/2, a21 + a22, b11, d2)
7. Strassen ( n/2, a11, b12 – b22, d3)
8. Strassen ( n/2, a22, b21 – b11, d4)
9. Strassen ( n/2, a11 + a12, b22, d5)
10.Strassen (n/2, a21 – a11, b11 + b12, d6)
11.Strassen (n/2, a12 – a22, b21 + b22, d7)
12.C = d1+d4-d5+d7 d3+d5 d2+d4 D1-d2+d3+d6
end if
return (C)
8
Code:
#include <stdio.h>
int main()
{
int a[2][2],b[2][2],c[2][2],i,j;
int m1,m2,m3,m4,m5,m6,m7;
printf("Enter the 4 elements of first matrix: ");
for(i=0;i<2;i++)
for(j=0;j<2;j++)
scanf("%d",&a[i][j]);
printf("Enter the 4 elements of second matrix: "); for(i=0;i<2;i++)
for(j=0;j<2;j++)
scanf("%d",&b[i][j]);
printf("nThe first matrix isn");
for(i=0;i<2;i++)
{ printf("n");
for(j=0;j<2;j++)
printf("%dt",a[i][j]); }
printf("nThe second matrix isn");
9
for(i=0;i<2;i++) {
printf("n");
for(j=0;j<2;j++)
printf("%dt",b[i][j]); }
m1= (a[0][0] + a[1][1])*(b[0][0]+b[1][1]);
m2= (a[1][0]+a[1][1])*b[0][0];
m3= a[0][0]*(b[0][1]-b[1][1]);
m4= a[1][1]*(b[1][0]-b[0][0]);
m5= (a[0][0]+a[0][1])*b[1][1];
m6= (a[1][0]-a[0][0])*(b[0][0]+b[0][1]);
m7= (a[0][1]-a[1][1])*(b[1][0]+b[1][1]);
c[0][0]=m1+m4-m5+m7;
c[0][1]=m3+m5;
c[1][0]=m2+m4;
c[1][1]=m1-m2+m3+m6;
printf("nAfter multiplication using n");
for(i=0;i<2;i++) {
printf("n");
for(j=0;j<2;j++)
printf("%dt",c[i][j]); }
return 0;
}
62 51
Output:
Complexity: The time complexity is O(N2.8074).
10
Conclusion
The Strassen algorithm is a fast matrix multiplication algorithm that reduces
the number of basic multiplications required for matrix multiplication.
It reduced the number of multiplications from 8 (in the standard matrix
multiplication) to 7, which results in a slightly lower overall time complexity.
11
Thank You
12

More Related Content

Similar to Strassen’s Algorithm and matrix multiplication

Ch04
Ch04Ch04
Paper computer
Paper computerPaper computer
Paper computer
bikram ...
 
Paper computer
Paper computerPaper computer
Paper computer
bikram ...
 
Lemh104
Lemh104Lemh104
Cryptography and Network Security chapter 4.ppt
Cryptography and Network Security chapter 4.pptCryptography and Network Security chapter 4.ppt
Cryptography and Network Security chapter 4.ppt
the9amit
 
Nbhm m. a. and m.sc. scholarship test september 20, 2014 with answer key
Nbhm m. a. and m.sc. scholarship test september 20, 2014 with answer keyNbhm m. a. and m.sc. scholarship test september 20, 2014 with answer key
Nbhm m. a. and m.sc. scholarship test september 20, 2014 with answer key
MD Kutubuddin Sardar
 
CH04.ppt
CH04.pptCH04.ppt
add math form 4/5
add math form 4/5add math form 4/5
add math form 4/5
Sofia Mahmood
 
Number theory
Number theoryNumber theory
Number theory
dhivyakesavan3
 
matrices and determinantes
matrices and determinantes matrices and determinantes
matrices and determinantes
gandhinagar
 
M112rev
M112revM112rev
Stressen's matrix multiplication
Stressen's matrix multiplicationStressen's matrix multiplication
Stressen's matrix multiplication
Kumar
 
BFS algo.ppt
BFS algo.pptBFS algo.ppt
BFS algo.ppt
SandeepRanjan26
 
Numeros reales y_plano_numerico1.1_compressed
Numeros reales y_plano_numerico1.1_compressedNumeros reales y_plano_numerico1.1_compressed
Numeros reales y_plano_numerico1.1_compressed
AntonelaSantana1
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
MadhuriMulik1
 
Last+minute+revision(+Final)+(1) (1).pptx
Last+minute+revision(+Final)+(1) (1).pptxLast+minute+revision(+Final)+(1) (1).pptx
Last+minute+revision(+Final)+(1) (1).pptx
AryanMishra860130
 
Ch9-Gauss_Elimination4.pdf
Ch9-Gauss_Elimination4.pdfCh9-Gauss_Elimination4.pdf
Ch9-Gauss_Elimination4.pdf
RahulUkhande
 
final sci lab.pptx
final sci lab.pptxfinal sci lab.pptx
final sci lab.pptx
girish741205
 

Similar to Strassen’s Algorithm and matrix multiplication (18)

Ch04
Ch04Ch04
Ch04
 
Paper computer
Paper computerPaper computer
Paper computer
 
Paper computer
Paper computerPaper computer
Paper computer
 
Lemh104
Lemh104Lemh104
Lemh104
 
Cryptography and Network Security chapter 4.ppt
Cryptography and Network Security chapter 4.pptCryptography and Network Security chapter 4.ppt
Cryptography and Network Security chapter 4.ppt
 
Nbhm m. a. and m.sc. scholarship test september 20, 2014 with answer key
Nbhm m. a. and m.sc. scholarship test september 20, 2014 with answer keyNbhm m. a. and m.sc. scholarship test september 20, 2014 with answer key
Nbhm m. a. and m.sc. scholarship test september 20, 2014 with answer key
 
CH04.ppt
CH04.pptCH04.ppt
CH04.ppt
 
add math form 4/5
add math form 4/5add math form 4/5
add math form 4/5
 
Number theory
Number theoryNumber theory
Number theory
 
matrices and determinantes
matrices and determinantes matrices and determinantes
matrices and determinantes
 
M112rev
M112revM112rev
M112rev
 
Stressen's matrix multiplication
Stressen's matrix multiplicationStressen's matrix multiplication
Stressen's matrix multiplication
 
BFS algo.ppt
BFS algo.pptBFS algo.ppt
BFS algo.ppt
 
Numeros reales y_plano_numerico1.1_compressed
Numeros reales y_plano_numerico1.1_compressedNumeros reales y_plano_numerico1.1_compressed
Numeros reales y_plano_numerico1.1_compressed
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Last+minute+revision(+Final)+(1) (1).pptx
Last+minute+revision(+Final)+(1) (1).pptxLast+minute+revision(+Final)+(1) (1).pptx
Last+minute+revision(+Final)+(1) (1).pptx
 
Ch9-Gauss_Elimination4.pdf
Ch9-Gauss_Elimination4.pdfCh9-Gauss_Elimination4.pdf
Ch9-Gauss_Elimination4.pdf
 
final sci lab.pptx
final sci lab.pptxfinal sci lab.pptx
final sci lab.pptx
 

Recently uploaded

Heart Touching Romantic Love Shayari In English with Images
Heart Touching Romantic Love Shayari In English with ImagesHeart Touching Romantic Love Shayari In English with Images
Heart Touching Romantic Love Shayari In English with Images
Short Good Quotes
 
➒➌➎➏➑➐➋➑➐➐ Kalyan Matka Satta Matka Dpboss Matka Guessing Indian Matka
➒➌➎➏➑➐➋➑➐➐ Kalyan Matka Satta Matka Dpboss Matka Guessing Indian Matka➒➌➎➏➑➐➋➑➐➐ Kalyan Matka Satta Matka Dpboss Matka Guessing Indian Matka
➒➌➎➏➑➐➋➑➐➐ Kalyan Matka Satta Matka Dpboss Matka Guessing Indian Matka
➒➌➎➏➑➐➋➑➐➐Dpboss Matka Guessing Satta Matka Kalyan Chart Indian Matka
 
This is a test powerpoint!!!!!!!!!!!!!!!
This is a test powerpoint!!!!!!!!!!!!!!!This is a test powerpoint!!!!!!!!!!!!!!!
This is a test powerpoint!!!!!!!!!!!!!!!
briannedpegg
 
❼❷⓿❺❻❷❽❷❼❽ Dpboss Kalyan Satta Matka Guessing Matka Result Main Bazar chart
❼❷⓿❺❻❷❽❷❼❽ Dpboss Kalyan Satta Matka Guessing Matka Result Main Bazar chart❼❷⓿❺❻❷❽❷❼❽ Dpboss Kalyan Satta Matka Guessing Matka Result Main Bazar chart
❼❷⓿❺❻❷❽❷❼❽ Dpboss Kalyan Satta Matka Guessing Matka Result Main Bazar chart
❼❷⓿❺❻❷❽❷❼❽ Dpboss Kalyan Satta Matka Guessing Matka Result Main Bazar chart
 
2024 MATFORCE Youth Poster Contest Winners
2024 MATFORCE Youth Poster Contest Winners2024 MATFORCE Youth Poster Contest Winners
2024 MATFORCE Youth Poster Contest Winners
matforce
 
Full CAD Project Cardiovascuwhore Debut PDF CAD Meena Pittman
Full CAD Project Cardiovascuwhore Debut PDF CAD Meena PittmanFull CAD Project Cardiovascuwhore Debut PDF CAD Meena Pittman
Full CAD Project Cardiovascuwhore Debut PDF CAD Meena Pittman
meenap32
 
All the images mentioned in 'See What You're Missing'
All the images mentioned in 'See What You're Missing'All the images mentioned in 'See What You're Missing'
All the images mentioned in 'See What You're Missing'
Dave Boyle
 
AMCC-Syllabus-Art-Appreciation-2024-Summer.pdf
AMCC-Syllabus-Art-Appreciation-2024-Summer.pdfAMCC-Syllabus-Art-Appreciation-2024-Summer.pdf
AMCC-Syllabus-Art-Appreciation-2024-Summer.pdf
ROENSHANERAMONAL1
 
Barbie Made To Move Skin Tones Matches.pptx
Barbie Made To Move Skin Tones Matches.pptxBarbie Made To Move Skin Tones Matches.pptx
Barbie Made To Move Skin Tones Matches.pptx
LinaCosta15
 
Tibbetts_HappyAwesome_NewArc Sketch to AI
Tibbetts_HappyAwesome_NewArc Sketch to AITibbetts_HappyAwesome_NewArc Sketch to AI
Tibbetts_HappyAwesome_NewArc Sketch to AI
Todd Tibbetts
 
一比一原版加拿大多伦多大学毕业证(uoft毕业证书)如何办理
一比一原版加拿大多伦多大学毕业证(uoft毕业证书)如何办理一比一原版加拿大多伦多大学毕业证(uoft毕业证书)如何办理
一比一原版加拿大多伦多大学毕业证(uoft毕业证书)如何办理
taqyea
 
➒➌➎➏➑➐➋➑➐➐ Dpboss Satta Matka Matka Guessing Kalyan Chart Indian Matka Satta ...
➒➌➎➏➑➐➋➑➐➐ Dpboss Satta Matka Matka Guessing Kalyan Chart Indian Matka Satta ...➒➌➎➏➑➐➋➑➐➐ Dpboss Satta Matka Matka Guessing Kalyan Chart Indian Matka Satta ...
➒➌➎➏➑➐➋➑➐➐ Dpboss Satta Matka Matka Guessing Kalyan Chart Indian Matka Satta ...
➒➌➎➏➑➐➋➑➐➐Dpboss Matka Guessing Satta Matka Kalyan Chart Indian Matka
 
Colour Theory for Painting - Fine Artist.pdf
Colour Theory for Painting - Fine Artist.pdfColour Theory for Painting - Fine Artist.pdf
Colour Theory for Painting - Fine Artist.pdf
Ketan Naik
 
HOW TO USE PINTEREST_by: Clarissa Credito
HOW TO USE PINTEREST_by: Clarissa CreditoHOW TO USE PINTEREST_by: Clarissa Credito
HOW TO USE PINTEREST_by: Clarissa Credito
ClarissaAlanoCredito
 
Minor_Michael_PowerPoint-Presentation.pptx
Minor_Michael_PowerPoint-Presentation.pptxMinor_Michael_PowerPoint-Presentation.pptx
Minor_Michael_PowerPoint-Presentation.pptx
MichaelMinor19
 
哪里购买美国乔治城大学毕业证硕士学位证书原版一模一样
哪里购买美国乔治城大学毕业证硕士学位证书原版一模一样哪里购买美国乔治城大学毕业证硕士学位证书原版一模一样
哪里购买美国乔治城大学毕业证硕士学位证书原版一模一样
tc73868
 
Ealing London Independent Photography meeting - June 2024
Ealing London Independent Photography meeting - June 2024Ealing London Independent Photography meeting - June 2024
Ealing London Independent Photography meeting - June 2024
Sean McDonnell
 
My storyboard for a sword fight scene with lightsabers
My storyboard for a sword fight scene with lightsabersMy storyboard for a sword fight scene with lightsabers
My storyboard for a sword fight scene with lightsabers
AlejandroGuarnGutirr
 
ARNAUVALERY RECORD STORE SCAVENGER HUNT.
ARNAUVALERY RECORD STORE SCAVENGER HUNT.ARNAUVALERY RECORD STORE SCAVENGER HUNT.
ARNAUVALERY RECORD STORE SCAVENGER HUNT.
ValeryArnau
 
FinalFinalSelf-PortraiturePowerPoint.pptx
FinalFinalSelf-PortraiturePowerPoint.pptxFinalFinalSelf-PortraiturePowerPoint.pptx
FinalFinalSelf-PortraiturePowerPoint.pptx
abbieharman
 

Recently uploaded (20)

Heart Touching Romantic Love Shayari In English with Images
Heart Touching Romantic Love Shayari In English with ImagesHeart Touching Romantic Love Shayari In English with Images
Heart Touching Romantic Love Shayari In English with Images
 
➒➌➎➏➑➐➋➑➐➐ Kalyan Matka Satta Matka Dpboss Matka Guessing Indian Matka
➒➌➎➏➑➐➋➑➐➐ Kalyan Matka Satta Matka Dpboss Matka Guessing Indian Matka➒➌➎➏➑➐➋➑➐➐ Kalyan Matka Satta Matka Dpboss Matka Guessing Indian Matka
➒➌➎➏➑➐➋➑➐➐ Kalyan Matka Satta Matka Dpboss Matka Guessing Indian Matka
 
This is a test powerpoint!!!!!!!!!!!!!!!
This is a test powerpoint!!!!!!!!!!!!!!!This is a test powerpoint!!!!!!!!!!!!!!!
This is a test powerpoint!!!!!!!!!!!!!!!
 
❼❷⓿❺❻❷❽❷❼❽ Dpboss Kalyan Satta Matka Guessing Matka Result Main Bazar chart
❼❷⓿❺❻❷❽❷❼❽ Dpboss Kalyan Satta Matka Guessing Matka Result Main Bazar chart❼❷⓿❺❻❷❽❷❼❽ Dpboss Kalyan Satta Matka Guessing Matka Result Main Bazar chart
❼❷⓿❺❻❷❽❷❼❽ Dpboss Kalyan Satta Matka Guessing Matka Result Main Bazar chart
 
2024 MATFORCE Youth Poster Contest Winners
2024 MATFORCE Youth Poster Contest Winners2024 MATFORCE Youth Poster Contest Winners
2024 MATFORCE Youth Poster Contest Winners
 
Full CAD Project Cardiovascuwhore Debut PDF CAD Meena Pittman
Full CAD Project Cardiovascuwhore Debut PDF CAD Meena PittmanFull CAD Project Cardiovascuwhore Debut PDF CAD Meena Pittman
Full CAD Project Cardiovascuwhore Debut PDF CAD Meena Pittman
 
All the images mentioned in 'See What You're Missing'
All the images mentioned in 'See What You're Missing'All the images mentioned in 'See What You're Missing'
All the images mentioned in 'See What You're Missing'
 
AMCC-Syllabus-Art-Appreciation-2024-Summer.pdf
AMCC-Syllabus-Art-Appreciation-2024-Summer.pdfAMCC-Syllabus-Art-Appreciation-2024-Summer.pdf
AMCC-Syllabus-Art-Appreciation-2024-Summer.pdf
 
Barbie Made To Move Skin Tones Matches.pptx
Barbie Made To Move Skin Tones Matches.pptxBarbie Made To Move Skin Tones Matches.pptx
Barbie Made To Move Skin Tones Matches.pptx
 
Tibbetts_HappyAwesome_NewArc Sketch to AI
Tibbetts_HappyAwesome_NewArc Sketch to AITibbetts_HappyAwesome_NewArc Sketch to AI
Tibbetts_HappyAwesome_NewArc Sketch to AI
 
一比一原版加拿大多伦多大学毕业证(uoft毕业证书)如何办理
一比一原版加拿大多伦多大学毕业证(uoft毕业证书)如何办理一比一原版加拿大多伦多大学毕业证(uoft毕业证书)如何办理
一比一原版加拿大多伦多大学毕业证(uoft毕业证书)如何办理
 
➒➌➎➏➑➐➋➑➐➐ Dpboss Satta Matka Matka Guessing Kalyan Chart Indian Matka Satta ...
➒➌➎➏➑➐➋➑➐➐ Dpboss Satta Matka Matka Guessing Kalyan Chart Indian Matka Satta ...➒➌➎➏➑➐➋➑➐➐ Dpboss Satta Matka Matka Guessing Kalyan Chart Indian Matka Satta ...
➒➌➎➏➑➐➋➑➐➐ Dpboss Satta Matka Matka Guessing Kalyan Chart Indian Matka Satta ...
 
Colour Theory for Painting - Fine Artist.pdf
Colour Theory for Painting - Fine Artist.pdfColour Theory for Painting - Fine Artist.pdf
Colour Theory for Painting - Fine Artist.pdf
 
HOW TO USE PINTEREST_by: Clarissa Credito
HOW TO USE PINTEREST_by: Clarissa CreditoHOW TO USE PINTEREST_by: Clarissa Credito
HOW TO USE PINTEREST_by: Clarissa Credito
 
Minor_Michael_PowerPoint-Presentation.pptx
Minor_Michael_PowerPoint-Presentation.pptxMinor_Michael_PowerPoint-Presentation.pptx
Minor_Michael_PowerPoint-Presentation.pptx
 
哪里购买美国乔治城大学毕业证硕士学位证书原版一模一样
哪里购买美国乔治城大学毕业证硕士学位证书原版一模一样哪里购买美国乔治城大学毕业证硕士学位证书原版一模一样
哪里购买美国乔治城大学毕业证硕士学位证书原版一模一样
 
Ealing London Independent Photography meeting - June 2024
Ealing London Independent Photography meeting - June 2024Ealing London Independent Photography meeting - June 2024
Ealing London Independent Photography meeting - June 2024
 
My storyboard for a sword fight scene with lightsabers
My storyboard for a sword fight scene with lightsabersMy storyboard for a sword fight scene with lightsabers
My storyboard for a sword fight scene with lightsabers
 
ARNAUVALERY RECORD STORE SCAVENGER HUNT.
ARNAUVALERY RECORD STORE SCAVENGER HUNT.ARNAUVALERY RECORD STORE SCAVENGER HUNT.
ARNAUVALERY RECORD STORE SCAVENGER HUNT.
 
FinalFinalSelf-PortraiturePowerPoint.pptx
FinalFinalSelf-PortraiturePowerPoint.pptxFinalFinalSelf-PortraiturePowerPoint.pptx
FinalFinalSelf-PortraiturePowerPoint.pptx
 

Strassen’s Algorithm and matrix multiplication

  • 1. Strassen’s Algorithm PR ES EN TATIO N BY, ABDOURAZAK H. GUEDI I M S C ( I T) 1
  • 2. content  Introduction  Procedure  Formulas Pseudo code Conclusion 2
  • 3. Introduction The Strassen algorithm, also known as Strassen's matrix multiplication algorithm. Strassen in 1969 which gives an overview that how we can find the multiplication of two matrix 2*2 dimension by the brute-force algorithm. But by using divide and conquer technique the overall complexity for multiplication of two matrices is reduced. This happens by decreasing the total number of multiplication performed at the expenses of a slight increase in the number of addition. 3
  • 4. For multiplying the two 2*2 dimension matrices Strassen's used some formulas in which there are eight multiplication and eighteen addition, subtraction, but in brute force algorithm, there is seven multiplication and four addition. The utility of Strassen's formula is shown by its asymptotic superiority when order n of matrix reaches infinity. Let us consider two matrices A and B, n*n dimension, where n is a power of two. It can be observed that we can contain four n/2*n/2 submatrices from A, B and their product C. C is the resultant matrix of A and B. Introduction 4
  • 5. Procedure for Strassen matrix multiplication There are some procedures: 1.Divide a matrix of order of 2*2 recursively till we get the matrix of 2*2. 2.Use the previous set of formulas to carry out 2*2 matrix multiplication. 3.In this seven multiplication and four additions, subtraction are performed. 4.Combine the result of two matrixes to find the final product or final matrix. 5
  • 6. Formulas for Strassen matrix multiplication In Strassen's matrix multiplication there are seven multiplication and four addition, subtraction in total. D1 = (a11 + a22).(b11 + b22) D2 = (a21 + a22).b11 D3 = (b12 – b22).a11 D4 = (b21 – b11).a22 D5 = (a11 + a12).b22 D6 = (a21 – a11).(b11 + b12) D7 = (a12 – a22).(b21 + b22) C11 = d1 + d4 – d5 + d7 C12 = d3 + d5 C21 = d2 + d4 C22 = d1 - d2 + d3 + d6 6
  • 7. Pseudo code Algorithm Strassen(n, a, b, d) 1. If n = threshold 2. C = a * b Else 3. Partition a into four sub matrices a11,a12,a21,a22. 4. Partition b into four sub matrices b11,b12,b21,b22. 5. Strassen ( n/2, a11 + a22, b11 + b22, d1) 7
  • 8. 6. Strassen ( n/2, a21 + a22, b11, d2) 7. Strassen ( n/2, a11, b12 – b22, d3) 8. Strassen ( n/2, a22, b21 – b11, d4) 9. Strassen ( n/2, a11 + a12, b22, d5) 10.Strassen (n/2, a21 – a11, b11 + b12, d6) 11.Strassen (n/2, a12 – a22, b21 + b22, d7) 12.C = d1+d4-d5+d7 d3+d5 d2+d4 D1-d2+d3+d6 end if return (C) 8
  • 9. Code: #include <stdio.h> int main() { int a[2][2],b[2][2],c[2][2],i,j; int m1,m2,m3,m4,m5,m6,m7; printf("Enter the 4 elements of first matrix: "); for(i=0;i<2;i++) for(j=0;j<2;j++) scanf("%d",&a[i][j]); printf("Enter the 4 elements of second matrix: "); for(i=0;i<2;i++) for(j=0;j<2;j++) scanf("%d",&b[i][j]); printf("nThe first matrix isn"); for(i=0;i<2;i++) { printf("n"); for(j=0;j<2;j++) printf("%dt",a[i][j]); } printf("nThe second matrix isn"); 9
  • 10. for(i=0;i<2;i++) { printf("n"); for(j=0;j<2;j++) printf("%dt",b[i][j]); } m1= (a[0][0] + a[1][1])*(b[0][0]+b[1][1]); m2= (a[1][0]+a[1][1])*b[0][0]; m3= a[0][0]*(b[0][1]-b[1][1]); m4= a[1][1]*(b[1][0]-b[0][0]); m5= (a[0][0]+a[0][1])*b[1][1]; m6= (a[1][0]-a[0][0])*(b[0][0]+b[0][1]); m7= (a[0][1]-a[1][1])*(b[1][0]+b[1][1]); c[0][0]=m1+m4-m5+m7; c[0][1]=m3+m5; c[1][0]=m2+m4; c[1][1]=m1-m2+m3+m6; printf("nAfter multiplication using n"); for(i=0;i<2;i++) { printf("n"); for(j=0;j<2;j++) printf("%dt",c[i][j]); } return 0; } 62 51 Output: Complexity: The time complexity is O(N2.8074). 10
  • 11. Conclusion The Strassen algorithm is a fast matrix multiplication algorithm that reduces the number of basic multiplications required for matrix multiplication. It reduced the number of multiplications from 8 (in the standard matrix multiplication) to 7, which results in a slightly lower overall time complexity. 11