Wiris

Documentation / Nubric

  • Demos
  • Visit our website
  • Contact us
  • MathType

    • WirisQuizzes

      • Nubric

        • CalcMe

          • MathPlayer

            • Store FAQ

              • MathFlow

                • BF FAQ

                  • Miscellaneous

                    • Wiris Integrations

                      • Home
                      • Nubric
                      • Using Nubric
                      • Advanced Logic in Nubric
                      • Advanced Logic Examples in Nubric
                      • Advanced Logic Examples in Nubric

                      How to generate linearly independent or dependent 3D vectors

                      Reading time: 2min

                      Use this method when you want students to determine whether a set of three 3D vectors is linearly independent or linearly dependent, with a controlled outcome.

                      Following this guide, you will generate a set of three 3D vectors that is guaranteed to be either:

                      • Linearly dependent (by construction), or
                      • Linearly independent (by determinant check).

                      See it in action: Watch how this logic is implemented inside Nubric:

                      Your browser does not support HTML5 video.

                      Before you begin

                      Requirements

                      • Basic knowledge of how to create a Nubric question.
                      • Familiarity with adding and editing question algorithms.
                      • Basic understanding of determinants and linear dependence.

                      Steps

                      Generate two linearly independent base vectors.

                      u1 = random([-5..5] / [0])
                      u2 = random([-5..5] / [0])
                      u3 = random([-5..5] / [0])
                      u = [u1, u2, u3]
                      
                      v1 = random([-5..5] / [0])
                      v2 = random([-5..5] / [0])
                      v3 = random([-5..5] / [0])
                      
                      while vectorial_product(u,[v1,v2,v3])==[0,0,0] 
                          v1 = random([-5..5] / [0])
                          v2 = random([-5..5] / [0])
                          v3 = random([-5..5] / [0])
                      end
                      v = [v1, v2, v3]

                      This ensures:

                      • u is a non-zero vector.
                      • v is not a scalar multiple of u
                      • So {u, v} is linearly independent.

                      Generate a dependent third vector (controlled dependence).

                      k1 = random([-3..3] / [0])
                      k2 = random([-3..3] / [0])
                      
                      w = k1 * u + k2 * v

                      Since w is a linear combination of u and v, the set {u, v, w} is guaranteed to be linearly dependent.

                      Generate an independent third vector (controlled independence).

                      t1 = random([-5..5] / [0])
                      t2 = random([-5..5] / [0])
                      t3 = random([-5..5] / [0])
                      
                      while determinant([u,v,[t1,t2,t3]]) == 0
                          t1 = random([-5..5] / [0])
                          t2 = random([-5..5] / [0])
                          t3 = random([-5..5] / [0])
                      end
                      t = [t1, t2, t3]

                      This ensures that {u, v, t} is linearly independent.

                      Verify it worked

                      • Preview the question multiple times.
                      • For dependent sets, verify that one vector is a linear combination of the others.
                      • For independent sets, confirm the determinant of the matrix formed by the vectors is non-zero.
                      • Ensure no zero vectors appear.

                      Full algorithm (copy-paste version)

                      Use the complete version below if you want to copy the logic directly into your question algorithm:

                      # Generate two linearly independent 3D vectors u and v
                      u1 = random([-5..5] / [0])
                      u2 = random([-5..5] / [0])
                      u3 = random([-5..5] / [0])
                      u = [u1, u2, u3]
                      
                      v1 = random([-5..5] / [0])
                      v2 = random([-5..5] / [0])
                      v3 = random([-5..5] / [0])
                      
                      while vectorial_product(u,[v1,v2,v3])==[0,0,0] 
                          v1 = random([-5..5] / [0])
                          v2 = random([-5..5] / [0])
                          v3 = random([-5..5] / [0])
                      end
                      v = [v1, v2, v3]
                      
                      # Generate dependent third vector
                      k1 = random([-3..3] / [0])
                      k2 = random([-3..3] / [0])
                      w = k1 * u + k2 * v
                      
                      # Generate independent third vector
                      t1 = random([-5..5] / [0])
                      t2 = random([-5..5] / [0])
                      t3 = random([-5..5] / [0])
                      
                      while determinant([u,v,[t1,t2,t3]]) == 0
                          t1 = random([-5..5] / [0])
                          t2 = random([-5..5] / [0])
                          t3 = random([-5..5] / [0])
                      end
                      t = [t1, t2, t3]

                      Options and variations

                      • If you only want dependent sets, you can remove the independent vector generation section.
                      • If you only want independent sets, you can remove the dependent vector logic.
                      • If you want larger coordinate values, you can increase the interval in the random() calls.
                      • If you want 2D vectors instead, you can remove the third coordinate and adapt determinant checks accordingly.

                      Common errors

                      Vectorial product is always zero.
                      Ensure vectors are regenerated inside the while loop.

                      Determinant loop runs too long.
                      Broaden the interval to increase variability.

                      An unexpected zero vector appears.
                      Confirm that zero is excluded in the random interval (/[0]).

                      Related

                      • Understanding Advanced Logic in Nubric
                      • Common Patterns and Best Practices
                      • Glossary of Commands

                      Was this article helpful?

                      Give feedback about this article

                      Related Articles

                      • Linear algebra
                      • Vector field

                      How to generate linearly independent or dependent 3D vectors

                      Before you begin Steps Verify it worked Full algorithm (copy-paste version) Options and variations Common errors Related

                      Empowering STEM education

                      MathType

                      • Office Tools
                      • LMS
                      • XML
                      • HTML

                      WirisQuizzes

                      Nubric

                      Integrations

                      Solutions

                      • Education
                      • Publishing houses – platforms and interactive
                      • Publishing houses – Print and digital
                      • Technical writers

                      Pricing

                      Downloads

                      Blog

                      • Success stories

                      About us

                      • Careers
                      • Partnership

                      Contact Us

                      Contact Sales

                      European union (European Regional Development Fund) and 1EdTech (TrustEd Apps Certified)
                      • Cookie Policy
                      • Terms of Use
                      • Privacy Policy / GDPR
                      • Student Data Privacy
                      • Compliance
                      • Cookie Settings

                      © Wiris 2026

                      Expand